Class ParsableNalUnitBitArray
- java.lang.Object
-
- com.google.android.exoplayer2.util.ParsableNalUnitBitArray
-
public final class ParsableNalUnitBitArray extends Object
Wraps a byte array, providing methods that allow it to be read as a NAL unit bitstream.Whenever the byte sequence [0, 0, 3] appears in the wrapped byte array, it is treated as [0, 0] for all reading/skipping operations, which makes the bitstream appear to be unescaped.
-
-
Constructor Summary
Constructors Constructor Description ParsableNalUnitBitArray(byte[] data, int offset, int limit)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanReadBits(int numBits)Returns whether it's possible to readnbits starting from the current offset.booleancanReadExpGolombCodedNum()Returns whether it is possible to read an Exp-Golomb-coded integer starting from the current offset.booleanreadBit()Reads a single bit.intreadBits(int numBits)Reads up to 32 bits.intreadSignedExpGolombCodedInt()Reads an signed Exp-Golomb-coded format integer.intreadUnsignedExpGolombCodedInt()Reads an unsigned Exp-Golomb-coded format integer.voidreset(byte[] data, int offset, int limit)Resets the wrapped data, limit and offset.voidskipBit()Skips a single bit.voidskipBits(int numBits)Skips bits and moves current reading position forward.
-
-
-
Method Detail
-
reset
public void reset(byte[] data, int offset, int limit)Resets the wrapped data, limit and offset.- Parameters:
data- The data to wrap.offset- The byte offset indatato start reading from.limit- The byte offset of the end of the bitstream indata.
-
skipBit
public void skipBit()
Skips a single bit.
-
skipBits
public void skipBits(int numBits)
Skips bits and moves current reading position forward.- Parameters:
numBits- The number of bits to skip.
-
canReadBits
public boolean canReadBits(int numBits)
Returns whether it's possible to readnbits starting from the current offset. The offset is not modified.- Parameters:
numBits- The number of bits.- Returns:
- Whether it is possible to read
nbits.
-
readBit
public boolean readBit()
Reads a single bit.- Returns:
- Whether the bit is set.
-
readBits
public int readBits(int numBits)
Reads up to 32 bits.- Parameters:
numBits- The number of bits to read.- Returns:
- An integer whose bottom n bits hold the read data.
-
canReadExpGolombCodedNum
public boolean canReadExpGolombCodedNum()
Returns whether it is possible to read an Exp-Golomb-coded integer starting from the current offset. The offset is not modified.- Returns:
- Whether it is possible to read an Exp-Golomb-coded integer.
-
readUnsignedExpGolombCodedInt
public int readUnsignedExpGolombCodedInt()
Reads an unsigned Exp-Golomb-coded format integer.- Returns:
- The value of the parsed Exp-Golomb-coded integer.
-
readSignedExpGolombCodedInt
public int readSignedExpGolombCodedInt()
Reads an signed Exp-Golomb-coded format integer.- Returns:
- The value of the parsed Exp-Golomb-coded integer.
-
-