diff options
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/ALc.c | 4 | ||||
-rw-r--r-- | Alc/ALu.c | 1 | ||||
-rw-r--r-- | Alc/mixer.c | 38 | ||||
-rw-r--r-- | Alc/mixer_c.c | 3 | ||||
-rw-r--r-- | Alc/mixer_defs.h | 1 | ||||
-rw-r--r-- | Alc/mixer_sse2.c | 8 | ||||
-rw-r--r-- | Alc/mixer_sse41.c | 8 |
7 files changed, 42 insertions, 21 deletions
@@ -1011,9 +1011,11 @@ static void alc_initconfig(void) DefaultResampler = LinearResampler; else if(strcasecmp(str, "sinc4") == 0) DefaultResampler = FIR4Resampler; + else if(strcasecmp(str, "sinc6") == 0) + DefaultResampler = FIR6Resampler; else if(strcasecmp(str, "cubic") == 0) { - ERR("Resampler option \"cubic\" is deprecated, using sinc4\n"); + WARN("Resampler option \"cubic\" is deprecated, using sinc4\n"); DefaultResampler = FIR4Resampler; } else @@ -80,6 +80,7 @@ extern inline ALuint64 clampu64(ALuint64 val, ALuint64 min, ALuint64 max); extern inline ALfloat lerp(ALfloat val1, ALfloat val2, ALfloat mu); extern inline ALfloat resample_fir4(ALfloat val0, ALfloat val1, ALfloat val2, ALfloat val3, ALuint frac); +extern inline ALfloat resample_fir6(ALfloat val0, ALfloat val1, ALfloat val2, ALfloat val3, ALfloat val4, ALfloat val5, ALuint frac); extern inline void aluVectorSet(aluVector *restrict vector, ALfloat x, ALfloat y, ALfloat z, ALfloat w); diff --git a/Alc/mixer.c b/Alc/mixer.c index b2bd1dce..dedcb5b9 100644 --- a/Alc/mixer.c +++ b/Alc/mixer.c @@ -43,7 +43,7 @@ static_assert((INT_MAX>>FRACTIONBITS)/MAX_PITCH > BUFFERSIZE, extern inline void InitiatePositionArrays(ALuint frac, ALuint increment, ALuint *frac_arr, ALuint *pos_arr, ALuint size); -alignas(16) ALfloat ResampleCoeffs[FRACTIONONE][4]; +alignas(16) union ResamplerCoeffs ResampleCoeffs; static HrtfMixerFunc MixHrtfSamples = MixHrtf_C; @@ -104,6 +104,8 @@ static inline ResamplerFunc SelectResampler(enum Resampler resampler) return Resample_fir4_32_SSE2; #endif return Resample_fir4_32_C; + case FIR6Resampler: + return Resample_fir6_32_C; case ResamplerMax: /* Shouldn't happen */ break; @@ -113,27 +115,39 @@ static inline ResamplerFunc SelectResampler(enum Resampler resampler) } -static float lanc2(float x) +static float lanc(float r, float x) { if(x == 0.0f) return 1.0f; - if(fabsf(x) >= 2.0f) + if(fabsf(x) >= r) return 0.0f; - return 2.0f*sinf(x*F_PI)*sinf(x*F_PI/2.0f) / + return r*sinf(x*F_PI)*sinf(x*F_PI/r) / (F_PI*F_PI * x*x); } void aluInitMixer(void) { ALuint i; - for(i = 0;i < FRACTIONONE;i++) - { - ALfloat mu = (ALfloat)i / FRACTIONONE; - ResampleCoeffs[i][0] = lanc2(mu - -1.0f); - ResampleCoeffs[i][1] = lanc2(mu - 0.0f); - ResampleCoeffs[i][2] = lanc2(mu - 1.0f); - ResampleCoeffs[i][3] = lanc2(mu - 2.0f); - } + if(DefaultResampler == FIR6Resampler) + for(i = 0;i < FRACTIONONE;i++) + { + ALfloat mu = (ALfloat)i / FRACTIONONE; + ResampleCoeffs.FIR6[i][0] = lanc(3.0f, mu - -2.0f); + ResampleCoeffs.FIR6[i][1] = lanc(3.0f, mu - -1.0f); + ResampleCoeffs.FIR6[i][2] = lanc(3.0f, mu - 0.0f); + ResampleCoeffs.FIR6[i][3] = lanc(3.0f, mu - 1.0f); + ResampleCoeffs.FIR6[i][4] = lanc(3.0f, mu - 2.0f); + ResampleCoeffs.FIR6[i][5] = lanc(3.0f, mu - 3.0f); + } + else if(DefaultResampler == FIR4Resampler) + for(i = 0;i < FRACTIONONE;i++) + { + ALfloat mu = (ALfloat)i / FRACTIONONE; + ResampleCoeffs.FIR4[i][0] = lanc(2.0f, mu - -1.0f); + ResampleCoeffs.FIR4[i][1] = lanc(2.0f, mu - 0.0f); + ResampleCoeffs.FIR4[i][2] = lanc(2.0f, mu - 1.0f); + ResampleCoeffs.FIR4[i][3] = lanc(2.0f, mu - 2.0f); + } MixHrtfSamples = SelectHrtfMixer(); MixSamples = SelectMixer(); diff --git a/Alc/mixer_c.c b/Alc/mixer_c.c index 6164eb00..59ee5ebf 100644 --- a/Alc/mixer_c.c +++ b/Alc/mixer_c.c @@ -14,6 +14,8 @@ static inline ALfloat lerp32(const ALfloat *vals, ALuint frac) { return lerp(vals[0], vals[1], frac * (1.0f/FRACTIONONE)); } static inline ALfloat fir4_32(const ALfloat *vals, ALuint frac) { return resample_fir4(vals[-1], vals[0], vals[1], vals[2], frac); } +static inline ALfloat fir6_32(const ALfloat *vals, ALuint frac) +{ return resample_fir6(vals[-2], vals[-1], vals[0], vals[1], vals[2], vals[3], frac); } const ALfloat *Resample_copy32_C(const ALfloat *src, ALuint UNUSED(frac), ALuint UNUSED(increment), ALfloat *restrict dst, ALuint numsamples) @@ -46,6 +48,7 @@ const ALfloat *Resample_##Sampler##_C(const ALfloat *src, ALuint frac, \ DECL_TEMPLATE(point32) DECL_TEMPLATE(lerp32) DECL_TEMPLATE(fir4_32) +DECL_TEMPLATE(fir6_32) #undef DECL_TEMPLATE diff --git a/Alc/mixer_defs.h b/Alc/mixer_defs.h index e577fafc..4c94954f 100644 --- a/Alc/mixer_defs.h +++ b/Alc/mixer_defs.h @@ -16,6 +16,7 @@ const ALfloat *Resample_copy32_C(const ALfloat *src, ALuint frac, ALuint increme const ALfloat *Resample_point32_C(const ALfloat *src, ALuint frac, ALuint increment, ALfloat *restrict dst, ALuint dstlen); const ALfloat *Resample_lerp32_C(const ALfloat *src, ALuint frac, ALuint increment, ALfloat *restrict dst, ALuint dstlen); const ALfloat *Resample_fir4_32_C(const ALfloat *src, ALuint frac, ALuint increment, ALfloat *restrict dst, ALuint dstlen); +const ALfloat *Resample_fir6_32_C(const ALfloat *src, ALuint frac, ALuint increment, ALfloat *restrict dst, ALuint dstlen); /* C mixers */ diff --git a/Alc/mixer_sse2.c b/Alc/mixer_sse2.c index 09a797c3..a6f2bb4e 100644 --- a/Alc/mixer_sse2.c +++ b/Alc/mixer_sse2.c @@ -100,10 +100,10 @@ const ALfloat *Resample_fir4_32_SSE2(const ALfloat *src, ALuint frac, ALuint inc 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[frac_.i[0]]); - __m128 k1 = _mm_load_ps(ResampleCoeffs[frac_.i[1]]); - __m128 k2 = _mm_load_ps(ResampleCoeffs[frac_.i[2]]); - __m128 k3 = _mm_load_ps(ResampleCoeffs[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); diff --git a/Alc/mixer_sse41.c b/Alc/mixer_sse41.c index c85a733d..b9ef608a 100644 --- a/Alc/mixer_sse41.c +++ b/Alc/mixer_sse41.c @@ -104,10 +104,10 @@ const ALfloat *Resample_fir4_32_SSE41(const ALfloat *src, ALuint frac, ALuint in 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[frac_.i[0]]); - __m128 k1 = _mm_load_ps(ResampleCoeffs[frac_.i[1]]); - __m128 k2 = _mm_load_ps(ResampleCoeffs[frac_.i[2]]); - __m128 k3 = _mm_load_ps(ResampleCoeffs[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); |