Mercurial > mplayer.hg
diff libmpcodecs/vd_ffmpeg.c @ 34313:8f2167abd6e0
Try harder to extract a sensible palette from extradata.
Fixes samples/V-codecs/QPEG/MITSUMI.AVI.
author | reimar |
---|---|
date | Tue, 06 Dec 2011 19:59:16 +0000 |
parents | 119af6360b00 |
children | 7203c1affdc9 |
line wrap: on
line diff
--- a/libmpcodecs/vd_ffmpeg.c Mon Dec 05 18:27:40 2011 +0000 +++ b/libmpcodecs/vd_ffmpeg.c Tue Dec 06 19:59:16 2011 +0000 @@ -787,15 +787,21 @@ pkt.flags = AV_PKT_FLAG_KEY; if (!ctx->palette_sent && sh->bih && sh->bih->biBitCount <= 8) { /* Pass palette to codec */ + uint8_t *pal_data = (uint8_t *)(sh->bih+1); unsigned palsize = sh->bih->biSize - sizeof(*sh->bih); - if (palsize == 0) { - /* Palette size in biClrUsed */ - palsize = sh->bih->biClrUsed * 4; + unsigned needed_size = 4 << sh->bih->biBitCount; + // Assume palette outside bih in rest of chunk. + // Fixes samples/V-codecs/QPEG/MITSUMI.AVI + if (palsize < needed_size && + sh->bih_size > sh->bih->biSize && + sh->bih_size - sh->bih->biSize > palsize) { + pal_data = (uint8_t *)sh->bih + sh->bih->biSize; + palsize = sh->bih_size - sh->bih->biSize; } // if still 0, we simply have no palette in extradata. if (palsize) { uint8_t *pal = av_packet_new_side_data(&pkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE); - memcpy(pal, sh->bih+1, FFMIN(palsize, AVPALETTE_SIZE)); + memcpy(pal, pal_data, FFMIN(palsize, AVPALETTE_SIZE)); } ctx->palette_sent = 1; }