-- Mats Peterson http://matsp888.no-ip.org/~mats/
>From 602db1c464b7a432b4f4b471cbeed401cd220e4c Mon Sep 17 00:00:00 2001 From: Mats Peterson <matsp...@yahoo.com> Date: Thu, 3 Mar 2016 00:28:23 +0100 Subject: [PATCH v5 3/4] lavf/riffenc: Handle palette for non-raw codecs
--- libavformat/riffenc.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c index 1dd7971..195a58e 100644 --- a/libavformat/riffenc.c +++ b/libavformat/riffenc.c @@ -209,12 +209,17 @@ 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; + enum AVPixelFormat pix_fmt = enc->pix_fmt; + int pal_avi; - raw_pal_avi = !for_asf && enc->codec_id == AV_CODEC_ID_RAWVIDEO && - !enc->codec_tag && - enc->bits_per_coded_sample >= 1 && enc->bits_per_coded_sample <= 8; - if (!enc->extradata_size && raw_pal_avi) + if (pix_fmt == AV_PIX_FMT_NONE && enc->bits_per_coded_sample == 1) + pix_fmt = AV_PIX_FMT_MONOWHITE; + pal_avi = !for_asf && + (pix_fmt == AV_PIX_FMT_PAL8 || + 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 */ @@ -239,11 +244,8 @@ void ff_put_bmp_header(AVIOContext *pb, AVCodecContext *enc, avio_write(pb, enc->extradata, extradata_size); if (!for_asf && extradata_size & 1) avio_w8(pb, 0); - } else if (raw_pal_avi) { + } else if (pal_avi) { int i; - enum AVPixelFormat pix_fmt = enc->pix_fmt; - if (pix_fmt == AV_PIX_FMT_NONE && enc->bits_per_coded_sample == 1) - pix_fmt = AV_PIX_FMT_MONOWHITE; for (i = 0; i < 1 << enc->bits_per_coded_sample; i++) { /* Initialize 1 bpp palette to black & white */ if (i == 0 && pix_fmt == AV_PIX_FMT_MONOWHITE) -- 1.7.10.4
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel