org.xiph.speex
Class Bits

java.lang.Object
  extended byorg.xiph.speex.Bits

public class Bits
extends java.lang.Object

Speex bit packing and unpacking class.

Version:
$Revision: 1.5 $
Author:
Jim Lawrence, helloNetwork.com, Marc Gimpel, Wimba S.A. (marc@wimba.com)

Field Summary
private  int bitPtr
          Position of the bit "cursor" within the current byte
private  int bytePtr
          Position of the byte "cursor"
private  byte[] bytes
          "raw" data
static int DEFAULT_BUFFER_SIZE
          Default buffer size
 
Constructor Summary
Bits()
           
 
Method Summary
 void advance(int n)
          Advance n bits.
 byte[] getBuffer()
          Returns the current buffer array.
 int getBufferSize()
          Returns the number of bytes used in the current buffer.
 void init()
          Initialise the bit packing variables.
 void pack(int data, int nbBits)
          Write N bits of the given data to the buffer.
 int peek()
          Take a peek at the next bit.
 void read_from(byte[] newbytes, int offset, int len)
          Read the given array into the buffer.
protected  void setBuffer(byte[] newBuffer)
          Sets the buffer to the given value.
 int unpack(int nbBits)
          Read the next N bits from the buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_BUFFER_SIZE

public static final int DEFAULT_BUFFER_SIZE
Default buffer size

See Also:
Constant Field Values

bytes

private byte[] bytes
"raw" data


bytePtr

private int bytePtr
Position of the byte "cursor"


bitPtr

private int bitPtr
Position of the bit "cursor" within the current byte

Constructor Detail

Bits

public Bits()
Method Detail

init

public void init()
Initialise the bit packing variables.


advance

public void advance(int n)
Advance n bits.

Parameters:
n - - the number of bits to advance.

setBuffer

protected void setBuffer(byte[] newBuffer)
Sets the buffer to the given value.

Parameters:
newBuffer -

peek

public int peek()
Take a peek at the next bit.

Returns:
the next bit.

read_from

public void read_from(byte[] newbytes,
                      int offset,
                      int len)
Read the given array into the buffer.

Parameters:
newbytes -
offset -
len -

unpack

public int unpack(int nbBits)
Read the next N bits from the buffer.

Parameters:
nbBits - - the number of bits to read.
Returns:
the next N bits from the buffer.

pack

public void pack(int data,
                 int nbBits)
Write N bits of the given data to the buffer.

Parameters:
data - - the data to write.
nbBits - - the number of bits of the data to write.

getBuffer

public byte[] getBuffer()
Returns the current buffer array.

Returns:
the current buffer array.

getBufferSize

public int getBufferSize()
Returns the number of bytes used in the current buffer.

Returns:
the number of bytes used in the current buffer.


Copyright © 1999-2004 Wimba S.A. All Rights Reserved.