Forget patch 2/3 and 3/3 from the old patch set.

From the Microsoft documentation for BITMAPINFOHEADER at
https://msdn.microsoft.com/en-us/library/windows/desktop/dd318229%28v=vs.85%29.aspx:

"biSize: Specifies the number of bytes required by the structure. This
value does not include the size of the color table or the size of the
color masks, if they are appended to the end of structure."

So, biSize is always 40. Also, Windows Media Player won't detect video
encoded with Microsoft Video 1 in 8 bpp mode if this value is anything
else than 40. I don't know about other codecs, they probably work.
Anyway, we should stick with the specs, and not include the palette size
in that field.

Regarding the biClrUsed field, I'm setting it to 1 <<
bits_per_coded_sample if palettized video, since setting it to 0 is
another case where it won't work with Windows Media Player and Microsoft
Video 1 in 8 bpp mode.

Mats

--
Mats Peterson
http://matsp888.no-ip.org/~mats/
>From 55673291cb279db673b9a64fcb042fc98a3cab9b Mon Sep 17 00:00:00 2001
From: Mats Peterson <matsp...@yahoo.com>
Date: Fri, 11 Mar 2016 05:02:54 +0100
Subject: [PATCH 1/3] lavf/riffenc: Improve spec compliance

---
 libavformat/riffenc.c |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c
index 195a58e..518b292 100644
--- a/libavformat/riffenc.c
+++ b/libavformat/riffenc.c
@@ -222,8 +222,14 @@ void ff_put_bmp_header(AVIOContext *pb, AVCodecContext *enc,
     if (!enc->extradata_size && pal_avi)
         extradata_size = 4 * (1 << enc->bits_per_coded_sample);
 
-    /* size */
-    avio_wl32(pb, 40 + (ignore_extradata ? 0 :extradata_size));
+    /*
+     * Size (not including the size of extra data like the color table or
+     * color masks).
+     * An exception is made for HuffYUV, which includes the size of the
+     * Huffman tables here.
+     */
+    avio_wl32(pb, 40 + (ignore_extradata ||
+              enc->codec_id != AV_CODEC_ID_HUFFYUV ? 0 : extradata_size));
     avio_wl32(pb, enc->width);
     //We always store RGB TopDown
     avio_wl32(pb, enc->codec_tag || keep_height ? enc->height : -enc->height);
@@ -236,7 +242,8 @@ void ff_put_bmp_header(AVIOContext *pb, AVCodecContext *enc,
     avio_wl32(pb, (enc->width * enc->height * (enc->bits_per_coded_sample ? enc->bits_per_coded_sample : 24)+7) / 8);
     avio_wl32(pb, 0);
     avio_wl32(pb, 0);
-    avio_wl32(pb, 0);
+    /* number of color indices in the color table that are used */
+    avio_wl32(pb, pal_avi ? 1 << enc->bits_per_coded_sample : 0);
     avio_wl32(pb, 0);
 
     if (!ignore_extradata) {
-- 
1.7.10.4

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to