[FFmpeg-devel] [Question] Optimal Huffman Table for MJPEG
Sat Apr 11 09:16:39 CEST 2009
On Sat, Apr 11, 2009 at 4:03 AM, Indrani Kundu Saha
<indranikundusaha at gmail.com> wrote:
> Suppose after the frame has been encoded, I have the following encoded
> symbols for DC Luminance:
> 14 24 6 29 14 29 62 150
> Now, I create a huffman tree out of these symbols and assign codes as follows:
> 29:00 14:01 6:100 24:011 150:010 62:001
> Thus, we have two codes of length 02, and 3 codes of length 03.
> Now the Huffman table takes in only the codeword length and the code
> word itself.
> How do I convert this to a Huffman table representation (i.e. length -
> Can I use:
> length - Bits - Code
> 02 ? ? ? 00,01 - ?01, 02
> 03 ? ? ? 011,010,001 - 03,04,05
> I have a bug in my code and I think it might be related to my updating the DHT.
> Similar logic applies to DC chrominance and AC luminance/chrominance.
Have you ever heard of prefix property of codes? Each Huffman code
should not be a prefix of another code (like 01 and 011 in your case),
otherwise it cannot be decoded properly. Maybe just inversion of codes
would be enough for you (i.e. 001 -> 100)
More information about the ffmpeg-devel