ppmd-core
A pure-Rust implementation of the PPMd (Prediction by Partial Matching, variant D) compressor with an underlying range coder.
Designed for safety (no unsafe), and zero-dependency entropy coding in your Rust projects.
Features
- PPMd order-N modeling (1 ≤ N ≤ 16)
- Adaptive frequency tables with escape mechanism
- High-speed range encoder/decoder
- Configurable context order: trade CPU/memory vs. compression ratio
- Safe Rust only (
#![forbid(unsafe_code)])
Quick Start
File-based API
use ;
In-memory API
If you prefer streaming or in-memory buffers:
use ;
use ;
Tuning and Performance
- Order (context length)
- Low (1–3): very fast, minimal memory, poorer compression
- Medium (4–8): balanced speed vs. ratio (DEFAULT = 5)
- High (9–16): best ratio, more memory, slower
MAX_FREQ: Controls the maximum per-symbol count in any context (prevents overflow).
You can tweak DEFAULT_ORDER or call encode_file(..., Some(order)) to experiment.
Benchmark (TODO) your own data with:
License
MIT OR Apache-2.0 (See LICENSE-APACHE and LICENSE-MIT files.)