Browse code

bfi: store palette data in the context

Store palette data in the codec context, do not assume that the frame
allocated the first time by avctx->get_buffer will be returned again.

This requires to store the palette which comes with the first frame in
the context, and copy it to the following frames.

Fix trac issue #84.

Signed-off-by: Stefano Sabatini <stefano.sabatini-lala@poste.it>

Stefano Sabatini authored on 2011/04/26 03:26:15
Showing 1 changed files
... ...
@@ -34,6 +34,7 @@ typedef struct BFIContext {
34 34
     AVCodecContext *avctx;
35 35
     AVFrame frame;
36 36
     uint8_t *dst;
37
+    uint32_t pal[256];
37 38
 } BFIContext;
38 39
 
39 40
 static av_cold int bfi_decode_init(AVCodecContext * avctx)
... ...
@@ -85,10 +86,13 @@ static int bfi_decode_frame(AVCodecContext * avctx, void *data,
85 85
                     (avctx->extradata[i * 3 + j] >> 4)) << shift;
86 86
             pal++;
87 87
         }
88
+        memcpy(bfi->pal, bfi->frame.data[1], sizeof(bfi->pal));
88 89
         bfi->frame.palette_has_changed = 1;
89 90
     } else {
90 91
         bfi->frame.pict_type = FF_P_TYPE;
91 92
         bfi->frame.key_frame = 0;
93
+        bfi->frame.palette_has_changed = 0;
94
+        memcpy(bfi->frame.data[1], bfi->pal, sizeof(bfi->pal));
92 95
     }
93 96
 
94 97
     buf += 4; //Unpacked size, not required.