]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/gifdec.c
vc1dec: Update destination pointers in context for fields
[ffmpeg] / libavcodec / gifdec.c
index 2a962e5de0a919b6478034404124b68271db2cd2..9b74d342c8ea210f86ee0aef329e195801b8090b 100644 (file)
@@ -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;
 }