From 2d8591c27e2dc582a7020e2580e16278dbfbddff Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Sat, 9 Apr 2011 15:49:51 +0200 Subject: make containers pass palette change in AVPacket Signed-off-by: Luca Barbato --- libavcodec/msrle.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'libavcodec/msrle.c') diff --git a/libavcodec/msrle.c b/libavcodec/msrle.c index a400589fde..f426b058bd 100644 --- a/libavcodec/msrle.c +++ b/libavcodec/msrle.c @@ -26,9 +26,6 @@ * http://www.pcisys.net/~melanson/codecs/ * * The MS RLE decoder outputs PAL8 colorspace data. - * - * Note that this decoder expects the palette colors from the end of the - * BITMAPINFO header passed through palctrl. */ #include @@ -46,6 +43,7 @@ typedef struct MsrleContext { const unsigned char *buf; int size; + uint32_t pal[256]; } MsrleContext; static av_cold int msrle_decode_init(AVCodecContext *avctx) @@ -91,13 +89,16 @@ static int msrle_decode_frame(AVCodecContext *avctx, return -1; } - if (s->avctx->palctrl) { - /* make the palette available */ - memcpy(s->frame.data[1], s->avctx->palctrl->palette, AVPALETTE_SIZE); - if (s->avctx->palctrl->palette_changed) { + if (avctx->bits_per_coded_sample <= 8) { + const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); + + if (pal) { s->frame.palette_has_changed = 1; - s->avctx->palctrl->palette_changed = 0; + memcpy(s->pal, pal, AVPALETTE_SIZE); } + + /* make the palette available */ + memcpy(s->frame.data[1], s->pal, AVPALETTE_SIZE); } /* FIXME how to correctly detect RLE ??? */ -- cgit v1.2.3