Wednesday, December 25, 2013

FMod - LZW Done

I have definitely had enough LZW compression for a while. Today, I modified the decompression algorithm to use byte arrays instead of strings and bytes instead of booleans (booleans always take four bytes). That was easy, but there was still one major thing left to do: compression.

Since I am now very familiar with the LZW way, compression was not as difficult. It did, however, require consulting a few more sources for examples in other languages. It didn't help that the site I referenced for decompression had an incorrect algorithm for compression. I did not heed the Internet's suggestions to use a real dictionary or any kind of hashing, instead using my trusty list of byte array. It required some more super inline lambdas to make accessing it work, but it's pretty fast.

Bit-level IO is done in the opposite order as decompression; it reads the input by bytes and keeps an output list of bits, which is shoved into bytes when the output is finalized.

Check it out - Keen LZW compressor in VB.NET

No comments:

Post a Comment