diff options
author | Chris Robinson <[email protected]> | 2012-09-08 21:34:36 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2012-09-08 21:34:36 -0700 |
commit | 1c0302509066d02798a391f8b5f33255846d251e (patch) | |
tree | a35553c9a44043c0a472f7d26fc7722b9f063389 /Alc | |
parent | 7a37a63b8ecfdb005b8650ea59064d216e1a230c (diff) |
Separate the resampling and mixing steps
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/ALu.c | 12 | ||||
-rw-r--r-- | Alc/mixer.c | 219 | ||||
-rw-r--r-- | Alc/mixer_c.c | 8 | ||||
-rw-r--r-- | Alc/mixer_defs.h | 50 | ||||
-rw-r--r-- | Alc/mixer_inc.c | 349 | ||||
-rw-r--r-- | Alc/mixer_neon.c | 8 | ||||
-rw-r--r-- | Alc/mixer_sse.c | 8 |
7 files changed, 248 insertions, 406 deletions
@@ -175,10 +175,10 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext) BufferListItem = BufferListItem->next; } if(!DirectChannels && Device->Hrtf) - ALSource->Params.DryMix = SelectHrtfMixer(Resampler); + ALSource->Params.DryMix = SelectHrtfMixer(); else - ALSource->Params.DryMix = SelectDirectMixer(Resampler); - ALSource->Params.WetMix = SelectSendMixer(Resampler); + ALSource->Params.DryMix = SelectDirectMixer(); + ALSource->Params.WetMix = SelectSendMixer(); /* Calculate gains */ DryGain = clampf(SourceVolume, MinVolume, MaxVolume); @@ -670,10 +670,10 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext) BufferListItem = BufferListItem->next; } if(Device->Hrtf) - ALSource->Params.DryMix = SelectHrtfMixer(Resampler); + ALSource->Params.DryMix = SelectHrtfMixer(); else - ALSource->Params.DryMix = SelectDirectMixer(Resampler); - ALSource->Params.WetMix = SelectSendMixer(Resampler); + ALSource->Params.DryMix = SelectDirectMixer(); + ALSource->Params.WetMix = SelectSendMixer(); if(Device->Hrtf) { diff --git a/Alc/mixer.c b/Alc/mixer.c index 10e3d4e2..affe4a80 100644 --- a/Alc/mixer.c +++ b/Alc/mixer.c @@ -39,151 +39,46 @@ #include "mixer_defs.h" -DryMixerFunc SelectDirectMixer(enum Resampler Resampler) +DryMixerFunc SelectDirectMixer(void) { #ifdef HAVE_SSE if((CPUCapFlags&CPU_CAP_SSE)) - { - switch(Resampler) - { - case PointResampler: - return MixDirect_point32_SSE; - case LinearResampler: - return MixDirect_lerp32_SSE; - case CubicResampler: - return MixDirect_cubic32_SSE; - case ResamplerMax: - break; - } - } + return MixDirect_SSE; #endif #ifdef HAVE_NEON if((CPUCapFlags&CPU_CAP_NEON)) - { - switch(Resampler) - { - case PointResampler: - return MixDirect_point32_Neon; - case LinearResampler: - return MixDirect_lerp32_Neon; - case CubicResampler: - return MixDirect_cubic32_Neon; - case ResamplerMax: - break; - } - } + return MixDirect_Neon; #endif - switch(Resampler) - { - case PointResampler: - return MixDirect_point32_C; - case LinearResampler: - return MixDirect_lerp32_C; - case CubicResampler: - return MixDirect_cubic32_C; - case ResamplerMax: - break; - } - return NULL; + return MixDirect_C; } -DryMixerFunc SelectHrtfMixer(enum Resampler Resampler) +DryMixerFunc SelectHrtfMixer(void) { #ifdef HAVE_SSE if((CPUCapFlags&CPU_CAP_SSE)) - { - switch(Resampler) - { - case PointResampler: - return MixDirect_Hrtf_point32_SSE; - case LinearResampler: - return MixDirect_Hrtf_lerp32_SSE; - case CubicResampler: - return MixDirect_Hrtf_cubic32_SSE; - case ResamplerMax: - break; - } - } + return MixDirect_Hrtf_SSE; #endif #ifdef HAVE_NEON if((CPUCapFlags&CPU_CAP_NEON)) - { - switch(Resampler) - { - case PointResampler: - return MixDirect_Hrtf_point32_Neon; - case LinearResampler: - return MixDirect_Hrtf_lerp32_Neon; - case CubicResampler: - return MixDirect_Hrtf_cubic32_Neon; - case ResamplerMax: - break; - } - } + return MixDirect_Hrtf_Neon; #endif - switch(Resampler) - { - case PointResampler: - return MixDirect_Hrtf_point32_C; - case LinearResampler: - return MixDirect_Hrtf_lerp32_C; - case CubicResampler: - return MixDirect_Hrtf_cubic32_C; - case ResamplerMax: - break; - } - return NULL; + return MixDirect_Hrtf_C; } -WetMixerFunc SelectSendMixer(enum Resampler Resampler) +WetMixerFunc SelectSendMixer(void) { #ifdef HAVE_SSE if((CPUCapFlags&CPU_CAP_SSE)) - { - switch(Resampler) - { - case PointResampler: - return MixSend_point32_SSE; - case LinearResampler: - return MixSend_lerp32_SSE; - case CubicResampler: - return MixSend_cubic32_SSE; - case ResamplerMax: - break; - } - } + return MixSend_SSE; #endif #ifdef HAVE_NEON if((CPUCapFlags&CPU_CAP_NEON)) - { - switch(Resampler) - { - case PointResampler: - return MixSend_point32_Neon; - case LinearResampler: - return MixSend_lerp32_Neon; - case CubicResampler: - return MixSend_cubic32_Neon; - case ResamplerMax: - break; - } - } + return MixSend_Neon; #endif - switch(Resampler) - { - case PointResampler: - return MixSend_point32_C; - case LinearResampler: - return MixSend_lerp32_C; - case CubicResampler: - return MixSend_cubic32_C; - case ResamplerMax: - break; - } - return NULL; + return MixSend_C; } @@ -234,6 +129,68 @@ 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; + } +} + + ALvoid MixSource(ALsource *Source, ALCdevice *Device, ALuint SamplesToDo) { ALbufferlistitem *BufferListItem; @@ -247,7 +204,7 @@ ALvoid MixSource(ALsource *Source, ALCdevice *Device, ALuint SamplesToDo) ALuint NumChannels; ALuint FrameSize; ALint64 DataSize64; - ALuint i; + ALuint i, j; /* Get source info */ State = Source->state; @@ -468,16 +425,24 @@ ALvoid MixSource(ALsource *Source, ALCdevice *Device, ALuint SamplesToDo) BufferSize = minu(BufferSize, (SamplesToDo-OutPos)); SrcData += BufferPrePadding*NumChannels; - Source->Params.DryMix(Source, Device, &Source->Params.Direct, - SrcData, DataPosFrac, - OutPos, SamplesToDo, BufferSize); - for(i = 0;i < Device->NumAuxSends;i++) + for(i = 0;i < NumChannels;i++) { - if(!Source->Params.Slot[i]) - continue; - Source->Params.WetMix(Source, i, &Source->Params.Send[i], - SrcData, DataPosFrac, - OutPos, SamplesToDo, BufferSize); + ALfloat ResampledData[BUFFERSIZE]; + + Resample(Resampler, SrcData+i, DataPosFrac, increment, + NumChannels, ResampledData, BufferSize); + + Source->Params.DryMix(Source, Device, &Source->Params.Direct, + ResampledData, i, OutPos, SamplesToDo, + BufferSize); + for(j = 0;j < Device->NumAuxSends;j++) + { + if(!Source->Params.Slot[j]) + continue; + Source->Params.WetMix(Source, j, &Source->Params.Send[j], + ResampledData, i, OutPos, SamplesToDo, + BufferSize); + } } for(i = 0;i < BufferSize;i++) { diff --git a/Alc/mixer_c.c b/Alc/mixer_c.c index a7d47840..5cb5acb4 100644 --- a/Alc/mixer_c.c +++ b/Alc/mixer_c.c @@ -45,13 +45,5 @@ static __inline void ApplyValue(ALfloat *RESTRICT Output, ALfloat value, const A #define SUFFIX C -#define Sampler point32 #include "mixer_inc.c" -#undef Sampler -#define Sampler lerp32 -#include "mixer_inc.c" -#undef Sampler -#define Sampler cubic32 -#include "mixer_inc.c" -#undef Sampler #undef SUFFIX diff --git a/Alc/mixer_defs.h b/Alc/mixer_defs.h index 75ac9bda..5c8e5a9f 100644 --- a/Alc/mixer_defs.h +++ b/Alc/mixer_defs.h @@ -6,55 +6,23 @@ #include "alMain.h" #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)); } - struct ALsource; struct DirectParams; struct SendParams; /* C mixers */ -void MixDirect_Hrtf_point32_C(struct ALsource*,ALCdevice*,struct DirectParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); -void MixDirect_Hrtf_lerp32_C(struct ALsource*,ALCdevice*,struct DirectParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); -void MixDirect_Hrtf_cubic32_C(struct ALsource*,ALCdevice*,struct DirectParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); - -void MixDirect_point32_C(struct ALsource*,ALCdevice*,struct DirectParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); -void MixDirect_lerp32_C(struct ALsource*,ALCdevice*,struct DirectParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); -void MixDirect_cubic32_C(struct ALsource*,ALCdevice*,struct DirectParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); - -void MixSend_point32_C(struct ALsource*,ALuint,struct SendParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); -void MixSend_lerp32_C(struct ALsource*,ALuint,struct SendParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); -void MixSend_cubic32_C(struct ALsource*,ALuint,struct SendParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); +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); +void MixSend_C(struct ALsource*,ALuint,struct SendParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); /* SSE mixers */ -void MixDirect_Hrtf_point32_SSE(struct ALsource*,ALCdevice*,struct DirectParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); -void MixDirect_Hrtf_lerp32_SSE(struct ALsource*,ALCdevice*,struct DirectParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); -void MixDirect_Hrtf_cubic32_SSE(struct ALsource*,ALCdevice*,struct DirectParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); - -void MixDirect_point32_SSE(struct ALsource*,ALCdevice*,struct DirectParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); -void MixDirect_lerp32_SSE(struct ALsource*,ALCdevice*,struct DirectParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); -void MixDirect_cubic32_SSE(struct ALsource*,ALCdevice*,struct DirectParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); - -void MixSend_point32_SSE(struct ALsource*,ALuint,struct SendParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); -void MixSend_lerp32_SSE(struct ALsource*,ALuint,struct SendParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); -void MixSend_cubic32_SSE(struct ALsource*,ALuint,struct SendParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); +void MixDirect_Hrtf_SSE(struct ALsource*,ALCdevice*,struct DirectParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); +void MixDirect_SSE(struct ALsource*,ALCdevice*,struct DirectParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); +void MixSend_SSE(struct ALsource*,ALuint,struct SendParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); /* Neon mixers */ -void MixDirect_Hrtf_point32_Neon(struct ALsource*,ALCdevice*,struct DirectParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); -void MixDirect_Hrtf_lerp32_Neon(struct ALsource*,ALCdevice*,struct DirectParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); -void MixDirect_Hrtf_cubic32_Neon(struct ALsource*,ALCdevice*,struct DirectParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); - -void MixDirect_point32_Neon(struct ALsource*,ALCdevice*,struct DirectParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); -void MixDirect_lerp32_Neon(struct ALsource*,ALCdevice*,struct DirectParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); -void MixDirect_cubic32_Neon(struct ALsource*,ALCdevice*,struct DirectParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); - -void MixSend_point32_Neon(struct ALsource*,ALuint,struct SendParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); -void MixSend_lerp32_Neon(struct ALsource*,ALuint,struct SendParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); -void MixSend_cubic32_Neon(struct ALsource*,ALuint,struct SendParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); +void MixDirect_Hrtf_Neon(struct ALsource*,ALCdevice*,struct DirectParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); +void MixDirect_Neon(struct ALsource*,ALCdevice*,struct DirectParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); +void MixSend_Neon(struct ALsource*,ALuint,struct SendParams*,const ALfloat*RESTRICT,ALuint,ALuint,ALuint,ALuint); #endif /* MIXER_DEFS_H */ diff --git a/Alc/mixer_inc.c b/Alc/mixer_inc.c index 64fe0cdb..6c10a660 100644 --- a/Alc/mixer_inc.c +++ b/Alc/mixer_inc.c @@ -17,12 +17,11 @@ #define REAL_MERGE2(a,b) a##b #define MERGE2(a,b) REAL_MERGE2(a,b) -#define REAL_MERGE4(a,b,c,d) a##b##c##d -#define MERGE4(a,b,c,d) REAL_MERGE4(a,b,c,d) -#define MixDirect_Hrtf MERGE4(MixDirect_Hrtf_,Sampler,_,SUFFIX) -#define MixDirect MERGE4(MixDirect_,Sampler,_,SUFFIX) -#define MixSend MERGE4(MixSend_,Sampler,_,SUFFIX) +#define MixDirect_Hrtf MERGE2(MixDirect_Hrtf_,SUFFIX) +#define MixDirect MERGE2(MixDirect_,SUFFIX) +#define MixSend MERGE2(MixSend_,SUFFIX) + static __inline void ApplyCoeffsStep(ALuint Offset, ALfloat (*RESTRICT Values)[2], ALfloat (*RESTRICT Coeffs)[2], @@ -33,226 +32,178 @@ static __inline void ApplyCoeffs(ALuint Offset, ALfloat (*RESTRICT Values)[2], ALfloat left, ALfloat right); static __inline void ApplyValue(ALfloat *RESTRICT Output, ALfloat value, const ALfloat *DrySend); -static __inline ALfloat Sampler(const ALfloat *vals, ALint step, ALint frac); + void MixDirect_Hrtf(ALsource *Source, ALCdevice *Device, DirectParams *params, - const ALfloat *RESTRICT data, ALuint srcfrac, + const ALfloat *RESTRICT data, ALuint srcchan, ALuint OutPos, ALuint SamplesToDo, ALuint BufferSize) { - const ALuint NumChannels = Source->NumChannels; const ALint *RESTRICT DelayStep = params->Hrtf.DelayStep; ALfloat (*RESTRICT DryBuffer)[MaxChannels]; ALfloat *RESTRICT ClickRemoval, *RESTRICT PendingClicks; ALfloat (*RESTRICT CoeffStep)[2] = params->Hrtf.CoeffStep; - ALuint pos, frac; + ALfloat (*RESTRICT TargetCoeffs)[2] = params->Hrtf.Coeffs[srcchan]; + ALuint *RESTRICT TargetDelay = params->Hrtf.Delay[srcchan]; + ALfloat *RESTRICT History = Source->Hrtf.History[srcchan]; + ALfloat (*RESTRICT Values)[2] = Source->Hrtf.Values[srcchan]; + ALint Counter = maxu(Source->Hrtf.Counter, OutPos) - OutPos; + ALuint Offset = Source->Hrtf.Offset + OutPos; + ALIGN(16) ALfloat Coeffs[HRIR_LENGTH][2]; + ALuint Delay[2]; + ALfloat left, right; FILTER *DryFilter; - ALuint BufferIdx; - ALuint increment; ALfloat value; - ALuint i, c; - - increment = Source->Params.Step; + ALuint pos; + ALuint c; DryBuffer = Device->DryBuffer; ClickRemoval = Device->ClickRemoval; PendingClicks = Device->PendingClicks; DryFilter = ¶ms->iirFilter; - for(i = 0;i < NumChannels;i++) + pos = 0; + for(c = 0;c < HRIR_LENGTH;c++) + { + Coeffs[c][0] = TargetCoeffs[c][0] - (CoeffStep[c][0]*Counter); + Coeffs[c][1] = TargetCoeffs[c][1] - (CoeffStep[c][1]*Counter); + } + + Delay[0] = TargetDelay[0] - (DelayStep[0]*Counter); + Delay[1] = TargetDelay[1] - (DelayStep[1]*Counter); + + if(LIKELY(OutPos == 0)) + { + value = lpFilter2PC(DryFilter, srcchan, data[pos]); + + History[Offset&SRC_HISTORY_MASK] = value; + left = lerp(History[(Offset-(Delay[0]>>HRTFDELAY_BITS))&SRC_HISTORY_MASK], + History[(Offset-(Delay[0]>>HRTFDELAY_BITS)-1)&SRC_HISTORY_MASK], + (Delay[0]&HRTFDELAY_MASK)*(1.0f/HRTFDELAY_FRACONE)); + right = lerp(History[(Offset-(Delay[1]>>HRTFDELAY_BITS))&SRC_HISTORY_MASK], + History[(Offset-(Delay[1]>>HRTFDELAY_BITS)-1)&SRC_HISTORY_MASK], + (Delay[1]&HRTFDELAY_MASK)*(1.0f/HRTFDELAY_FRACONE)); + + ClickRemoval[FrontLeft] -= Values[(Offset+1)&HRIR_MASK][0] + + Coeffs[0][0] * left; + ClickRemoval[FrontRight] -= Values[(Offset+1)&HRIR_MASK][1] + + Coeffs[0][1] * right; + } + for(pos = 0;pos < BufferSize && Counter > 0;pos++) + { + value = lpFilter2P(DryFilter, srcchan, data[pos]); + + History[Offset&SRC_HISTORY_MASK] = value; + left = lerp(History[(Offset-(Delay[0]>>HRTFDELAY_BITS))&SRC_HISTORY_MASK], + History[(Offset-(Delay[0]>>HRTFDELAY_BITS)-1)&SRC_HISTORY_MASK], + (Delay[0]&HRTFDELAY_MASK)*(1.0f/HRTFDELAY_FRACONE)); + right = lerp(History[(Offset-(Delay[1]>>HRTFDELAY_BITS))&SRC_HISTORY_MASK], + History[(Offset-(Delay[1]>>HRTFDELAY_BITS)-1)&SRC_HISTORY_MASK], + (Delay[1]&HRTFDELAY_MASK)*(1.0f/HRTFDELAY_FRACONE)); + + Delay[0] += DelayStep[0]; + Delay[1] += DelayStep[1]; + + Values[Offset&HRIR_MASK][0] = 0.0f; + Values[Offset&HRIR_MASK][1] = 0.0f; + Offset++; + + ApplyCoeffsStep(Offset, Values, Coeffs, CoeffStep, left, right); + DryBuffer[OutPos][FrontLeft] += Values[Offset&HRIR_MASK][0]; + DryBuffer[OutPos][FrontRight] += Values[Offset&HRIR_MASK][1]; + + OutPos++; + Counter--; + } + + Delay[0] >>= HRTFDELAY_BITS; + Delay[1] >>= HRTFDELAY_BITS; + for(;pos < BufferSize;pos++) + { + value = lpFilter2P(DryFilter, srcchan, data[pos]); + + History[Offset&SRC_HISTORY_MASK] = value; + left = History[(Offset-Delay[0])&SRC_HISTORY_MASK]; + right = History[(Offset-Delay[1])&SRC_HISTORY_MASK]; + + Values[Offset&HRIR_MASK][0] = 0.0f; + Values[Offset&HRIR_MASK][1] = 0.0f; + Offset++; + + ApplyCoeffs(Offset, Values, Coeffs, left, right); + DryBuffer[OutPos][FrontLeft] += Values[Offset&HRIR_MASK][0]; + DryBuffer[OutPos][FrontRight] += Values[Offset&HRIR_MASK][1]; + + OutPos++; + } + if(LIKELY(OutPos == SamplesToDo)) { - ALfloat (*RESTRICT TargetCoeffs)[2] = params->Hrtf.Coeffs[i]; - ALuint *RESTRICT TargetDelay = params->Hrtf.Delay[i]; - ALfloat *RESTRICT History = Source->Hrtf.History[i]; - ALfloat (*RESTRICT Values)[2] = Source->Hrtf.Values[i]; - ALint Counter = maxu(Source->Hrtf.Counter, OutPos) - OutPos; - ALuint Offset = Source->Hrtf.Offset + OutPos; - ALIGN(16) ALfloat Coeffs[HRIR_LENGTH][2]; - ALuint Delay[2]; - ALfloat left, right; - - pos = 0; - frac = srcfrac; - - for(c = 0;c < HRIR_LENGTH;c++) - { - Coeffs[c][0] = TargetCoeffs[c][0] - (CoeffStep[c][0]*Counter); - Coeffs[c][1] = TargetCoeffs[c][1] - (CoeffStep[c][1]*Counter); - } - - Delay[0] = TargetDelay[0] - (DelayStep[0]*Counter); - Delay[1] = TargetDelay[1] - (DelayStep[1]*Counter); - - if(LIKELY(OutPos == 0)) - { - value = Sampler(data + pos*NumChannels + i, NumChannels, frac); - value = lpFilter2PC(DryFilter, i, value); - - History[Offset&SRC_HISTORY_MASK] = value; - left = lerp(History[(Offset-(Delay[0]>>HRTFDELAY_BITS))&SRC_HISTORY_MASK], - History[(Offset-(Delay[0]>>HRTFDELAY_BITS)-1)&SRC_HISTORY_MASK], - (Delay[0]&HRTFDELAY_MASK)*(1.0f/HRTFDELAY_FRACONE)); - right = lerp(History[(Offset-(Delay[1]>>HRTFDELAY_BITS))&SRC_HISTORY_MASK], - History[(Offset-(Delay[1]>>HRTFDELAY_BITS)-1)&SRC_HISTORY_MASK], - (Delay[1]&HRTFDELAY_MASK)*(1.0f/HRTFDELAY_FRACONE)); - - ClickRemoval[FrontLeft] -= Values[(Offset+1)&HRIR_MASK][0] + - Coeffs[0][0] * left; - ClickRemoval[FrontRight] -= Values[(Offset+1)&HRIR_MASK][1] + - Coeffs[0][1] * right; - } - for(BufferIdx = 0;BufferIdx < BufferSize && Counter > 0;BufferIdx++) - { - value = Sampler(data + pos*NumChannels + i, NumChannels, frac); - value = lpFilter2P(DryFilter, i, value); - - History[Offset&SRC_HISTORY_MASK] = value; - left = lerp(History[(Offset-(Delay[0]>>HRTFDELAY_BITS))&SRC_HISTORY_MASK], - History[(Offset-(Delay[0]>>HRTFDELAY_BITS)-1)&SRC_HISTORY_MASK], - (Delay[0]&HRTFDELAY_MASK)*(1.0f/HRTFDELAY_FRACONE)); - right = lerp(History[(Offset-(Delay[1]>>HRTFDELAY_BITS))&SRC_HISTORY_MASK], - History[(Offset-(Delay[1]>>HRTFDELAY_BITS)-1)&SRC_HISTORY_MASK], - (Delay[1]&HRTFDELAY_MASK)*(1.0f/HRTFDELAY_FRACONE)); - - Delay[0] += DelayStep[0]; - Delay[1] += DelayStep[1]; - - Values[Offset&HRIR_MASK][0] = 0.0f; - Values[Offset&HRIR_MASK][1] = 0.0f; - Offset++; - - ApplyCoeffsStep(Offset, Values, Coeffs, CoeffStep, left, right); - DryBuffer[OutPos][FrontLeft] += Values[Offset&HRIR_MASK][0]; - DryBuffer[OutPos][FrontRight] += Values[Offset&HRIR_MASK][1]; - - frac += increment; - pos += frac>>FRACTIONBITS; - frac &= FRACTIONMASK; - OutPos++; - Counter--; - } - - Delay[0] >>= HRTFDELAY_BITS; - Delay[1] >>= HRTFDELAY_BITS; - for(;BufferIdx < BufferSize;BufferIdx++) - { - value = Sampler(data + pos*NumChannels + i, NumChannels, frac); - value = lpFilter2P(DryFilter, i, value); - - History[Offset&SRC_HISTORY_MASK] = value; - left = History[(Offset-Delay[0])&SRC_HISTORY_MASK]; - right = History[(Offset-Delay[1])&SRC_HISTORY_MASK]; - - Values[Offset&HRIR_MASK][0] = 0.0f; - Values[Offset&HRIR_MASK][1] = 0.0f; - Offset++; - - ApplyCoeffs(Offset, Values, Coeffs, left, right); - DryBuffer[OutPos][FrontLeft] += Values[Offset&HRIR_MASK][0]; - DryBuffer[OutPos][FrontRight] += Values[Offset&HRIR_MASK][1]; - - frac += increment; - pos += frac>>FRACTIONBITS; - frac &= FRACTIONMASK; - OutPos++; - } - if(LIKELY(OutPos == SamplesToDo)) - { - value = Sampler(data + pos*NumChannels + i, NumChannels, frac); - value = lpFilter2PC(DryFilter, i, value); - - History[Offset&SRC_HISTORY_MASK] = value; - left = History[(Offset-Delay[0])&SRC_HISTORY_MASK]; - right = History[(Offset-Delay[1])&SRC_HISTORY_MASK]; - - PendingClicks[FrontLeft] += Values[(Offset+1)&HRIR_MASK][0] + - Coeffs[0][0] * left; - PendingClicks[FrontRight] += Values[(Offset+1)&HRIR_MASK][1] + - Coeffs[0][1] * right; - } - OutPos -= BufferSize; + value = lpFilter2PC(DryFilter, srcchan, data[pos]); + + History[Offset&SRC_HISTORY_MASK] = value; + left = History[(Offset-Delay[0])&SRC_HISTORY_MASK]; + right = History[(Offset-Delay[1])&SRC_HISTORY_MASK]; + + PendingClicks[FrontLeft] += Values[(Offset+1)&HRIR_MASK][0] + + Coeffs[0][0] * left; + PendingClicks[FrontRight] += Values[(Offset+1)&HRIR_MASK][1] + + Coeffs[0][1] * right; } } void MixDirect(ALsource *Source, ALCdevice *Device, DirectParams *params, - const ALfloat *RESTRICT data, ALuint srcfrac, + const ALfloat *RESTRICT data, ALuint srcchan, ALuint OutPos, ALuint SamplesToDo, ALuint BufferSize) { - const ALuint NumChannels = Source->NumChannels; ALfloat (*RESTRICT DryBuffer)[MaxChannels]; ALfloat *RESTRICT ClickRemoval, *RESTRICT PendingClicks; ALIGN(16) ALfloat DrySend[MaxChannels]; FILTER *DryFilter; - ALuint pos, frac; - ALuint BufferIdx; - ALuint increment; + ALuint pos; ALfloat value; - ALuint i, c; - - increment = Source->Params.Step; + ALuint c; + (void)Source; DryBuffer = Device->DryBuffer; ClickRemoval = Device->ClickRemoval; PendingClicks = Device->PendingClicks; DryFilter = ¶ms->iirFilter; - for(i = 0;i < NumChannels;i++) + for(c = 0;c < MaxChannels;c++) + DrySend[c] = params->Gains[srcchan][c]; + + pos = 0; + if(OutPos == 0) { - for(c = 0;c < MaxChannels;c++) - DrySend[c] = params->Gains[i][c]; - - pos = 0; - frac = srcfrac; - - if(OutPos == 0) - { - value = Sampler(data + pos*NumChannels + i, NumChannels, frac); - - value = lpFilter2PC(DryFilter, i, value); - ApplyValue(ClickRemoval, -value, DrySend); - } - for(BufferIdx = 0;BufferIdx < BufferSize;BufferIdx++) - { - value = Sampler(data + pos*NumChannels + i, NumChannels, frac); - - value = lpFilter2P(DryFilter, i, value); - ApplyValue(DryBuffer[OutPos], value, DrySend); - - frac += increment; - pos += frac>>FRACTIONBITS; - frac &= FRACTIONMASK; - OutPos++; - } - if(OutPos == SamplesToDo) - { - value = Sampler(data + pos*NumChannels + i, NumChannels, frac); - - value = lpFilter2PC(DryFilter, i, value); - ApplyValue(PendingClicks, value, DrySend); - } - OutPos -= BufferSize; + value = lpFilter2PC(DryFilter, srcchan, data[pos]); + ApplyValue(ClickRemoval, -value, DrySend); + } + for(pos = 0;pos < BufferSize;pos++) + { + value = lpFilter2P(DryFilter, srcchan, data[pos]); + ApplyValue(DryBuffer[OutPos], value, DrySend); + OutPos++; + } + if(OutPos == SamplesToDo) + { + value = lpFilter2PC(DryFilter, srcchan, data[pos]); + ApplyValue(PendingClicks, value, DrySend); } } void MixSend(ALsource *Source, ALuint sendidx, SendParams *params, - const ALfloat *RESTRICT data, ALuint srcfrac, + const ALfloat *RESTRICT data, ALuint srcchan, ALuint OutPos, ALuint SamplesToDo, ALuint BufferSize) { - const ALuint NumChannels = Source->NumChannels; ALeffectslot *Slot; ALfloat WetSend; ALfloat *WetBuffer; ALfloat *WetClickRemoval; ALfloat *WetPendingClicks; FILTER *WetFilter; - ALuint pos, frac; - ALuint BufferIdx; - ALuint increment; + ALuint pos; ALfloat value; - ALuint i; - - increment = Source->Params.Step; Slot = Source->Params.Slot[sendidx]; WetBuffer = Slot->WetBuffer; @@ -261,38 +212,22 @@ void MixSend(ALsource *Source, ALuint sendidx, SendParams *params, WetFilter = ¶ms->iirFilter; WetSend = params->Gain; - for(i = 0;i < NumChannels;i++) + pos = 0; + if(OutPos == 0) + { + value = lpFilter2PC(WetFilter, srcchan, data[pos]); + WetClickRemoval[0] -= value * WetSend; + } + for(pos = 0;pos < BufferSize;pos++) + { + value = lpFilter2P(WetFilter, srcchan, data[pos]); + WetBuffer[OutPos] += value * WetSend; + OutPos++; + } + if(OutPos == SamplesToDo) { - pos = 0; - frac = srcfrac; - - if(OutPos == 0) - { - value = Sampler(data + pos*NumChannels + i, NumChannels, frac); - - value = lpFilter2PC(WetFilter, i, value); - WetClickRemoval[0] -= value * WetSend; - } - for(BufferIdx = 0;BufferIdx < BufferSize;BufferIdx++) - { - value = Sampler(data + pos*NumChannels + i, NumChannels, frac); - - value = lpFilter2P(WetFilter, i, value); - WetBuffer[OutPos] += value * WetSend; - - frac += increment; - pos += frac>>FRACTIONBITS; - frac &= FRACTIONMASK; - OutPos++; - } - if(OutPos == SamplesToDo) - { - value = Sampler(data + pos*NumChannels + i, NumChannels, frac); - - value = lpFilter2PC(WetFilter, i, value); - WetPendingClicks[0] += value * WetSend; - } - OutPos -= BufferSize; + value = lpFilter2PC(WetFilter, srcchan, data[pos]); + WetPendingClicks[0] += value * WetSend; } } @@ -300,8 +235,6 @@ void MixSend(ALsource *Source, ALuint sendidx, SendParams *params, #undef MixDirect #undef MixDirect_Hrtf -#undef MERGE4 -#undef REAL_MERGE4 #undef MERGE2 #undef REAL_MERGE2 diff --git a/Alc/mixer_neon.c b/Alc/mixer_neon.c index 246b4308..4824c597 100644 --- a/Alc/mixer_neon.c +++ b/Alc/mixer_neon.c @@ -63,13 +63,5 @@ static __inline void ApplyValue(ALfloat *RESTRICT Output, ALfloat value, const A #define SUFFIX Neon -#define Sampler point32 #include "mixer_inc.c" -#undef Sampler -#define Sampler lerp32 -#include "mixer_inc.c" -#undef Sampler -#define Sampler cubic32 -#include "mixer_inc.c" -#undef Sampler #undef SUFFIX diff --git a/Alc/mixer_sse.c b/Alc/mixer_sse.c index 0f80b095..2824beb4 100644 --- a/Alc/mixer_sse.c +++ b/Alc/mixer_sse.c @@ -77,13 +77,5 @@ static __inline void ApplyValue(ALfloat *RESTRICT Output, ALfloat value, const A #define SUFFIX SSE -#define Sampler point32 #include "mixer_inc.c" -#undef Sampler -#define Sampler lerp32 -#include "mixer_inc.c" -#undef Sampler -#define Sampler cubic32 -#include "mixer_inc.c" -#undef Sampler #undef SUFFIX |