summaryrefslogtreecommitdiff
path: root/libavcodec/gifdec.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2012-11-21 21:34:46 +0100
committerAnton Khirnov <anton@khirnov.net>2013-03-08 07:38:30 +0100
commit759001c534287a96dc96d1e274665feb7059145d (patch)
tree6ace9560c20aa30db92067c5b45d7bd86e458d10 /libavcodec/gifdec.c
parent6e7b50b4270116ded8b874d76cb7c5b1a0341827 (diff)
lavc decoders: work with refcounted frames.
Diffstat (limited to 'libavcodec/gifdec.c')
-rw-r--r--libavcodec/gifdec.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/libavcodec/gifdec.c b/libavcodec/gifdec.c
index 2a962e5de0..9b74d342c8 100644
--- a/libavcodec/gifdec.c
+++ b/libavcodec/gifdec.c
@@ -34,7 +34,6 @@
#define GCE_DISPOSAL_RESTORE 3
typedef struct GifState {
- AVFrame picture;
int screen_width;
int screen_height;
int bits_per_pixel;
@@ -63,7 +62,7 @@ typedef struct GifState {
static const uint8_t gif87a_sig[6] = "GIF87a";
static const uint8_t gif89a_sig[6] = "GIF89a";
-static int gif_read_image(GifState *s)
+static int gif_read_image(GifState *s, AVFrame *frame)
{
int left, top, width, height, bits_per_pixel, code_size, flags;
int is_interleaved, has_local_palette, y, pass, y1, linesize, n, i;
@@ -112,8 +111,8 @@ static int gif_read_image(GifState *s)
s->bytestream_end - s->bytestream, FF_LZW_GIF);
/* read all the image */
- linesize = s->picture.linesize[0];
- ptr1 = s->picture.data[0] + top * linesize + left;
+ linesize = frame->linesize[0];
+ ptr1 = frame->data[0] + top * linesize + left;
ptr = ptr1;
pass = 0;
y1 = 0;
@@ -245,7 +244,7 @@ static int gif_read_header1(GifState *s)
return 0;
}
-static int gif_parse_next_image(GifState *s)
+static int gif_parse_next_image(GifState *s, AVFrame *frame)
{
while (s->bytestream < s->bytestream_end) {
int code = bytestream_get_byte(&s->bytestream);
@@ -255,7 +254,7 @@ static int gif_parse_next_image(GifState *s)
switch (code) {
case ',':
- return gif_read_image(s);
+ return gif_read_image(s, frame);
case '!':
if ((ret = gif_read_extension(s)) < 0)
return ret;
@@ -276,9 +275,6 @@ static av_cold int gif_decode_init(AVCodecContext *avctx)
s->avctx = avctx;
- avcodec_get_frame_defaults(&s->picture);
- avctx->coded_frame= &s->picture;
- s->picture.data[0] = NULL;
ff_lzw_decode_open(&s->lzw);
return 0;
}
@@ -302,18 +298,15 @@ static int gif_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
return ret;
avcodec_set_dimensions(avctx, s->screen_width, s->screen_height);
- if (s->picture.data[0])
- avctx->release_buffer(avctx, &s->picture);
- if ((ret = ff_get_buffer(avctx, &s->picture)) < 0) {
+ if ((ret = ff_get_buffer(avctx, picture, 0)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
- s->image_palette = (uint32_t *)s->picture.data[1];
- ret = gif_parse_next_image(s);
+ s->image_palette = (uint32_t *)picture->data[1];
+ ret = gif_parse_next_image(s, picture);
if (ret < 0)
return ret;
- *picture = s->picture;
*got_frame = 1;
return s->bytestream - buf;
}
@@ -323,8 +316,6 @@ static av_cold int gif_decode_close(AVCodecContext *avctx)
GifState *s = avctx->priv_data;
ff_lzw_decode_close(&s->lzw);
- if(s->picture.data[0])
- avctx->release_buffer(avctx, &s->picture);
return 0;
}