[FFmpeg-devel] [PATCH] avoid floating point for -t endtime

Michael Niedermayer michaelni
Sun Feb 7 01:22:57 CET 2010


On Sat, Feb 06, 2010 at 04:16:20PM +0100, Reimar D?ffinger wrote:
> On Sat, Feb 06, 2010 at 03:36:14PM +0100, Michael Niedermayer wrote:
> > On Sat, Feb 06, 2010 at 02:38:27PM +0100, Reimar D?ffinger wrote:
> > > Hello,
> > > currently the roqvideo FATE test produces different results because of this.
> > > While the test needs to be changed anyway, patch below makes them give identical
> > > results.
> > > The calculation is not 100% exact since I can't multiply recording_time with
> > > anything to avoid an overflow (actually I am not sure about the av_mul_q of
> > > time_base and pts either).
> > 
> > see compare_ts() from nut.txt
> > also if we dont have such a function, it might make sense to add it to
> > libavutil
> 
> We have, attached patch uses it after moving it to libavutil.
> (Note I will test it as soon as compilation finishes, in about 15 minutes).

[...]
> @@ -127,3 +127,26 @@
>  
>      return nearest_q_idx;
>  }
> +
> +int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b)
> +{
> +    int64_t a, b, res;
> +
> +    if (ts_a == INT64_MIN)
> +        return ts_a < ts_b ? -1 : 0;
> +    if (ts_a == INT64_MAX)
> +        return ts_a > ts_b ?  1 : 0;
> +    if (ts_b == INT64_MIN)
> +        return ts_a > ts_b ?  1 : 0;
> +    if (ts_b == INT64_MAX)
> +        return ts_a < ts_b ? -1 : 0;
> +
> +    a = ts_a * tb_a.num * tb_b.den;
> +    b = ts_b * tb_b.num * tb_a.den;

read the nut spec again about compare_ts() this overflows for rather small
numbers

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

When the tyrant has disposed of foreign enemies by conquest or treaty, and
there is nothing more to fear from them, then he is always stirring up
some war or other, in order that the people may require a leader. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100207/c2dc0fd0/attachment.pgp>



More information about the ffmpeg-devel mailing list