Class NalUnitUtil
- java.lang.Object
-
- com.google.android.exoplayer2.util.NalUnitUtil
-
@Deprecated public final class NalUnitUtil extends Object
Deprecated.com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.Utility methods for handling H.264/AVC and H.265/HEVC NAL units.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
NalUnitUtil.H265SpsData
Deprecated.Holds data parsed from a H.265 sequence parameter set NAL unit.static class
NalUnitUtil.PpsData
Deprecated.Holds data parsed from a picture parameter set NAL unit.static class
NalUnitUtil.SpsData
Deprecated.Holds data parsed from a H.264 sequence parameter set NAL unit.
-
Field Summary
Fields Modifier and Type Field Description static float[]
ASPECT_RATIO_IDC_VALUES
Deprecated.Aspect ratios indexed by aspect_ratio_idc, in H.264 and H.265 SPSs.static int
EXTENDED_SAR
Deprecated.Value for aspect_ratio_idc indicating an extended aspect ratio, in H.264 and H.265 SPSs.static byte[]
NAL_START_CODE
Deprecated.Four initial bytes that must prefix NAL units for decoding.static int
NAL_UNIT_TYPE_AUD
Deprecated.Access unit delimiter.static int
NAL_UNIT_TYPE_IDR
Deprecated.Coded slice of an IDR picture.static int
NAL_UNIT_TYPE_NON_IDR
Deprecated.Coded slice of a non-IDR picture.static int
NAL_UNIT_TYPE_PARTITION_A
Deprecated.Coded slice data partition A.static int
NAL_UNIT_TYPE_PPS
Deprecated.Picture parameter set.static int
NAL_UNIT_TYPE_SEI
Deprecated.Supplemental enhancement information.static int
NAL_UNIT_TYPE_SPS
Deprecated.Sequence parameter set.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static void
clearPrefixFlags(boolean[] prefixFlags)
Deprecated.Clears prefix flags, as used byfindNalUnit(byte[], int, int, boolean[])
.static void
discardToSps(ByteBuffer data)
Deprecated.Discards data from the buffer up to the first SPS, wheredata.position()
is interpreted as the length of the buffer.static int
findNalUnit(byte[] data, int startOffset, int endOffset, boolean[] prefixFlags)
Deprecated.Finds the first NAL unit indata
.static int
getH265NalUnitType(byte[] data, int offset)
Deprecated.Returns the type of the H.265 NAL unit indata
that starts atoffset
.static int
getNalUnitType(byte[] data, int offset)
Deprecated.Returns the type of the NAL unit indata
that starts atoffset
.static boolean
isNalUnitSei(String mimeType, byte nalUnitHeaderFirstByte)
Deprecated.Returns whether the NAL unit with the specified header contains supplemental enhancement information.static NalUnitUtil.H265SpsData
parseH265SpsNalUnit(byte[] nalData, int nalOffset, int nalLimit)
Deprecated.Parses a H.265 SPS NAL unit using the syntax defined in ITU-T Recommendation H.265 (2019) subsection 7.3.2.2.1.static NalUnitUtil.H265SpsData
parseH265SpsNalUnitPayload(byte[] nalData, int nalOffset, int nalLimit)
Deprecated.Parses a H.265 SPS NAL unit payload (excluding the NAL unit header) using the syntax defined in ITU-T Recommendation H.265 (2019) subsection 7.3.2.2.1.static NalUnitUtil.PpsData
parsePpsNalUnit(byte[] nalData, int nalOffset, int nalLimit)
Deprecated.Parses a PPS NAL unit using the syntax defined in ITU-T Recommendation H.264 (2013) subsection 7.3.2.2.static NalUnitUtil.PpsData
parsePpsNalUnitPayload(byte[] nalData, int nalOffset, int nalLimit)
Deprecated.Parses a PPS NAL unit payload (excluding the NAL unit header) using the syntax defined in ITU-T Recommendation H.264 (2013) subsection 7.3.2.2.static NalUnitUtil.SpsData
parseSpsNalUnit(byte[] nalData, int nalOffset, int nalLimit)
Deprecated.Parses a SPS NAL unit using the syntax defined in ITU-T Recommendation H.264 (2013) subsection 7.3.2.1.1.static NalUnitUtil.SpsData
parseSpsNalUnitPayload(byte[] nalData, int nalOffset, int nalLimit)
Deprecated.Parses a SPS NAL unit payload (excluding the NAL unit header) using the syntax defined in ITU-T Recommendation H.264 (2013) subsection 7.3.2.1.1.static int
unescapeStream(byte[] data, int limit)
Deprecated.Unescapesdata
up to the specified limit, replacing occurrences of [0, 0, 3] with [0, 0].
-
-
-
Field Detail
-
NAL_UNIT_TYPE_NON_IDR
public static final int NAL_UNIT_TYPE_NON_IDR
Deprecated.Coded slice of a non-IDR picture.- See Also:
- Constant Field Values
-
NAL_UNIT_TYPE_PARTITION_A
public static final int NAL_UNIT_TYPE_PARTITION_A
Deprecated.Coded slice data partition A.- See Also:
- Constant Field Values
-
NAL_UNIT_TYPE_IDR
public static final int NAL_UNIT_TYPE_IDR
Deprecated.Coded slice of an IDR picture.- See Also:
- Constant Field Values
-
NAL_UNIT_TYPE_SEI
public static final int NAL_UNIT_TYPE_SEI
Deprecated.Supplemental enhancement information.- See Also:
- Constant Field Values
-
NAL_UNIT_TYPE_SPS
public static final int NAL_UNIT_TYPE_SPS
Deprecated.Sequence parameter set.- See Also:
- Constant Field Values
-
NAL_UNIT_TYPE_PPS
public static final int NAL_UNIT_TYPE_PPS
Deprecated.Picture parameter set.- See Also:
- Constant Field Values
-
NAL_UNIT_TYPE_AUD
public static final int NAL_UNIT_TYPE_AUD
Deprecated.Access unit delimiter.- See Also:
- Constant Field Values
-
NAL_START_CODE
public static final byte[] NAL_START_CODE
Deprecated.Four initial bytes that must prefix NAL units for decoding.
-
EXTENDED_SAR
public static final int EXTENDED_SAR
Deprecated.Value for aspect_ratio_idc indicating an extended aspect ratio, in H.264 and H.265 SPSs.- See Also:
- Constant Field Values
-
ASPECT_RATIO_IDC_VALUES
public static final float[] ASPECT_RATIO_IDC_VALUES
Deprecated.Aspect ratios indexed by aspect_ratio_idc, in H.264 and H.265 SPSs.
-
-
Method Detail
-
unescapeStream
public static int unescapeStream(byte[] data, int limit)
Deprecated.Unescapesdata
up to the specified limit, replacing occurrences of [0, 0, 3] with [0, 0]. The unescaped data is returned in-place, with the return value indicating its length.Executions of this method are mutually exclusive, so it should not be called with very large buffers.
- Parameters:
data
- The data to unescape.limit
- The limit (exclusive) of the data to unescape.- Returns:
- The length of the unescaped data.
-
discardToSps
public static void discardToSps(ByteBuffer data)
Deprecated.Discards data from the buffer up to the first SPS, wheredata.position()
is interpreted as the length of the buffer.When the method returns,
data.position()
will contain the new length of the buffer. If the buffer is not empty it is guaranteed to start with an SPS.- Parameters:
data
- Buffer containing start code delimited NAL units.
-
isNalUnitSei
public static boolean isNalUnitSei(@Nullable String mimeType, byte nalUnitHeaderFirstByte)
Deprecated.Returns whether the NAL unit with the specified header contains supplemental enhancement information.- Parameters:
mimeType
- The sample MIME type, ornull
if unknown.nalUnitHeaderFirstByte
- The first byte of nal_unit().- Returns:
- Whether the NAL unit with the specified header is an SEI NAL unit. False is returned if
the
MimeType
isnull
.
-
getNalUnitType
public static int getNalUnitType(byte[] data, int offset)
Deprecated.Returns the type of the NAL unit indata
that starts atoffset
.- Parameters:
data
- The data to search.offset
- The start offset of a NAL unit. Must lie between-3
(inclusive) anddata.length - 3
(exclusive).- Returns:
- The type of the unit.
-
getH265NalUnitType
public static int getH265NalUnitType(byte[] data, int offset)
Deprecated.Returns the type of the H.265 NAL unit indata
that starts atoffset
.- Parameters:
data
- The data to search.offset
- The start offset of a NAL unit. Must lie between-3
(inclusive) anddata.length - 3
(exclusive).- Returns:
- The type of the unit.
-
parseSpsNalUnit
public static NalUnitUtil.SpsData parseSpsNalUnit(byte[] nalData, int nalOffset, int nalLimit)
Deprecated.Parses a SPS NAL unit using the syntax defined in ITU-T Recommendation H.264 (2013) subsection 7.3.2.1.1.- Parameters:
nalData
- A buffer containing escaped SPS data.nalOffset
- The offset of the NAL unit header innalData
.nalLimit
- The limit of the NAL unit innalData
.- Returns:
- A parsed representation of the SPS data.
-
parseSpsNalUnitPayload
public static NalUnitUtil.SpsData parseSpsNalUnitPayload(byte[] nalData, int nalOffset, int nalLimit)
Deprecated.Parses a SPS NAL unit payload (excluding the NAL unit header) using the syntax defined in ITU-T Recommendation H.264 (2013) subsection 7.3.2.1.1.- Parameters:
nalData
- A buffer containing escaped SPS data.nalOffset
- The offset of the NAL unit payload innalData
.nalLimit
- The limit of the NAL unit innalData
.- Returns:
- A parsed representation of the SPS data.
-
parseH265SpsNalUnit
public static NalUnitUtil.H265SpsData parseH265SpsNalUnit(byte[] nalData, int nalOffset, int nalLimit)
Deprecated.Parses a H.265 SPS NAL unit using the syntax defined in ITU-T Recommendation H.265 (2019) subsection 7.3.2.2.1.- Parameters:
nalData
- A buffer containing escaped SPS data.nalOffset
- The offset of the NAL unit header innalData
.nalLimit
- The limit of the NAL unit innalData
.- Returns:
- A parsed representation of the SPS data.
-
parseH265SpsNalUnitPayload
public static NalUnitUtil.H265SpsData parseH265SpsNalUnitPayload(byte[] nalData, int nalOffset, int nalLimit)
Deprecated.Parses a H.265 SPS NAL unit payload (excluding the NAL unit header) using the syntax defined in ITU-T Recommendation H.265 (2019) subsection 7.3.2.2.1.- Parameters:
nalData
- A buffer containing escaped SPS data.nalOffset
- The offset of the NAL unit payload innalData
.nalLimit
- The limit of the NAL unit innalData
.- Returns:
- A parsed representation of the SPS data.
-
parsePpsNalUnit
public static NalUnitUtil.PpsData parsePpsNalUnit(byte[] nalData, int nalOffset, int nalLimit)
Deprecated.Parses a PPS NAL unit using the syntax defined in ITU-T Recommendation H.264 (2013) subsection 7.3.2.2.- Parameters:
nalData
- A buffer containing escaped PPS data.nalOffset
- The offset of the NAL unit header innalData
.nalLimit
- The limit of the NAL unit innalData
.- Returns:
- A parsed representation of the PPS data.
-
parsePpsNalUnitPayload
public static NalUnitUtil.PpsData parsePpsNalUnitPayload(byte[] nalData, int nalOffset, int nalLimit)
Deprecated.Parses a PPS NAL unit payload (excluding the NAL unit header) using the syntax defined in ITU-T Recommendation H.264 (2013) subsection 7.3.2.2.- Parameters:
nalData
- A buffer containing escaped PPS data.nalOffset
- The offset of the NAL unit payload innalData
.nalLimit
- The limit of the NAL unit innalData
.- Returns:
- A parsed representation of the PPS data.
-
findNalUnit
public static int findNalUnit(byte[] data, int startOffset, int endOffset, boolean[] prefixFlags)
Deprecated.Finds the first NAL unit indata
.If
prefixFlags
is null then the first three bytes of a NAL unit must be entirely contained within the part of the array being searched in order for it to be found.When
prefixFlags
is non-null, this method supports finding NAL units whose first four bytes spandata
arrays passed to successive calls. To use this feature, pass the sameprefixFlags
parameter to successive calls. State maintained in this parameter enables the detection of such NAL units. Note that when using this feature, the return value may be 3, 2 or 1 less thanstartOffset
, to indicate a NAL unit starting 3, 2 or 1 bytes before the first byte in the current array.- Parameters:
data
- The data to search.startOffset
- The offset (inclusive) in the data to start the search.endOffset
- The offset (exclusive) in the data to end the search.prefixFlags
- A boolean array whose first three elements are used to store the state required to detect NAL units where the NAL unit prefix spans array boundaries. The array must be at least 3 elements long.- Returns:
- The offset of the NAL unit, or
endOffset
if a NAL unit was not found.
-
clearPrefixFlags
public static void clearPrefixFlags(boolean[] prefixFlags)
Deprecated.Clears prefix flags, as used byfindNalUnit(byte[], int, int, boolean[])
.- Parameters:
prefixFlags
- The flags to clear.
-
-