Replies: 2 comments 10 replies
-
Aa the good old multiple literals technique, love it. But it's not used. Here are the disadvantages.
|
Beta Was this translation helpful? Give feedback.
-
Elaborating on above
there are two types of table based Huffman decoders,
I'm gonna use STB , so here's the fast path, https://github.com/nothings/stb/blob/5736b15f7ea0ffb08dd38af21067c314d6a3aae9/stb_image.h#L4249-L4255 And the slow path Now this can have apply the optimization for multiple literals, in the fast path. It's possible to fill the fastpath tables with 2 literals if both literals consume less than Longer codes will take time, bit it's compression, we expect more shorter codes than longer ones, otherwise it won't work.
So the main table has sub-tables, and we allocate and partition it into sub tables. Long codes get two table lookups and short codes only get one, but this doesn't allow us to have space for multi-entries, since the whole space is used. Here is where we use it, zune-image/zune-inflate/src/decoder.rs Lines 1132 to 1140 in 83c11db PS this may be information overload, it was for me, so here are some links that helped me https://cbloomrants.blogspot.com/search?q=huffman+codes Feel free to ask for any clarifications |
Beta Was this translation helpful? Give feedback.
-
fdeflate
uses 12-bit indices to get multiple literals from a single table lookup, improving performance. The technique is described here: image-rs/image#1852 (comment)I'm curious if this optimization is applicable to
zune-inflate
. If not already done and not conflicting with other parts of the library, this could serve as a further optimization.Beta Was this translation helpful? Give feedback.
All reactions