From f7813a5324be39d13ab536c245d15dfc602a7849 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Sun, 29 Dec 2013 12:19:38 +0000 Subject: basic type mechanism working --- ffmpeg/libavutil/rational.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'ffmpeg/libavutil/rational.c') diff --git a/ffmpeg/libavutil/rational.c b/ffmpeg/libavutil/rational.c index 768f252..ec2f2e5 100644 --- a/ffmpeg/libavutil/rational.c +++ b/ffmpeg/libavutil/rational.c @@ -26,7 +26,6 @@ */ #include "avassert.h" -//#include #include #include "common.h" @@ -111,11 +110,14 @@ AVRational av_d2q(double d, int max) int64_t den; if (isnan(d)) return (AVRational) { 0,0 }; - if (isinf(d)) + if (fabs(d) > INT_MAX + 3LL) 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, (int64_t)(d * den + 0.5), 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