aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/effects
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-05-04 04:53:50 -0700
committerChris Robinson <[email protected]>2018-05-04 04:53:50 -0700
commitbe30e6bf8ff02536d092af3fe5bb847a57ee1fbf (patch)
tree616d7e4faba80b3ff2410218754b4ffae1b51bfb /Alc/effects
parent1fb6428ffa2fe7030c3ccdffbe985ff184af0829 (diff)
Don't assume the FPU is round-to-zero in the pitch shifter
Diffstat (limited to 'Alc/effects')
-rw-r--r--Alc/effects/pshifter.c24
1 files changed, 3 insertions, 21 deletions
diff --git a/Alc/effects/pshifter.c b/Alc/effects/pshifter.c
index 61857343..bf36f5eb 100644
--- a/Alc/effects/pshifter.c
+++ b/Alc/effects/pshifter.c
@@ -106,28 +106,10 @@ static void InitHannWindow(void)
static alonce_flag HannInitOnce = AL_ONCE_FLAG_INIT;
-/* Fast double-to-int conversion. Assumes the FPU is already in round-to-zero
- * mode. */
-static inline ALint fastd2i(ALdouble d)
+static inline ALint double2int(ALdouble d)
{
- /* NOTE: SSE2 is required for the efficient double-to-int opcodes on x86.
- * Otherwise, we need to rely on x87's fistp opcode with it already in
- * round-to-zero mode. x86-64 guarantees SSE2 support.
- */
-#if (defined(__i386__) && !defined(__SSE2_MATH__)) || (defined(_M_IX86_FP) && (_M_IX86_FP < 2))
-#ifdef HAVE_LRINTF
- return lrint(d);
-#elif defined(_MSC_VER) && defined(_M_IX86)
- ALint i;
- __asm fld d
- __asm fistp i
- return i;
-#else
- return (ALint)d;
-#endif
-#else
+ /* TODO: Make a more efficient version for x87. */
return (ALint)d;
-#endif
}
@@ -349,7 +331,7 @@ static ALvoid ALpshifterState_process(ALpshifterState *state, ALsizei SamplesToD
tmp = (component.Phase - state->LastPhase[k]) - k*expected;
/* Map delta phase into +/- Pi interval */
- qpd = fastd2i(tmp / M_PI);
+ qpd = double2int(tmp / M_PI);
tmp -= M_PI * (qpd + (qpd%2));
/* Get deviation from bin frequency from the +/- Pi interval */