Class Bits
java.lang.Object
javaforce.codec.speex.Bits
Speex bit packing and unpacking class.
- Version:
- $Revision$
- Author:
- Jim Lawrence, helloNetwork.com, Marc Gimpel, Wimba S.A. (mgimpel@horizonwimba.com)
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadvance(int n) Advance n bits.byte[]Returns the current buffer array.intReturns the number of bytes used in the current buffer.voidinit()Initialise the bit packing variables.voidpack(int data, int nbBits) Write N bits of the given data to the buffer.intpeek()Take a peek at the next bit.voidread_from(byte[] newbytes, int offset, int len) Read the given array into the buffer.protected voidsetBuffer(byte[] newBuffer) Sets the buffer to the given value.intunpack(int nbBits) Read the next N bits from the buffer.
-
Field Details
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZEDefault buffer size- See Also:
-
-
Constructor Details
-
Bits
public Bits()
-
-
Method Details
-
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.
-