Function exr::compression::piz::huffman::build_canonical_table
source · fn build_canonical_table(code_table: &mut [u64])
Expand description
Build a “canonical” Huffman code table:
- for each (uncompressed) symbol, code contains the length of the corresponding code (in the compressed data)
- canonical codes are computed and stored in code
- the rules for constructing canonical codes are as follows:
- shorter codes (if filled with zeroes to the right) have a numerically higher value than longer codes
- for codes with the same length, numerical values increase with numerical symbol values
- because the canonical code table can be constructed from symbol lengths alone, the code table can be transmitted without sending the actual code values
- see http://www.compressconsult.com/huffman/