Good day! I try to understand some principles of Compression with dynamic Huffman Codes (Deflate). I made a ZIP with txt file inside and started to analyse compressed data. Here it is.
ed c2 01 0d 00 00 0c 02 a0 ac bf fd 3b 98 c3 0d c6 7d 54 55 55 55 55 55 55 75 6e 01 (in hex format)
First 3 bits - 101: 1 - last block; 10 - Compression with dynamic Huffman codes.
So 11101 = HLIT - 257; HLIT = 286; 00010 = HDIST - 1; HDIST = 3; 1110 = HCLEN - 4; HCLEN = 18.
After that i need to read HCLEN*3 bits. In my example i need to read 18*3 bits and build Huffman tree. So lets go.
Thanks for your answer!
Well i just need to decompress not all compressed data, but only a few first bytes of it and so i need to write my own function, which will be able to do it. I cant find in the net suitable code, unfortunately.
In type=2 mode you can't "just decode a few bytes" - you'd have to include half of raw2dec source,
because to decode these bytes, you need to determine which huffman codes are assigned to them.
And for that, you need to decode the primary length table and build the huffman code from it.