|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jj2000.j2k.codestream.writer.BitOutputBuffer
This class implements a buffer for writing bits, with the required bit stuffing policy for the packet headers. The bits are stored in a byte array in the order in which they are written. The byte array is automatically reallocated and enlarged whenever necessary. A BitOutputBuffer object may be reused by calling its 'reset()' method.
NOTE: The methods implemented in this class are intended to be used only in writing packet heads, since a special bit stuffing procedure is used, as required for the packet heads.
Field Summary | |
(package private) int |
avbits
The number of available bits in the current byte |
(package private) byte[] |
buf
The buffer where we store the data |
(package private) int |
curbyte
The position of the current byte to write |
static int |
SZ_INCR
The increment size for the buffer, 16 bytes. |
static int |
SZ_INIT
The initial size for the buffer, 32 bytes. |
Constructor Summary | |
BitOutputBuffer()
Creates a new BitOutputBuffer width a buffer of length 'SZ_INIT'. |
Method Summary | |
byte[] |
getBuffer()
Returns the byte buffer. |
int |
getLength()
Returns the current length of the buffer, in bytes. |
void |
reset()
Resets the buffer. |
byte[] |
toByteArray(byte[] data)
Returns the byte buffer data in a new array. |
java.lang.String |
toString()
Prints information about this object for debugging purposes |
void |
writeBit(int bit)
Writes a bit to the buffer at the current position. |
void |
writeBits(int bits,
int n)
Writes the n least significant bits of 'bits' to the buffer at the current position. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
byte[] buf
int curbyte
int avbits
public static final int SZ_INCR
public static final int SZ_INIT
Constructor Detail |
public BitOutputBuffer()
Method Detail |
public void reset()
public final void writeBit(int bit)
This method is declared final to increase performance.
bit
- The bit to write, 0 or 1.public final void writeBits(int bits, int n)
This method is declared final to increase performance.
bits
- The bits to write.n
- The number of LSBs in 'bits' to write.public final int getLength()
This method is declared final to increase performance.
public final byte[] getBuffer()
This method is declared final to increase performance.
public byte[] toByteArray(byte[] data)
data
- If non-null this array is used to return the data, which
mus be large enough. Otherwise a new one is created and returned.
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |