[MPlayer-cvslog] r34401 - in trunk: libmpcodecs/vd_ffmpeg.c libmpdemux/aviheader.c libmpdemux/stheader.h
reimar
subversion at mplayerhq.hu
Tue Dec 6 20:59:17 CET 2011
Author: reimar
Date: Tue Dec 6 20:59:16 2011
New Revision: 34401
Log:
Try harder to extract a sensible palette from extradata.
Fixes samples/V-codecs/QPEG/MITSUMI.AVI.
Modified:
trunk/libmpcodecs/vd_ffmpeg.c
trunk/libmpdemux/aviheader.c
trunk/libmpdemux/stheader.h
Modified: trunk/libmpcodecs/vd_ffmpeg.c
==============================================================================
--- trunk/libmpcodecs/vd_ffmpeg.c Mon Dec 5 19:27:40 2011 (r34400)
+++ trunk/libmpcodecs/vd_ffmpeg.c Tue Dec 6 20:59:16 2011 (r34401)
@@ -787,15 +787,21 @@ static mp_image_t *decode(sh_video_t *sh
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;
}
Modified: trunk/libmpdemux/aviheader.c
==============================================================================
--- trunk/libmpdemux/aviheader.c Mon Dec 5 19:27:40 2011 (r34400)
+++ trunk/libmpdemux/aviheader.c Tue Dec 6 20:59:16 2011 (r34401)
@@ -267,7 +267,8 @@ while(1){
break; }
case ckidSTREAMFORMAT: { // read 'strf'
if(last_fccType==streamtypeVIDEO){
- sh_video->bih=calloc(FFMAX(chunksize, sizeof(*sh_video->bih)), 1);
+ sh_video->bih_size = FFMAX(chunksize, sizeof(*sh_video->bih));
+ sh_video->bih=calloc(sh_video->bih_size, 1);
// sh_video->bih=malloc(chunksize); memset(sh_video->bih,0,chunksize);
mp_msg(MSGT_HEADER, MSGL_V, "Found 'bih', %u bytes of %zu\n",
chunksize, sizeof(*sh_video->bih));
Modified: trunk/libmpdemux/stheader.h
==============================================================================
--- trunk/libmpdemux/stheader.h Mon Dec 5 19:27:40 2011 (r34400)
+++ trunk/libmpdemux/stheader.h Tue Dec 6 20:59:16 2011 (r34401)
@@ -116,6 +116,7 @@ typedef struct sh_video {
// win32-compatible codec parameters:
AVIStreamHeader video;
BITMAPINFOHEADER* bih;
+ int bih_size;
void* ImageDesc; // for quicktime codecs
} sh_video_t;
More information about the MPlayer-cvslog
mailing list