aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2012-09-14 04:13:18 -0700
committerChris Robinson <[email protected]>2012-09-14 04:13:18 -0700
commit7635afcb520747b74b7c65bb522016c2c7c2da4d (patch)
tree85eba69b24c5c089730636c10aa46dda361cc86a /Alc
parent74aee374a646aec1b1ebe40f9efbae692e9720d6 (diff)
Use a source param for the resampler and move them to the mixer source
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALu.c23
-rw-r--r--Alc/mixer.c67
-rw-r--r--Alc/mixer_c.c35
-rw-r--r--Alc/mixer_defs.h6
4 files changed, 67 insertions, 64 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index cb180ee3..b61e035c 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -51,6 +51,27 @@ ALfloat ConeScale = 1.0f;
ALfloat ZScale = 1.0f;
+static ResamplerFunc SelectResampler(enum Resampler Resampler, ALuint increment)
+{
+ if(increment == FRACTIONONE)
+ return Resample_point32_C;
+ switch(Resampler)
+ {
+ case PointResampler:
+ return Resample_point32_C;
+ case LinearResampler:
+ return Resample_lerp32_C;
+ case CubicResampler:
+ return Resample_cubic32_C;
+ case ResamplerMax:
+ /* Shouldn't happen */
+ break;
+ }
+
+ return NULL;
+}
+
+
static DryMixerFunc SelectDirectMixer(void)
{
#ifdef HAVE_SSE
@@ -210,6 +231,7 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
if(ALSource->Params.Step == 0)
ALSource->Params.Step = 1;
}
+ ALSource->Params.Resample = SelectResampler(Resampler, ALSource->Params.Step);
Channels = ALBuffer->FmtChannels;
break;
@@ -703,6 +725,7 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
if(ALSource->Params.Step == 0)
ALSource->Params.Step = 1;
}
+ ALSource->Params.Resample = SelectResampler(Resampler, ALSource->Params.Step);
break;
}
diff --git a/Alc/mixer.c b/Alc/mixer.c
index da3dcc20..1ae51b6f 100644
--- a/Alc/mixer.c
+++ b/Alc/mixer.c
@@ -84,68 +84,6 @@ static void SilenceStack(ALfloat *dst, ALuint samples)
}
-static __inline ALfloat point32(const ALfloat *vals, ALint step, ALint frac)
-{ return vals[0]; (void)step; (void)frac; }
-static __inline ALfloat lerp32(const ALfloat *vals, ALint step, ALint frac)
-{ return lerp(vals[0], vals[step], frac * (1.0f/FRACTIONONE)); }
-static __inline ALfloat cubic32(const ALfloat *vals, ALint step, ALint frac)
-{ return cubic(vals[-step], vals[0], vals[step], vals[step+step],
- frac * (1.0f/FRACTIONONE)); }
-
-#define DECL_TEMPLATE(Sampler) \
-static void Resample_##Sampler(const ALfloat *data, ALuint frac, \
- ALuint increment, ALuint NumChannels, ALfloat *RESTRICT OutBuffer, \
- ALuint BufferSize) \
-{ \
- ALuint pos = 0; \
- ALfloat value; \
- ALuint i; \
- \
- for(i = 0;i < BufferSize+1;i++) \
- { \
- value = Sampler(data + pos*NumChannels, NumChannels, frac); \
- OutBuffer[i] = value; \
- \
- frac += increment; \
- pos += frac>>FRACTIONBITS; \
- frac &= FRACTIONMASK; \
- } \
-}
-
-DECL_TEMPLATE(point32)
-DECL_TEMPLATE(lerp32)
-DECL_TEMPLATE(cubic32)
-
-#undef DECL_TEMPLATE
-
-static void Resample(enum Resampler Resampler, const ALfloat *data, ALuint frac,
- ALuint increment, ALuint NumChannels,
- ALfloat *RESTRICT OutBuffer, ALuint BufferSize)
-{
- if(increment == FRACTIONONE)
- goto do_point;
- switch(Resampler)
- {
- case PointResampler:
- do_point:
- Resample_point32(data, frac, increment, NumChannels,
- OutBuffer, BufferSize);
- break;
- case LinearResampler:
- Resample_lerp32(data, frac, increment, NumChannels,
- OutBuffer, BufferSize);
- break;
- case CubicResampler:
- Resample_cubic32(data, frac, increment, NumChannels,
- OutBuffer, BufferSize);
- break;
- case ResamplerMax:
- /* Shouldn't happen */
- break;
- }
-}
-
-
static void Filter2P(FILTER *filter, ALuint chan, ALfloat *RESTRICT dst,
const ALfloat *RESTRICT src, ALuint numsamples)
{
@@ -401,11 +339,12 @@ ALvoid MixSource(ALsource *Source, ALCdevice *Device, ALuint SamplesToDo)
ALIGN(16) ALfloat FilteredData[BUFFERSIZE];
ALfloat ResampledData[BUFFERSIZE];
- Resample(Resampler, SrcData+i, DataPosFrac, increment,
- NumChannels, ResampledData, BufferSize);
+ Source->Params.Resample(SrcData+i, DataPosFrac, increment,
+ NumChannels, ResampledData, BufferSize);
Filter2P(&directparms->iirFilter, i, FilteredData, ResampledData,
BufferSize);
+
Source->Params.DryMix(Source, Device, directparms,
FilteredData, i, OutPos, SamplesToDo,
BufferSize);
diff --git a/Alc/mixer_c.c b/Alc/mixer_c.c
index fab13c0f..f3e416a0 100644
--- a/Alc/mixer_c.c
+++ b/Alc/mixer_c.c
@@ -6,6 +6,41 @@
#include "alu.h"
+static __inline ALfloat point32(const ALfloat *vals, ALint step, ALint frac)
+{ return vals[0]; (void)step; (void)frac; }
+static __inline ALfloat lerp32(const ALfloat *vals, ALint step, ALint frac)
+{ return lerp(vals[0], vals[step], frac * (1.0f/FRACTIONONE)); }
+static __inline ALfloat cubic32(const ALfloat *vals, ALint step, ALint frac)
+{ return cubic(vals[-step], vals[0], vals[step], vals[step+step],
+ frac * (1.0f/FRACTIONONE)); }
+
+#define DECL_TEMPLATE(Sampler) \
+void Resample_##Sampler##_C(const ALfloat *data, ALuint frac, \
+ ALuint increment, ALuint NumChannels, ALfloat *RESTRICT OutBuffer, \
+ ALuint BufferSize) \
+{ \
+ ALuint pos = 0; \
+ ALfloat value; \
+ ALuint i; \
+ \
+ for(i = 0;i < BufferSize+1;i++) \
+ { \
+ value = Sampler(data + pos*NumChannels, NumChannels, frac); \
+ OutBuffer[i] = value; \
+ \
+ frac += increment; \
+ pos += frac>>FRACTIONBITS; \
+ frac &= FRACTIONMASK; \
+ } \
+}
+
+DECL_TEMPLATE(point32)
+DECL_TEMPLATE(lerp32)
+DECL_TEMPLATE(cubic32)
+
+#undef DECL_TEMPLATE
+
+
static __inline void ApplyCoeffsStep(ALuint Offset, ALfloat (*RESTRICT Values)[2],
const ALuint IrSize,
ALfloat (*RESTRICT Coeffs)[2],
diff --git a/Alc/mixer_defs.h b/Alc/mixer_defs.h
index 7e930a39..38cdb935 100644
--- a/Alc/mixer_defs.h
+++ b/Alc/mixer_defs.h
@@ -10,6 +10,12 @@ struct ALsource;
struct DirectParams;
struct SendParams;
+/* C resamplers */
+void Resample_point32_C(const ALfloat *src, ALuint frac, ALuint increment, ALuint NumChannels, ALfloat *RESTRICT dst, ALuint dstlen);
+void Resample_lerp32_C(const ALfloat *src, ALuint frac, ALuint increment, ALuint NumChannels, ALfloat *RESTRICT dst, ALuint dstlen);
+void Resample_cubic32_C(const ALfloat *src, ALuint frac, ALuint increment, ALuint NumChannels, ALfloat *RESTRICT dst, ALuint dstlen);
+
+
/* C mixers */
void MixDirect_Hrtf_C(struct ALsource*,ALCdevice*,struct DirectParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint);
void MixDirect_C(struct ALsource*,ALCdevice*,struct DirectParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint);