Fix std/deflate degenerate H-D Huffman table

RFC 1951 section 3.2.7. "Compression with dynamic Huffman codes
(BTYPE=10)" says, "If only one distance code is used, it is encoded
using one bit, not zero bits; in this case there is a single code length
of one, with one unused code."

I had previously mis-read that excerpt to also require that the sole
distance code was the shortest distance (code 0, a distance of 1).

Fixes #66
This commit is contained in:
Nigel Tao committed 2022-01-08 13:57:34 +11:00
1 parent dda01f1a77
commit f86c80e425
7 files changed
+75 -28

No files matched your search

@@ -2,8 +2,8 @@ Running degenerate-huffman-unused.deflate through script/print-bits.go and
adding commentary:
offset xoffset ASCII hex binary
000000 0x0000 . 0x05 0b_...._.101 Dynamic Huffman block, final
000000 0x0000 . 0x05 0b_0000_0... NumLCodes: 257
000000 0x0000 . 0x04 0b_...._.100 Dynamic Huffman block, non-final
000000 0x0000 . 0x04 0b_0000_0... NumLCodes: 257
000001 0x0001 . 0xC0 0b_...0_0000 NumDCodes: 1
000001 0x0001 . 0xC0 0b_110._.... NumCLCodeLengths: 18
000002 0x0002 ! 0x21 0b_...._...1
@@ -63,4 +63,7 @@ Apply H-L and H-D.
000013 0x000D . 0x89 0b_..0._.... lcode: 111 literal 'o'
000013 0x000D . 0x89 0b_.0.._.... lcode: 111 literal 'o'
000013 0x000D . 0x89 0b_1..._.... lcode: 256 end of block
000014 0x000E . 0x01 0b_...._...1
000014 0x000E . 0x1B 0b_...._...1
The second Dynamic Huffman block (the final one) continues after that, but this
commentary stops here.