deadbeef.Tools
Class BitStream

java.lang.Object
  extended by deadbeef.Tools.BitStream

public class BitStream
extends java.lang.Object

Simple helper class to read bitwise from a buffer.

Author:
0xdeadbeef

Constructor Summary
BitStream(byte[] buffer)
          Constructor
 
Method Summary
 int bitsLeft()
          Get number of bits left in buffer
 int readBits(int n)
          Read n bits from buffer (n <= 32)
 void syncToByte()
          Synchronize to next byte in data buffer (skip remaining 0-7 bits)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitStream

public BitStream(byte[] buffer)
Constructor

Parameters:
buffer - Byte array to create bitstream for
Method Detail

bitsLeft

public int bitsLeft()
Get number of bits left in buffer

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)