[Vorbis-dev] Fixed x64 patch for libvorbis r15108
cygon at nuclex.org
Thu Jul 10 23:07:12 PDT 2008
xiphmont at xiph.org wrote:
> Sorry, originally replied to only Ivo by accident:
> "Round toward closest" is the intended behavior cross-platform
> (including negative numbers), although Vorbis is not sensitive to
> specific roundoff behavior. Noise normalization in the encoder will
> mostly override the effects of dodgy rounding.
Thanks, already picked that up from the sources.
I seem to have none of the platforms available where 'truncate' is the
default rounding scheme, but as long as floor() gives consistent results
(:D) the new default rounding code you suggested should always work now.
The SSE2 code I introduced for x64 builds always performs 'toward
closest' roundings (SSE2 actually uses different instructions for
different rounding schemes, there's no error-prone switchable rounding
mode like in the FPU).
Interestingly, even if I use trunc() to force a 'truncate' rounding, the
original code would lead to incorrect results: -2.9 -> 2 and a
conditional (x < 0) ? (int)(x-.5) : (int)(x+.5) produces correct
results. At least with IEEE 754 floats, where only a bit indicates
negative numbers, 'truncate' appears to be the same as 'towards zero'
rounding, the behavior I get consistently on the machines I can test on
(msvc-win32, msvc-win64, gcc-win32, gcc-linux).
More information about the Vorbis-dev