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.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Apache License 2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

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)