Expand description
PPMd-style entropy coder for byte streams.
This crate implements a Prediction by Partial Matching (PPM) compressor/decompressor using a range encoder/decoder underneath. PPM builds adaptive probability models based on the last N bytes of context, where N is the “order.” Higher orders give better compression at the cost of more memory and CPU; lower orders run faster but yield larger output.
§Key Parameters
DEFAULT_ORDER: u8 = 5
The default context length (order-5). A good middle ground between speed and compression.MAX_FREQ: u8 = 124
Maximum per-symbol frequency in any context. Caps frequencies to avoid overflow.TOP: u32 = 1 << 24andBOT: u32 = 1 << 15
Thresholds used by the underlying range coder to renormalize its internal registers. You generally don’t need to touch these unless you’re tuning the coder itself.
Structs§
- PpmModel
- The central PPM model. Maintains up to
max_ordercontexts and dynamically updates symbol frequencies as you encode or decode. - Range
Decoder - Streaming range‐decoder for arithmetic coding.
- Range
Encoder - Streaming range‐encoder for arithmetic coding.
Enums§
- PpmError
- The set of errors that can occur during PPM encoding or decoding.
Constants§
Functions§
- decode_
file - Decompress
input_path(which must have been produced byencode_file) back intooutput_path, using the defaultDEFAULT_ORDER = 5. - encode_
file - Compress the file at
input_pathintooutput_pathusing PPM.