[FFmpeg-devel] [PATCH] Fix Raw rgb/bgr Vertical Flip in AviSynth

Josh Harris qt
Mon Aug 31 05:19:21 CEST 2009


on 8/29/2009 5:46 AM Reimar D?ffinger wrote:
> On Sun, Aug 23, 2009 at 11:39:50PM -0700, Josh Harris wrote:
>   
>> Index: libavformat/avisynth.c
>> ===================================================================
>> --- libavformat/avisynth.c	(revision 19254)
>> +++ libavformat/avisynth.c	(working copy)
>> @@ -124,6 +124,14 @@
>>                    st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, imgfmt.bmiHeader.biCompression);
>>  
>>                    st->duration = stream->info.dwLength;
>> +
>> +                  if (st->codec->codec_tag == 0 && st->codec->height > 0 && st->codec->extradata_size < 1U<<30){
>>     
>
> Going by codec_tag seems simply wrong, sure it shouldn't be codec_id?
>
>   
>> +                    st->codec->extradata_size += 9;
>> +                    st->codec->extradata = av_realloc(st->codec->extradata, st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
>> +                    if (st->codec->extradata)
>> +                      memcpy(st->codec->extradata + st->codec->extradata_size - 9, "BottomUp", 9);
>> +                  }
>>     
>
> Why all the mess? It seems to me that extradata is never set, so why use
> realloc etc.? Similar to r19698 should be enough I think.
>   

To be honest, I don't know...Code was commited (r17475) to
libavformat/avidec.c to handle this for AVIs (
http://lists.mplayerhq.hu/pipermail/ffmpeg-cvslog/2009-February/020437.html
) on 2009-02-21 and it was written using codec_tag and realloc.  I just
copied it from there.

>   
>> +                  st->codec->height = FFABS(st->codec->height);
>>     
>
> Is there a sample for that (height < 0)?
>   

For AviSynth scripts, not that I know of, so I guess the FFABS line can
be considered unnecessary but it seems like good practice to leave it
in.  The problem is that the code commited in r17475 to
libavcodec/rawdec.c assumes TopDown for raw RGB data unless
st->codec->extradata is set with BottomUp.  This means that AviSynth
RGB24 and RGB32 scripts are currently being decoded upside down.



More information about the ffmpeg-devel mailing list