ft2-clone

Fasttracker 2 clone
Log | Files | Refs | README | LICENSE

commit a2ad39d0d2debea543b5e44df66a986caf45efdd
parent 7fe7a353c680694c0223cee6cbdfce2199ed7608
Author: Olav Sørensen <olav.sorensen@live.no>
Date:   Tue, 29 Dec 2020 13:05:20 +0100

[x86/x86_64] Speed up linear interpolation resampler

Diffstat:
Msrc/mixer/ft2_mix_macros.h | 10++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/mixer/ft2_mix_macros.h b/src/mixer/ft2_mix_macros.h @@ -131,13 +131,19 @@ #define LINEAR_INTERPOLATION8(s, f) \ { \ - const double dFrac = (const double)((uint32_t)f * (1.0 / (UINT32_MAX+1.0))); /* 0.0 .. 0.999999999 */ \ + /* uint32_t -> int32_t so that we can use SIMD for fast int->double conversion */ \ + const int32_t frac = (uint32_t)(f) >> 1; /* (2^32)-1 -> (2^31)-1 */ \ + \ + const double dFrac = (double)(frac * (1.0 / (INT32_MAX+1.0))); /* 0.0 .. 0.999999999 */ \ dSample = ((s[0] + (s[1]-s[0]) * dFrac)) * (1.0 / 128.0); \ } \ #define LINEAR_INTERPOLATION16(s, f) \ { \ - const double dFrac = (const double)((uint32_t)f * (1.0 / (UINT32_MAX+1.0))); /* 0.0 .. 0.999999999 */ \ + /* uint32_t -> int32_t so that we can use SIMD for fast int->double conversion */ \ + const int32_t frac = (uint32_t)(f) >> 1; /* (2^32)-1 -> (2^31)-1 */ \ + \ + const double dFrac = (double)(frac * (1.0 / (INT32_MAX+1.0))); /* 0.0 .. 0.999999999 */ \ dSample = ((s[0] + (s[1]-s[0]) * dFrac)) * (1.0 / 32768.0); \ } \