Building a data compression utility in Haskell using Huffman codes
lazamar.github.io
Building a data compression utility in Haskell using Huffman codes
1–10 of 94 posts
Re: Building a data compression utility in Haskell using Huffman codes
#2Re: Building a data compression utility in Haskell using Huffman codes
#3Re: Building a data compression utility in Haskell using Huffman codes
#4Re: Building a data compression utility in Haskell using Huffman codes
#5The only reason Huffman codes are used is they were invented first and arithmetic codes were patented. That patent has now expired, so we should use the better design.
Re: Building a data compression utility in Haskell using Huffman codes
#6For all readers, arithmetic codes are better in nearly all ways. They can be implemented in less RAM and code, they compress and decompress to a better ratio, and the probabilities of different symbols appearing can be dynamically updated during the stream far more easily. The only reason Huffman codes are used is they were invented first and arithmetic codes were patented. That patent has now expired, so we should u…
* They usually self synchronize when some data is corrupted (but not guaranteed, does not apply where the Huffman table is dynamic)
* Neither Huffman nor arithmetic codes are easy to parallelize the decoding of, but Huffman is slightly easier.
Re: Building a data compression utility in Haskell using Huffman codes
#7For all readers, arithmetic codes are better in nearly all ways. They can be implemented in less RAM and code, they compress and decompress to a better ratio, and the probabilities of different symbols appearing can be dynamically updated during the stream far more easily. The only reason Huffman codes are used is they were invented first and arithmetic codes were patented. That patent has now expired, so we should u…
Are you thinking of pre-defined Huffman tables that aren't adapted to the input? Because the latter ought to be as good as it gets.
(I agree with the other benefits. Since arithmetic coding tables are built in a streaming fashion rather than constructing the codebook up front, they are more memory-efficient while working.)
Re: Building a data compression utility in Haskell using Huffman codes
#8I mention this only because, when I learned the tree-based approach at uni, I simply wasn't aware that there was another way to do it, and I'm wondering how many of you that's true for as well.
While the tree approach is intuitive and illuminating, it probably makes more sense to work with in-place arrays, since the situations when you care most about compression are probably the situations when you have a lot of data and want to run fast.
In-Place Calculation of Minimum-Redundancy Codes
Moffat, Katajainen. 1995.
http://hjemmesider.diku.dk/~jyrki/Paper/WADS95.pdfRe: Building a data compression utility in Haskell using Huffman codes
#9There exists an array-based, in-place algorithm for this, reducing the need to allocate trees and chase pointers. I mention this only because, when I learned the tree-based approach at uni, I simply wasn't aware that there was another way to do it, and I'm wondering how many of you that's true for as well. While the tree approach is intuitive and illuminating, it probably makes more sense to work with in-place arrays…
Or in general, refer to "On the Implementation of Minimum Redundancy Prefix Codes" by Moffat and Turpin (1997), as strongly recommended and later explained by Charles Bloom [1].
[1] https://cbloomrants.blogspot.com/2010/08/08-12-10-lost-huffm...
Re: Building a data compression utility in Haskell using Huffman codes
#10For all readers, arithmetic codes are better in nearly all ways. They can be implemented in less RAM and code, they compress and decompress to a better ratio, and the probabilities of different symbols appearing can be dynamically updated during the stream far more easily. The only reason Huffman codes are used is they were invented first and arithmetic codes were patented. That patent has now expired, so we should u…