diff options
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/mixer.c | 59 | ||||
-rw-r--r-- | Alc/mixer_c.c | 3 | ||||
-rw-r--r-- | Alc/mixer_defs.h | 11 | ||||
-rw-r--r-- | Alc/mixer_neon.c | 83 | ||||
-rw-r--r-- | Alc/mixer_sse3.c | 75 | ||||
-rw-r--r-- | Alc/mixer_sse41.c | 81 |
6 files changed, 26 insertions, 286 deletions
diff --git a/Alc/mixer.c b/Alc/mixer.c index d5cf30cc..a48b0e29 100644 --- a/Alc/mixer.c +++ b/Alc/mixer.c @@ -43,22 +43,21 @@ static_assert((INT_MAX>>FRACTIONBITS)/MAX_PITCH > BUFFERSIZE, extern inline void InitiatePositionArrays(ALuint frac, ALint increment, ALuint *restrict frac_arr, ALint *restrict pos_arr, ALsizei size); -alignas(16) union ResamplerCoeffs ResampleCoeffs; +alignas(16) ALfloat ResampleCoeffs_FIR4[FRACTIONONE][4]; enum Resampler { PointResampler, LinearResampler, FIR4Resampler, - FIR8Resampler, BSincResampler, ResamplerDefault = LinearResampler }; -/* FIR8 requires 3 extra samples before the current position, and 4 after. */ -static_assert(MAX_PRE_SAMPLES >= 3, "MAX_PRE_SAMPLES must be at least 3!"); -static_assert(MAX_POST_SAMPLES >= 4, "MAX_POST_SAMPLES must be at least 4!"); +/* BSinc requires up to 11 extra samples before the current position, and 12 after. */ +static_assert(MAX_PRE_SAMPLES >= 11, "MAX_PRE_SAMPLES must be at least 11!"); +static_assert(MAX_POST_SAMPLES >= 12, "MAX_POST_SAMPLES must be at least 12!"); static MixerFunc MixSamples = Mix_C; @@ -140,20 +139,6 @@ static inline ResamplerFunc SelectResampler(enum Resampler resampler) return Resample_fir4_32_SSE3; #endif return Resample_fir4_32_C; - case FIR8Resampler: -#ifdef HAVE_NEON - if((CPUCapFlags&CPU_CAP_NEON)) - return Resample_fir8_32_Neon; -#endif -#ifdef HAVE_SSE4_1 - if((CPUCapFlags&CPU_CAP_SSE4_1)) - return Resample_fir8_32_SSE41; -#endif -#ifdef HAVE_SSE3 - if((CPUCapFlags&CPU_CAP_SSE3)) - return Resample_fir8_32_SSE3; -#endif - return Resample_fir8_32_C; case BSincResampler: #ifdef HAVE_NEON if((CPUCapFlags&CPU_CAP_NEON)) @@ -264,13 +249,11 @@ void aluInitMixer(void) resampler = LinearResampler; else if(strcasecmp(str, "sinc4") == 0) resampler = FIR4Resampler; - else if(strcasecmp(str, "sinc8") == 0) - resampler = FIR8Resampler; else if(strcasecmp(str, "bsinc") == 0) resampler = BSincResampler; - else if(strcasecmp(str, "cubic") == 0) + else if(strcasecmp(str, "cubic") == 0 || strcasecmp(str, "sinc8") == 0) { - WARN("Resampler option \"cubic\" is deprecated, using sinc4\n"); + WARN("Resampler option \"%s\" is deprecated, using sinc4\n", str); resampler = FIR4Resampler; } else @@ -284,28 +267,14 @@ void aluInitMixer(void) } } - if(resampler == FIR8Resampler) - for(i = 0;i < FRACTIONONE;i++) - { - ALdouble mu = (ALdouble)i / FRACTIONONE; - ResampleCoeffs.FIR8[i][0] = SincKaiser(4.0, mu - -3.0); - ResampleCoeffs.FIR8[i][1] = SincKaiser(4.0, mu - -2.0); - ResampleCoeffs.FIR8[i][2] = SincKaiser(4.0, mu - -1.0); - ResampleCoeffs.FIR8[i][3] = SincKaiser(4.0, mu - 0.0); - ResampleCoeffs.FIR8[i][4] = SincKaiser(4.0, mu - 1.0); - ResampleCoeffs.FIR8[i][5] = SincKaiser(4.0, mu - 2.0); - ResampleCoeffs.FIR8[i][6] = SincKaiser(4.0, mu - 3.0); - ResampleCoeffs.FIR8[i][7] = SincKaiser(4.0, mu - 4.0); - } - else if(resampler == FIR4Resampler) - for(i = 0;i < FRACTIONONE;i++) - { - ALdouble mu = (ALdouble)i / FRACTIONONE; - ResampleCoeffs.FIR4[i][0] = SincKaiser(2.0, mu - -1.0); - ResampleCoeffs.FIR4[i][1] = SincKaiser(2.0, mu - 0.0); - ResampleCoeffs.FIR4[i][2] = SincKaiser(2.0, mu - 1.0); - ResampleCoeffs.FIR4[i][3] = SincKaiser(2.0, mu - 2.0); - } + for(i = 0;i < FRACTIONONE;i++) + { + ALdouble mu = (ALdouble)i / FRACTIONONE; + ResampleCoeffs_FIR4[i][0] = SincKaiser(2.0, mu - -1.0); + ResampleCoeffs_FIR4[i][1] = SincKaiser(2.0, mu - 0.0); + ResampleCoeffs_FIR4[i][2] = SincKaiser(2.0, mu - 1.0); + ResampleCoeffs_FIR4[i][3] = SincKaiser(2.0, mu - 2.0); + } MixHrtfSamples = SelectHrtfMixer(); MixSamples = SelectMixer(); diff --git a/Alc/mixer_c.c b/Alc/mixer_c.c index 323f1363..a3d79a46 100644 --- a/Alc/mixer_c.c +++ b/Alc/mixer_c.c @@ -14,8 +14,6 @@ static inline ALfloat lerp32(const ALfloat *restrict vals, ALuint frac) { return lerp(vals[0], vals[1], frac * (1.0f/FRACTIONONE)); } static inline ALfloat fir4_32(const ALfloat *restrict vals, ALuint frac) { return resample_fir4(vals[-1], vals[0], vals[1], vals[2], frac); } -static inline ALfloat fir8_32(const ALfloat *restrict vals, ALuint frac) -{ return resample_fir8(vals[-3], vals[-2], vals[-1], vals[0], vals[1], vals[2], vals[3], vals[4], frac); } const ALfloat *Resample_copy32_C(const InterpState* UNUSED(state), @@ -51,7 +49,6 @@ const ALfloat *Resample_##Sampler##_C(const InterpState* UNUSED(state), \ DECL_TEMPLATE(point32) DECL_TEMPLATE(lerp32) DECL_TEMPLATE(fir4_32) -DECL_TEMPLATE(fir8_32) #undef DECL_TEMPLATE diff --git a/Alc/mixer_defs.h b/Alc/mixer_defs.h index 60735c9f..b76c9aee 100644 --- a/Alc/mixer_defs.h +++ b/Alc/mixer_defs.h @@ -16,7 +16,6 @@ const ALfloat *Resample_copy32_C(const InterpState *state, const ALfloat *restri const ALfloat *Resample_point32_C(const InterpState *state, const ALfloat *restrict src, ALuint frac, ALint increment, ALfloat *restrict dst, ALsizei dstlen); const ALfloat *Resample_lerp32_C(const InterpState *state, const ALfloat *restrict src, ALuint frac, ALint increment, ALfloat *restrict dst, ALsizei dstlen); const ALfloat *Resample_fir4_32_C(const InterpState *state, const ALfloat *restrict src, ALuint frac, ALint increment, ALfloat *restrict dst, ALsizei dstlen); -const ALfloat *Resample_fir8_32_C(const InterpState *state, const ALfloat *restrict src, ALuint frac, ALint increment, ALfloat *restrict dst, ALsizei dstlen); const ALfloat *Resample_bsinc32_C(const InterpState *state, const ALfloat *restrict src, ALuint frac, ALint increment, ALfloat *restrict dst, ALsizei dstlen); @@ -81,13 +80,6 @@ const ALfloat *Resample_fir4_32_SSE41(const InterpState *state, const ALfloat *r ALuint frac, ALint increment, ALfloat *restrict dst, ALsizei numsamples); -const ALfloat *Resample_fir8_32_SSE3(const InterpState *state, const ALfloat *restrict src, - ALuint frac, ALint increment, ALfloat *restrict dst, - ALsizei numsamples); -const ALfloat *Resample_fir8_32_SSE41(const InterpState *state, const ALfloat *restrict src, - ALuint frac, ALint increment, ALfloat *restrict dst, - ALsizei numsamples); - const ALfloat *Resample_bsinc32_SSE(const InterpState *state, const ALfloat *restrict src, ALuint frac, ALint increment, ALfloat *restrict dst, ALsizei dstlen); @@ -115,9 +107,6 @@ const ALfloat *Resample_lerp32_Neon(const InterpState *state, const ALfloat *res const ALfloat *Resample_fir4_32_Neon(const InterpState *state, const ALfloat *restrict src, ALuint frac, ALint increment, ALfloat *restrict dst, ALsizei numsamples); -const ALfloat *Resample_fir8_32_Neon(const InterpState *state, const ALfloat *restrict src, - ALuint frac, ALint increment, ALfloat *restrict dst, - ALsizei numsamples); const ALfloat *Resample_bsinc32_Neon(const InterpState *state, const ALfloat *restrict src, ALuint frac, ALint increment, ALfloat *restrict dst, ALsizei dstlen); diff --git a/Alc/mixer_neon.c b/Alc/mixer_neon.c index 543ff0f3..727c5c55 100644 --- a/Alc/mixer_neon.c +++ b/Alc/mixer_neon.c @@ -90,10 +90,10 @@ const ALfloat *Resample_fir4_32_Neon(const InterpState* UNUSED(state), const float32x4_t val1 = vld1q_f32(&src[pos_[1]]); const float32x4_t val2 = vld1q_f32(&src[pos_[2]]); const float32x4_t val3 = vld1q_f32(&src[pos_[3]]); - float32x4_t k0 = vld1q_f32(ResampleCoeffs.FIR4[frac_[0]]); - float32x4_t k1 = vld1q_f32(ResampleCoeffs.FIR4[frac_[1]]); - float32x4_t k2 = vld1q_f32(ResampleCoeffs.FIR4[frac_[2]]); - float32x4_t k3 = vld1q_f32(ResampleCoeffs.FIR4[frac_[3]]); + float32x4_t k0 = vld1q_f32(ResampleCoeffs_FIR4[frac_[0]]); + float32x4_t k1 = vld1q_f32(ResampleCoeffs_FIR4[frac_[1]]); + float32x4_t k2 = vld1q_f32(ResampleCoeffs_FIR4[frac_[2]]); + float32x4_t k3 = vld1q_f32(ResampleCoeffs_FIR4[frac_[3]]); float32x4_t out; k0 = vmulq_f32(k0, val0); @@ -136,81 +136,6 @@ const ALfloat *Resample_fir4_32_Neon(const InterpState* UNUSED(state), return dst; } -const ALfloat *Resample_fir8_32_Neon(const InterpState* UNUSED(state), - const ALfloat *restrict src, ALuint frac, ALint increment, - ALfloat *restrict dst, ALsizei numsamples) -{ - const int32x4_t increment4 = vdupq_n_s32(increment*4); - const uint32x4_t fracMask4 = vdupq_n_u32(FRACTIONMASK); - alignas(16) ALint pos_[4]; - alignas(16) ALuint frac_[4]; - int32x4_t pos4; - uint32x4_t frac4; - ALsizei i, j; - - InitiatePositionArrays(frac, increment, frac_, pos_, 4); - - frac4 = vld1q_u32(frac_); - pos4 = vld1q_s32(pos_); - - src -= 3; - for(i = 0;numsamples-i > 3;i += 4) - { - float32x4_t out[2]; - for(j = 0;j < 8;j+=4) - { - const float32x4_t val0 = vld1q_f32(&src[pos_[0]+j]); - const float32x4_t val1 = vld1q_f32(&src[pos_[1]+j]); - const float32x4_t val2 = vld1q_f32(&src[pos_[2]+j]); - const float32x4_t val3 = vld1q_f32(&src[pos_[3]+j]); - float32x4_t k0 = vld1q_f32(&ResampleCoeffs.FIR4[frac_[0]][j]); - float32x4_t k1 = vld1q_f32(&ResampleCoeffs.FIR4[frac_[1]][j]); - float32x4_t k2 = vld1q_f32(&ResampleCoeffs.FIR4[frac_[2]][j]); - float32x4_t k3 = vld1q_f32(&ResampleCoeffs.FIR4[frac_[3]][j]); - - k0 = vmulq_f32(k0, val0); - k1 = vmulq_f32(k1, val1); - k2 = vmulq_f32(k2, val2); - k3 = vmulq_f32(k3, val3); - k0 = vcombine_f32(vpadd_f32(vget_low_f32(k0), vget_high_f32(k0)), - vpadd_f32(vget_low_f32(k1), vget_high_f32(k1))); - k2 = vcombine_f32(vpadd_f32(vget_low_f32(k2), vget_high_f32(k2)), - vpadd_f32(vget_low_f32(k3), vget_high_f32(k3))); - out[j>>2] = vcombine_f32(vpadd_f32(vget_low_f32(k0), vget_high_f32(k0)), - vpadd_f32(vget_low_f32(k2), vget_high_f32(k2))); - } - - out[0] = vaddq_f32(out[0], out[1]); - vst1q_f32(&dst[i], out[0]); - - frac4 = vaddq_u32(frac4, (uint32x4_t)increment4); - pos4 = vaddq_s32(pos4, (int32x4_t)vshrq_n_u32(frac4, FRACTIONBITS)); - frac4 = vandq_u32(frac4, fracMask4); - - vst1q_s32(pos_, pos4); - vst1q_u32(frac_, frac4); - } - - if(i < numsamples) - { - /* NOTE: These four elements represent the position *after* the last - * four samples, so the lowest element is the next position to - * resample. - */ - ALint pos = pos_[0]; - frac = frac_[0]; - do { - dst[i] = resample_fir8(src[pos ], src[pos+1], src[pos+2], src[pos+3], - src[pos+4], src[pos+5], src[pos+6], src[pos+7], frac); - - frac += increment; - pos += frac>>FRACTIONBITS; - frac &= FRACTIONMASK; - } while(++i < numsamples); - } - return dst; -} - const ALfloat *Resample_bsinc32_Neon(const InterpState *state, const ALfloat *restrict src, ALuint frac, ALint increment, ALfloat *restrict dst, ALsizei dstlen) diff --git a/Alc/mixer_sse3.c b/Alc/mixer_sse3.c index 3b444158..861cfc38 100644 --- a/Alc/mixer_sse3.c +++ b/Alc/mixer_sse3.c @@ -55,10 +55,10 @@ const ALfloat *Resample_fir4_32_SSE3(const InterpState* UNUSED(state), const __m128 val1 = _mm_loadu_ps(&src[pos_.i[1]]); const __m128 val2 = _mm_loadu_ps(&src[pos_.i[2]]); const __m128 val3 = _mm_loadu_ps(&src[pos_.i[3]]); - __m128 k0 = _mm_load_ps(ResampleCoeffs.FIR4[frac_.i[0]]); - __m128 k1 = _mm_load_ps(ResampleCoeffs.FIR4[frac_.i[1]]); - __m128 k2 = _mm_load_ps(ResampleCoeffs.FIR4[frac_.i[2]]); - __m128 k3 = _mm_load_ps(ResampleCoeffs.FIR4[frac_.i[3]]); + __m128 k0 = _mm_load_ps(ResampleCoeffs_FIR4[frac_.i[0]]); + __m128 k1 = _mm_load_ps(ResampleCoeffs_FIR4[frac_.i[1]]); + __m128 k2 = _mm_load_ps(ResampleCoeffs_FIR4[frac_.i[2]]); + __m128 k3 = _mm_load_ps(ResampleCoeffs_FIR4[frac_.i[3]]); __m128 out; k0 = _mm_mul_ps(k0, val0); @@ -95,70 +95,3 @@ const ALfloat *Resample_fir4_32_SSE3(const InterpState* UNUSED(state), } return dst; } - -const ALfloat *Resample_fir8_32_SSE3(const InterpState* UNUSED(state), - const ALfloat *restrict src, ALuint frac, ALint increment, - ALfloat *restrict dst, ALsizei numsamples) -{ - const __m128i increment4 = _mm_set1_epi32(increment*4); - const __m128i fracMask4 = _mm_set1_epi32(FRACTIONMASK); - union { alignas(16) ALint i[4]; float f[4]; } pos_; - union { alignas(16) ALuint i[4]; float f[4]; } frac_; - __m128i frac4, pos4; - ALsizei i, j; - ALint pos; - - InitiatePositionArrays(frac, increment, frac_.i, pos_.i, 4); - - frac4 = _mm_castps_si128(_mm_load_ps(frac_.f)); - pos4 = _mm_castps_si128(_mm_load_ps(pos_.f)); - - src -= 3; - for(i = 0;numsamples-i > 3;i += 4) - { - __m128 out[2]; - for(j = 0;j < 8;j+=4) - { - const __m128 val0 = _mm_loadu_ps(&src[pos_.i[0]+j]); - const __m128 val1 = _mm_loadu_ps(&src[pos_.i[1]+j]); - const __m128 val2 = _mm_loadu_ps(&src[pos_.i[2]+j]); - const __m128 val3 = _mm_loadu_ps(&src[pos_.i[3]+j]); - __m128 k0 = _mm_load_ps(&ResampleCoeffs.FIR8[frac_.i[0]][j]); - __m128 k1 = _mm_load_ps(&ResampleCoeffs.FIR8[frac_.i[1]][j]); - __m128 k2 = _mm_load_ps(&ResampleCoeffs.FIR8[frac_.i[2]][j]); - __m128 k3 = _mm_load_ps(&ResampleCoeffs.FIR8[frac_.i[3]][j]); - - k0 = _mm_mul_ps(k0, val0); - k1 = _mm_mul_ps(k1, val1); - k2 = _mm_mul_ps(k2, val2); - k3 = _mm_mul_ps(k3, val3); - k0 = _mm_hadd_ps(k0, k1); - k2 = _mm_hadd_ps(k2, k3); - out[j>>2] = _mm_hadd_ps(k0, k2); - } - - out[0] = _mm_add_ps(out[0], out[1]); - _mm_store_ps(&dst[i], out[0]); - - frac4 = _mm_add_epi32(frac4, increment4); - pos4 = _mm_add_epi32(pos4, _mm_srli_epi32(frac4, FRACTIONBITS)); - frac4 = _mm_and_si128(frac4, fracMask4); - - _mm_store_ps(pos_.f, _mm_castsi128_ps(pos4)); - _mm_store_ps(frac_.f, _mm_castsi128_ps(frac4)); - } - - pos = pos_.i[0]; - frac = frac_.i[0]; - - for(;i < numsamples;i++) - { - dst[i] = resample_fir8(src[pos ], src[pos+1], src[pos+2], src[pos+3], - src[pos+4], src[pos+5], src[pos+6], src[pos+7], frac); - - frac += increment; - pos += frac>>FRACTIONBITS; - frac &= FRACTIONMASK; - } - return dst; -} diff --git a/Alc/mixer_sse41.c b/Alc/mixer_sse41.c index 7ae5bec7..61be4cae 100644 --- a/Alc/mixer_sse41.c +++ b/Alc/mixer_sse41.c @@ -109,10 +109,10 @@ const ALfloat *Resample_fir4_32_SSE41(const InterpState* UNUSED(state), const __m128 val1 = _mm_loadu_ps(&src[pos_.i[1]]); const __m128 val2 = _mm_loadu_ps(&src[pos_.i[2]]); const __m128 val3 = _mm_loadu_ps(&src[pos_.i[3]]); - __m128 k0 = _mm_load_ps(ResampleCoeffs.FIR4[frac_.i[0]]); - __m128 k1 = _mm_load_ps(ResampleCoeffs.FIR4[frac_.i[1]]); - __m128 k2 = _mm_load_ps(ResampleCoeffs.FIR4[frac_.i[2]]); - __m128 k3 = _mm_load_ps(ResampleCoeffs.FIR4[frac_.i[3]]); + __m128 k0 = _mm_load_ps(ResampleCoeffs_FIR4[frac_.i[0]]); + __m128 k1 = _mm_load_ps(ResampleCoeffs_FIR4[frac_.i[1]]); + __m128 k2 = _mm_load_ps(ResampleCoeffs_FIR4[frac_.i[2]]); + __m128 k3 = _mm_load_ps(ResampleCoeffs_FIR4[frac_.i[3]]); __m128 out; k0 = _mm_mul_ps(k0, val0); @@ -152,76 +152,3 @@ const ALfloat *Resample_fir4_32_SSE41(const InterpState* UNUSED(state), } return dst; } - -const ALfloat *Resample_fir8_32_SSE41(const InterpState* UNUSED(state), - const ALfloat *restrict src, ALuint frac, ALint increment, - ALfloat *restrict dst, ALsizei numsamples) -{ - const __m128i increment4 = _mm_set1_epi32(increment*4); - const __m128i fracMask4 = _mm_set1_epi32(FRACTIONMASK); - union { alignas(16) ALint i[4]; float f[4]; } pos_; - union { alignas(16) ALuint i[4]; float f[4]; } frac_; - __m128i frac4, pos4; - ALsizei i, j; - ALint pos; - - InitiatePositionArrays(frac, increment, frac_.i, pos_.i, 4); - - frac4 = _mm_castps_si128(_mm_load_ps(frac_.f)); - pos4 = _mm_castps_si128(_mm_load_ps(pos_.f)); - - src -= 3; - for(i = 0;numsamples-i > 3;i += 4) - { - __m128 out[2]; - for(j = 0;j < 8;j+=4) - { - const __m128 val0 = _mm_loadu_ps(&src[pos_.i[0]+j]); - const __m128 val1 = _mm_loadu_ps(&src[pos_.i[1]+j]); - const __m128 val2 = _mm_loadu_ps(&src[pos_.i[2]+j]); - const __m128 val3 = _mm_loadu_ps(&src[pos_.i[3]+j]); - __m128 k0 = _mm_load_ps(&ResampleCoeffs.FIR8[frac_.i[0]][j]); - __m128 k1 = _mm_load_ps(&ResampleCoeffs.FIR8[frac_.i[1]][j]); - __m128 k2 = _mm_load_ps(&ResampleCoeffs.FIR8[frac_.i[2]][j]); - __m128 k3 = _mm_load_ps(&ResampleCoeffs.FIR8[frac_.i[3]][j]); - - k0 = _mm_mul_ps(k0, val0); - k1 = _mm_mul_ps(k1, val1); - k2 = _mm_mul_ps(k2, val2); - k3 = _mm_mul_ps(k3, val3); - k0 = _mm_hadd_ps(k0, k1); - k2 = _mm_hadd_ps(k2, k3); - out[j>>2] = _mm_hadd_ps(k0, k2); - } - - out[0] = _mm_add_ps(out[0], out[1]); - _mm_store_ps(&dst[i], out[0]); - - frac4 = _mm_add_epi32(frac4, increment4); - pos4 = _mm_add_epi32(pos4, _mm_srli_epi32(frac4, FRACTIONBITS)); - frac4 = _mm_and_si128(frac4, fracMask4); - - pos_.i[0] = _mm_extract_epi32(pos4, 0); - pos_.i[1] = _mm_extract_epi32(pos4, 1); - pos_.i[2] = _mm_extract_epi32(pos4, 2); - pos_.i[3] = _mm_extract_epi32(pos4, 3); - frac_.i[0] = _mm_extract_epi32(frac4, 0); - frac_.i[1] = _mm_extract_epi32(frac4, 1); - frac_.i[2] = _mm_extract_epi32(frac4, 2); - frac_.i[3] = _mm_extract_epi32(frac4, 3); - } - - pos = pos_.i[0]; - frac = frac_.i[0]; - - for(;i < numsamples;i++) - { - dst[i] = resample_fir8(src[pos ], src[pos+1], src[pos+2], src[pos+3], - src[pos+4], src[pos+5], src[pos+6], src[pos+7], frac); - - frac += increment; - pos += frac>>FRACTIONBITS; - frac &= FRACTIONMASK; - } - return dst; -} |