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

Michael Niedermayer michaelni
Sun Mar 29 05:08:54 CEST 2009

On Sat, Mar 28, 2009 at 09:23:13PM -0400, Indrani Kundu Saha wrote:
> 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.
> Questions:

> - Is it correct to create the temp buffer using av_malloc() as a link
> list of symbols?

its probably possible to use a local array with fixed size

> - 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?

If the decoder can decode the image and its output is identical then its
probably 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


Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Rewriting code that is poorly written but fully understood is good.
Rewriting code that one doesnt understand is a sign that one is less smart
then the original author, trying to rewrite it will not make it better.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090329/8e82df8c/attachment.pgp>

More information about the ffmpeg-devel mailing list