[FFmpeg-devel] Question: Optimal Huffman Table for (M)JPEG: GSoC Qual task

Indrani Kundu Saha indranikundusaha
Sun Mar 29 03:23:13 CEST 2009

For creating the optimal huffman encoding, I am doing the following:
+ After encoding the frame, the probability of each byte/word is put
in a temp buffer. The temp buffer is created using av_malloc().
+Huffman Tree is built over the symbols and code words assigned to each symbol.

- Is it correct to create the temp buffer using av_malloc() as a link
list of symbols?
- I am using all the symbols present after the header and before the
EOI marker (0xFFD9). This includes all the AC/DC coeff for Y/C_b/C_r.
- When I am re-encoding the image  with the optimal Huffman tree, as
created above, I am writing dumping the codeword associated with each
symbol. For eg, if word 'DA' gets code word 1001, then I am doing
    put_bits(p, 8, 3E9);
This is done over all the symbols. This greatly reduces the encoded image size.
Is this correct?

-  Do I need to replace the DHT with the optimum huffman table so that
the decoder can understand? If not, how does the decoder understand
the optimum table?


More information about the ffmpeg-devel mailing list