[FFmpeg-devel] [PATCH] Add a time_base field to AVFilterPad.

Stefano Sabatini stefano.sabatini-lala
Tue Oct 5 11:16:51 CEST 2010


On date Monday 2010-10-04 00:12:15 +0200, Michael Niedermayer encoded:
> On Sun, Oct 03, 2010 at 11:23:49PM +0200, Stefano Sabatini wrote:
> > On date Sunday 2010-10-03 21:07:55 +0200, Michael Niedermayer encoded:
[...]
> > static int config_output(AVFilterLink *outlink)
> > {
> >     AVFilterContext *ctx = outlink->src;
> > 
> >     /* choose the output timebase */
> >     AVRational tb1 = ctx->input_pads[MAIN   ].time_base;
> >     AVRational tb2 = ctx->input_pads[OVERLAY].time_base;
> >     AVRational tb;
> >     int exact = 1;
> > 
> >     exact *= av_reduce(&tb1.num, &tb1.den, tb1.num, tb1.den, INT32_MAX);
> >     exact *= av_reduce(&tb2.num, &tb2.den, tb2.num, tb2.den, INT32_MAX);
> >     exact *= av_reduce(&tb.num, &tb.den,
> >                        (int64_t)tb1.num * tb2.num, (int64_t)tb1.den * tb2.den, INT_MAX);
> 
> your code makes no sense
> with a/b and c/d
> 
> you need something like:
> reduce(gcd(ad,cb)/bd)

AVRational = {int, int}

int*int may overflow int64_t, so I convert {int,int} to {int32_t,int32_t}.

Finally I do int32_t*int32_t in the third reduce, so I know that it
can't overflow int64_t:
   exact *= av_reduce(&tb.num, &tb.den,
                      (int64_t)tb1.num * tb2.num, (int64_t)tb1.den * tb2.den, INT_MAX);

Regards.
-- 
FFmpeg = Fundamental and Fabulous Mythic Peaceful Ephemeral Genius



More information about the ffmpeg-devel mailing list