|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.OutputStream
pt.tumba.ngram.compression.ArithCodeOutputStream
public class ArithCodeOutputStream
A filter output stream which uses a statistical model and
arithmetic coding for compression of bytes read from an underlying
arithmetic encoder. This encoder may be constructed from an output
stream or bit output. Given a model and a stream, this class
operates in the same way as
java.util.zip.GZIPOutputStream.
ArithCodeInputStream,
ArithCodeModel| Field Summary | |
|---|---|
private ArithEncoder |
_encoder
The arithmetic encoder used to write coded bytes. |
private int[] |
_interval
Interval used for coding ranges. |
private ArithCodeModel |
_model
The model on which the output stream is based. |
| Constructor Summary | |
|---|---|
ArithCodeOutputStream(ArithEncoder encoder,
ArithCodeModel model)
Construct an output stream that writes to the specified output events with the given arithmetic encoder with the given statistical model. |
|
ArithCodeOutputStream(BitOutput bitOut,
ArithCodeModel model)
Construct an output stream that writes to the specified bit output using arithmetic coding with the given statistical model. |
|
ArithCodeOutputStream(java.io.BufferedOutputStream out,
ArithCodeModel model)
Construct an output stream that writes to the specified buffered output stream using arithmetic coding with the given statistical model. |
|
ArithCodeOutputStream(java.io.OutputStream out,
ArithCodeModel model)
Construct an output stream that writes to the specified output stream using arithmetic coding with the given statistical model. |
|
| Method Summary | |
|---|---|
void |
close()
Close this output stream. |
private void |
encode(int symbol)
Writes encoded symbol after necessary escapes to the underlying encoder. |
void |
flush()
Flushes underlying stream. |
void |
write(byte[] bs)
Writes array of bytes to the output stream. |
void |
write(byte[] bs,
int off,
int len)
Writes section of array of bytes to the output stream. |
void |
write(int i)
Writes the eight low-order bits of argument to the output stream as a byte. |
| 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 ArithEncoder _encoder
private final int[] _interval
| Constructor Detail |
|---|
public ArithCodeOutputStream(ArithEncoder encoder,
ArithCodeModel model)
encoder - Arithmetic encoder to use for coding output.model - Statistical model of byte stream.
public ArithCodeOutputStream(BitOutput bitOut,
ArithCodeModel model)
bitOut - Bit output to write coded bits to.model - Statistical model of byte stream.
public ArithCodeOutputStream(java.io.BufferedOutputStream out,
ArithCodeModel model)
model - Statistical model of byte stream.out - Buffered output stream to write coded bits to.
public ArithCodeOutputStream(java.io.OutputStream out,
ArithCodeModel model)
output - Output stream to write coded bits to.model - Statistical model of byte stream.| Method Detail |
|---|
public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in class java.io.OutputStreamjava.io.IOException - If there is an exception in the underlying encoder.
public void flush()
throws java.io.IOException
flush in interface java.io.Flushableflush in class java.io.OutputStreamjava.io.IOException - If there is an exception flushing the underlying stream.
public void write(byte[] bs)
throws java.io.IOException
write in class java.io.OutputStreambs - Array of bytes to write.
java.io.IOException - If there is an exception in writing to the underlying encoder.
public void write(byte[] bs,
int off,
int len)
throws java.io.IOException
write in class java.io.OutputStreambs - Array of bytes to write.off - Index from which to start writing.len - Number of bytes to write.
java.io.IOException - If there is an exception in writing to the underlying encoder.
public void write(int i)
throws java.io.IOException
write in class java.io.OutputStreami - Bits to write.
java.io.IOException - If there is an exception in writing to the underlying encoder.
private void encode(int symbol)
throws java.io.IOException
symbol - Symbol to encode.
java.io.IOException - If the underlying encoder throws an IOException.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||