Expand description
Entropy coding primitives.
This module provides simplified implementations of common entropy coding techniques used in video codecs: arithmetic coding, range coding, and Huffman coding.
Structs§
- Adaptive
Frequency Tracker - Adaptive frequency tracker using a sliding window.
- Arithmetic
Coder - Simplified binary arithmetic coder.
- Cabac
Context - A single CABAC context model.
- Cabac
Encoder - CABAC encoder with multiple context models.
- Huffman
Node - A node in a Huffman tree.
- Prob
Table Entry - Pre-computed lookup table entry for one probability value.
- Range
Coder - Simplified range coder (decoder side).
- Range
Encoder - Multi-symbol range encoder that writes bytes to an output buffer.
- Table
Arithmetic Coder - High-throughput table-based arithmetic coder.
- Table
Arithmetic Decoder - Table-based arithmetic decoder counterpart.
Functions§
- build_
huffman_ tree - Builds a Huffman tree from a frequency table using a greedy (priority-queue) algorithm.
- build_
prob_ table - Builds a probability lookup table for
n_symssymbols. - compare_
coding_ strategies - Compare two coding strategies and return which uses fewer estimated bits.
- compute_
huffman_ codes - Traverses the Huffman tree depth-first, collecting
(symbol, code_bits)pairs at each leaf. - estimate_
block_ entropy - Estimate the number of bits needed to encode a block of symbols without actually producing a bitstream.
- estimate_
entropy_ from_ freqs - Estimate the entropy (bits per symbol) of a frequency distribution.
- optimal_
code_ lengths - Compute optimal code lengths for a set of symbol frequencies.