Been studying some LZ77/LZSS-based compression algorithms recently, and I had a ...
cliffle @cliffle@hachyderm.io
Been studying some LZ77/LZSS-based compression algorithms recently, and I had a realization I thought was interesting:
If you apply entropy coding to literal (non-repeated) bytes in an LZSS stream, the probability estimate for each byte needs to be the likelihood of it being a _surprise,_ breaking any existing byte sequence in the history window.
The most common bytes in a certain ASCII corpus are what you'd expect: <space>ETAIONSHRDLU<newline>
But the most common _surprising_ bytes for LZSS with a 2kiB sliding window are different:
<newline>AOUIES<space>LCRPMD
The need for efficient encoding of newline makes sense, if you think about it. Given only a set of previous strings, it is very difficult to predict in English where a linebreak will fall -- because it ignores the properties that determine linebreak placement, namely, length of the current line so far and length of the next word.
I've found at least one text compressor in the wild that gets these frequency assumptions wrong, at a cost of several percent.