[MPlayer-dev-eng] [PATCH] MPEG-2 TS 60000/1001 FPS Conversion Error in mencoder
Uoti Urpala
uoti.urpala at pp1.inet.fi
Sun Nov 26 22:48:43 CET 2006
On Sun, 2006-11-26 at 15:58 -0500, Eric Lammerts wrote:
> When you go from a rational number to floating point and then back to a
> rational number you'll lose precision. It is unavoidable.
It's avoidable if there's a limit on the numerator/denominator sizes of
the rationals and the floats have enough precision compared to that. The
difference of two rationals a/b and p/q is at least 1/bq; thus if you
have a limit M then converting a float point number approximating a/b
back to the closest possible rational gives a/b as long as the floating
point number has enough precision to tell it's closer to a/b than to
(a/b +- 1/bM)=(a*M +- 1)/bM. About log2(M**2) == 2log2(M) bits of
precision is enough to convert any rational within that limit to
floating point and back without any loss of precision.
> So we should either fix that and make the fps numbers rationals, or (as a
> dirty workaround) make everything after such conversions less picky about
> exact matches (e.g., in find_frame_rate_index() change the "if(dmin)" to
> "if(dmin > 1)").
Just using doubles instead of single precision floats should be enough
as long as the frame rates do not have numerators or denominators in the
tens of millions.
More information about the MPlayer-dev-eng
mailing list