mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-01-11 09:59:50 +00:00
cosmetics: Use 'num' instead of 'nom' as abbreviation for numerator.
Originally committed as revision 16910 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
7591b30499
commit
674bd4f691
@ -33,23 +33,23 @@
|
|||||||
#include "mathematics.h"
|
#include "mathematics.h"
|
||||||
#include "rational.h"
|
#include "rational.h"
|
||||||
|
|
||||||
int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max){
|
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max){
|
||||||
AVRational a0={0,1}, a1={1,0};
|
AVRational a0={0,1}, a1={1,0};
|
||||||
int sign= (nom<0) ^ (den<0);
|
int sign= (num<0) ^ (den<0);
|
||||||
int64_t gcd= av_gcd(FFABS(nom), FFABS(den));
|
int64_t gcd= av_gcd(FFABS(num), FFABS(den));
|
||||||
|
|
||||||
if(gcd){
|
if(gcd){
|
||||||
nom = FFABS(nom)/gcd;
|
num = FFABS(num)/gcd;
|
||||||
den = FFABS(den)/gcd;
|
den = FFABS(den)/gcd;
|
||||||
}
|
}
|
||||||
if(nom<=max && den<=max){
|
if(num<=max && den<=max){
|
||||||
a1= (AVRational){nom, den};
|
a1= (AVRational){num, den};
|
||||||
den=0;
|
den=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(den){
|
while(den){
|
||||||
uint64_t x = nom / den;
|
uint64_t x = num / den;
|
||||||
int64_t next_den= nom - den*x;
|
int64_t next_den= num - den*x;
|
||||||
int64_t a2n= x*a1.num + a0.num;
|
int64_t a2n= x*a1.num + a0.num;
|
||||||
int64_t a2d= x*a1.den + a0.den;
|
int64_t a2d= x*a1.den + a0.den;
|
||||||
|
|
||||||
@ -57,19 +57,19 @@ int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max)
|
|||||||
if(a1.num) x= (max - a0.num) / a1.num;
|
if(a1.num) x= (max - a0.num) / a1.num;
|
||||||
if(a1.den) x= FFMIN(x, (max - a0.den) / a1.den);
|
if(a1.den) x= FFMIN(x, (max - a0.den) / a1.den);
|
||||||
|
|
||||||
if (den*(2*x*a1.den + a0.den) > nom*a1.den)
|
if (den*(2*x*a1.den + a0.den) > num*a1.den)
|
||||||
a1 = (AVRational){x*a1.num + a0.num, x*a1.den + a0.den};
|
a1 = (AVRational){x*a1.num + a0.num, x*a1.den + a0.den};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
a0= a1;
|
a0= a1;
|
||||||
a1= (AVRational){a2n, a2d};
|
a1= (AVRational){a2n, a2d};
|
||||||
nom= den;
|
num= den;
|
||||||
den= next_den;
|
den= next_den;
|
||||||
}
|
}
|
||||||
assert(av_gcd(a1.num, a1.den) <= 1U);
|
assert(av_gcd(a1.num, a1.den) <= 1U);
|
||||||
|
|
||||||
*dst_nom = sign ? -a1.num : a1.num;
|
*dst_num = sign ? -a1.num : a1.num;
|
||||||
*dst_den = a1.den;
|
*dst_den = a1.den;
|
||||||
|
|
||||||
return den==0;
|
return den==0;
|
||||||
|
@ -64,14 +64,14 @@ static inline double av_q2d(AVRational a){
|
|||||||
/**
|
/**
|
||||||
* Reduces a fraction.
|
* Reduces a fraction.
|
||||||
* This is useful for framerate calculations.
|
* This is useful for framerate calculations.
|
||||||
* @param dst_nom destination numerator
|
* @param dst_num destination numerator
|
||||||
* @param dst_den destination denominator
|
* @param dst_den destination denominator
|
||||||
* @param nom source numerator
|
* @param num source numerator
|
||||||
* @param den source denominator
|
* @param den source denominator
|
||||||
* @param max the maximum allowed for dst_nom & dst_den
|
* @param max the maximum allowed for dst_num & dst_den
|
||||||
* @return 1 if exact, 0 otherwise
|
* @return 1 if exact, 0 otherwise
|
||||||
*/
|
*/
|
||||||
int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max);
|
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Multiplies two rationals.
|
* Multiplies two rationals.
|
||||||
|
Loading…
Reference in New Issue
Block a user