diff options
author | kcat <[email protected]> | 2019-08-18 15:15:09 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2019-08-18 15:15:09 -0700 |
commit | 71ddb86047d8bd0e3d73b3368cb92356c1ea71a3 (patch) | |
tree | 0a920cc503835067d18763a63c38426be32e89a5 /alc/effects/pshifter.cpp | |
parent | c89fb550b6d9e1afd74efca4af6570ad01ea3bfe (diff) | |
parent | 550f1dce1fa00bc084e6dacbb40fdafb6867a015 (diff) |
Merge pull request #328 from Raulshc/double2int
Move double2int function
Diffstat (limited to 'alc/effects/pshifter.cpp')
-rw-r--r-- | alc/effects/pshifter.cpp | 35 |
1 files changed, 1 insertions, 34 deletions
diff --git a/alc/effects/pshifter.cpp b/alc/effects/pshifter.cpp index 819e510c..0ba0b496 100644 --- a/alc/effects/pshifter.cpp +++ b/alc/effects/pshifter.cpp @@ -34,6 +34,7 @@ #include "alcmain.h" #include "alcomplex.h" #include "alcontext.h" +#include "alnumeric.h" #include "alu.h" @@ -48,40 +49,6 @@ using complex_d = std::complex<double>; #define STFT_STEP (STFT_SIZE / OVERSAMP) #define FIFO_LATENCY (STFT_STEP * (OVERSAMP-1)) -inline int double2int(double d) -{ -#if defined(HAVE_SSE_INTRINSICS) - return _mm_cvttsd_si32(_mm_set_sd(d)); - -#elif ((defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__)) && \ - !defined(__SSE2_MATH__)) || (defined(_MSC_VER) && defined(_M_IX86_FP) && _M_IX86_FP < 2) - - int sign, shift; - int64_t mant; - union { - double d; - int64_t i64; - } conv; - - conv.d = d; - sign = (conv.i64>>63) | 1; - shift = ((conv.i64>>52)&0x7ff) - (1023+52); - - /* Over/underflow */ - if UNLIKELY(shift >= 63 || shift < -52) - return 0; - - mant = (conv.i64&0xfffffffffffff_i64) | 0x10000000000000_i64; - if LIKELY(shift < 0) - return (int)(mant >> -shift) * sign; - return (int)(mant << shift) * sign; - -#else - - return static_cast<int>(d); -#endif -} - /* Define a Hann window, used to filter the STFT input and output. */ /* Making this constexpr seems to require C++14. */ std::array<ALdouble,STFT_SIZE> InitHannWindow() |