[FFmpeg-devel] [PATCH]Do not add palette size to the bitmapheader size

Carl Eugen Hoyos cehoyos at ag.or.at
Mon Sep 29 09:33:16 CEST 2014


On Monday 29 September 2014 01:22:38 am Carl Eugen Hoyos wrote:
> Attached patch is the first part of the fix for ticket #1304.

New, tested patch attached.

Please comment, Carl Eugen
-------------- next part --------------
diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c
index 2eb2ae1..723e802 100644
--- a/libavformat/riffenc.c
+++ b/libavformat/riffenc.c
@@ -212,9 +212,12 @@ void ff_put_bmp_header(AVIOContext *pb, AVCodecContext *enc,
     int keep_height = enc->extradata_size >= 9 &&
                       !memcmp(enc->extradata + enc->extradata_size - 9, "BottomUp", 9);
     int extradata_size = enc->extradata_size - 9*keep_height;
+    int palette_size = enc->pix_fmt == AV_PIX_FMT_PAL8 && extradata_size >= AVPALETTE_SIZE ?
+                       AVPALETTE_SIZE :
+                       0;
 
     /* size */
-    avio_wl32(pb, 40 + (ignore_extradata ? 0 :extradata_size));
+    avio_wl32(pb, 40 + (ignore_extradata ? 0 : extradata_size - palette_size));
     avio_wl32(pb, enc->width);
     //We always store RGB TopDown
     avio_wl32(pb, enc->codec_tag || keep_height ? enc->height : -enc->height);


More information about the ffmpeg-devel mailing list