diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2006-07-20 10:14:06 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2006-07-20 10:14:06 +0000 |
commit | 79dc59b726f73f9464c8d5f74e8a01fab8151836 (patch) | |
tree | ee949090217c6864f3410028763502dc3bc4d212 /libavutil/rational.c | |
parent | 0912bf577afdac4505d4186d918ca7e59688453d (diff) | |
download | ffmpeg-79dc59b726f73f9464c8d5f74e8a01fab8151836.tar.gz |
simplify
Originally committed as revision 5802 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavutil/rational.c')
-rw-r--r-- | libavutil/rational.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/libavutil/rational.c b/libavutil/rational.c index df4b218317..4a7b0edf72 100644 --- a/libavutil/rational.c +++ b/libavutil/rational.c @@ -76,8 +76,7 @@ AVRational av_mul_q(AVRational b, AVRational c){ * returns b/c. */ AVRational av_div_q(AVRational b, AVRational c){ - av_reduce(&b.num, &b.den, b.num * (int64_t)c.den, b.den * (int64_t)c.num, INT_MAX); - return b; + return av_mul_q(b, (AVRational){c.den, c.num}); } /** @@ -92,8 +91,7 @@ AVRational av_add_q(AVRational b, AVRational c){ * returns b-c. */ AVRational av_sub_q(AVRational b, AVRational c){ - av_reduce(&b.num, &b.den, b.num * (int64_t)c.den - c.num * (int64_t)b.den, b.den * (int64_t)c.den, INT_MAX); - return b; + return av_add_q(b, (AVRational){-c.num, c.den}); } /** @@ -102,7 +100,8 @@ AVRational av_sub_q(AVRational b, AVRational c){ */ AVRational av_d2q(double d, int max){ AVRational a; - int exponent= FFMAX( (int)(log(fabs(d) + 1e-20)/log(2)), 0); +#define LOG2 0.69314718055994530941723212145817656807550013436025 + int exponent= FFMAX( (int)(log(fabs(d) + 1e-20)/LOG2), 0); int64_t den= 1LL << (61 - exponent); av_reduce(&a.num, &a.den, (int64_t)(d * den + 0.5), den, max); |