public final class BitDecoder
extends java.lang.Object
The actual bit access is done via a BitRegister instance. Multiple bit registers can be used in parallel.
| Constructor and Description |
|---|
BitDecoder(BitRegister[] registers)
Construct
BitDecoder. |
BitDecoder(BitRegister[] registers,
byte... trailingBytes)
Construct
BitDecoder. |
| Modifier and Type | Method and Description |
|---|---|
void |
alignToByte()
Make sure the next decode or read action is byte-aligned.
|
void |
clear()
Clear all pending bits.
|
int |
decodeBits(java.nio.channels.ReadableByteChannel src,
int count)
Decode a number of bits from the source channel and discard them.
|
int |
decodeBits(java.nio.channels.ReadableByteChannel src,
int count,
int registerIndex)
Decode a number of bits from the source channel and discard them.
|
int |
peekBits(java.nio.channels.ReadableByteChannel src,
int count)
Decode a number of bits from the source channel without discarding them.
|
int |
peekBits(java.nio.channels.ReadableByteChannel src,
int count,
int registerIndex)
Decode a number of bits from the source channel without discarding them.
|
int |
readByte(java.nio.channels.ReadableByteChannel src)
Perform a direct byte-aligned read of a single byte and discard the
corresponding bits.
|
int |
readBytes(java.nio.channels.ReadableByteChannel src,
java.nio.ByteBuffer dst)
Perform a direct byte-aligned read and discard the corresponding bits.
|
void |
reset()
Reset the decoder to it's initial state.
|
long |
totalIn()
Get the total number of decoded bytes.
|
public BitDecoder(BitRegister[] registers)
BitDecoder.registers - The bit registers to use.public BitDecoder(BitRegister[] registers, byte... trailingBytes)
BitDecoder.registers - The bit registers to use.trailingBytes - The optional bytes to feed after the underlying
reader has reached EOF.public void reset()
public void clear()
public long totalIn()
public int peekBits(java.nio.channels.ReadableByteChannel src,
int count)
throws java.io.IOException
This function uses the register 0 for bit decoding.
src - The source channel to decode from.count - The number of bits to decode.java.io.IOException - if an I/O error occurs.public int peekBits(java.nio.channels.ReadableByteChannel src,
int count,
int registerIndex)
throws java.io.IOException
src - The source channel to decode from.count - The number of bits to decode.registerIndex - The register to use for bit decoding.java.io.IOException - if an I/O error occurs.public int decodeBits(java.nio.channels.ReadableByteChannel src,
int count)
throws java.io.IOException
This function uses the register 0 for bit decoding.
src - The source channel to decode from.count - The number of bits to decode.java.io.IOException - if an I/O error occurs.public int decodeBits(java.nio.channels.ReadableByteChannel src,
int count,
int registerIndex)
throws java.io.IOException
src - The source channel to decode from.count - The number of bits to decode.registerIndex - The register to use for bit decoding.java.io.IOException - if an I/O error occurs.public void alignToByte()
public int readBytes(java.nio.channels.ReadableByteChannel src,
java.nio.ByteBuffer dst)
throws java.io.IOException
This function allows optimized access bulk reading data.
src - The source channel to read from.dst - The ByteBuffer to read into.-1 if the channel reached
end-of-stream.java.io.IOException - if an I/O error occurs.public int readByte(java.nio.channels.ReadableByteChannel src)
throws java.io.IOException
src - The source channel to read from.-1 if the channel reached end-of-stream.java.io.IOException - if an I/O error occurs.