From a57116f7888a0fdbdac9ed01ce8237c8296a2f65 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 25 Mar 2019 22:52:15 -0700 Subject: Scale floats directly to 32-bit integer values Rather than scaling to a 25-bit integer and shifting for the extra 7 bits. This should improve precision for values closer to 0. --- Alc/converter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Alc/converter.cpp') diff --git a/Alc/converter.cpp b/Alc/converter.cpp index 884a98da..5535fd42 100644 --- a/Alc/converter.cpp +++ b/Alc/converter.cpp @@ -22,7 +22,7 @@ template<> inline ALfloat LoadSample(DevFmtTypeTraits::T template<> inline ALfloat LoadSample(DevFmtTypeTraits::Type val) { return val * (1.0f/32768.0f); } template<> inline ALfloat LoadSample(DevFmtTypeTraits::Type val) -{ return (val>>7) * (1.0f/16777216.0f); } +{ return val * (1.0f/2147483648.0f); } template<> inline ALfloat LoadSample(DevFmtTypeTraits::Type val) { return val; } @@ -68,7 +68,7 @@ inline typename DevFmtTypeTraits::Type StoreSample(ALfloat); template<> inline ALfloat StoreSample(ALfloat val) { return val; } template<> inline ALint StoreSample(ALfloat val) -{ return fastf2i(clampf(val*16777216.0f, -16777216.0f, 16777215.0f))<<7; } +{ return fastf2i(clampf(val*2147483648.0f, -2147483648.0f, 2147483520.0f)); } template<> inline ALshort StoreSample(ALfloat val) { return fastf2i(clampf(val*32768.0f, -32768.0f, 32767.0f)); } template<> inline ALbyte StoreSample(ALfloat val) -- cgit v1.2.3