Skip to main content

Crate djvu_zp

Crate djvu_zp 

Source
Expand description

ZP adaptive binary arithmetic coder — pure-Rust clean-room implementation.

This crate implements the ZP (Z-Prime) adaptive binary arithmetic coder from the DjVu v3 specification (https://www.sndjvu.org/spec.html), used by the JB2, IW44, and BZZ codecs that make up a DjVu file.

§Usage

Decoder (no_std-capable, no allocations):

use djvu_zp::ZpDecoder;
let compressed: &[u8] = &[0x00, 0x00];
let mut dec = ZpDecoder::new(compressed)?;
let mut ctx = 0u8;
let _bit = dec.decode_bit(&mut ctx);

Encoder (requires std feature, default-on):

use djvu_zp::encoder::ZpEncoder;
let mut enc = ZpEncoder::new();
let mut ctx = 0u8;
enc.encode_bit(&mut ctx, true);
let _bytes: Vec<u8> = enc.finish();

§Features

  • std (default) — enables encoder::ZpEncoder. The decoder works with or without std and never allocates.

Modules§

encoder
ZP adaptive binary arithmetic encoder.
tables
ZP coder state tables from the DjVu v3 specification.

Structs§

ZpDecoder
ZP (Z-Prime) adaptive binary arithmetic decoder.

Enums§

ZpError
Errors that can occur while initializing or decoding a ZP stream.