I hope this one is an acceptable compromise. Original description follows:
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 40 for palettized video as well. And Windows Media Player
won't display any video when using Microsoft Video 1 in 8 bpp mode or
RLE4/RLE8 if this value is set to anything else than 40.
Regarding the biClrUsed field, I'm setting it to 1 <<
bits_per_coded_sample if palettized video, since setting it to 0 won't
work with Windows Media Player and AVI files with xxpc (palette change)
chunks for some reason.
Mats
--
Mats Peterson
http://matsp888.no-ip.org/~mats/
>From 1abbf6d514963e94578160fabc829d8bdd6d72c0 Mon Sep 17 00:00:00 2001
From: Mats Peterson <matsp...@yahoo.com>
Date: Sun, 13 Mar 2016 08:59:22 +0100
Subject: [PATCH 1/2 v2] lavf/riffenc: Improve spec compliance; Fix WMP playback of AVI with xxpc chunks
---
libavformat/riffenc.c | 12 ++++++------
tests/ref/lavf-fate/avi_cram | 2 +-
tests/ref/vsynth/vsynth1-bpp1 | 2 +-
tests/ref/vsynth/vsynth2-bpp1 | 2 +-
tests/ref/vsynth/vsynth3-bpp1 | 2 +-
tests/ref/vsynth/vsynth_lena-bpp1 | 2 +-
tests/ref/vsynth/vsynth_lena-ffv1-v3-yuv420 | 4 ----
7 files changed, 11 insertions(+), 15 deletions(-)
delete mode 100644 tests/ref/vsynth/vsynth_lena-ffv1-v3-yuv420
diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c
index 195a58e..33879ea 100644
--- a/libavformat/riffenc.c
+++ b/libavformat/riffenc.c
@@ -219,11 +219,8 @@ void ff_put_bmp_header(AVIOContext *pb, AVCodecContext *enc,
pix_fmt == AV_PIX_FMT_MONOWHITE ||
pix_fmt == AV_PIX_FMT_MONOBLACK);
- 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 the color table or color masks) */
+ avio_wl32(pb, 40 + (ignore_extradata || pal_avi ? 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 +233,10 @@ 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.
+ * A value of 0 means 2^biBitCount indices, but this doesn't work
+ * with Windows Media Player and files containing xxpc chunks. */
+ avio_wl32(pb, pal_avi ? 1 << enc->bits_per_coded_sample : 0);
avio_wl32(pb, 0);
if (!ignore_extradata) {
diff --git a/tests/ref/lavf-fate/avi_cram b/tests/ref/lavf-fate/avi_cram
index 7864ab9..7b4e69c 100644
--- a/tests/ref/lavf-fate/avi_cram
+++ b/tests/ref/lavf-fate/avi_cram
@@ -1,3 +1,3 @@
-e202447ccd6660149c17070204d258a4 *./tests/data/lavf-fate/lavf.avi
+ba77c5c8bd2b0d1e0478d143346cc3b3 *./tests/data/lavf-fate/lavf.avi
928228 ./tests/data/lavf-fate/lavf.avi
./tests/data/lavf-fate/lavf.avi CRC=0xa4770de2
diff --git a/tests/ref/vsynth/vsynth1-bpp1 b/tests/ref/vsynth/vsynth1-bpp1
index 92d5987..af1fb0e 100644
--- a/tests/ref/vsynth/vsynth1-bpp1
+++ b/tests/ref/vsynth/vsynth1-bpp1
@@ -1,4 +1,4 @@
-0fcba876d3e499c0bebf7bb32a7f83f2 *tests/data/fate/vsynth1-bpp1.avi
+a0b35707a9aa7144e3e1c70c1d01f4ce *tests/data/fate/vsynth1-bpp1.avi
640460 tests/data/fate/vsynth1-bpp1.avi
cd1e1448d9895561347ceb66d0add34d *tests/data/fate/vsynth1-bpp1.out.rawvideo
stddev: 84.48 PSNR: 9.60 MAXDIFF: 218 bytes: 7603200/ 7603200
diff --git a/tests/ref/vsynth/vsynth2-bpp1 b/tests/ref/vsynth/vsynth2-bpp1
index 2a2a63e..4005755 100644
--- a/tests/ref/vsynth/vsynth2-bpp1
+++ b/tests/ref/vsynth/vsynth2-bpp1
@@ -1,4 +1,4 @@
-af7eae5293b820493d1f4e6d258d8da0 *tests/data/fate/vsynth2-bpp1.avi
+a0330430d7dbd76cbd6d099b778397e8 *tests/data/fate/vsynth2-bpp1.avi
640460 tests/data/fate/vsynth2-bpp1.avi
f0dfc0e87e5d96bce29a5944b1bd7471 *tests/data/fate/vsynth2-bpp1.out.rawvideo
stddev: 68.98 PSNR: 11.36 MAXDIFF: 218 bytes: 7603200/ 7603200
diff --git a/tests/ref/vsynth/vsynth3-bpp1 b/tests/ref/vsynth/vsynth3-bpp1
index b3b757c..3c8c47a 100644
--- a/tests/ref/vsynth/vsynth3-bpp1
+++ b/tests/ref/vsynth/vsynth3-bpp1
@@ -1,4 +1,4 @@
-01b0fbf35305b50b1c148c0a23f2cff4 *tests/data/fate/vsynth3-bpp1.avi
+4c8777a88a9e52b99d5a345acffcbf06 *tests/data/fate/vsynth3-bpp1.avi
20460 tests/data/fate/vsynth3-bpp1.avi
52ae74ef7910e5b603c12288d425b9ae *tests/data/fate/vsynth3-bpp1.out.rawvideo
stddev: 84.76 PSNR: 9.57 MAXDIFF: 232 bytes: 86700/ 86700
diff --git a/tests/ref/vsynth/vsynth_lena-bpp1 b/tests/ref/vsynth/vsynth_lena-bpp1
index 57219cc..3489989 100644
--- a/tests/ref/vsynth/vsynth_lena-bpp1
+++ b/tests/ref/vsynth/vsynth_lena-bpp1
@@ -1,4 +1,4 @@
-930d019cbf8e06c67bdec58a3639c045 *tests/data/fate/vsynth_lena-bpp1.avi
+32673399a8442e397a608839eb3e95cb *tests/data/fate/vsynth_lena-bpp1.avi
640460 tests/data/fate/vsynth_lena-bpp1.avi
6183ba861d4e48d4aaefc514fde270e5 *tests/data/fate/vsynth_lena-bpp1.out.rawvideo
stddev: 83.28 PSNR: 9.72 MAXDIFF: 215 bytes: 7603200/ 7603200
diff --git a/tests/ref/vsynth/vsynth_lena-ffv1-v3-yuv420 b/tests/ref/vsynth/vsynth_lena-ffv1-v3-yuv420
deleted file mode 100644
index 7db437e..0000000
--- a/tests/ref/vsynth/vsynth_lena-ffv1-v3-yuv420
+++ /dev/null
@@ -1,4 +0,0 @@
-ed72c22374718589ffacd7ea15424687 *tests/data/fate/vsynth_lena-ffv1-v3-yuv420.avi
-3547792 tests/data/fate/vsynth_lena-ffv1-v3-yuv420.avi
-dde5895817ad9d219f79a52d0bdfb001 *tests/data/fate/vsynth_lena-ffv1-v3-yuv420.out.rawvideo
-stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 7603200/ 7603200
--
1.7.10.4
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel