aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/mixer
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-12-26 15:35:05 -0800
committerChris Robinson <[email protected]>2018-12-26 15:35:05 -0800
commit4f253a935a14e49a77516a56e0d4c6d6177a56b6 (patch)
tree088b3171e77f6c7863c9bbe851b4f82f4a58fbe3 /Alc/mixer
parentc5be03b51e8fd9bda3a46c345bdc945cfd965c2e (diff)
Handle HRTF coefficients and values by reference where possible
Diffstat (limited to 'Alc/mixer')
-rw-r--r--Alc/mixer/defs.h16
-rw-r--r--Alc/mixer/hrtf_inc.cpp23
-rw-r--r--Alc/mixer/mixer_c.cpp10
-rw-r--r--Alc/mixer/mixer_neon.cpp13
-rw-r--r--Alc/mixer/mixer_sse.cpp10
5 files changed, 37 insertions, 35 deletions
diff --git a/Alc/mixer/defs.h b/Alc/mixer/defs.h
index 5fa88773..5bdf6e30 100644
--- a/Alc/mixer/defs.h
+++ b/Alc/mixer/defs.h
@@ -10,6 +10,7 @@
struct MixGains;
struct MixHrtfParams;
struct HrtfState;
+struct DirectHrtfState;
/* C resamplers */
const ALfloat *Resample_copy_C(const InterpState *state, const ALfloat *RESTRICT src, ALsizei frac, ALint increment, ALfloat *RESTRICT dst, ALsizei dstlen);
@@ -30,9 +31,8 @@ void MixHrtfBlend_C(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
MixHrtfParams *newparams, HrtfState *hrtfstate,
ALsizei BufferSize);
void MixDirectHrtf_C(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
- const ALfloat *data, ALsizei Offset, const ALsizei IrSize,
- const ALfloat (*RESTRICT Coeffs)[2], ALfloat (*RESTRICT Values)[2],
- ALsizei BufferSize);
+ const ALfloat *data, DirectHrtfState *State, const ALsizei Chan,
+ const ALsizei BufferSize);
void Mix_C(const ALfloat *data, ALsizei OutChans, ALfloat (*RESTRICT OutBuffer)[BUFFERSIZE],
ALfloat *CurrentGains, const ALfloat *TargetGains, ALsizei Counter, ALsizei OutPos,
ALsizei BufferSize);
@@ -51,9 +51,8 @@ void MixHrtfBlend_SSE(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
MixHrtfParams *newparams, HrtfState *hrtfstate,
ALsizei BufferSize);
void MixDirectHrtf_SSE(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
- const ALfloat *data, ALsizei Offset, const ALsizei IrSize,
- const ALfloat (*RESTRICT Coeffs)[2], ALfloat (*RESTRICT Values)[2],
- ALsizei BufferSize);
+ const ALfloat *data, DirectHrtfState *State, const ALsizei Chan,
+ const ALsizei BufferSize);
void Mix_SSE(const ALfloat *data, ALsizei OutChans, ALfloat (*RESTRICT OutBuffer)[BUFFERSIZE],
ALfloat *CurrentGains, const ALfloat *TargetGains, ALsizei Counter, ALsizei OutPos,
ALsizei BufferSize);
@@ -98,9 +97,8 @@ void MixHrtfBlend_Neon(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
MixHrtfParams *newparams, HrtfState *hrtfstate,
ALsizei BufferSize);
void MixDirectHrtf_Neon(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
- const ALfloat *data, ALsizei Offset, const ALsizei IrSize,
- const ALfloat (*RESTRICT Coeffs)[2], ALfloat (*RESTRICT Values)[2],
- ALsizei BufferSize);
+ const ALfloat *data, DirectHrtfState *State, const ALsizei Chan,
+ const ALsizei BufferSize);
void Mix_Neon(const ALfloat *data, ALsizei OutChans, ALfloat (*RESTRICT OutBuffer)[BUFFERSIZE],
ALfloat *CurrentGains, const ALfloat *TargetGains, ALsizei Counter, ALsizei OutPos,
ALsizei BufferSize);
diff --git a/Alc/mixer/hrtf_inc.cpp b/Alc/mixer/hrtf_inc.cpp
index d811bd61..e82bad85 100644
--- a/Alc/mixer/hrtf_inc.cpp
+++ b/Alc/mixer/hrtf_inc.cpp
@@ -8,10 +8,9 @@
#include "defs.h"
-static inline void ApplyCoeffs(ALsizei Offset, ALfloat (*RESTRICT Values)[2],
- const ALsizei irSize,
- const ALfloat (*RESTRICT Coeffs)[2],
- ALfloat left, ALfloat right);
+static inline void ApplyCoeffs(ALsizei Offset, ALfloat (&Values)[HRIR_LENGTH][2],
+ const ALsizei irSize, const ALfloat (&Coeffs)[HRIR_LENGTH][2],
+ const ALfloat left, const ALfloat right);
void MixHrtf(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
@@ -19,7 +18,7 @@ void MixHrtf(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
const ALsizei IrSize, MixHrtfParams *hrtfparams, HrtfState *hrtfstate,
ALsizei BufferSize)
{
- const ALfloat (*Coeffs)[2] = hrtfparams->Coeffs;
+ const ALfloat (&Coeffs)[HRIR_LENGTH][2] = *hrtfparams->Coeffs;
const ALsizei Delay[2] = { hrtfparams->Delay[0], hrtfparams->Delay[1] };
const ALfloat gainstep = hrtfparams->GainStep;
const ALfloat gain = hrtfparams->Gain;
@@ -59,11 +58,11 @@ void MixHrtfBlend(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
MixHrtfParams *newparams, HrtfState *hrtfstate,
ALsizei BufferSize)
{
- const ALfloat (*OldCoeffs)[2] = oldparams->Coeffs;
+ const ALfloat (&OldCoeffs)[HRIR_LENGTH][2] = oldparams->Coeffs;
const ALsizei OldDelay[2] = { oldparams->Delay[0], oldparams->Delay[1] };
const ALfloat oldGain = oldparams->Gain;
const ALfloat oldGainStep = -oldGain / (ALfloat)BufferSize;
- const ALfloat (*NewCoeffs)[2] = newparams->Coeffs;
+ const ALfloat (&NewCoeffs)[HRIR_LENGTH][2] = *newparams->Coeffs;
const ALsizei NewDelay[2] = { newparams->Delay[0], newparams->Delay[1] };
const ALfloat newGain = newparams->Gain;
const ALfloat newGainStep = newparams->GainStep;
@@ -103,10 +102,14 @@ void MixHrtfBlend(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
}
void MixDirectHrtf(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
- const ALfloat *data, ALsizei Offset, const ALsizei IrSize,
- const ALfloat (*RESTRICT Coeffs)[2], ALfloat (*RESTRICT Values)[2],
- ALsizei BufferSize)
+ const ALfloat *data, DirectHrtfState *State, const ALsizei Chan,
+ const ALsizei BufferSize)
{
+ const ALsizei IrSize{State->IrSize};
+ ALsizei Offset{State->Offset};
+ ALfloat (&Values)[HRIR_LENGTH][2] = State->Chan[Chan].Values;
+ const ALfloat (&Coeffs)[HRIR_LENGTH][2] = State->Chan[Chan].Coeffs;
+
ASSUME(IrSize >= 4);
ASSUME(BufferSize > 0);
diff --git a/Alc/mixer/mixer_c.cpp b/Alc/mixer/mixer_c.cpp
index bbf58325..d98b8e2e 100644
--- a/Alc/mixer/mixer_c.cpp
+++ b/Alc/mixer/mixer_c.cpp
@@ -103,15 +103,15 @@ const ALfloat *Resample_bsinc_C(const InterpState *state, const ALfloat *RESTRIC
{ return DoResample<do_bsinc>(state, src-state->bsinc.l, frac, increment, dst, numsamples); }
-static inline void ApplyCoeffs(ALsizei Offset, ALfloat (*RESTRICT Values)[2],
- const ALsizei IrSize,
- const ALfloat (*RESTRICT Coeffs)[2],
- ALfloat left, ALfloat right)
+static inline void ApplyCoeffs(ALsizei Offset, ALfloat (&Values)[HRIR_LENGTH][2],
+ const ALsizei IrSize, const ALfloat (&Coeffs)[HRIR_LENGTH][2],
+ const ALfloat left, const ALfloat right)
{
ALsizei off{Offset&HRIR_MASK};
ALsizei count{mini(IrSize, HRIR_LENGTH - off)};
- ASSUME(IrSize > 0);
+ ASSUME(IrSize >= 2);
+ ASSUME(&Values != &Coeffs);
ASSUME(count > 0);
for(ALsizei c{0};;)
diff --git a/Alc/mixer/mixer_neon.cpp b/Alc/mixer/mixer_neon.cpp
index fa777eac..4843922f 100644
--- a/Alc/mixer/mixer_neon.cpp
+++ b/Alc/mixer/mixer_neon.cpp
@@ -133,12 +133,13 @@ const ALfloat *Resample_bsinc_Neon(const InterpState *state,
}
-static inline void ApplyCoeffs(ALsizei Offset, ALfloat (*RESTRICT Values)[2],
- const ALsizei IrSize,
- const ALfloat (*RESTRICT Coeffs)[2],
- ALfloat left, ALfloat right)
+static inline void ApplyCoeffs(ALsizei Offset, ALfloat (&Values)[HRIR_LENGTH][2],
+ const ALsizei IrSize, const ALfloat (&Coeffs)[HRIR_LENGTH][2],
+ const ALfloat left, const ALfloat right)
{
- ALsizei c;
+ ASSUME(IrSize >= 2);
+ ASSUME(&Values != &Coeffs);
+
float32x4_t leftright4;
{
float32x2_t leftright2 = vdup_n_f32(0.0);
@@ -147,7 +148,7 @@ static inline void ApplyCoeffs(ALsizei Offset, ALfloat (*RESTRICT Values)[2],
leftright4 = vcombine_f32(leftright2, leftright2);
}
- for(c = 0;c < IrSize;c += 2)
+ for(ALsizei c{0};c < IrSize;c += 2)
{
const ALsizei o0 = (Offset+c)&HRIR_MASK;
const ALsizei o1 = (o0+1)&HRIR_MASK;
diff --git a/Alc/mixer/mixer_sse.cpp b/Alc/mixer/mixer_sse.cpp
index 09307697..5d82e5ae 100644
--- a/Alc/mixer/mixer_sse.cpp
+++ b/Alc/mixer/mixer_sse.cpp
@@ -79,16 +79,16 @@ const ALfloat *Resample_bsinc_SSE(const InterpState *state, const ALfloat *RESTR
}
-static inline void ApplyCoeffs(ALsizei Offset, ALfloat (*RESTRICT Values)[2],
- const ALsizei IrSize,
- const ALfloat (*RESTRICT Coeffs)[2],
- ALfloat left, ALfloat right)
+static inline void ApplyCoeffs(ALsizei Offset, ALfloat (&Values)[HRIR_LENGTH][2],
+ const ALsizei IrSize, const ALfloat (&Coeffs)[HRIR_LENGTH][2],
+ const ALfloat left, const ALfloat right)
{
const __m128 lrlr = _mm_setr_ps(left, right, left, right);
__m128 vals = _mm_setzero_ps();
__m128 coeffs;
- ASSUME(IrSize > 1);
+ ASSUME(IrSize >= 2);
+ ASSUME(&Values != &Coeffs);
ALsizei off{Offset&HRIR_MASK};
if((Offset&1))