diff libmpcodecs/vd_ffmpeg.c @ 34221:12bcb27faa26

Do not create a 0-sized palette side data from extradata. Fixes decoding of interplay video files.
author reimar
date Sun, 06 Nov 2011 00:26:16 +0000
parents 9f7eb00ed9f8
children 43b60a64debf
line wrap: on
line diff
--- a/libmpcodecs/vd_ffmpeg.c	Sat Nov 05 23:12:16 2011 +0000
+++ b/libmpcodecs/vd_ffmpeg.c	Sun Nov 06 00:26:16 2011 +0000
@@ -785,13 +785,16 @@
     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));
+        // 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));
+        }
         ctx->palette_sent = 1;
     }
     ret = avcodec_decode_video2(avctx, pic, &got_picture, &pkt);