Looking for help understanding Huffand code length encoding

14 views
Skip to first unread message

William Calliari

unread,
Jul 19, 2022, 7:48:13 AMJul 19
to WebP Discussion
Hello kind people.

I'm trying to understand the WebP standard and most of the specification until now was written quite clearly. However I can't wrap my head around the normal code length code is supposed to work. I tried reading the documentation and skimmed through the source code of libwebp, but I can't understand how it is possible to encode all possible Huffman code books in that format.

From my understanding, the maximal number of code lengths that can be stored with the normal code length code is 19 (ReadBits(4) + 4). So what happens if there is a image with more than nineteen different code lengths or some of those are used to pad out with zeros? I feel like I have a grasp about what the individual parts do and am just missing the piece that fits it all together.

Thanks for your help.

Vincent Rabaud

unread,
Jul 19, 2022, 8:58:44 AMJul 19
to WebP Discussion, William Calliari
Hi William,

the spec has been updated to clarify this part indeed. Huffman codes are not mentioned anymore, but the prefix code should be better explained here: https://chromium.googlesource.com/webm/libwebp/+/refs/heads/main/doc/webp-lossless-bitstream-spec.txt#838
The official website will soon be updated with it.

Reply all
Reply to author
Forward
0 new messages