From c29eb6348980bf101f2a043d3f3b017dc1c48538 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 13 Jun 2014 11:42:04 -0700 Subject: Combine some dry and wet path types --- Alc/ALu.c | 95 +++++++++++++++++++++++++++----------------------------- Alc/mixer.c | 2 +- Alc/mixer_c.c | 18 +++++------ Alc/mixer_defs.h | 7 ++--- Alc/mixer_neon.c | 18 +++++------ Alc/mixer_sse.c | 18 +++++------ 6 files changed, 76 insertions(+), 82 deletions(-) (limited to 'Alc') diff --git a/Alc/ALu.c b/Alc/ALu.c index 488a7273..bddabeae 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -125,7 +125,7 @@ static HrtfMixerFunc SelectHrtfMixer(void) return MixDirect_Hrtf_C; } -static DryMixerFunc SelectDirectMixer(void) +static MixerFunc SelectDirectMixer(void) { #ifdef HAVE_SSE if((CPUCapFlags&CPU_CAP_SSE)) @@ -139,7 +139,7 @@ static DryMixerFunc SelectDirectMixer(void) return MixDirect_C; } -static WetMixerFunc SelectSendMixer(void) +static MixerFunc SelectSendMixer(void) { #ifdef HAVE_SSE if((CPUCapFlags&CPU_CAP_SSE)) @@ -427,20 +427,20 @@ ALvoid CalcNonAttnSourceParams(ALactivesource *src, const ALCcontext *ALContext) { for(c = 0;c < num_channels;c++) { - ALfloat *restrict Target = src->Direct.Mix.Gains[c].Target; + MixGains *gains = src->Direct.Mix.Gains[c]; for(j = 0;j < MaxChannels;j++) - Target[j] = 0.0f; + gains[j].Target = 0.0f; } for(c = 0;c < num_channels;c++) { - ALfloat *restrict Target = src->Direct.Mix.Gains[c].Target; + MixGains *gains = src->Direct.Mix.Gains[c]; for(i = 0;i < (ALint)Device->NumChan;i++) { enum Channel chan = Device->Speaker2Chan[i]; if(chan == chans[c].channel) { - Target[chan] = DryGain; + gains[chan].Target = DryGain; break; } } @@ -450,13 +450,11 @@ ALvoid CalcNonAttnSourceParams(ALactivesource *src, const ALCcontext *ALContext) { for(i = 0;i < num_channels;i++) { - ALfloat *restrict Current = src->Direct.Mix.Gains[i].Current; - ALfloat *restrict Step = src->Direct.Mix.Gains[i].Step; - ALfloat *restrict Target = src->Direct.Mix.Gains[i].Target; + MixGains *gains = src->Direct.Mix.Gains[i]; for(j = 0;j < MaxChannels;j++) { - Current[j] = Target[j]; - Step[j] = 1.0f; + gains[j].Current = gains[j].Target; + gains[j].Step = 1.0f; } } src->Direct.Counter = 0; @@ -466,18 +464,16 @@ ALvoid CalcNonAttnSourceParams(ALactivesource *src, const ALCcontext *ALContext) { for(i = 0;i < num_channels;i++) { - ALfloat *restrict Current = src->Direct.Mix.Gains[i].Current; - ALfloat *restrict Step = src->Direct.Mix.Gains[i].Step; - ALfloat *restrict Target = src->Direct.Mix.Gains[i].Target; + MixGains *gains = src->Direct.Mix.Gains[i]; for(j = 0;j < MaxChannels;j++) { - ALfloat cur = maxf(Current[j], FLT_EPSILON); - ALfloat trg = maxf(Target[j], FLT_EPSILON); + ALfloat cur = maxf(gains[j].Current, FLT_EPSILON); + ALfloat trg = maxf(gains[j].Target, FLT_EPSILON); if(fabs(trg - cur) >= GAIN_SILENCE_THRESHOLD) - Step[j] = powf(trg/cur, 1.0f/64.0f); + gains[j].Step = powf(trg/cur, 1.0f/64.0f); else - Step[j] = 1.0f; - Current[j] = cur; + gains[j].Step = 1.0f; + gains[j].Current = cur; } } src->Direct.Counter = 64; @@ -522,35 +518,37 @@ ALvoid CalcNonAttnSourceParams(ALactivesource *src, const ALCcontext *ALContext) { for(i = 0;i < num_channels;i++) { - ALfloat *restrict Target = src->Direct.Mix.Gains[i].Target; + MixGains *gains = src->Direct.Mix.Gains[i]; for(j = 0;j < MaxChannels;j++) - Target[j] = 0.0f; + gains[j].Target = 0.0f; } DryGain *= lerp(1.0f, 1.0f/sqrtf((float)Device->NumChan), hwidth/F_PI); for(c = 0;c < num_channels;c++) { - ALfloat *restrict Target = src->Direct.Mix.Gains[c].Target; + MixGains *gains = src->Direct.Mix.Gains[c]; + ALfloat Target[MaxChannels]; + /* Special-case LFE */ if(chans[c].channel == LFE) { - Target[chans[c].channel] = DryGain; + gains[chans[c].channel].Target = DryGain; continue; } ComputeAngleGains(Device, chans[c].angle, hwidth, DryGain, Target); + for(i = 0;i < MaxChannels;i++) + gains[i].Target = Target[i]; } if(!src->Direct.Moving) { for(i = 0;i < num_channels;i++) { - ALfloat *restrict Current = src->Direct.Mix.Gains[i].Current; - ALfloat *restrict Step = src->Direct.Mix.Gains[i].Step; - ALfloat *restrict Target = src->Direct.Mix.Gains[i].Target; + MixGains *gains = src->Direct.Mix.Gains[i]; for(j = 0;j < MaxChannels;j++) { - Current[j] = Target[j]; - Step[j] = 1.0f; + gains[j].Current = gains[j].Target; + gains[j].Step = 1.0f; } } src->Direct.Counter = 0; @@ -560,18 +558,16 @@ ALvoid CalcNonAttnSourceParams(ALactivesource *src, const ALCcontext *ALContext) { for(i = 0;i < num_channels;i++) { - ALfloat *restrict Current = src->Direct.Mix.Gains[i].Current; - ALfloat *restrict Step = src->Direct.Mix.Gains[i].Step; - ALfloat *restrict Target = src->Direct.Mix.Gains[i].Target; + MixGains *gains = src->Direct.Mix.Gains[i]; for(j = 0;j < MaxChannels;j++) { - ALfloat trg = maxf(Target[j], FLT_EPSILON); - ALfloat cur = maxf(Current[j], FLT_EPSILON); + ALfloat trg = maxf(gains[j].Target, FLT_EPSILON); + ALfloat cur = maxf(gains[j].Current, FLT_EPSILON); if(fabs(trg - cur) >= GAIN_SILENCE_THRESHOLD) - Step[j] = powf(trg/cur, 1.0f/64.0f); + gains[j].Step = powf(trg/cur, 1.0f/64.0f); else - Step[j] = 1.0f; - Current[j] = cur; + gains[j].Step = 1.0f; + gains[j].Current = cur; } } src->Direct.Counter = 64; @@ -1046,16 +1042,17 @@ ALvoid CalcSourceParams(ALactivesource *src, const ALCcontext *ALContext) } else { - ALfloat *restrict Target = src->Direct.Mix.Gains[0].Target; + MixGains *gains = src->Direct.Mix.Gains[0]; ALfloat DirGain = 0.0f; ALfloat AmbientGain; for(j = 0;j < MaxChannels;j++) - Target[j] = 0.0f; + gains[j].Target = 0.0f; /* Normalize the length, and compute panned gains. */ if(Distance > FLT_EPSILON) { + ALfloat Target[MaxChannels]; ALfloat invlen = 1.0f/Distance; Position[0] *= invlen; Position[1] *= invlen; @@ -1064,6 +1061,8 @@ ALvoid CalcSourceParams(ALactivesource *src, const ALCcontext *ALContext) DirGain = sqrtf(Position[0]*Position[0] + Position[2]*Position[2]); ComputeAngleGains(Device, atan2f(Position[0], -Position[2]*ZScale), 0.0f, DryGain*DirGain, Target); + for(j = 0;j < MaxChannels;j++) + gains[j].Target = Target[j]; } /* Adjustment for vertical offsets. Not the greatest, but simple @@ -1072,34 +1071,30 @@ ALvoid CalcSourceParams(ALactivesource *src, const ALCcontext *ALContext) for(i = 0;i < (ALint)Device->NumChan;i++) { enum Channel chan = Device->Speaker2Chan[i]; - Target[chan] = maxf(Target[chan], AmbientGain); + gains[chan].Target = maxf(gains[chan].Target, AmbientGain); } if(!src->Direct.Moving) { - ALfloat *restrict Current = src->Direct.Mix.Gains[0].Current; - ALfloat *restrict Step = src->Direct.Mix.Gains[0].Step; for(j = 0;j < MaxChannels;j++) { - Current[j] = Target[j]; - Step[j] = 1.0f; + gains[j].Current = gains[j].Target; + gains[j].Step = 1.0f; } src->Direct.Counter = 0; src->Direct.Moving = AL_TRUE; } else { - ALfloat *restrict Current = src->Direct.Mix.Gains[0].Current; - ALfloat *restrict Step = src->Direct.Mix.Gains[0].Step; for(j = 0;j < MaxChannels;j++) { - ALfloat cur = maxf(Current[j], FLT_EPSILON); - ALfloat trg = maxf(Target[j], FLT_EPSILON); + ALfloat cur = maxf(gains[j].Current, FLT_EPSILON); + ALfloat trg = maxf(gains[j].Target, FLT_EPSILON); if(fabs(trg - cur) >= GAIN_SILENCE_THRESHOLD) - Step[j] = powf(trg/cur, 1.0f/64.0f); + gains[j].Step = powf(trg/cur, 1.0f/64.0f); else - Step[j] = 1.0f; - Current[j] = cur; + gains[j].Step = 1.0f; + gains[j].Current = cur; } src->Direct.Counter = 64; } diff --git a/Alc/mixer.c b/Alc/mixer.c index 6a4abfc6..c7abbfed 100644 --- a/Alc/mixer.c +++ b/Alc/mixer.c @@ -358,7 +358,7 @@ ALvoid MixSource(ALactivesource *src, ALCdevice *Device, ALuint SamplesToDo) parms->Filters[chan].ActiveType ); if(!src->IsHrtf) - src->Dry.Mix(parms->OutBuffer, samples, &parms->Mix.Gains[chan], + src->Dry.Mix(parms->OutBuffer, samples, parms->Mix.Gains[chan], parms->Counter, OutPos, DstBufferSize); else src->Dry.HrtfMix( diff --git a/Alc/mixer_c.c b/Alc/mixer_c.c index 6dd01e7d..f919ad79 100644 --- a/Alc/mixer_c.c +++ b/Alc/mixer_c.c @@ -104,8 +104,8 @@ void MixDirect_C(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *data, for(c = 0;c < MaxChannels;c++) { ALuint pos = 0; - DrySend = Gains->Current[c]; - Step = Gains->Step[c]; + DrySend = Gains[c].Current; + Step = Gains[c].Step; if(Step != 1.0f && Counter > 0) { for(;pos < BufferSize && pos < Counter;pos++) @@ -114,8 +114,8 @@ void MixDirect_C(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *data, DrySend *= Step; } if(pos == Counter) - DrySend = Gains->Target[c]; - Gains->Current[c] = DrySend; + DrySend = Gains[c].Target; + Gains[c].Current = DrySend; } if(!(DrySend > GAIN_SILENCE_THRESHOLD)) @@ -127,14 +127,14 @@ void MixDirect_C(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *data, void MixSend_C(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *data, - MixGainMono *Gain, ALuint Counter, ALuint OutPos, ALuint BufferSize) + MixGains *Gain, ALuint Counter, ALuint OutPos, ALuint BufferSize) { ALfloat WetSend, Step; { ALuint pos = 0; - WetSend = Gain->Current; - Step = Gain->Step; + WetSend = Gain[0].Current; + Step = Gain[0].Step; if(Step != 1.0f && Counter > 0) { for(;pos < BufferSize && pos < Counter;pos++) @@ -143,8 +143,8 @@ void MixSend_C(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *data, WetSend *= Step; } if(pos == Counter) - WetSend = Gain->Target; - Gain->Current = WetSend; + WetSend = Gain[0].Target; + Gain[0].Current = WetSend; } if(!(WetSend > GAIN_SILENCE_THRESHOLD)) diff --git a/Alc/mixer_defs.h b/Alc/mixer_defs.h index caa06c25..2ade14f0 100644 --- a/Alc/mixer_defs.h +++ b/Alc/mixer_defs.h @@ -7,7 +7,6 @@ #include "alu.h" struct MixGains; -struct MixGainMono; struct HrtfParams; struct HrtfState; @@ -28,7 +27,7 @@ void MixDirect_C(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *data, struct MixGains *Gains, ALuint Counter, ALuint OutPos, ALuint BufferSize); void MixSend_C(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *data, - struct MixGainMono *Gain, ALuint Counter, ALuint OutPos, + struct MixGains *Gain, ALuint Counter, ALuint OutPos, ALuint BufferSize); /* SSE mixers */ @@ -40,7 +39,7 @@ void MixDirect_SSE(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *dat struct MixGains *Gains, ALuint Counter, ALuint OutPos, ALuint BufferSize); void MixSend_SSE(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *data, - struct MixGainMono *Gain, ALuint Counter, ALuint OutPos, + struct MixGains *Gain, ALuint Counter, ALuint OutPos, ALuint BufferSize); /* SSE resamplers */ @@ -72,7 +71,7 @@ void MixDirect_Neon(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *da struct MixGains *Gains, ALuint Counter, ALuint OutPos, ALuint BufferSize); void MixSend_Neon(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *data, - struct MixGainMono *Gain, ALuint Counter, ALuint OutPos, + struct MixGains *Gain, ALuint Counter, ALuint OutPos, ALuint BufferSize); #endif /* MIXER_DEFS_H */ diff --git a/Alc/mixer_neon.c b/Alc/mixer_neon.c index 6a0421a5..ecae2692 100644 --- a/Alc/mixer_neon.c +++ b/Alc/mixer_neon.c @@ -85,8 +85,8 @@ void MixDirect_Neon(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *da for(c = 0;c < MaxChannels;c++) { ALuint pos = 0; - DrySend = Gains->Current[c]; - Step = Gains->Step[c]; + DrySend = Gains[c].Current; + Step = Gains[c].Step; if(Step != 1.0f && Counter > 0) { for(;pos < BufferSize && pos < Counter;pos++) @@ -95,8 +95,8 @@ void MixDirect_Neon(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *da DrySend *= Step; } if(pos == Counter) - DrySend = Gains->Target[c]; - Gains->Current[c] = DrySend; + DrySend = Gains[c].Target; + Gains[c].Current = DrySend; /* Mix until pos is aligned with 4 or the mix is done. */ for(;pos < BufferSize && (pos&3) != 0;pos++) OutBuffer[c][OutPos+pos] += data[pos]*DrySend; @@ -119,15 +119,15 @@ void MixDirect_Neon(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *da void MixSend_Neon(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *data, - MixGainMono *Gain, ALuint Counter, ALuint OutPos, ALuint BufferSize) + MixGains *Gain, ALuint Counter, ALuint OutPos, ALuint BufferSize) { ALfloat WetGain, Step; float32x4_t gain; { ALuint pos = 0; - WetGain = Gain->Current; - Step = Gain->Step; + WetGain = Gain[0].Current; + Step = Gain[0].Step; if(Step != 1.0f && Counter > 0) { for(;pos < BufferSize && pos < Counter;pos++) @@ -136,8 +136,8 @@ void MixSend_Neon(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *data WetGain *= Step; } if(pos == Counter) - WetGain = Gain->Target; - Gain->Current = WetGain; + WetGain = Gain[0].Target; + Gain[0].Current = WetGain; for(;pos < BufferSize && (pos&3) != 0;pos++) OutBuffer[0][OutPos+pos] += data[pos]*WetGain; } diff --git a/Alc/mixer_sse.c b/Alc/mixer_sse.c index c4e1fdf5..64fd1c12 100644 --- a/Alc/mixer_sse.c +++ b/Alc/mixer_sse.c @@ -148,8 +148,8 @@ void MixDirect_SSE(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *dat for(c = 0;c < MaxChannels;c++) { ALuint pos = 0; - DrySend = Gains->Current[c]; - Step = Gains->Step[c]; + DrySend = Gains[c].Current; + Step = Gains[c].Step; if(Step != 1.0f && Counter > 0) { /* Mix with applying gain steps in aligned multiples of 4. */ @@ -179,8 +179,8 @@ void MixDirect_SSE(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *dat DrySend *= Step; } if(pos == Counter) - DrySend = Gains->Target[c]; - Gains->Current[c] = DrySend; + DrySend = Gains[c].Target; + Gains[c].Current = DrySend; /* Mix until pos is aligned with 4 or the mix is done. */ for(;pos < BufferSize && (pos&3) != 0;pos++) OutBuffer[c][OutPos+pos] += data[pos]*DrySend; @@ -203,15 +203,15 @@ void MixDirect_SSE(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *dat void MixSend_SSE(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *data, - MixGainMono *Gain, ALuint Counter, ALuint OutPos, ALuint BufferSize) + MixGains *Gain, ALuint Counter, ALuint OutPos, ALuint BufferSize) { ALfloat WetGain, Step; __m128 gain, step; { ALuint pos = 0; - WetGain = Gain->Current; - Step = Gain->Step; + WetGain = Gain[0].Current; + Step = Gain[0].Step; if(Step != 1.0f && Counter > 0) { if(BufferSize-pos > 3 && Counter-pos > 3) @@ -239,8 +239,8 @@ void MixSend_SSE(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *data, WetGain *= Step; } if(pos == Counter) - WetGain = Gain->Target; - Gain->Current = WetGain; + WetGain = Gain[0].Target; + Gain[0].Current = WetGain; for(;pos < BufferSize && (pos&3) != 0;pos++) OutBuffer[0][OutPos+pos] += data[pos]*WetGain; } -- cgit v1.2.3