|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object it.unimi.di.mg4j.io.ArithmeticCoder
public final class ArithmeticCoder
An arithmetic coder.
This class provides an arithmetic coder. The output of the coder goes to
an OutputBitStream
. You must first create a coder specifying the
number of input symbols, then call encode(int, OutputBitStream)
for
all symbols to be coded, and finally flush(OutputBitStream)
. This
last operation will output some bits so that the last symbol is encoded
nonambiguously.
The code is inspired by the arithmetic coder 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).
ArithmeticDecoder
Field Summary | |
---|---|
static int |
BITS
Number of bits used by the coder. |
Constructor Summary | |
---|---|
ArithmeticCoder(int n)
Creates a new coder. |
Method Summary | |
---|---|
int |
encode(int x,
OutputBitStream obs)
Encodes a symbol. |
int |
flush(OutputBitStream obs)
Flushes the last bits. |
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 ArithmeticCoder(int n)
n
- number of symbols used by the coder.Method Detail |
---|
public int encode(int x, OutputBitStream obs) throws IOException
x
- a bit.obs
- the output stream.
IOException
- if obs
does.public int flush(OutputBitStream obs) throws IOException
This method must be called when coding is over. It guarantees that enough bits are output to make the decoding of the last symbol nonambiguous, whichever bits follow in the stream.
obs
- the output stream.
IOException
- if obs
does.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |