forked from SerenityOS/serenity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibGfx/WebPWriter: Use huffman compression
This implements some of basic webp compression: Huffman coding. (The other parts of the basics are backreferences, and color cache entries; and after that there are the four transforms -- predictor, subtract green, color indexing, color.) How much huffman coding helps depends on the input's entropy. Constant-color channels are now encoded in constant space, but otherwise a huffman code always needs at least one bit per symbol. This means just huffman coding can at the very best reduce output size to 1/8th of input size. For three test input files: sunset-retro.png (876K): 2.25M -> 2.02M (helps fairly little; from 2.6x as big as the png input to 2.36x) giphy.gif (184k): 11M -> 4.9M (pretty decent, from 61x as big as the gif input to 27x as big) 7z7c.gif (11K): 775K -> 118K (almost as good as possible an improvement for just huffman coding, from 70x as big as the gif input to 10.7x as big) No measurable encoding perf impact for encoding. The code is pretty similar to Deflate.cpp in LibCompress, with just enough differences that sharing code doesn't look like it's worth it to me. I left comments outlining similarities.
- Loading branch information
Showing
1 changed file
with
220 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters