|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object it.unimi.di.mg4j.io.ArithmeticDecoder
public final class ArithmeticDecoder
An arithmetic decoder.
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
Field Summary | |
---|---|
static int |
BITS
Number of bits used by the decoder. |
Constructor Summary | |
---|---|
ArithmeticDecoder(int n)
Creates a new decoder. |
Method Summary | |
---|---|
int |
decode(InputBitStream ibs)
Decodes a symbol. |
void |
flush(InputBitStream ibs)
Flushes (reads) the disambiguating bits. |
long |
getWindow()
Returns the current bit stream window. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int BITS
Constructor Detail |
---|
public ArithmeticDecoder(int n)
n
- number of symbols used by the decoder.Method Detail |
---|
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.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |