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

2015-11-07 Thread Ni Hui
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@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2015-11-10 Thread Ni Hui
this commit 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@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2015-11-10 Thread Ni Hui
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@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel