Commit 46ad287a authored by Michael Niedermayer's avatar Michael Niedermayer

avutil/rational: avoid llrint() and rint()

This should workaround issues with these functions on ia64 and sparc64

Fixes Ticket2713
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 65abce67
......@@ -114,9 +114,10 @@ AVRational av_d2q(double d, int max)
return (AVRational) { d < 0 ? -1 : 1, 0 };
exponent = FFMAX( (int)(log(fabs(d) + 1e-20)/LOG2), 0);
den = 1LL << (61 - exponent);
av_reduce(&a.num, &a.den, rint(d * den), den, max);
// (int64_t)rint() and llrint() do not work with gcc on ia64 and sparc64
av_reduce(&a.num, &a.den, floor(d * den + 0.5), den, max);
if ((!a.num || !a.den) && d && max>0 && max<INT_MAX)
av_reduce(&a.num, &a.den, llrint(d * den), den, INT_MAX);
av_reduce(&a.num, &a.den, floor(d * den + 0.5), den, INT_MAX);
return a;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment