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

Paul B Mahol onemda at gmail.com
Tue Nov 10 19:45:09 CET 2015


On 11/10/15, Ni Hui <shuizhuyuanluo at 126.com> wrote:
> this updated patch fix the return code of avcodec_decode_video2 for gif
> decoding
>
> ff_lzw_decode_tail() now returns the consumed bytes in lzw decompress
> and gif frame data buffer is skipped properly
> gifdec is the only user of ff_lzw_decode_tail()
>
> my usecase tested and the return code problem got disappered :)
>
>
> ---
>  libavcodec/gifdec.c | 5 +++--
>  libavcodec/lzw.c    | 3 ++-
>  libavcodec/lzw.h    | 2 +-
>  3 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/libavcodec/gifdec.c b/libavcodec/gifdec.c
> index 9f2e6eb..20ae903 100644
> --- a/libavcodec/gifdec.c
> +++ b/libavcodec/gifdec.c
> @@ -130,7 +130,7 @@ static void gif_copy_img_rect(const uint32_t *src,
> uint32_t *dst,
>  static int gif_read_image(GifState *s, AVFrame *frame)
>  {
>      int left, top, width, height, bits_per_pixel, code_size, flags, pw;
> -    int is_interleaved, has_local_palette, y, pass, y1, linesize, pal_size;
> +    int is_interleaved, has_local_palette, y, pass, y1, linesize, pal_size,
> lzwed_len;
>      uint32_t *ptr, *pal, *px, *pr, *ptr1;
>      int ret;
>      uint8_t *idx;
> @@ -293,7 +293,8 @@ static int gif_read_image(GifState *s, AVFrame *frame)
>
>   decode_tail:
>      /* read the garbage data until end marker is found */
> -    ff_lzw_decode_tail(s->lzw);
> +    lzwed_len = ff_lzw_decode_tail(s->lzw);
> +    bytestream2_skipu(&s->gb, lzwed_len);
>
>      /* Graphic Control Extension's scope is single frame.
>       * Remove its influence. */
> diff --git a/libavcodec/lzw.c b/libavcodec/lzw.c
> index 6832c12..b0b9a34 100644
> --- a/libavcodec/lzw.c
> +++ b/libavcodec/lzw.c
> @@ -93,7 +93,7 @@ static int lzw_get_code(struct LZWState * s)
>      return c & s->curmask;
>  }
>
> -void ff_lzw_decode_tail(LZWState *p)
> +int ff_lzw_decode_tail(LZWState *p)
>  {
>      struct LZWState *s = (struct LZWState *)p;
>
> @@ -104,6 +104,7 @@ void ff_lzw_decode_tail(LZWState *p)
>          }
>      }else
>          bytestream2_skip(&s->gb, bytestream2_get_bytes_left(&s->gb));
> +    return bytestream2_tell(&s->gb);
>  }
>
>  av_cold void ff_lzw_decode_open(LZWState **p)
> diff --git a/libavcodec/lzw.h b/libavcodec/lzw.h
> index 4653c1c..6af8a6b 100644
> --- a/libavcodec/lzw.h
> +++ b/libavcodec/lzw.h
> @@ -47,7 +47,7 @@ void ff_lzw_decode_open(LZWState **p);
>  void ff_lzw_decode_close(LZWState **p);
>  int ff_lzw_decode_init(LZWState *s, int csize, const uint8_t *buf, int
> buf_size, int mode);
>  int ff_lzw_decode(LZWState *s, uint8_t *buf, int len);
> -void ff_lzw_decode_tail(LZWState *lzw);
> +int ff_lzw_decode_tail(LZWState *lzw);
>
>  /** LZW encode state */
>  struct LZWEncodeState;
> --
> 2.4.1
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

probably ok


More information about the ffmpeg-devel mailing list