|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object pt.tumba.ngram.compression.ArithDecoder
public final class ArithDecoder
Performs arithmetic decoding, converting bit input into
cumulative probability interval output. Returns probabilities as
integer counts low
, high
and
total
, with the range being
[low/total,high/total)
.
ArithEncoder
,
BitInput
Field Summary | |
---|---|
private int |
_bufferedBits
Number of bits that have been buffered. |
private boolean |
_endOfStream
Value will be true if the end of stream has
been reached. |
protected long |
_high
The high bound on the current interval for coding. |
private BitInput |
_in
Input stream from which to read bits. |
protected long |
_low
The low bound on the current interval for coding. |
private long |
_value
Current bits for decoding. |
protected static int |
CODE_VALUE_BITS
Precision of coding, expressed in number of bits used for arithmetic before shifting out partial results. |
protected static long |
FIRST_QUARTER
1/4 of the largest possible value plus one. |
protected static long |
HALF
1/2 of the largest possible value; 2 * FIRST_QUARTER |
protected static long |
THIRD_QUARTER
3/4 of the largest possible value; 3 * FIRST_QUARTER |
protected static long |
TOP_VALUE
The largest possible interval value. |
Constructor Summary | |
---|---|
ArithDecoder(BitInput in)
Construct an arithmetic decoder that reads from the given bit input. |
|
ArithDecoder(java.io.InputStream in)
Construct an arithmetic decoder that reads from the given input stream. |
Method Summary | |
---|---|
private void |
bufferBit()
Reads a bit from the underlying bit input stream and buffers it. |
void |
close()
Closes underlying bit output. |
boolean |
endOfStream()
Returns true if the end of stream has been reached
and there are no more symbols to decode. |
int |
getCurrentSymbolCount(int totalCount)
Returns a count for the current symbol that will be between the low and high counts for the symbol in the model given the total count. |
void |
removeSymbolFromStream(int[] counts)
Removes a symbol from the input stream that was coded with counts { low, high, total } . |
void |
removeSymbolFromStream(long lowCount,
long highCount,
long totalCount)
Removes a symbol from the input stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected long _low
protected long _high
protected static final int CODE_VALUE_BITS
protected static final long TOP_VALUE
1
s.
protected static final long FIRST_QUARTER
protected static final long HALF
2 * FIRST_QUARTER
protected static final long THIRD_QUARTER
3 * FIRST_QUARTER
private final BitInput _in
private long _value
private boolean _endOfStream
true
if the end of stream has
been reached.
private int _bufferedBits
Constructor Detail |
---|
public ArithDecoder(BitInput in) throws java.io.IOException
in
- Bit input from which to read bits.
java.io.IOException
- If there is an exception buffering from the bit input stream.public ArithDecoder(java.io.InputStream in) throws java.io.IOException
in
- Input stream from which to read.
java.io.IOException
- If there is an exception buffering from input stream.Method Detail |
---|
public boolean endOfStream()
true
if the end of stream has been reached
and there are no more symbols to decode.
true
if the end of stream has been reached.public int getCurrentSymbolCount(int totalCount)
removeSymbolFromStream(int[])
is called.
totalCount
- The current total count for the model.
public void removeSymbolFromStream(int[] counts) throws java.io.IOException
{ low, high, total }
. Called after getCurrentSymbolCount(int)
.
counts
- Array of low, high and total count used to code the symbol.
java.io.IOException
- If there is an exception in buffering input from the underlying input stream.removeSymbolFromStream(long,long,long)
public void removeSymbolFromStream(long lowCount, long highCount, long totalCount) throws java.io.IOException
getCurrentSymbolCount(int)
.
lowCount
- Cumulative count for symbols indexed below symbol to be removed.highCount
- lowCount
plus count for this symbol.totalCount
- Total count for all symbols seen.
java.io.IOException
- If there is an exception in buffering input from the underlying input stream.public void close() throws java.io.IOException
java.io.IOException
- If there is an underlying I/O exception in the bit input.private void bufferBit() throws java.io.IOException
java.io.IOException
- If there is an IOException
buffering from the underlying bit stream.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |