Crate ans

Crate ans 

Source
Expand description

Asymmetric Numeral Systems (ANS) entropy coding primitives.

This crate provides a small, dependency-light implementation of rANS (range Asymmetric Numeral Systems), suitable as a building block for higher-level compression schemes (e.g. “bits-back” constructions used in ROC / set coding).

§Design

  • Explicit model: callers provide counts (frequencies) and the precision.
  • Small surface: encode/decode with a FrequencyTable.
  • No I/O: this crate is pure in-memory coding.

§Notes

  • This is not tuned for maximum speed; it is meant to be correct and easy to integrate.
  • Encoding returns a byte vector in a stack format: the decoder consumes bytes from the end (LIFO). This avoids reversing buffers.

Structs§

FrequencyTable
A frequency model for rANS with total (T = 2^{precision_bits}).

Enums§

AnsError
Errors for rANS operations.

Functions§

decode
Decode an rANS stream produced by encode.
encode
Encode symbols with rANS using table.