Expand description
rANS (range Asymmetric Numeral System) coder with SIMD optimizations.
This implements a vectorized rANS coder optimized for x86_64 with AVX2/BMI2. Falls back to scalar implementation on other architectures.
§Design
- Uses 8-way parallel rANS states for throughput
- 15-bit precision for probability quantization
- Interleaved bitstream for decoder efficiency
- Supports both streaming and batch modes
Structs§
- Blocked
Rans Decoder - Blocked rANS decoder for streaming large files.
- Blocked
Rans Encoder - Blocked rANS encoder for streaming large files.
- Cdf
- rANS CDF representation for a symbol.
- Rans
Decoder - Scalar rANS decoder.
- Rans
Encoder - Scalar rANS encoder.
- Simd
Rans Decoder - 8-way parallel rANS decoder using AVX2.
- Simd
Rans Encoder - 8-way parallel rANS encoder using AVX2.
Constants§
- ANS_
BITS - Number of bits for rANS probability precision
- ANS_
HIGH - Upper bound for rANS state (2^31)
- ANS_LOW
- Lower bound for rANS state (2^15)
- ANS_
TOTAL - Total probability range (2^15 = 32768)
- BLOCK_
SIZE - Block size for blocked rANS (128KB)
- RANS_
LANES - Number of parallel rANS streams
Functions§
- cdf_
for_ symbol - Get Cdf for a symbol from a CDF table.
- quantize_
pdf_ to_ rans_ cdf - Quantize PDF to rANS CDF table with guaranteed minimum frequencies.
- quantize_
pdf_ to_ rans_ cdf_ with_ buffer - Quantize PDF to rANS CDF using reusable scratch buffers.