Module rans

Module rans 

Source
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§

BlockedRansDecoder
Blocked rANS decoder for streaming large files.
BlockedRansEncoder
Blocked rANS encoder for streaming large files.
Cdf
rANS CDF representation for a symbol.
RansDecoder
Scalar rANS decoder.
RansEncoder
Scalar rANS encoder.
SimdRansDecoder
8-way parallel rANS decoder using AVX2.
SimdRansEncoder
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.