MCPcopy Create free account
hub / github.com/HandBrake/HandBrake / hb_reduce64

Function hb_reduce64

libhb/common.c:3789–3811  ·  view source on GitHub ↗

* hb_reduce64 ********************************************************************** * Given a numerator (num) and a denominator (den), reduce them to an * equivalent fraction and store the result in x and y. *********************************************************************/

Source from the content-addressed store, hash-verified

3787 * equivalent fraction and store the result in x and y.
3788 *********************************************************************/
3789void hb_reduce64( int64_t *x, int64_t *y, int64_t num, int64_t den )
3790{
3791 // find the greatest common divisor of num & den by Euclid's algorithm
3792 int64_t n = num, d = den;
3793 while ( d )
3794 {
3795 int64_t t = d;
3796 d = n % d;
3797 n = t;
3798 }
3799
3800 // at this point n is the gcd. if it's non-zero remove it from num
3801 // and den. Otherwise just return the original values.
3802 if ( n )
3803 {
3804 num /= n;
3805 den /= n;
3806 }
3807
3808 *x = num;
3809 *y = den;
3810
3811}
3812
3813void hb_limit_rational64( int64_t *x, int64_t *y, int64_t num, int64_t den, int64_t limit )
3814{

Callers 3

hb_set_anamorphic_size2Function · 0.85
hb_limit_rationalFunction · 0.85
hb_limit_rational64Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected