Skip to main content

Module huffman

Module huffman 

Source
Expand description

Canonical Huffman decoding (JPEG DHT style) with lookup-table acceleration.

Tables are described the JPEG way: counts[i] codes of length i + 1 followed by the symbol values in code order. Most RAW codecs (lossless JPEG, Nikon, Pentax, Sony ARW1, Kodak, Hasselblad, Leaf, Samsung…) use this representation with symbols that are the bit-length of a difference value.

The decoder uses a single LUT_BITS-bit lookup. Each entry either

  • holds the fully decoded difference (code + diff bits fit in the LUT), or
  • holds the code length and symbol (diff bits are then read separately), or
  • flags a long code that falls back to the canonical slow path.

Structs§

HuffTable
A canonical Huffman table with fast lookup.