[Ffmpeg-devel] [PATCH] change gif demuxer to gif decoder

Justin Ruggles jruggle
Sun Oct 22 20:37:51 CEST 2006


Benjamin Larsson wrote:
> Baptiste Coudurier wrote:
> 
> 
>>Hi
>>
>>Benjamin Larsson wrote:
>> 
>>
>>
>>>Baptiste Coudurier wrote:
>>>
>>>   
>>>
>>>
>>>>[...]
>>>>
>>>>     
>>>>
>>>>
>>>>>>>      
>>>>>>>
>>>>>>>           
>>>>>>>
>>>>>>
>>>>>>Ok, I'll do that. May I commit ?
>>>>>>    
>>>>>>
>>>>>>         
>>>>>>
>>>>>
>>>>>yes
>>>>>
>>>>>[...]
>>>>>  
>>>>>
>>>>>       
>>>>>
>>>>
>>>>Applied.
>>>>
>>>>
>>>>
>>>>     
>>>>
>>>
>>>Hi, can you export the gif LZW decoding code somehow ? It would be
>>>useful for tiff in mov.
>>>
>>>   
>>>
>>
>>Well, I guess, just move the code out of gifdec.c and put it in lzw.c,
>>do you want me to do it ?
>>
>> 
>>
> 
> 
> If it is ok with Michael. One thing though is that I don't know if the
> lzw in tiff is the same as in gif.

But looking having implemented TIFF LZW decoding and looking at the GIF
spec, they seem to be the same for 8-bit, but are different for other
bit depths.  GIF adapts the code size to the bit depth, while TIFF
always uses 8-bit codes no matter what.  From the 2 specs:

TIFF 6.0:
"The 'characters' that make up the LZW strings are bytes containing TIFF
uncompressed (Compression=1) image data, in out implementation. For
example, if BitsPerSample is 4, each 8-bit LZW character will contain
two 4-bit pixels. If BitsPerSample is 16, each 16-bit pixel will span
two 8-bit LZW characters."

GIF 89a:
"ESTABLISH CODE SIZE
The first byte of the Compressed Data stream is a value indicating the
minimum number of bits required to represent the set of actual pixel
values. Normally this will be the same as the number of color bits.
Because of some algorithmic constraints however, black & white images
which have one color bit must be indicated as having a code size of 2.
This code size value also implies that the compression codes must start
out one bit longer."

Hope that helps.  It doesn't look like it would be too hard to make a
single implementation which would work for both formats.

-Justin




More information about the ffmpeg-devel mailing list