|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.InputStream pt.tumba.ngram.compression.ArithCodeInputStream
public final class ArithCodeInputStream
An input stream which uses a statistical model and arithmetic
coding for decompression of encoded bytes read from an underlying
input stream. Given a statistical model of a byte sequence, it
operates in the same way as
java.util.zip.GZIPInputStream
.
ArithCodeOutputStream
,
ArithCodeModel
Field Summary | |
---|---|
private ArithDecoder |
_decoder
The arithmetic decoder used to read bytes. |
private int[] |
_interval
Interval used for coding ranges. |
private ArithCodeModel |
_model
The statistical model model on which the input stream is based. |
private int |
_nextByte
The buffered next byte to write. |
Constructor Summary | |
---|---|
ArithCodeInputStream(ArithDecoder decoder,
ArithCodeModel model)
Construct an arithmetic coded input stream from a specified arithmetic decoder and a statistical model. |
|
ArithCodeInputStream(BitInput in,
ArithCodeModel model)
Construct an arithmetic coded input stream from a specified bit input and a statistical model. |
|
ArithCodeInputStream(java.io.BufferedInputStream in,
ArithCodeModel model)
Construct an arithmetic coded input stream from a specified buffered input stream and a statistical model. |
|
ArithCodeInputStream(java.io.InputStream in,
ArithCodeModel model)
Construct an arithmetic coded input stream from a specified input stream and a statistical model. |
Method Summary | |
---|---|
int |
available()
Returns 1 if there is at least one byte
available to be read and returns 0 otherwise. |
void |
close()
Closes this input stream. |
private void |
decodeNextByte()
Buffers the next byte into _nextByte . |
void |
mark(int readLimit)
Not supported. |
boolean |
markSupported()
Returns false because marking is not supported. |
int |
read()
Reads the next byte from the input stream. |
int |
read(byte[] bs)
Read an array of bytes into the specified byte array, returning number of bytes read. |
int |
read(byte[] bs,
int off,
int len)
Read the specified number of bytes into the array, beginning from the position specified by the offset. |
void |
reset()
Not supported. |
long |
skip(long n)
Skips the given number of bytes from the input. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final ArithCodeModel _model
private final ArithDecoder _decoder
private int _nextByte
private final int[] _interval
Constructor Detail |
---|
public ArithCodeInputStream(ArithDecoder decoder, ArithCodeModel model) throws java.io.IOException
decoder
- Arithmetic decoder from which to read input events.model
- Statistical model for arithmetic coding.
java.io.IOException
- If there is an I/O exception in the underlying input stream.public ArithCodeInputStream(BitInput in, ArithCodeModel model) throws java.io.IOException
bitIn
- Bit input from which to read bits.model
- Statistical model for arithmetic coding.
java.io.IOException
- If there is an I/O exception in the underlying input stream.public ArithCodeInputStream(java.io.BufferedInputStream in, ArithCodeModel model) throws java.io.IOException
in
- Buffered input stream from which to read coded bits.model
- Statistical model for arithmetic coding.
java.io.IOException
- If there is an I/O exception in the underlying input stream.public ArithCodeInputStream(java.io.InputStream in, ArithCodeModel model) throws java.io.IOException
in
- Input stream from which to read coded bits.model
- Statistical model for arithmetic coding.
java.io.IOException
- If there is an I/O exception in the underlying input stream.Method Detail |
---|
public int available()
1
if there is at least one byte
available to be read and returns 0
otherwise.
available
in class java.io.InputStream
1
if at least one byte is available and 0
otherwise.public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in class java.io.InputStream
java.io.IOException
- If there is an exception closing the underlying input stream.public void mark(int readLimit)
mark
in class java.io.InputStream
public boolean markSupported()
false
because marking is not supported.
markSupported
in class java.io.InputStream
false
.public int read(byte[] bs) throws java.io.IOException
read
in class java.io.InputStream
bs
- Byte array into which to read the bytes.
java.io.IOException
- If there is an I/O exception reading from the underlying stream.public int read(byte[] bs, int off, int len) throws java.io.IOException
read
in class java.io.InputStream
bs
- Byte array into which to read the bytes.off
- Offset into byte array from which to begin writing output.len
- Maximum number of bytes to read.
java.io.IOException
- If there is an I/O exception reading from the underlying stream.public int read() throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
- If there is an I/O exception reading from the underlying stream.public void reset() throws java.io.IOException
IOException
if called.
reset
in class java.io.InputStream
java.io.IOException
- whenever called.public long skip(long n) throws java.io.IOException
skip
in class java.io.InputStream
n
- Number of bytes to skip.
java.io.IOException
- If there is an I/O exception reading from the underlying stream.private void decodeNextByte() throws java.io.IOException
_nextByte
.
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |