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

nihui shuizhuyuanluo at 126.com
Mon Nov 9 04:05:28 CET 2015


hi

I've attached a testcase for the issus it fixed
check the mail attachment please

best wishes
nihui


At 2015-11-07 23:13:42, "nihui" <shuizhuyuanluo at 126.com> wrote:
>avcodec_decode_video2 should return the number of bytes used if frame decompressed correctly
>the current gif decoder just returns the number of bytes of header part of one frame, not including the lzw compressed image data bytes, which should be included too
>
>as one avpacket may contain multiple picture frame
>the following usecase will fail on the second call of decode function (nused is smaller than expected for gif animation)
>
>// pkt is a valid AVPacket from av_read_frame loop
>while (pkt.size > 0)
>{
>    int nused = avcodec_decode_video2( ..... );
>    if (nused < 0)
>    {
>        // deocde error
>    }
>    ...... // process here
>    ......
>    pkt.data += nused;
>    pkt.size -= nused;
>}
>
>
>best wishes
>nihui
>
>At 2015-11-07 22:35:06, "Paul B Mahol" <onemda at gmail.com> wrote:
>>On 11/7/15, Ni Hui <shuizhuyuanluo at 126.com> 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));
>>> +
>>>      /* Graphic Control Extension's scope is single frame.
>>>       * Remove its influence. */
>>>      s->transparent_color_index = -1;
>>> --
>>> 2.4.1
>>>
>>>
>>> _______________________________________________
>>> ffmpeg-devel mailing list
>>> ffmpeg-devel at ffmpeg.org
>>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>
>>
>>Are there files this actually fixes?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: a.gif
Type: image/gif
Size: 265717 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20151109/ffab0d07/attachment.gif>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: main.cpp
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20151109/ffab0d07/attachment.ksh>


More information about the ffmpeg-devel mailing list