[FFmpeg-devel] [PATCH] bfi: correctly allocate palette data in the context
Stefano Sabatini
stefano.sabatini-lala at poste.it
Mon Apr 25 20:30:54 CEST 2011
Store palette data in the data, 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.
---
libavcodec/bfi.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/libavcodec/bfi.c b/libavcodec/bfi.c
index ff74233..6fc1628 100644
--- a/libavcodec/bfi.c
+++ b/libavcodec/bfi.c
@@ -34,6 +34,7 @@ typedef struct BFIContext {
AVCodecContext *avctx;
AVFrame frame;
uint8_t *dst;
+ uint32_t pal[256];
} BFIContext;
static av_cold int bfi_decode_init(AVCodecContext * avctx)
@@ -85,10 +86,13 @@ static int bfi_decode_frame(AVCodecContext * avctx, void *data,
(avctx->extradata[i * 3 + j] >> 4)) << shift;
pal++;
}
+ memcpy(bfi->pal, bfi->frame.data[1], sizeof(bfi->pal));
bfi->frame.palette_has_changed = 1;
} else {
bfi->frame.pict_type = FF_P_TYPE;
bfi->frame.key_frame = 0;
+ bfi->frame.palette_has_changed = 0;
+ memcpy(bfi->frame.data[1], bfi->pal, sizeof(bfi->pal));
}
buf += 4; //Unpacked size, not required.
--
1.7.2.3
More information about the ffmpeg-devel
mailing list