Mercurial > libavcodec.hg
diff common.c @ 1548:dd544554ed42 libavcodec
AVRational
sample_aspect_ratio
aspect ratio in JPEG JFIF is SAR not DAR !
removed nonsense SAR guessing code
various related cleanups
bugs?
author | michael |
---|---|
date | Mon, 20 Oct 2003 20:23:46 +0000 |
parents | 79dddc5cd990 |
children | 932d306bf1dc |
line wrap: on
line diff
--- a/common.c Mon Oct 20 10:33:13 2003 +0000 +++ b/common.c Mon Oct 20 20:23:46 2003 +0000 @@ -386,29 +386,3 @@ if(b) return ff_gcd(b, a%b); else return a; } - -void ff_float2fraction(int *nom_arg, int *denom_arg, double f, int max){ - double best_diff=1E10, diff; - int best_denom=1, best_nom=1; - int nom, denom, gcd; - - //brute force here, perhaps we should try continued fractions if we need large max ... - for(denom=1; denom<=max; denom++){ - nom= (int)(f*denom + 0.5); - if(nom<=0 || nom>max) continue; - - diff= ABS( f - (double)nom / (double)denom ); - if(diff < best_diff){ - best_diff= diff; - best_nom= nom; - best_denom= denom; - } - } - - gcd= ff_gcd(best_nom, best_denom); - best_nom /= gcd; - best_denom /= gcd; - - *nom_arg= best_nom; - *denom_arg= best_denom; -}