aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-01-17 16:49:26 -0800
committerChris Robinson <[email protected]>2017-01-17 16:49:26 -0800
commitba0944af9ba8d851bc5b6ad99f314bbdac269716 (patch)
tree3031abd32f417c78b52476fccac0aa0ac6611996
parentbfb7a6e4c85838bf2f6ed28fba452c55ad50c566 (diff)
Pass the left and right buffers to the hrtf mixers directly
-rw-r--r--Alc/ALu.c30
-rw-r--r--Alc/mixer.c10
-rw-r--r--Alc/mixer_defs.h12
-rw-r--r--Alc/mixer_inc.c16
-rw-r--r--OpenAL32/Include/alu.h10
5 files changed, 41 insertions, 37 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 7022f792..02b4ffe8 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -1486,8 +1486,9 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
if(device->Hrtf.Handle)
{
- int lidx = GetChannelIdxByName(device->RealOut, FrontLeft);
- int ridx = GetChannelIdxByName(device->RealOut, FrontRight);
+ HrtfDirectMixerFunc HrtfMix;
+ ALsizei irsize;
+ int lidx, ridx;
if(device->AmbiUp)
ambiup_process(device->AmbiUp,
@@ -1495,20 +1496,21 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
SAFE_CONST(ALfloatBUFFERSIZE*,device->FOAOut.Buffer), SamplesToDo
);
- if(lidx != -1 && ridx != -1)
+ lidx = GetChannelIdxByName(device->RealOut, FrontLeft);
+ ridx = GetChannelIdxByName(device->RealOut, FrontRight);
+ assert(lidx != -1 && ridx != -1);
+
+ HrtfMix = SelectHrtfMixer();
+ irsize = device->Hrtf.IrSize;
+ for(c = 0;c < device->Dry.NumChannels;c++)
{
- HrtfDirectMixerFunc HrtfMix = SelectHrtfMixer();
- ALsizei irsize = device->Hrtf.IrSize;
- for(c = 0;c < device->Dry.NumChannels;c++)
- {
- HrtfMix(device->RealOut.Buffer, lidx, ridx,
- device->Dry.Buffer[c], device->Hrtf.Offset, irsize,
- device->Hrtf.Coeffs[c], device->Hrtf.Values[c],
- SamplesToDo
- );
- }
- device->Hrtf.Offset += SamplesToDo;
+ HrtfMix(device->RealOut.Buffer[lidx], device->RealOut.Buffer[ridx],
+ device->Dry.Buffer[c], device->Hrtf.Offset, irsize,
+ device->Hrtf.Coeffs[c], device->Hrtf.Values[c],
+ SamplesToDo
+ );
}
+ device->Hrtf.Offset += SamplesToDo;
}
else if(device->AmbiDecoder)
{
diff --git a/Alc/mixer.c b/Alc/mixer.c
index e759482e..2d804b1f 100644
--- a/Alc/mixer.c
+++ b/Alc/mixer.c
@@ -589,7 +589,7 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam
{
ALfloat delta = 1.0f / (ALfloat)Counter;
ALfloat coeffdiff;
- ALsizei delaydiff;
+ ALint delaydiff;
for(j = 0;j < IrSize;j++)
{
coeffdiff = parms->Hrtf.Target.Coeffs[j][0] - parms->Hrtf.Current.Coeffs[j][0];
@@ -609,9 +609,11 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam
ridx = GetChannelIdxByName(Device->RealOut, FrontRight);
assert(lidx != -1 && ridx != -1);
- MixHrtfSamples(voice->DirectOut.Buffer, lidx, ridx, samples, Counter,
- voice->Offset, OutPos, IrSize, &hrtfparams,
- &parms->Hrtf.State, DstBufferSize);
+ MixHrtfSamples(
+ voice->DirectOut.Buffer[lidx], voice->DirectOut.Buffer[ridx],
+ samples, Counter, voice->Offset, OutPos, IrSize, &hrtfparams,
+ &parms->Hrtf.State, DstBufferSize
+ );
}
}
diff --git a/Alc/mixer_defs.h b/Alc/mixer_defs.h
index 6d2b3c04..64da7680 100644
--- a/Alc/mixer_defs.h
+++ b/Alc/mixer_defs.h
@@ -21,11 +21,11 @@ const ALfloat *Resample_bsinc32_C(const BsincState *state, const ALfloat *restri
/* C mixers */
-void MixHrtf_C(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALsizei lidx, ALsizei ridx,
+void MixHrtf_C(ALfloat *restrict LeftOut, ALfloat *restrict RightOut,
const ALfloat *data, ALsizei Counter, ALsizei Offset, ALsizei OutPos,
const ALsizei IrSize, const struct MixHrtfParams *hrtfparams,
struct HrtfState *hrtfstate, ALsizei BufferSize);
-void MixDirectHrtf_C(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALsizei lidx, ALsizei ridx,
+void MixDirectHrtf_C(ALfloat *restrict LeftOut, ALfloat *restrict RightOut,
const ALfloat *data, ALsizei Offset, const ALsizei IrSize,
ALfloat (*restrict Coeffs)[2], ALfloat (*restrict Values)[2],
ALsizei BufferSize);
@@ -37,11 +37,11 @@ void MixRow_C(ALfloat *OutBuffer, const ALfloat *Gains,
ALsizei InPos, ALsizei BufferSize);
/* SSE mixers */
-void MixHrtf_SSE(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALsizei lidx, ALsizei ridx,
+void MixHrtf_SSE(ALfloat *restrict LeftOut, ALfloat *restrict RightOut,
const ALfloat *data, ALsizei Counter, ALsizei Offset, ALsizei OutPos,
const ALsizei IrSize, const struct MixHrtfParams *hrtfparams,
struct HrtfState *hrtfstate, ALsizei BufferSize);
-void MixDirectHrtf_SSE(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALsizei lidx, ALsizei ridx,
+void MixDirectHrtf_SSE(ALfloat *restrict LeftOut, ALfloat *restrict RightOut,
const ALfloat *data, ALsizei Offset, const ALsizei IrSize,
ALfloat (*restrict Coeffs)[2], ALfloat (*restrict Values)[2],
ALsizei BufferSize);
@@ -93,11 +93,11 @@ const ALfloat *Resample_fir8_32_SSE41(const BsincState *state, const ALfloat *re
ALsizei numsamples);
/* Neon mixers */
-void MixHrtf_Neon(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALsizei lidx, ALsizei ridx,
+void MixHrtf_Neon(ALfloat *restrict LeftOut, ALfloat *restrict RightOut,
const ALfloat *data, ALsizei Counter, ALsizei Offset, ALsizei OutPos,
const ALsizei IrSize, const struct MixHrtfParams *hrtfparams,
struct HrtfState *hrtfstate, ALsizei BufferSize);
-void MixDirectHrtf_Neon(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALsizei lidx, ALsizei ridx,
+void MixDirectHrtf_Neon(ALfloat *restrict LeftOut, ALfloat *restrict RightOut,
const ALfloat *data, ALsizei Offset, const ALsizei IrSize,
ALfloat (*restrict Coeffs)[2], ALfloat (*restrict Values)[2],
ALsizei BufferSize);
diff --git a/Alc/mixer_inc.c b/Alc/mixer_inc.c
index 38b0242e..8215743e 100644
--- a/Alc/mixer_inc.c
+++ b/Alc/mixer_inc.c
@@ -23,7 +23,7 @@ static inline void ApplyCoeffs(ALsizei Offset, ALfloat (*restrict Values)[2],
ALfloat left, ALfloat right);
-void MixHrtf(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALsizei lidx, ALsizei ridx,
+void MixHrtf(ALfloat *restrict LeftOut, ALfloat *restrict RightOut,
const ALfloat *data, ALsizei Counter, ALsizei Offset, ALsizei OutPos,
const ALsizei IrSize, const MixHrtfParams *hrtfparams, HrtfState *hrtfstate,
ALsizei BufferSize)
@@ -67,9 +67,9 @@ void MixHrtf(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALsizei lidx, ALsizei ri
}
for(i = 0;i < todo;i++)
- OutBuffer[lidx][OutPos+i] += out[i][0];
+ LeftOut[OutPos+i] += out[i][0];
for(i = 0;i < todo;i++)
- OutBuffer[ridx][OutPos+i] += out[i][1];
+ RightOut[OutPos+i] += out[i][1];
OutPos += todo;
}
@@ -108,14 +108,14 @@ skip_stepping:
}
for(i = 0;i < todo;i++)
- OutBuffer[lidx][OutPos+i] += out[i][0];
+ LeftOut[OutPos+i] += out[i][0];
for(i = 0;i < todo;i++)
- OutBuffer[ridx][OutPos+i] += out[i][1];
+ RightOut[OutPos+i] += out[i][1];
OutPos += todo;
}
}
-void MixDirectHrtf(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALsizei lidx, ALsizei ridx,
+void MixDirectHrtf(ALfloat *restrict LeftOut, ALfloat *restrict RightOut,
const ALfloat *data, ALsizei Offset, const ALsizei IrSize,
ALfloat (*restrict Coeffs)[2], ALfloat (*restrict Values)[2],
ALsizei BufferSize)
@@ -141,9 +141,9 @@ void MixDirectHrtf(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALsizei lidx, ALsi
}
for(i = 0;i < todo;i++)
- OutBuffer[lidx][pos+i] += out[i][0];
+ LeftOut[pos+i] += out[i][0];
for(i = 0;i < todo;i++)
- OutBuffer[ridx][pos+i] += out[i][1];
+ RightOut[pos+i] += out[i][1];
pos += todo;
}
}
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index 4a424246..21b787d2 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -160,14 +160,14 @@ typedef void (*MixerFunc)(const ALfloat *data, ALsizei OutChans,
typedef void (*RowMixerFunc)(ALfloat *OutBuffer, const ALfloat *gains,
const ALfloat (*restrict data)[BUFFERSIZE], ALsizei InChans,
ALsizei InPos, ALsizei BufferSize);
-typedef void (*HrtfMixerFunc)(ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALsizei lidx, ALsizei ridx,
+typedef void (*HrtfMixerFunc)(ALfloat *restrict LeftOut, ALfloat *restrict RightOut,
const ALfloat *data, ALsizei Counter, ALsizei Offset, ALsizei OutPos,
const ALsizei IrSize, const MixHrtfParams *hrtfparams,
HrtfState *hrtfstate, ALsizei BufferSize);
-typedef void (*HrtfDirectMixerFunc)(ALfloat (*restrict OutBuffer)[BUFFERSIZE],
- ALsizei lidx, ALsizei ridx, const ALfloat *data, ALsizei Offset,
- const ALsizei IrSize, ALfloat (*restrict Coeffs)[2],
- ALfloat (*restrict Values)[2], ALsizei BufferSize);
+typedef void (*HrtfDirectMixerFunc)(ALfloat *restrict LeftOut, ALfloat *restrict RightOut,
+ const ALfloat *data, ALsizei Offset, const ALsizei IrSize,
+ ALfloat (*restrict Coeffs)[2], ALfloat (*restrict Values)[2],
+ ALsizei BufferSize);
#define GAIN_MIX_MAX (16.0f) /* +24dB */