2 releases
0.1.1 | Aug 19, 2022 |
---|---|
0.1.0 | Aug 19, 2022 |
#734 in Compression
16KB
293 lines
An adaptive Huffman encoder, for use in compression schemes.
To encode data, instantiate a Codec
object, and repeatedly call
Codec::write_and_update
. To decode data, instantiate a Codec
object,
and repeatedly call Codec::read_and_update
.
State is shared between the encoder and decoder implicitly; that is, it is constructed from the sequence of encoded or decoded symbols, rather than being communicated in the data. Thus, exactly the same data must be decoded on the decode side as was encoded on the encode side, or the decoder will go off the rails and produce nonsense. Furthermore, each side must be constructed with the same parameters, and the same major version of this library must be used.
The encoder does not emit any special symbol for EOF. Thus, either the application must designate its own EOF symbol (emitting it on the encoder, and stopping decoding when it is read), or it must somehow communicate the length of the input file out of band and only read that many symbols.
Dependencies
~99KB