Package bdsup2sub.tools
Class BitStream
java.lang.Object
bdsup2sub.tools.BitStream
Simple helper class to read bitwise from a buffer.
-
Field Details
-
buffer
private final byte[] bufferData buffer -
byteOfs
private int byteOfsOffset to current byte in buffer -
b
private int bCurrent byte from the buffer -
bits
private int bitsBits left in current byte b
-
-
Constructor Details
-
BitStream
public BitStream(byte[] buffer) - Parameters:
buffer
- Byte array to create bitstream for
-
-
Method Details
-
bitsLeft
public int bitsLeft()- Returns:
- Number of bits left in buffer
-
readBits
public int readBits(int n) Read n bits from buffer (n <= 32)- Parameters:
n
- Number of bits to read from buffer (n<=32)- Returns:
- Value containing the n bits (last bit read is LSB)
-
syncToByte
public void syncToByte()Synchronize to next byte in data buffer (skip remaining 0-7 bits)
-