mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-23 08:00:20 +00:00
1a9d8e8fbe
Deflate and WebP can store at most 15 bits per symbol, meaning their huffman trees can be at most 15 levels deep. During construction, when we hit this level, we used to try again with an ever lower frequency cap per symbol. This had the effect of giving the symbols with the highest frequency lower frequencies first, causing the most-frequent symbols to be merged. For example, maybe the most-frequent symbol had 1 bit, and the 2nd-frequent two bits (and everything else at least 3). With the cap, the two most frequent symbols might both have 2 symbols, freeing up bits for the lower levels of the tree. This has the effect of making the most-frequent symbols longer at first, which isn't great for file size. Instead of using a frequency cap, ignore ever more of the low bits of the frequency. This sacrifices resolution where it hurts the lower levels of the tree first, and those are stored less frequently. For deflate, the 64 kiB block size means this doesn't have a big effect, but for WebP it can have a big effect: sunset-retro.png (876K): 2.02M -> 1.73M -- now (very slightly) smaller than twice the input size! Maybe we'll be competitive one day. (For wow.webp and 7z7c.webp, it has no effect, since we don't hit the "tree too deep" case there, since those have relatively few colors.) No behavior change other than smaller file size. (No performance cost either, and it's less code too.) |
||
---|---|---|
.. | ||
Brotli.cpp | ||
Brotli.h | ||
BrotliDictionary.cpp | ||
BrotliDictionary.cpp.dict.bin | ||
BrotliDictionary.h | ||
CMakeLists.txt | ||
Deflate.cpp | ||
Deflate.h | ||
DeflateTables.h | ||
Gzip.cpp | ||
Gzip.h | ||
Huffman.h | ||
Lzma.cpp | ||
Lzma.h | ||
Lzma2.cpp | ||
Lzma2.h | ||
Lzw.h | ||
PackBitsDecoder.cpp | ||
PackBitsDecoder.h | ||
Xz.cpp | ||
Xz.h | ||
Zlib.cpp | ||
Zlib.h |