compressionhuffman-codedeflatelz77

LZ77 Extra Bits in DEFLATE


In the LZ77 phase of the DEFLATE compression, extra bits are used to represent the length and distances of the back reference. However, are these extra bits concatenated onto the base values to form a unique code to be Huffman coded, or is the base value alone Huffman coded with the extra bits tacked on afterwards, i.e. during encoding?

In the first case, the lengths 11 and 12 would be different Huffman tree nodes, with each node representing their respective frequencies. But in the second case, 11 and 12 would be the same Huffman tree nodes and the frequency of said node being the combination of 11 and 12.

In the former case, the extra bits would be added pre-Huffman coding. But in the latter case, extra bits would be added after Huffman coding.

Thanks!


Solution

  • The base value alone is Huffman coded, with that code followed by the associated number of extra bits representing a value to be added to the base.