Commit f4e486a9 authored by michael's avatar michael

simplify


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@5802 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent d63bda6d
...@@ -76,8 +76,7 @@ AVRational av_mul_q(AVRational b, AVRational c){ ...@@ -76,8 +76,7 @@ AVRational av_mul_q(AVRational b, AVRational c){
* returns b/c. * returns b/c.
*/ */
AVRational av_div_q(AVRational b, AVRational 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 av_mul_q(b, (AVRational){c.den, c.num});
return b;
} }
/** /**
...@@ -92,8 +91,7 @@ AVRational av_add_q(AVRational b, AVRational c){ ...@@ -92,8 +91,7 @@ AVRational av_add_q(AVRational b, AVRational c){
* returns b-c. * returns b-c.
*/ */
AVRational av_sub_q(AVRational b, AVRational 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 av_add_q(b, (AVRational){-c.num, c.den});
return b;
} }
/** /**
...@@ -102,7 +100,8 @@ AVRational av_sub_q(AVRational b, AVRational c){ ...@@ -102,7 +100,8 @@ AVRational av_sub_q(AVRational b, AVRational c){
*/ */
AVRational av_d2q(double d, int max){ AVRational av_d2q(double d, int max){
AVRational a; 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); int64_t den= 1LL << (61 - exponent);
av_reduce(&a.num, &a.den, (int64_t)(d * den + 0.5), den, max); av_reduce(&a.num, &a.den, (int64_t)(d * den + 0.5), den, max);
......
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