djvu-zp
Pure-Rust clean-room implementation of the ZP adaptive binary arithmetic coder specified in the DjVu v3 specification.
ZP is the entropy coder underlying every codec in a DjVu file: BZZ (text-chunk compression), JB2 (bilevel image), and IW44 (wavelet color/grey image).
This crate exposes the coder primitives so codec implementations and other downstream consumers (e.g. format-conformance tools, fuzz harnesses) can share one well-tested implementation.
Status
Extracted from the djvu-rs umbrella
crate as part of issue #229.
The decoder is the same code shipped in djvu-rs ≥ 0.14, vetted by the
project's full corpus + property + fuzz suite.
Usage
Decoder (no-std capable, no allocations)
use ZpDecoder;
let compressed: & = &;
let mut dec = new?;
let mut ctx = 0u8;
let _bit = dec.decode_bit;
# Ok::
Encoder (requires std, default-on)
use ZpEncoder;
let mut enc = new;
let mut ctx = 0u8;
enc.encode_bit;
let bytes: = enc.finish;
Features
| Feature | Default | Effect |
|---|---|---|
std |
✓ | Enables [encoder::ZpEncoder]. The decoder works either way and never allocates. |
License
MIT — see the upstream djvu-rs
repository.