aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-12-15 12:23:28 -0800
committerChris Robinson <[email protected]>2014-12-15 12:23:28 -0800
commita606bbc7f106b9e741a2e9c2a4726431699cb4ff (patch)
treecd2e570f8a0007fffc87122bc296aef0a347373d /Alc
parent4b77f4ef07302acbe4a36d21450510c63bb72a47 (diff)
Use a lookup table to do cubic resampling
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c1
-rw-r--r--Alc/ALu.c2
-rw-r--r--Alc/mixer.c17
-rw-r--r--Alc/mixer_c.c2
4 files changed, 20 insertions, 2 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index d2b98edf..4bdf4fb0 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -1006,6 +1006,7 @@ static void alc_initconfig(void)
WARN("Invalid resampler: %s\n", str);
}
}
+ aluInitResamplers();
str = getenv("ALSOFT_TRAP_ERROR");
if(str && (strcasecmp(str, "true") == 0 || strtol(str, NULL, 0) == 1))
diff --git a/Alc/ALu.c b/Alc/ALu.c
index d7830ae7..57a68c24 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -82,7 +82,7 @@ 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 cubic(ALfloat val0, ALfloat val1, ALfloat val2, ALfloat val3, ALfloat mu);
+extern inline ALfloat cubic(ALfloat val0, ALfloat val1, ALfloat val2, ALfloat val3, ALuint frac);
static inline HrtfMixerFunc SelectHrtfMixer(void)
diff --git a/Alc/mixer.c b/Alc/mixer.c
index ae049ac8..a11b44dd 100644
--- a/Alc/mixer.c
+++ b/Alc/mixer.c
@@ -40,6 +40,23 @@
extern inline void InitiatePositionArrays(ALuint frac, ALuint increment, ALuint *frac_arr, ALuint *pos_arr, ALuint size);
+alignas(16) ALfloat CubicLUT[FRACTIONONE][4];
+
+
+void aluInitResamplers(void)
+{
+ ALuint i;
+ for(i = 0;i < FRACTIONONE;i++)
+ {
+ ALfloat mu = (ALfloat)i / FRACTIONONE;
+ ALfloat mu2 = mu*mu, mu3 = mu*mu*mu;
+ CubicLUT[i][0] = -0.5f*mu3 + mu2 + -0.5f*mu;
+ CubicLUT[i][1] = 1.5f*mu3 + -2.5f*mu2 + 1.0f;
+ CubicLUT[i][2] = -1.5f*mu3 + 2.0f*mu2 + 0.5f*mu;
+ CubicLUT[i][3] = 0.5f*mu3 + -0.5f*mu2;
+ }
+}
+
static inline HrtfMixerFunc SelectHrtfMixer(void)
{
diff --git a/Alc/mixer_c.c b/Alc/mixer_c.c
index f5898024..cd7499f0 100644
--- a/Alc/mixer_c.c
+++ b/Alc/mixer_c.c
@@ -13,7 +13,7 @@ static inline ALfloat point32(const ALfloat *vals, ALuint UNUSED(frac))
static inline ALfloat lerp32(const ALfloat *vals, ALuint frac)
{ return lerp(vals[0], vals[1], frac * (1.0f/FRACTIONONE)); }
static inline ALfloat cubic32(const ALfloat *vals, ALuint frac)
-{ return cubic(vals[-1], vals[0], vals[1], vals[2], frac * (1.0f/FRACTIONONE)); }
+{ return cubic(vals[-1], vals[0], vals[1], vals[2], frac); }
const ALfloat *Resample_copy32_C(const ALfloat *src, ALuint UNUSED(frac),
ALuint increment, ALfloat *restrict dst, ALuint numsamples)