Class ParsableBitArray
- java.lang.Object
-
- com.google.android.exoplayer2.util.ParsableBitArray
-
@Deprecated public final class ParsableBitArray 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.Wraps a byte array, providing methods that allow it to be read as a bitstream.
-
-
Field Summary
Fields Modifier and Type Field Description byte[]dataDeprecated.
-
Constructor Summary
Constructors Constructor Description ParsableBitArray()Deprecated.Creates a new instance that initially has no backing data.ParsableBitArray(byte[] data)Deprecated.Creates a new instance that wraps an existing array.ParsableBitArray(byte[] data, int limit)Deprecated.Creates a new instance that wraps an existing array.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description intbitsLeft()Deprecated.Returns the number of bits yet to be read.voidbyteAlign()Deprecated.Aligns the position to the next byte boundary.intgetBytePosition()Deprecated.Returns the current byte offset.intgetPosition()Deprecated.Returns the current bit offset.voidputInt(int value, int numBits)Deprecated.OverwritesnumBitsfrom this array using thenumBitsleast significant bits fromvalue.booleanreadBit()Deprecated.Reads a single bit.voidreadBits(byte[] buffer, int offset, int numBits)Deprecated.ReadsnumBitsbits intobuffer.intreadBits(int numBits)Deprecated.Reads up to 32 bits.longreadBitsToLong(int numBits)Deprecated.Reads up to 64 bits.voidreadBytes(byte[] buffer, int offset, int length)Deprecated.Reads the nextlengthbytes intobuffer.StringreadBytesAsString(int length)Deprecated.Reads the nextlengthbytes as a UTF-8 string.StringreadBytesAsString(int length, Charset charset)Deprecated.Reads the nextlengthbytes as a string encoded inCharset.voidreset(byte[] data)Deprecated.Updates the instance to wrapdata, and resets the position to zero.voidreset(byte[] data, int limit)Deprecated.Updates the instance to wrapdata, and resets the position to zero.voidreset(ParsableByteArray parsableByteArray)Deprecated.Sets this instance's data, position and limit to match the providedparsableByteArray.voidsetPosition(int position)Deprecated.Sets the current bit offset.voidskipBit()Deprecated.Skips a single bit.voidskipBits(int numBits)Deprecated.Skips bits and moves current reading position forward.voidskipBytes(int length)Deprecated.Skips the nextlengthbytes.
-
-
-
Constructor Detail
-
ParsableBitArray
public ParsableBitArray()
Deprecated.Creates a new instance that initially has no backing data.
-
ParsableBitArray
public ParsableBitArray(byte[] data)
Deprecated.Creates a new instance that wraps an existing array.- Parameters:
data- The data to wrap.
-
ParsableBitArray
public ParsableBitArray(byte[] data, int limit)Deprecated.Creates a new instance that wraps an existing array.- Parameters:
data- The data to wrap.limit- The limit in bytes.
-
-
Method Detail
-
reset
public void reset(byte[] data)
Deprecated.Updates the instance to wrapdata, and resets the position to zero.- Parameters:
data- The array to wrap.
-
reset
public void reset(ParsableByteArray parsableByteArray)
Deprecated.Sets this instance's data, position and limit to match the providedparsableByteArray. Any modifications to the underlying data array will be visible in both instances- Parameters:
parsableByteArray- TheParsableByteArray.
-
reset
public void reset(byte[] data, int limit)Deprecated.Updates the instance to wrapdata, and resets the position to zero.- Parameters:
data- The array to wrap.limit- The limit in bytes.
-
bitsLeft
public int bitsLeft()
Deprecated.Returns the number of bits yet to be read.
-
getPosition
public int getPosition()
Deprecated.Returns the current bit offset.
-
getBytePosition
public int getBytePosition()
Deprecated.Returns the current byte offset. Must only be called when the position is byte aligned.- Throws:
IllegalStateException- If the position isn't byte aligned.
-
setPosition
public void setPosition(int position)
Deprecated.Sets the current bit offset.- Parameters:
position- The position to set.
-
skipBit
public void skipBit()
Deprecated.Skips a single bit.
-
skipBits
public void skipBits(int numBits)
Deprecated.Skips bits and moves current reading position forward.- Parameters:
numBits- The number of bits to skip.
-
readBit
public boolean readBit()
Deprecated.Reads a single bit.- Returns:
- Whether the bit is set.
-
readBits
public int readBits(int numBits)
Deprecated.Reads up to 32 bits.- Parameters:
numBits- The number of bits to read.- Returns:
- An integer whose bottom
numBitsbits hold the read data.
-
readBitsToLong
public long readBitsToLong(int numBits)
Deprecated.Reads up to 64 bits.- Parameters:
numBits- The number of bits to read.- Returns:
- A long whose bottom
numBitsbits hold the read data.
-
readBits
public void readBits(byte[] buffer, int offset, int numBits)Deprecated.ReadsnumBitsbits intobuffer.- Parameters:
buffer- The array into which the read data should be written. The trailingnumBits % 8bits are written into the most significant bits of the last modifiedbufferbyte. The remaining ones are unmodified.offset- The offset inbufferat which the read data should be written.numBits- The number of bits to read.
-
byteAlign
public void byteAlign()
Deprecated.Aligns the position to the next byte boundary. Does nothing if the position is already aligned.
-
readBytes
public void readBytes(byte[] buffer, int offset, int length)Deprecated.Reads the nextlengthbytes intobuffer. Must only be called when the position is byte aligned.- Parameters:
buffer- The array into which the read data should be written.offset- The offset inbufferat which the read data should be written.length- The number of bytes to read.- Throws:
IllegalStateException- If the position isn't byte aligned.- See Also:
System.arraycopy(Object, int, Object, int, int)
-
skipBytes
public void skipBytes(int length)
Deprecated.Skips the nextlengthbytes. Must only be called when the position is byte aligned.- Parameters:
length- The number of bytes to read.- Throws:
IllegalStateException- If the position isn't byte aligned.
-
readBytesAsString
public String readBytesAsString(int length)
Deprecated.Reads the nextlengthbytes as a UTF-8 string. Must only be called when the position is byte aligned.- Parameters:
length- The number of bytes to read.- Returns:
- The string encoded by the bytes in UTF-8.
-
readBytesAsString
public String readBytesAsString(int length, Charset charset)
Deprecated.Reads the nextlengthbytes as a string encoded inCharset. Must only be called when the position is byte aligned.- Parameters:
length- The number of bytes to read.charset- The character set of the encoded characters.- Returns:
- The string encoded by the bytes in the specified character set.
-
putInt
public void putInt(int value, int numBits)Deprecated.OverwritesnumBitsfrom this array using thenumBitsleast significant bits fromvalue. Bits are written in order from most significant to least significant. The read position is advanced bynumBits.- Parameters:
value- The integer whosenumBitsleast significant bits are written intodata.numBits- The number of bits to write.
-
-