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 SummaryNested Classes Modifier and Type Class Description static classNalUnitUtil.H265SpsDataDeprecated.Holds data parsed from a H.265 sequence parameter set NAL unit.static classNalUnitUtil.PpsDataDeprecated.Holds data parsed from a picture parameter set NAL unit.static classNalUnitUtil.SpsDataDeprecated.Holds data parsed from a H.264 sequence parameter set NAL unit.
 - 
Field SummaryFields Modifier and Type Field Description static float[]ASPECT_RATIO_IDC_VALUESDeprecated.Aspect ratios indexed by aspect_ratio_idc, in H.264 and H.265 SPSs.static intEXTENDED_SARDeprecated.Value for aspect_ratio_idc indicating an extended aspect ratio, in H.264 and H.265 SPSs.static byte[]NAL_START_CODEDeprecated.Four initial bytes that must prefix NAL units for decoding.static intNAL_UNIT_TYPE_AUDDeprecated.Access unit delimiter.static intNAL_UNIT_TYPE_IDRDeprecated.Coded slice of an IDR picture.static intNAL_UNIT_TYPE_NON_IDRDeprecated.Coded slice of a non-IDR picture.static intNAL_UNIT_TYPE_PARTITION_ADeprecated.Coded slice data partition A.static intNAL_UNIT_TYPE_PPSDeprecated.Picture parameter set.static intNAL_UNIT_TYPE_SEIDeprecated.Supplemental enhancement information.static intNAL_UNIT_TYPE_SPSDeprecated.Sequence parameter set.
 - 
Method SummaryAll Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voidclearPrefixFlags(boolean[] prefixFlags)Deprecated.Clears prefix flags, as used byfindNalUnit(byte[], int, int, boolean[]).static voiddiscardToSps(ByteBuffer data)Deprecated.Discards data from the buffer up to the first SPS, wheredata.position()is interpreted as the length of the buffer.static intfindNalUnit(byte[] data, int startOffset, int endOffset, boolean[] prefixFlags)Deprecated.Finds the first NAL unit indata.static intgetH265NalUnitType(byte[] data, int offset)Deprecated.Returns the type of the H.265 NAL unit indatathat starts atoffset.static intgetNalUnitType(byte[] data, int offset)Deprecated.Returns the type of the NAL unit indatathat starts atoffset.static booleanisNalUnitSei(String mimeType, byte nalUnitHeaderFirstByte)Deprecated.Returns whether the NAL unit with the specified header contains supplemental enhancement information.static NalUnitUtil.H265SpsDataparseH265SpsNalUnit(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.H265SpsDataparseH265SpsNalUnitPayload(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.PpsDataparsePpsNalUnit(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.PpsDataparsePpsNalUnitPayload(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.SpsDataparseSpsNalUnit(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.SpsDataparseSpsNalUnitPayload(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 intunescapeStream(byte[] data, int limit)Deprecated.Unescapesdataup to the specified limit, replacing occurrences of [0, 0, 3] with [0, 0].
 
- 
- 
- 
Field Detail- 
NAL_UNIT_TYPE_NON_IDRpublic 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_Apublic static final int NAL_UNIT_TYPE_PARTITION_A Deprecated.Coded slice data partition A.- See Also:
- Constant Field Values
 
 - 
NAL_UNIT_TYPE_IDRpublic static final int NAL_UNIT_TYPE_IDR Deprecated.Coded slice of an IDR picture.- See Also:
- Constant Field Values
 
 - 
NAL_UNIT_TYPE_SEIpublic static final int NAL_UNIT_TYPE_SEI Deprecated.Supplemental enhancement information.- See Also:
- Constant Field Values
 
 - 
NAL_UNIT_TYPE_SPSpublic static final int NAL_UNIT_TYPE_SPS Deprecated.Sequence parameter set.- See Also:
- Constant Field Values
 
 - 
NAL_UNIT_TYPE_PPSpublic static final int NAL_UNIT_TYPE_PPS Deprecated.Picture parameter set.- See Also:
- Constant Field Values
 
 - 
NAL_UNIT_TYPE_AUDpublic static final int NAL_UNIT_TYPE_AUD Deprecated.Access unit delimiter.- See Also:
- Constant Field Values
 
 - 
NAL_START_CODEpublic static final byte[] NAL_START_CODE Deprecated.Four initial bytes that must prefix NAL units for decoding.
 - 
EXTENDED_SARpublic 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_VALUESpublic static final float[] ASPECT_RATIO_IDC_VALUES Deprecated.Aspect ratios indexed by aspect_ratio_idc, in H.264 and H.265 SPSs.
 
- 
 - 
Method Detail- 
unescapeStreampublic static int unescapeStream(byte[] data, int limit)Deprecated.Unescapesdataup 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.
 
 - 
discardToSpspublic 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.
 
 - 
isNalUnitSeipublic 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, or- nullif 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 MimeTypeisnull.
 
 - 
getNalUnitTypepublic static int getNalUnitType(byte[] data, int offset)Deprecated.Returns the type of the NAL unit indatathat starts atoffset.- Parameters:
- data- The data to search.
- offset- The start offset of a NAL unit. Must lie between- -3(inclusive) and- data.length - 3(exclusive).
- Returns:
- The type of the unit.
 
 - 
getH265NalUnitTypepublic static int getH265NalUnitType(byte[] data, int offset)Deprecated.Returns the type of the H.265 NAL unit indatathat starts atoffset.- Parameters:
- data- The data to search.
- offset- The start offset of a NAL unit. Must lie between- -3(inclusive) and- data.length - 3(exclusive).
- Returns:
- The type of the unit.
 
 - 
parseSpsNalUnitpublic 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 in- nalData.
- nalLimit- The limit of the NAL unit in- nalData.
- Returns:
- A parsed representation of the SPS data.
 
 - 
parseSpsNalUnitPayloadpublic 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 in- nalData.
- nalLimit- The limit of the NAL unit in- nalData.
- Returns:
- A parsed representation of the SPS data.
 
 - 
parseH265SpsNalUnitpublic 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 in- nalData.
- nalLimit- The limit of the NAL unit in- nalData.
- Returns:
- A parsed representation of the SPS data.
 
 - 
parseH265SpsNalUnitPayloadpublic 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 in- nalData.
- nalLimit- The limit of the NAL unit in- nalData.
- Returns:
- A parsed representation of the SPS data.
 
 - 
parsePpsNalUnitpublic 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 in- nalData.
- nalLimit- The limit of the NAL unit in- nalData.
- Returns:
- A parsed representation of the PPS data.
 
 - 
parsePpsNalUnitPayloadpublic 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 in- nalData.
- nalLimit- The limit of the NAL unit in- nalData.
- Returns:
- A parsed representation of the PPS data.
 
 - 
findNalUnitpublic static int findNalUnit(byte[] data, int startOffset, int endOffset, boolean[] prefixFlags)Deprecated.Finds the first NAL unit indata.If prefixFlagsis 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 prefixFlagsis non-null, this method supports finding NAL units whose first four bytes spandataarrays passed to successive calls. To use this feature, pass the sameprefixFlagsparameter 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 endOffsetif a NAL unit was not found.
 
 - 
clearPrefixFlagspublic static void clearPrefixFlags(boolean[] prefixFlags) Deprecated.Clears prefix flags, as used byfindNalUnit(byte[], int, int, boolean[]).- Parameters:
- prefixFlags- The flags to clear.
 
 
- 
 
-