diff options
author | Mats Peterson <matsp888@yahoo.com> | 2016-02-20 12:57:50 +0100 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2016-02-21 03:30:50 +0100 |
commit | a51d82b85c83aa0d1a8295ed44a1c835065675e7 (patch) | |
tree | ffbf4f4c94a8780e486610ff71972ef619338404 /libavformat/riffenc.c | |
parent | f8d685270e5829ef670f7dc5eaa5f57a66c331d8 (diff) | |
download | ffmpeg-a51d82b85c83aa0d1a8295ed44a1c835065675e7.tar.gz |
lavf/avienc: Add palette after BITMAPINFOHEADER
lavf/riffenc: Write space for palette
tests/ref/vsynth: Update 1 bpp files for pal8
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat/riffenc.c')
-rw-r--r-- | libavformat/riffenc.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c index ceb27f272c..b626aaa0a1 100644 --- a/libavformat/riffenc.c +++ b/libavformat/riffenc.c @@ -209,6 +209,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 raw_pal_avi; + + raw_pal_avi = !for_asf && enc->codec_id == AV_CODEC_ID_RAWVIDEO && + enc->bits_per_coded_sample >= 1 && enc->bits_per_coded_sample <= 8; + if (!enc->extradata_size && raw_pal_avi) + extradata_size = 4 * (1 << enc->bits_per_coded_sample); /* size */ avio_wl32(pb, 40 + (ignore_extradata ? 0 :extradata_size)); @@ -228,10 +234,20 @@ void ff_put_bmp_header(AVIOContext *pb, AVCodecContext *enc, avio_wl32(pb, 0); if (!ignore_extradata) { - avio_write(pb, enc->extradata, extradata_size); - - if (!for_asf && extradata_size & 1) - avio_w8(pb, 0); + if (enc->extradata_size) { + avio_write(pb, enc->extradata, extradata_size); + if (!for_asf && extradata_size & 1) + avio_w8(pb, 0); + } else if (raw_pal_avi) { + int i; + for (i = 0; i < 1 << enc->bits_per_coded_sample; i++) { + /* Initialize 1 bpp palette to black & white */ + if (!i && enc->bits_per_coded_sample == 1) + avio_wl32(pb, 0xffffff); + else + avio_wl32(pb, 0); + } + } } } |