Mercurial > mplayer.hg
changeset 34021:fbb87f092560
Get rid of usage of deprecated palctrl which no longer works anyway.
Set up side data instead.
Note that for lavf demuxer we will use the merged side data anyway,
this is only for our own, e.g. AVI demuxer.
Fixes bug #1976.
author | reimar |
---|---|
date | Sat, 17 Sep 2011 16:48:40 +0000 |
parents | 0af747024f32 |
children | fab5ae1132e7 |
files | libmpcodecs/vd_ffmpeg.c |
diffstat | 1 files changed, 15 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpcodecs/vd_ffmpeg.c Sat Sep 17 14:56:35 2011 +0000 +++ b/libmpcodecs/vd_ffmpeg.c Sat Sep 17 16:48:40 2011 +0000 @@ -70,6 +70,7 @@ int ip_count; int b_count; AVRational last_sample_aspect_ratio; + int palette_sent; } vd_ffmpeg_ctx; #include "m_option.h" @@ -364,19 +365,6 @@ memcpy(avctx->extradata, sh->bih+1, avctx->extradata_size); break; } - /* Pass palette to codec */ - if (sh->bih && (sh->bih->biBitCount <= 8)) { - avctx->palctrl = av_mallocz(sizeof(AVPaletteControl)); - avctx->palctrl->palette_changed = 1; - if (sh->bih->biSize-sizeof(*sh->bih)) - /* Palette size in biSize */ - memcpy(avctx->palctrl->palette, sh->bih+1, - FFMIN(sh->bih->biSize-sizeof(*sh->bih), AVPALETTE_SIZE)); - else - /* Palette size in biClrUsed */ - memcpy(avctx->palctrl->palette, sh->bih+1, - FFMIN(sh->bih->biClrUsed * 4, AVPALETTE_SIZE)); - } if(sh->bih) avctx->bits_per_coded_sample= sh->bih->biBitCount; @@ -791,7 +779,21 @@ pkt.size = len; // HACK: make PNGs decode normally instead of as CorePNG delta frames pkt.flags = AV_PKT_FLAG_KEY; + if (!ctx->palette_sent && sh->bih && sh->bih->biBitCount <= 8) { + /* Pass palette to codec */ + uint8_t *pal = av_packet_new_side_data(&pkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE); + unsigned palsize = sh->bih->biSize - sizeof(*sh->bih); + if (palsize == 0) { + /* Palette size in biClrUsed */ + palsize = sh->bih->biClrUsed * 4; + } + memcpy(pal, sh->bih+1, FFMIN(palsize, AVPALETTE_SIZE)); + ctx->palette_sent = 1; + } ret = avcodec_decode_video2(avctx, pic, &got_picture, &pkt); + pkt.data = NULL; + pkt.size = 0; + av_destruct_packet(&pkt); dr1= ctx->do_dr1; if(ret<0) mp_msg(MSGT_DECVIDEO, MSGL_WARN, "Error while decoding frame!\n");