Hi, ----- Mail original ----- > Hi, > > ----- Mail original ----- > > On Tue, Sep 23, 2014 at 10:19:17AM +0200, Benoit Fouet wrote: > > > > Here is a patch to illustrate this... > > > > this looks better but: > > > > > > [...] > > > - ff_put_bmp_header(pb, enc, ff_codec_bmp_tags, 0, > > > 0); > > > + if (keep_height) { > > > + enc->extradata_size -= 9; > > > + if (!enc->extradata_size) > > > + av_freep(&enc->extradata); > > > + } > > > > what if extradata is stored in 2 files, the 2nd muxer would no > > longer > > see it > > also the muxer shouldnt change the encoders/demuxer extradata > > > > and cant all this logic be put in ff_put_bmp_header() ? > > might even be simpler > > > > Do you mean that ff_put_bmp_header() would check for the BottomUp > presence and not negate height in this case, and also only write the > palette in the stream? >
Patch attached, just in case this is what you meant...
From b8c8f07555769215af7a10c48e7a479f783a7c49 Mon Sep 17 00:00:00 2001 From: Benoit Fouet <benoit.fo...@free.fr> Date: Tue, 23 Sep 2014 10:07:10 +0200 Subject: [PATCH] avformat/riffenc: extend ff_put_bmp_header to be able to force height to not be changed. When stream copying, height shouldn't be changed when writing the BITMAPINFOHEADER header if the BottomUp information is present in the extradata. --- libavformat/riffenc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c index ef4d399..f1a2274 100644 --- a/libavformat/riffenc.c +++ b/libavformat/riffenc.c @@ -209,11 +209,13 @@ int ff_put_wav_header(AVIOContext *pb, AVCodecContext *enc, int flags) void ff_put_bmp_header(AVIOContext *pb, AVCodecContext *enc, const AVCodecTag *tags, int for_asf, int ignore_extradata) { + int keep_height = enc->extradata_size >= 9 && + !memcmp(enc->extradata + enc->extradata_size - 9, "BottomUp", 9); /* size */ avio_wl32(pb, 40 + (ignore_extradata ? 0 : enc->extradata_size)); avio_wl32(pb, enc->width); //We always store RGB TopDown - avio_wl32(pb, enc->codec_tag ? enc->height : -enc->height); + avio_wl32(pb, enc->codec_tag || keep_height ? enc->height : -enc->height); /* planes */ avio_wl16(pb, 1); /* depth */ @@ -227,7 +229,7 @@ void ff_put_bmp_header(AVIOContext *pb, AVCodecContext *enc, avio_wl32(pb, 0); if (!ignore_extradata) { - avio_write(pb, enc->extradata, enc->extradata_size); + avio_write(pb, enc->extradata, keep_height ? enc->extradata_size : enc->extradata_size - 9); if (!for_asf && enc->extradata_size & 1) avio_w8(pb, 0); -- 2.1.0.127.g0c72b98
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel