[FFmpeg-devel] [PATCH 7/7] Add check in av_write_header() which validates the rawvideo codec tag.

Stefano Sabatini stefano.sabatini-lala
Sat Jun 5 21:46:07 CEST 2010


On date Thursday 2010-06-03 02:06:40 +0200, Michael Niedermayer encoded:
> On Wed, Jun 02, 2010 at 07:35:47PM +0200, Stefano Sabatini wrote:
> > On date Tuesday 2010-06-01 19:59:55 +0200, Michael Niedermayer encoded:
> > > On Tue, Jun 01, 2010 at 07:29:34PM +0200, Stefano Sabatini wrote:
> > [...]
> > > what is unclear on
> > > rgb in avi must use codec_tag=0 ?
> > > the raw rgb format in avi is indicated by the number of bits per pixel
> > > not by the fourcc which must be set to 0.
> > > 
> > > 
> > > > 
> > > > What the code currently implements is just wrong for both AVI and NUT,
> > > > in the case of AVI if the pixel format cannot be mapped to any codec
> > > > tag, codec_tag is set to 0,
> > > 
> > > it must be 0 this is as it should be
> > > 
> > > 
> > > > which when reading it is interpreted as
> > > > YUV420P,
> > > 
> > > if so thats a bug and i would suspect a new one
> > 
> > A possible fix for nut attached.
> 
> what bug?
> this patch looks just wrong

If the pixel format is not associated to any codec tag, then the
rawvideo encoder sets to 0 the codec tag.
Then in av_write_header(), we have:

        if(s->oformat->codec_tag){
            if(st->codec->codec_tag){
                ...
            }else
                st->codec->codec_tag= av_codec_get_tag(s->oformat->codec_tag, st->codec->codec_id);
        }

and av_codec_get_tag() sets the value to the first value corresponding
to rawvideo. av_codec_get_tag() looks in ff_bmp_codec_tags and then in
ff_nut_video_tags, and takes the first entry of ff_nut_video_tags,
which is RGB15.

See the attached patch, I hope I got it right this time.
 
> we need a
> if(codec_id == CODEC_ID_RAWVIDEO && rgb)
>     codec_tag= 0
> in avienc.c before codec_tag is written in the file.
> 
> it just doesnt work without that.

I'll eventually post a fix for AVI in a separate thread.

Regards.
-- 
FFmpeg = Fabulous and Formidable Multimedia Puritan Efficient Gospel



More information about the ffmpeg-devel mailing list