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

Michael Niedermayer michaelni at gmx.at
Mon Sep 22 15:40:48 CEST 2014


On Mon, Sep 22, 2014 at 12:14:53PM +0200, Benoit Fouet wrote:
> Hi,
> 
> ----- Mail original -----
> > On Mon, Sep 22, 2014 at 11:28:31AM +0200, Benoit Fouet wrote:
> > > Hi,
> > > 
> > > ----- Mail original -----
> > > > On Mon, Sep 22, 2014 at 09:57:37AM +0200, Benoit Fouet wrote:
> > > > > Considering the palette is located at the end of extradata may
> > > > > be
> > > > > flawed
> > > > > when the extradata contains the palette followed by the
> > > > > BottomUp
> > > > > field.
> > > > > When the BottomUp field is present, exclude it from the
> > > > > palette.
> > > > > Fixes ticket #1304
> > > > > ---
> > > > >  libavformat/avidec.c | 4 ++++
> > > > >  1 file changed, 4 insertions(+)
> > > > > 
> > > > > diff --git a/libavformat/avidec.c b/libavformat/avidec.c
> > > > > index 5b260e2..f7b15b7 100644
> > > > > --- a/libavformat/avidec.c
> > > > > +++ b/libavformat/avidec.c
> > > > > @@ -756,6 +756,10 @@ static int avi_read_header(AVFormatContext
> > > > > *s)
> > > > >                          pal_size = FFMIN(pal_size,
> > > > >                          st->codec->extradata_size);
> > > > >                          pal_src  = st->codec->extradata +
> > > > >                                     st->codec->extradata_size -
> > > > >                                     pal_size;
> > > > > +                        /* Exclude the "BottomUp" field from
> > > > > the
> > > > > palette */
> > > > > +                        if (pal_src - st->codec->extradata >=
> > > > > 9 &&
> > > > > +                            !memcmp(st->codec->extradata +
> > > > > st->codec->extradata_size - 9, "BottomUp", 9))
> > > > > +                            pal_src -= 9;
> > > > >                          for (i = 0; i < pal_size / 4; i++)
> > > > >                              ast->pal[i] = 0xFFU<<24 |
> > > > >                              AV_RL32(pal_src+4*i);
> > > > >                          ast->has_pal = 1;
> > > > 
> > > > applied
> > > > 
> > > > though i suspect this only fixes demuxing/decoding of remuxed
> > > > files
> > > > with ffmpeg/ffplay.
> > > > I suspect the remuxed files still wont play with the official
> > > > avi/rawvideo code from MS or whatever the "reference" code would
> > > > be
> > > > 
> > > 
> > > I also have a "fix" for the muxer, though I'm still trying to see
> > > what the consequences of such a patch could be...
> > > See attached.
> > > 
> > > --
> > > Ben
> > > 
> > 
> > >  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. Sop 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

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User
questions about the command line tools should be sent to the ffmpeg-user ML.
And questions about how to use libav* should be sent to the libav-user ML.
-------------- 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/20140922/b8a2195a/attachment.asc>


More information about the ffmpeg-devel mailing list