[MPlayer-dev-eng] [PATCH] float comparisons and A/V desynchronization fix (mainly with real videos)
Rich Felker
dalias at aerifal.cx
Fri May 5 17:31:37 CEST 2006
On Fri, May 05, 2006 at 10:33:50AM +0200, Pierre Lombard wrote:
> Hi,
>
> The culprit file is libmpdemux/video.c: because of how floats are
> encoded in computers, you may almost never compare directly floating
> points values (floats are not a totally ordered set unlike integers for
> instance).
>
> This is why most math libs have an epsilon and also why a (myfloat ==
> 0.0f) will almost always fail...
>
> FWIW, I chose epsilon to be 1.0f/1000.0f as it seems to match a 1000fps
> precision - though it should indeed be related to both compared numbers.
1. All floats should be replaced with double.
2. Epsilon should be based on magnitude of both values and DBL_EPSILON
from float.h.
Rich
More information about the MPlayer-dev-eng
mailing list