[FFmpeg-devel] [PATCH] avcodec/gifdec: skip data lzw consumed

nihui shuizhuyuanluo at 126.com
Tue Nov 10 12:47:59 CET 2015


At 2015-11-10 06:41:47, "Michael Niedermayer" <michael at niedermayer.cc> wrote:
>On Sat, Nov 07, 2015 at 10:23:17PM +0800, Ni Hui wrote:
>> fix the return code value of avcodec_decode_video2 for gif decoding, which should be the consumed data length.
>> 
>> ---
>>  libavcodec/gifdec.c | 2 ++
>>  1 file changed, 2 insertions(+)
>> 
>> diff --git a/libavcodec/gifdec.c b/libavcodec/gifdec.c
>> index 9f2e6eb..5bcb176 100644
>> --- a/libavcodec/gifdec.c
>> +++ b/libavcodec/gifdec.c
>> @@ -295,6 +295,8 @@ static int gif_read_image(GifState *s, AVFrame *frame)
>>      /* read the garbage data until end marker is found */
>>      ff_lzw_decode_tail(s->lzw);
>>  
>> +    bytestream2_skipu(&s->gb, bytestream2_get_bytes_left(&s->gb));
>
>ff_lzw_decode_tail() could consume less than the whole if FF_LZW_GIF
>is set
>so this doesnt seem entirely correct unless iam missing something
>

yes, it could be less than the whole
however, we have to add ff_lzw_cur_ptr() or something like ff_lzw_consumed_len() if the real bytes lzw consumed needs to be retrieved from s->lzw
such solution is obsolete for http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=3fd60d804996031ceaba9cad0b38652b92551eb0

because the whole buffer is passed into ff_lzw_decode_init() anyway no matter lzw uses it all or not,
so it seems ok to just regard all buffer as consumed from the view of gif decoder, and that's simple.

best wishes
nihui


More information about the ffmpeg-devel mailing list