Package it.unimi.dsi.mg4j.io

Bit-level I/O classes.

See:
          Description

Interface Summary
RepositionableStream A basic interface specifying positioning methods for a byte stream.
 

Class Summary
ArithmeticCoder An arithmetic coder.
ArithmeticDecoder An arithmetic decoder.
DebugOutputBitStream A debugging wrapper for output bit streams.
FastBufferedInputStream Lightweight, unsynchronised, aligned input stream buffering class.
FastBufferedOutputStream Lightweight, unsynchronised, aligned output stream buffering class.
FastBufferedReader Lightweight, unsynchronised, aligned reader buffering class.
FastByteArrayInputStream Simple, fast and repositionable byte-array input stream.
FastByteArrayOutputStream Simple, fast byte-array output stream that exposes the backing array.
FastMultiByteArrayInputStream Simple, fast and repositionable byte array input stream that multiplexes its content among several arrays.
InputBitStream Bit-level input stream.
InterpolativeCoding Static methods implementing interpolative coding.
NullInputStream End-of-stream-only input stream.
NullOutputStream Throw-it-away output stream.
OutputBitStream Bit-level output stream.
 

Package it.unimi.dsi.mg4j.io Description

Bit-level I/O classes.

IMPORTANT: In MG4J 0.6, bit-level I/O has been completely rewritten. It is much faster, but there are also incompabilities. Mainly, unary representations are one-terminated sequences of zeroes (instead of zero-terminated sequences of ones), and positioning is on a bit, not a byte offset.

Package Specification

The standard Java API lacks bit-level I/O classes: to this purpose, MG4J provides InputBitStream and OutputBitStream, which can wrap any standard Java corresponding stream and make it work at the bit level; moreover, they provide support for several useful formats (such as unary, binary, minimal binary, γ, δ and Golomb encoding).

Compression can be achieved using self-delimiting formats supported by the classes above, or also by arithmetic coding, using the classes ArithmeticCoder and ArithmeticDecoder. Note that arithmetic coding is not very efficient in the present implementation, as it does not allow a varying number of symbols.

Bit input and output streams offer also efficient buffering and a way to reposition the bit stream in case the underlying byte stream is a file-based stream or a RepositionableStream.

Conventions

All coding methods work on natural numbers. The encoding of zero is very natural for some techniques, and much less natural for others. To keep methods rationally organised, all methods are able to encode any natural number. If, for instance, you want to write positive numbers in unary encoding and you do not want to waste a bit, you have to decrement them first (i.e., instead of p you must encode p−1).