How to decode adaptive huffman?

1

I am trying to decompress what would be a PNG file, I have come to the part of obtaining the data already compressed from the IDAT section, as I understand these data are decoded in an Adaptive Huffman, I have already researched in certain pages on the subject but I've run into the problem of not knowing how to sort the data, because as I've seen you have to sort them based on:

  

16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15

but nevertheless they are limited in showing a chain already ordered, the data that I have been able to obtain are:

  

HLIT = 286, HDIST = 27 and HCEN = 14

based on what would be HCEN I have obtained a series of bits grouped every 3 bits, which are as follows:

[ 110, 6 ][ 110, 6 ][ 101, 5 ][ 100, 4 ][ 011, 3 ][ 011, 3 ][ 000, 0 ][ 011, 3 ][ 000, 0 ][ 010, 2 ][ 000, 0 ][ 011, 3 ][ 000, 0 ][ 011, 3 ]

It should be noted that the corresponding value in decimal is found next to the bits.

In case what I'm looking for is the correct way to sort the bits and how to decompress the remaining data.

Update

Well I do not know if what I've done is fine but note that the sequence of 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2 , 14, 1, 15 corresponds to the new position of the elements because the bits seem to be disordered, so the bit that is worth 6 in the first position would now be in position 16 of a new clear chain that starts counting from 0

    
asked by Carlos Alexander 05.12.2018 в 18:13
source

0 answers