Reputation: 185
I am trying to implement an inflate algorithm for deflate-compressed data with static Huffman codes. After reading the specification I came into conclusion that these the steps that I am going to need:
Am I missing steps, or adding unnecessary steps?
Upvotes: 0
Views: 76
Reputation: 112404
#2 requires reading the specification, if there is one, after the first three bits. Those bits indicate if there is a specification, or if you should use the static tree description, or if the data is stored with no compression. In the latter case, you skip steps #2-4 and instead read the block length and complement, and then that number of bytes for that block.
#3 should be: decode the Huffman codes until an end-block code is read.
#4 is done at the same time as #3. As each code is decoded, that action is taken to generate the uncompressed data.
There should be a step #5: if that was not the last block (so marked in the first three bits), then go back to step #1.
Upvotes: 1