public final class ArithmeticDecoder extends Object
This class provides an arithmetic decoder. The input of the coder is an
InputBitStream. You must first create a decoder specifying the
number of input symbols, then call decode(InputBitStream) for all
symbols to be decoded, and finally flush(InputBitStream). This last
operation reads the bits flushed by ArithmeticCoder.flush(OutputBitStream). Thereafter, exactly BITS
excess bits will be present in the current window of the decoder. You can
get them using getWindow().
The code is inspired by the arithmetic decoder by John Carpinelli, Radford M. Neal, Wayne Salamonsen and Lang Stuiver, which is in turn based on Arithmetic Coding Revisited, by Alistair Moffat, Radford M. Neal and Ian H. Witten (Proc. IEEE Data Compression Conference, Snowbird, Utah, March 1995).
ArithmeticCoder| Modifier and Type | Field and Description |
|---|---|
static int |
BITS
Number of bits used by the decoder.
|
| Constructor and Description |
|---|
ArithmeticDecoder(int n)
Creates a new decoder.
|
| Modifier and Type | Method and Description |
|---|---|
int |
decode(InputBitStream ibs)
Decodes a symbol.
|
void |
flush(InputBitStream ibs)
Flushes (reads) the disambiguating bits.
|
long |
getWindow()
Returns the current bit stream window.
|
public static final int BITS
public ArithmeticDecoder(int n)
n - number of symbols used by the decoder.public int decode(InputBitStream ibs) throws IOException
ibs - the input stream.IOException - if ibs does.public void flush(InputBitStream ibs) throws IOException
This method must be called when all symbols have been decoded. After
the call, exactly BITS excess bits will be present in the
current window of the decoder. You can get them using getWindow();
usually you will then unget them to the bit stream.
ibs - the input stream.IOException - if ibs does.public long getWindow()
BITS bits.