[FFmpeg-devel] [PATCH] avformat/avidec: ensure that palette does not contain the BottomUp info.

Michael Niedermayer michaelni at gmx.at
Tue Sep 23 13:00:24 CEST 2014


On Tue, Sep 23, 2014 at 10:19:17AM +0200, Benoit Fouet wrote:
> Hi,
> 
> ----- Mail original -----
> > Hi,
> > 
> > ----- Mail original -----
> > 
> > [...]
> > 
> > > > > >  avienc.c |    7 +++++++
> > > > > >  1 file changed, 7 insertions(+)
> > > > > > 8ae96276e07eb00474ab2115f9ff9c3d0f690723  avienc.diff
> > > > > > diff --git a/libavformat/avienc.c b/libavformat/avienc.c
> > > > > > index c9d8b7f..2855293 100644
> > > > > > --- a/libavformat/avienc.c
> > > > > > +++ b/libavformat/avienc.c
> > > > > > @@ -299,6 +299,13 @@ static int
> > > > > > avi_write_header(AVFormatContext
> > > > > > *s)
> > > > > >          avio_wl32(pb, au_ssize); /* sample size */
> > > > > >          avio_wl32(pb, 0);
> > > > > >          avio_wl16(pb, enc->width);
> > > > > > +        if (   enc->extradata_size >= 9
> > > > > > +            && !memcmp(enc->extradata + enc->extradata_size
> > > > > > -
> > > > > > 9,
> > > > > > "BottomUp", 9)) {
> > > > > > +            enc->height = -enc->height;
> > > > > 
> > > > > i think its safer not to change AVCodecContext.height and just
> > > > > change
> > > > > the in the bitstream stored value instead
> > > > > 
> > > > 
> > > > The issue when doing this is that the BITMAPINFOHEADER is wrong.
> > > > So the image is still flipped.
> > > 
> > > Well then you need a local variable/array or value in the avi muxer
> > > context. values in AVCodecContext shouldnt really be randomly
> > > be overwritten by the muxer
> > > 
> > 
> > The only thing that is needed is to extend ff_put_bmp_header, so that
> > it can be asked to negate height in the BITMAPINFOHEADER header.
> > Would that be OK?
> > 
> 
> 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

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Let us carefully observe those good qualities wherein our enemies excel us
and endeavor to excel them, by avoiding what is faulty, and imitating what
is excellent in them. -- Plutarch
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140923/862ea6ad/attachment.asc>


More information about the ffmpeg-devel mailing list