aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALu.c2
-rw-r--r--Alc/mixer.c20
-rw-r--r--Alc/mixer_c.c39
-rw-r--r--Alc/mixer_defs.h12
-rw-r--r--Alc/mixer_neon.c71
-rw-r--r--Alc/mixer_sse3.c98
-rw-r--r--Alc/mixer_sse41.c69
7 files changed, 21 insertions, 290 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 5f0c556a..1964e6c7 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -69,8 +69,6 @@ extern inline ALuint64 maxu64(ALuint64 a, ALuint64 b);
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,
- const ALfloat *restrict filter);
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 5d6d14d7..a7f0f302 100644
--- a/Alc/mixer.c
+++ b/Alc/mixer.c
@@ -128,19 +128,7 @@ ResamplerFunc SelectResampler(enum Resampler resampler)
#endif
return Resample_lerp_C;
case FIR4Resampler:
-#ifdef HAVE_NEON
- if((CPUCapFlags&CPU_CAP_NEON))
- return Resample_fir4_Neon;
-#endif
-#ifdef HAVE_SSE4_1
- if((CPUCapFlags&CPU_CAP_SSE4_1))
- return Resample_fir4_SSE41;
-#endif
-#ifdef HAVE_SSE3
- if((CPUCapFlags&CPU_CAP_SSE3))
- return Resample_fir4_SSE3;
-#endif
- return Resample_fir4_C;
+ return Resample_cubic_C;
case BSinc12Resampler:
case BSinc24Resampler:
#ifdef HAVE_NEON
@@ -168,7 +156,7 @@ void aluInitMixer(void)
ResamplerDefault = PointResampler;
else if(strcasecmp(str, "linear") == 0)
ResamplerDefault = LinearResampler;
- else if(strcasecmp(str, "sinc4") == 0)
+ else if(strcasecmp(str, "cubic") == 0)
ResamplerDefault = FIR4Resampler;
else if(strcasecmp(str, "bsinc12") == 0)
ResamplerDefault = BSinc12Resampler;
@@ -179,9 +167,9 @@ void aluInitMixer(void)
WARN("Resampler option \"%s\" is deprecated, using bsinc12\n", str);
ResamplerDefault = BSinc12Resampler;
}
- else if(strcasecmp(str, "cubic") == 0 || strcasecmp(str, "sinc8") == 0)
+ else if(strcasecmp(str, "sinc4") == 0 || strcasecmp(str, "sinc8") == 0)
{
- WARN("Resampler option \"%s\" is deprecated, using sinc4\n", str);
+ WARN("Resampler option \"%s\" is deprecated, using cubic\n", str);
ResamplerDefault = FIR4Resampler;
}
else
diff --git a/Alc/mixer_c.c b/Alc/mixer_c.c
index e468fedb..41445fc4 100644
--- a/Alc/mixer_c.c
+++ b/Alc/mixer_c.c
@@ -12,7 +12,16 @@ static inline ALfloat do_point(const ALfloat *restrict vals, ALsizei UNUSED(frac
{ return vals[0]; }
static inline ALfloat do_lerp(const ALfloat *restrict vals, ALsizei frac)
{ return lerp(vals[0], vals[1], frac * (1.0f/FRACTIONONE)); }
-
+static inline ALfloat do_cubic(const ALfloat *restrict vals, ALsizei frac)
+{
+ ALfloat mu = frac * (1.0f/FRACTIONONE);
+ ALfloat mu2 = mu*mu, mu3 = mu2*mu;
+ ALfloat a0 = -0.5f*mu3 + mu2 + -0.5f*mu;
+ ALfloat a1 = 1.5f*mu3 + -2.5f*mu2 + 1.0f;
+ ALfloat a2 = -1.5f*mu3 + 2.0f*mu2 + 0.5f*mu;
+ ALfloat a3 = 0.5f*mu3 + -0.5f*mu2;
+ return vals[0]*a0 + vals[1]*a1 + vals[2]*a2 + vals[3]*a3;
+}
const ALfloat *Resample_copy_C(const InterpState* UNUSED(state),
const ALfloat *restrict src, ALsizei UNUSED(frac), ALint UNUSED(increment),
@@ -27,12 +36,14 @@ const ALfloat *Resample_copy_C(const InterpState* UNUSED(state),
return dst;
}
-#define DECL_TEMPLATE(Tag, Sampler) \
+#define DECL_TEMPLATE(Tag, Sampler, O) \
const ALfloat *Resample_##Tag##_C(const InterpState* UNUSED(state), \
const ALfloat *restrict src, ALsizei frac, ALint increment, \
ALfloat *restrict dst, ALsizei numsamples) \
{ \
ALsizei i; \
+ \
+ src -= O; \
for(i = 0;i < numsamples;i++) \
{ \
dst[i] = Sampler(src, frac); \
@@ -44,30 +55,12 @@ const ALfloat *Resample_##Tag##_C(const InterpState* UNUSED(state), \
return dst; \
}
-DECL_TEMPLATE(point, do_point)
-DECL_TEMPLATE(lerp, do_lerp)
+DECL_TEMPLATE(point, do_point, 0)
+DECL_TEMPLATE(lerp, do_lerp, 0)
+DECL_TEMPLATE(cubic, do_cubic, 1)
#undef DECL_TEMPLATE
-const ALfloat *Resample_fir4_C(const InterpState *state, const ALfloat *restrict src,
- ALsizei frac, ALint increment, ALfloat *restrict dst,
- ALsizei numsamples)
-{
- const ALfloat (*restrict filter)[4] = ASSUME_ALIGNED(state->sinc4.filter, 16);
- ALsizei i;
-
- src -= 1;
- for(i = 0;i < numsamples;i++)
- {
- dst[i] = resample_fir4(src[0], src[1], src[2], src[3], filter[frac]);
-
- frac += increment;
- src += frac>>FRACTIONBITS;
- frac &= FRACTIONMASK;
- }
- return dst;
-}
-
const ALfloat *Resample_bsinc_C(const InterpState *state, const ALfloat *restrict src,
ALsizei frac, ALint increment, ALfloat *restrict dst,
ALsizei dstlen)
diff --git a/Alc/mixer_defs.h b/Alc/mixer_defs.h
index 364bbf7a..fe19cef4 100644
--- a/Alc/mixer_defs.h
+++ b/Alc/mixer_defs.h
@@ -15,7 +15,7 @@ struct HrtfState;
const ALfloat *Resample_copy_C(const InterpState *state, const ALfloat *restrict src, ALsizei frac, ALint increment, ALfloat *restrict dst, ALsizei dstlen);
const ALfloat *Resample_point_C(const InterpState *state, const ALfloat *restrict src, ALsizei frac, ALint increment, ALfloat *restrict dst, ALsizei dstlen);
const ALfloat *Resample_lerp_C(const InterpState *state, const ALfloat *restrict src, ALsizei frac, ALint increment, ALfloat *restrict dst, ALsizei dstlen);
-const ALfloat *Resample_fir4_C(const InterpState *state, const ALfloat *restrict src, ALsizei frac, ALint increment, ALfloat *restrict dst, ALsizei dstlen);
+const ALfloat *Resample_cubic_C(const InterpState *state, const ALfloat *restrict src, ALsizei frac, ALint increment, ALfloat *restrict dst, ALsizei dstlen);
const ALfloat *Resample_bsinc_C(const InterpState *state, const ALfloat *restrict src, ALsizei frac, ALint increment, ALfloat *restrict dst, ALsizei dstlen);
@@ -83,13 +83,6 @@ const ALfloat *Resample_lerp_SSE41(const InterpState *state, const ALfloat *rest
ALsizei frac, ALint increment, ALfloat *restrict dst,
ALsizei numsamples);
-const ALfloat *Resample_fir4_SSE3(const InterpState *state, const ALfloat *restrict src,
- ALsizei frac, ALint increment, ALfloat *restrict dst,
- ALsizei numsamples);
-const ALfloat *Resample_fir4_SSE41(const InterpState *state, const ALfloat *restrict src,
- ALsizei frac, ALint increment, ALfloat *restrict dst,
- ALsizei numsamples);
-
const ALfloat *Resample_bsinc_SSE(const InterpState *state, const ALfloat *restrict src,
ALsizei frac, ALint increment, ALfloat *restrict dst,
ALsizei dstlen);
@@ -119,9 +112,6 @@ void MixRow_Neon(ALfloat *OutBuffer, const ALfloat *Gains,
const ALfloat *Resample_lerp_Neon(const InterpState *state, const ALfloat *restrict src,
ALsizei frac, ALint increment, ALfloat *restrict dst,
ALsizei numsamples);
-const ALfloat *Resample_fir4_Neon(const InterpState *state, const ALfloat *restrict src,
- ALsizei frac, ALint increment, ALfloat *restrict dst,
- ALsizei numsamples);
const ALfloat *Resample_bsinc_Neon(const InterpState *state, const ALfloat *restrict src,
ALsizei frac, ALint increment, ALfloat *restrict dst,
ALsizei dstlen);
diff --git a/Alc/mixer_neon.c b/Alc/mixer_neon.c
index b99dcf69..631e4f7c 100644
--- a/Alc/mixer_neon.c
+++ b/Alc/mixer_neon.c
@@ -66,77 +66,6 @@ const ALfloat *Resample_lerp_Neon(const InterpState* UNUSED(state),
return dst;
}
-const ALfloat *Resample_fir4_Neon(const InterpState *state,
- const ALfloat *restrict src, ALsizei frac, ALint increment,
- ALfloat *restrict dst, ALsizei numsamples)
-{
- const ALfloat (*restrict filter)[4] = ASSUME_ALIGNED(state->sinc4.filter, 16);
- const int32x4_t increment4 = vdupq_n_s32(increment*4);
- const int32x4_t fracMask4 = vdupq_n_s32(FRACTIONMASK);
- alignas(16) ALint pos_[4];
- alignas(16) ALsizei frac_[4];
- int32x4_t pos4;
- int32x4_t frac4;
- ALsizei i;
-
- InitiatePositionArrays(frac, increment, frac_, pos_, 4);
-
- frac4 = vld1q_s32(frac_);
- pos4 = vld1q_s32(pos_);
-
- --src;
- for(i = 0;numsamples-i > 3;i += 4)
- {
- const float32x4_t val0 = vld1q_f32(&src[pos_[0]]);
- 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(filter[frac_[0]]);
- float32x4_t k1 = vld1q_f32(filter[frac_[1]]);
- float32x4_t k2 = vld1q_f32(filter[frac_[2]]);
- float32x4_t k3 = vld1q_f32(filter[frac_[3]]);
- float32x4_t out;
-
- 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 = vcombine_f32(vpadd_f32(vget_low_f32(k0), vget_high_f32(k0)),
- vpadd_f32(vget_low_f32(k2), vget_high_f32(k2)));
-
- vst1q_f32(&dst[i], out);
-
- frac4 = vaddq_s32(frac4, increment4);
- pos4 = vaddq_s32(pos4, vshrq_n_s32(frac4, FRACTIONBITS));
- frac4 = vandq_s32(frac4, fracMask4);
-
- vst1q_s32(pos_, pos4);
- vst1q_s32(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_fir4(src[pos], src[pos+1], src[pos+2], src[pos+3], filter[frac]);
-
- frac += increment;
- pos += frac>>FRACTIONBITS;
- frac &= FRACTIONMASK;
- } while(++i < numsamples);
- }
- return dst;
-}
-
const ALfloat *Resample_bsinc_Neon(const InterpState *state,
const ALfloat *restrict src, ALsizei frac, ALint increment,
ALfloat *restrict dst, ALsizei dstlen)
diff --git a/Alc/mixer_sse3.c b/Alc/mixer_sse3.c
index d60fed5f..e69de29b 100644
--- a/Alc/mixer_sse3.c
+++ b/Alc/mixer_sse3.c
@@ -1,98 +0,0 @@
-/**
- * OpenAL cross platform audio library, SSE3 mixer functions
- *
- * Copyright (C) 2014 by Timothy Arceri <[email protected]>.
- * Copyright (C) 2015 by Chris Robinson <[email protected]>.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- * Or go to http://www.gnu.org/copyleft/lgpl.html
- */
-
-#include "config.h"
-
-#include <xmmintrin.h>
-#include <emmintrin.h>
-#include <pmmintrin.h>
-
-#include "alu.h"
-#include "mixer_defs.h"
-
-
-const ALfloat *Resample_fir4_SSE3(const InterpState *state,
- const ALfloat *restrict src, ALsizei frac, ALint increment,
- ALfloat *restrict dst, ALsizei numsamples)
-{
- const ALfloat (*restrict filter)[4] = ASSUME_ALIGNED(state->sinc4.filter, 16);
- 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) ALsizei i[4]; float f[4]; } frac_;
- __m128i frac4, pos4;
- ALint pos;
- ALsizei i;
-
- 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;
- for(i = 0;numsamples-i > 3;i += 4)
- {
- const __m128 val0 = _mm_loadu_ps(&src[pos_.i[0]]);
- 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(filter[frac_.i[0]]);
- __m128 k1 = _mm_load_ps(filter[frac_.i[1]]);
- __m128 k2 = _mm_load_ps(filter[frac_.i[2]]);
- __m128 k3 = _mm_load_ps(filter[frac_.i[3]]);
- __m128 out;
-
- 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 = _mm_hadd_ps(k0, k2);
-
- _mm_store_ps(&dst[i], out);
-
- 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));
- }
-
- /* NOTE: These four elements represent the position *after* the last four
- * samples, so the lowest element is the next position to resample.
- */
- pos = pos_.i[0];
- frac = frac_.i[0];
-
- for(;i < numsamples;i++)
- {
- dst[i] = resample_fir4(src[pos], src[pos+1], src[pos+2], src[pos+3], filter[frac]);
-
- frac += increment;
- pos += frac>>FRACTIONBITS;
- frac &= FRACTIONMASK;
- }
- return dst;
-}
diff --git a/Alc/mixer_sse41.c b/Alc/mixer_sse41.c
index 354d16b7..4f88d540 100644
--- a/Alc/mixer_sse41.c
+++ b/Alc/mixer_sse41.c
@@ -84,72 +84,3 @@ const ALfloat *Resample_lerp_SSE41(const InterpState* UNUSED(state),
}
return dst;
}
-
-const ALfloat *Resample_fir4_SSE41(const InterpState *state,
- const ALfloat *restrict src, ALsizei frac, ALint increment,
- ALfloat *restrict dst, ALsizei numsamples)
-{
- const ALfloat (*restrict filter)[4] = ASSUME_ALIGNED(state->sinc4.filter, 16);
- 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) ALsizei i[4]; float f[4]; } frac_;
- __m128i frac4, pos4;
- ALint pos;
- ALsizei i;
-
- 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;
- for(i = 0;numsamples-i > 3;i += 4)
- {
- const __m128 val0 = _mm_loadu_ps(&src[pos_.i[0]]);
- 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(filter[frac_.i[0]]);
- __m128 k1 = _mm_load_ps(filter[frac_.i[1]]);
- __m128 k2 = _mm_load_ps(filter[frac_.i[2]]);
- __m128 k3 = _mm_load_ps(filter[frac_.i[3]]);
- __m128 out;
-
- 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 = _mm_hadd_ps(k0, k2);
-
- _mm_store_ps(&dst[i], out);
-
- 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_fir4(src[pos], src[pos+1], src[pos+2], src[pos+3], filter[frac]);
-
- frac += increment;
- pos += frac>>FRACTIONBITS;
- frac &= FRACTIONMASK;
- }
- return dst;
-}