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

Function hb_reduce

libhb/common.c:3727–3750  ·  view source on GitHub ↗

* hb_reduce ********************************************************************** * 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

3725 * equivalent fraction and store the result in x and y.
3726 *********************************************************************/
3727void hb_reduce( int *x, int *y, int num, int den )
3728{
3729 // find the greatest common divisor of num & den by Euclid's algorithm
3730 int n = num, d = den;
3731 while ( d )
3732 {
3733 int t = d;
3734 d = n % d;
3735 n = t;
3736 }
3737
3738 // at this point n is the gcd. if it's non-zero remove it from num
3739 // and den. Otherwise just return the original values.
3740 if ( n )
3741 {
3742 *x = num / n;
3743 *y = den / n;
3744 }
3745 else
3746 {
3747 *x = num;
3748 *y = den;
3749 }
3750}
3751
3752void hb_limit_rational( int *x, int *y, int64_t num, int64_t den, int limit )
3753{

Callers 6

hb_set_anamorphic_size2Function · 0.85
do_jobFunction · 0.85
DecodePreviewsFunction · 0.85
avformatInitFunction · 0.85
encavcodecInitFunction · 0.85
ghb_update_title_infoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected