aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-01-23 12:23:05 -0800
committerChris Robinson <[email protected]>2019-01-23 12:23:05 -0800
commit8429770c3f4f6ab4bd21d5af518de58d6af3af57 (patch)
tree02a77ef595b71f571b718755e0a57e60af4ce2d4 /Alc
parentd3842a632da8542ac0c8fbdff39dc3d4a25c1a16 (diff)
Use template declarations for the HRTF mixers
Diffstat (limited to 'Alc')
-rw-r--r--Alc/alu.cpp9
-rw-r--r--Alc/mixer/defs.h47
-rw-r--r--Alc/mixer/hrtf_inc.cpp31
-rw-r--r--Alc/mixer/mixer_c.cpp28
-rw-r--r--Alc/mixer/mixer_neon.cpp28
-rw-r--r--Alc/mixer/mixer_sse.cpp28
-rw-r--r--Alc/mixvoice.cpp16
7 files changed, 109 insertions, 78 deletions
diff --git a/Alc/alu.cpp b/Alc/alu.cpp
index ed5cfe6f..c4492824 100644
--- a/Alc/alu.cpp
+++ b/Alc/alu.cpp
@@ -109,20 +109,19 @@ struct ChanMap {
ALfloat elevation;
};
-HrtfDirectMixerFunc MixDirectHrtf = MixDirectHrtf_C;
-
+HrtfDirectMixerFunc MixDirectHrtf = MixDirectHrtf_<CTag>;
inline HrtfDirectMixerFunc SelectHrtfMixer(void)
{
#ifdef HAVE_NEON
if((CPUCapFlags&CPU_CAP_NEON))
- return MixDirectHrtf_Neon;
+ return MixDirectHrtf_<NEONTag>;
#endif
#ifdef HAVE_SSE
if((CPUCapFlags&CPU_CAP_SSE))
- return MixDirectHrtf_SSE;
+ return MixDirectHrtf_<SSETag>;
#endif
- return MixDirectHrtf_C;
+ return MixDirectHrtf_<CTag>;
}
diff --git a/Alc/mixer/defs.h b/Alc/mixer/defs.h
index 03955b59..1aa6ba38 100644
--- a/Alc/mixer/defs.h
+++ b/Alc/mixer/defs.h
@@ -34,33 +34,12 @@ void Mix_(const ALfloat *data, const ALsizei OutChans, ALfloat (*OutBuffer)[BUFF
template<typename InstTag>
void MixRow_(ALfloat *OutBuffer, const ALfloat *Gains, const ALfloat (*data)[BUFFERSIZE], const ALsizei InChans, const ALsizei InPos, const ALsizei BufferSize);
-/* C mixers */
-void MixHrtf_C(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
- const ALfloat *data, ALsizei Offset, const ALsizei OutPos,
- const ALsizei IrSize, MixHrtfParams *hrtfparams,
- HrtfState *hrtfstate, const ALsizei BufferSize);
-void MixHrtfBlend_C(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
- const ALfloat *data, ALsizei Offset, const ALsizei OutPos,
- const ALsizei IrSize, const HrtfParams *oldparams,
- MixHrtfParams *newparams, HrtfState *hrtfstate,
- const ALsizei BufferSize);
-void MixDirectHrtf_C(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
- const ALfloat (*data)[BUFFERSIZE], DirectHrtfState *State,
- const ALsizei NumChans, const ALsizei BufferSize);
-
-/* SSE mixers */
-void MixHrtf_SSE(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
- const ALfloat *data, ALsizei Offset, const ALsizei OutPos,
- const ALsizei IrSize, MixHrtfParams *hrtfparams,
- HrtfState *hrtfstate, const ALsizei BufferSize);
-void MixHrtfBlend_SSE(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
- const ALfloat *data, ALsizei Offset, const ALsizei OutPos,
- const ALsizei IrSize, const HrtfParams *oldparams,
- MixHrtfParams *newparams, HrtfState *hrtfstate,
- const ALsizei BufferSize);
-void MixDirectHrtf_SSE(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
- const ALfloat (*data)[BUFFERSIZE], DirectHrtfState *State,
- const ALsizei NumChans, const ALsizei BufferSize);
+template<typename InstTag>
+void MixHrtf_(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut, const ALfloat *data, ALsizei Offset, const ALsizei OutPos, const ALsizei IrSize, MixHrtfParams *hrtfparams, HrtfState *hrtfstate, const ALsizei BufferSize);
+template<typename InstTag>
+void MixHrtfBlend_(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut, const ALfloat *data, ALsizei Offset, const ALsizei OutPos, const ALsizei IrSize, const HrtfParams *oldparams, MixHrtfParams *newparams, HrtfState *hrtfstate, const ALsizei BufferSize);
+template<typename InstTag>
+void MixDirectHrtf_(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut, const ALfloat (*data)[BUFFERSIZE], DirectHrtfState *State, const ALsizei NumChans, const ALsizei BufferSize);
/* Vectorized resampler helpers */
inline void InitiatePositionArrays(ALsizei frac, ALint increment, ALsizei *RESTRICT frac_arr, ALsizei *RESTRICT pos_arr, ALsizei size)
@@ -75,18 +54,4 @@ inline void InitiatePositionArrays(ALsizei frac, ALint increment, ALsizei *RESTR
}
}
-/* Neon mixers */
-void MixHrtf_Neon(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
- const ALfloat *data, ALsizei Offset, const ALsizei OutPos,
- const ALsizei IrSize, MixHrtfParams *hrtfparams,
- HrtfState *hrtfstate, const ALsizei BufferSize);
-void MixHrtfBlend_Neon(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
- const ALfloat *data, ALsizei Offset, const ALsizei OutPos,
- const ALsizei IrSize, const HrtfParams *oldparams,
- MixHrtfParams *newparams, HrtfState *hrtfstate,
- const ALsizei BufferSize);
-void MixDirectHrtf_Neon(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
- const ALfloat (*data)[BUFFERSIZE], DirectHrtfState *State,
- const ALsizei NumChans, const ALsizei BufferSize);
-
#endif /* MIXER_DEFS_H */
diff --git a/Alc/mixer/hrtf_inc.cpp b/Alc/mixer/hrtf_inc.cpp
index 594c6119..97065392 100644
--- a/Alc/mixer/hrtf_inc.cpp
+++ b/Alc/mixer/hrtf_inc.cpp
@@ -8,15 +8,15 @@
#include "defs.h"
-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);
+using ApplyCoeffsT = void(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,
- const ALfloat *data, ALsizei Offset, const ALsizei OutPos,
- const ALsizei IrSize, MixHrtfParams *hrtfparams, HrtfState *hrtfstate,
- const ALsizei BufferSize)
+template<ApplyCoeffsT ApplyCoeffs>
+inline void MixHrtfBase(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut, const ALfloat *data,
+ ALsizei Offset, const ALsizei OutPos, const ALsizei IrSize, MixHrtfParams *hrtfparams,
+ HrtfState *hrtfstate, const ALsizei BufferSize)
{
ASSUME(OutPos >= 0);
ASSUME(IrSize >= 4);
@@ -76,11 +76,11 @@ void MixHrtf(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
hrtfparams->Gain = gain + gainstep*stepcount;
}
-void MixHrtfBlend(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
- const ALfloat *data, ALsizei Offset, const ALsizei OutPos,
- const ALsizei IrSize, const HrtfParams *oldparams,
- MixHrtfParams *newparams, HrtfState *hrtfstate,
- const ALsizei BufferSize)
+template<ApplyCoeffsT ApplyCoeffs>
+inline void MixHrtfBlendBase(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
+ const ALfloat *data, ALsizei Offset, const ALsizei OutPos, const ALsizei IrSize,
+ const HrtfParams *oldparams, MixHrtfParams *newparams, HrtfState *hrtfstate,
+ const ALsizei BufferSize)
{
const ALfloat (&OldCoeffs)[HRIR_LENGTH][2] = oldparams->Coeffs;
const ALfloat oldGain{oldparams->Gain};
@@ -151,9 +151,10 @@ void MixHrtfBlend(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
newparams->Gain = newGainStep*stepcount;
}
-void MixDirectHrtf(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
- const ALfloat (*data)[BUFFERSIZE], DirectHrtfState *State,
- const ALsizei NumChans, const ALsizei BufferSize)
+template<ApplyCoeffsT ApplyCoeffs>
+inline void MixDirectHrtfBase(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
+ const ALfloat (*data)[BUFFERSIZE], DirectHrtfState *State, const ALsizei NumChans,
+ const ALsizei BufferSize)
{
ASSUME(NumChans > 0);
ASSUME(BufferSize > 0);
diff --git a/Alc/mixer/mixer_c.cpp b/Alc/mixer/mixer_c.cpp
index 6b1cc495..fad08e74 100644
--- a/Alc/mixer/mixer_c.cpp
+++ b/Alc/mixer/mixer_c.cpp
@@ -125,11 +125,33 @@ static inline void ApplyCoeffs(ALsizei Offset, ALfloat (&Values)[HRIR_LENGTH][2]
}
}
-#define MixHrtf MixHrtf_C
-#define MixHrtfBlend MixHrtfBlend_C
-#define MixDirectHrtf MixDirectHrtf_C
#include "hrtf_inc.cpp"
+template<>
+void MixHrtf_<CTag>(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut, const ALfloat *data,
+ ALsizei Offset, const ALsizei OutPos, const ALsizei IrSize, MixHrtfParams *hrtfparams,
+ HrtfState *hrtfstate, const ALsizei BufferSize)
+{
+ MixHrtfBase<ApplyCoeffs>(LeftOut, RightOut, data, Offset, OutPos, IrSize, hrtfparams,
+ hrtfstate, BufferSize);
+}
+
+template<>
+void MixHrtfBlend_<CTag>(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
+ const ALfloat *data, ALsizei Offset, const ALsizei OutPos, const ALsizei IrSize,
+ const HrtfParams *oldparams, MixHrtfParams *newparams, HrtfState *hrtfstate,
+ const ALsizei BufferSize)
+{
+ MixHrtfBlendBase<ApplyCoeffs>(LeftOut, RightOut, data, Offset, OutPos, IrSize, oldparams,
+ newparams, hrtfstate, BufferSize);
+}
+
+template<>
+void MixDirectHrtf_<CTag>(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
+ const ALfloat (*data)[BUFFERSIZE], DirectHrtfState *State, const ALsizei NumChans,
+ const ALsizei BufferSize)
+{ MixDirectHrtfBase<ApplyCoeffs>(LeftOut, RightOut, data, State, NumChans, BufferSize); }
+
template<>
void Mix_<CTag>(const ALfloat *data, const ALsizei OutChans, ALfloat (*OutBuffer)[BUFFERSIZE],
diff --git a/Alc/mixer/mixer_neon.cpp b/Alc/mixer/mixer_neon.cpp
index 978ea8d3..1c033bd3 100644
--- a/Alc/mixer/mixer_neon.cpp
+++ b/Alc/mixer/mixer_neon.cpp
@@ -164,11 +164,33 @@ static inline void ApplyCoeffs(ALsizei Offset, ALfloat (&Values)[HRIR_LENGTH][2]
}
}
-#define MixHrtf MixHrtf_Neon
-#define MixHrtfBlend MixHrtfBlend_Neon
-#define MixDirectHrtf MixDirectHrtf_Neon
#include "hrtf_inc.cpp"
+template<>
+void MixHrtf_<NEONTag>(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut, const ALfloat *data,
+ ALsizei Offset, const ALsizei OutPos, const ALsizei IrSize, MixHrtfParams *hrtfparams,
+ HrtfState *hrtfstate, const ALsizei BufferSize)
+{
+ MixHrtfBase<ApplyCoeffs>(LeftOut, RightOut, data, Offset, OutPos, IrSize, hrtfparams,
+ hrtfstate, BufferSize);
+}
+
+template<>
+void MixHrtfBlend_<NEONTag>(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
+ const ALfloat *data, ALsizei Offset, const ALsizei OutPos, const ALsizei IrSize,
+ const HrtfParams *oldparams, MixHrtfParams *newparams, HrtfState *hrtfstate,
+ const ALsizei BufferSize)
+{
+ MixHrtfBlendBase<ApplyCoeffs>(LeftOut, RightOut, data, Offset, OutPos, IrSize, oldparams,
+ newparams, hrtfstate, BufferSize);
+}
+
+template<>
+void MixDirectHrtf_<NEONTag>(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
+ const ALfloat (*data)[BUFFERSIZE], DirectHrtfState *State, const ALsizei NumChans,
+ const ALsizei BufferSize)
+{ MixDirectHrtfBase<ApplyCoeffs>(LeftOut, RightOut, data, State, NumChans, BufferSize); }
+
template<>
void Mix_<NEONTag>(const ALfloat *data, const ALsizei OutChans, ALfloat (*OutBuffer)[BUFFERSIZE],
diff --git a/Alc/mixer/mixer_sse.cpp b/Alc/mixer/mixer_sse.cpp
index adb0287d..3f756f2b 100644
--- a/Alc/mixer/mixer_sse.cpp
+++ b/Alc/mixer/mixer_sse.cpp
@@ -143,11 +143,33 @@ static inline void ApplyCoeffs(ALsizei Offset, ALfloat (&Values)[HRIR_LENGTH][2]
}
}
-#define MixHrtf MixHrtf_SSE
-#define MixHrtfBlend MixHrtfBlend_SSE
-#define MixDirectHrtf MixDirectHrtf_SSE
#include "hrtf_inc.cpp"
+template<>
+void MixHrtf_<SSETag>(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut, const ALfloat *data,
+ ALsizei Offset, const ALsizei OutPos, const ALsizei IrSize, MixHrtfParams *hrtfparams,
+ HrtfState *hrtfstate, const ALsizei BufferSize)
+{
+ MixHrtfBase<ApplyCoeffs>(LeftOut, RightOut, data, Offset, OutPos, IrSize, hrtfparams,
+ hrtfstate, BufferSize);
+}
+
+template<>
+void MixHrtfBlend_<SSETag>(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
+ const ALfloat *data, ALsizei Offset, const ALsizei OutPos, const ALsizei IrSize,
+ const HrtfParams *oldparams, MixHrtfParams *newparams, HrtfState *hrtfstate,
+ const ALsizei BufferSize)
+{
+ MixHrtfBlendBase<ApplyCoeffs>(LeftOut, RightOut, data, Offset, OutPos, IrSize, oldparams,
+ newparams, hrtfstate, BufferSize);
+}
+
+template<>
+void MixDirectHrtf_<SSETag>(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT RightOut,
+ const ALfloat (*data)[BUFFERSIZE], DirectHrtfState *State, const ALsizei NumChans,
+ const ALsizei BufferSize)
+{ MixDirectHrtfBase<ApplyCoeffs>(LeftOut, RightOut, data, State, NumChans, BufferSize); }
+
template<>
void Mix_<SSETag>(const ALfloat *data, const ALsizei OutChans, ALfloat (*OutBuffer)[BUFFERSIZE],
diff --git a/Alc/mixvoice.cpp b/Alc/mixvoice.cpp
index 35828ea3..6fecb830 100644
--- a/Alc/mixvoice.cpp
+++ b/Alc/mixvoice.cpp
@@ -58,8 +58,8 @@ Resampler ResamplerDefault = LinearResampler;
MixerFunc MixSamples = Mix_<CTag>;
RowMixerFunc MixRowSamples = MixRow_<CTag>;
-static HrtfMixerFunc MixHrtfSamples = MixHrtf_C;
-static HrtfMixerBlendFunc MixHrtfBlendSamples = MixHrtfBlend_C;
+static HrtfMixerFunc MixHrtfSamples = MixHrtf_<CTag>;
+static HrtfMixerBlendFunc MixHrtfBlendSamples = MixHrtfBlend_<CTag>;
static MixerFunc SelectMixer()
{
@@ -91,26 +91,26 @@ static inline HrtfMixerFunc SelectHrtfMixer()
{
#ifdef HAVE_NEON
if((CPUCapFlags&CPU_CAP_NEON))
- return MixHrtf_Neon;
+ return MixHrtf_<NEONTag>;
#endif
#ifdef HAVE_SSE
if((CPUCapFlags&CPU_CAP_SSE))
- return MixHrtf_SSE;
+ return MixHrtf_<SSETag>;
#endif
- return MixHrtf_C;
+ return MixHrtf_<CTag>;
}
static inline HrtfMixerBlendFunc SelectHrtfBlendMixer()
{
#ifdef HAVE_NEON
if((CPUCapFlags&CPU_CAP_NEON))
- return MixHrtfBlend_Neon;
+ return MixHrtfBlend_<NEONTag>;
#endif
#ifdef HAVE_SSE
if((CPUCapFlags&CPU_CAP_SSE))
- return MixHrtfBlend_SSE;
+ return MixHrtfBlend_<SSETag>;
#endif
- return MixHrtfBlend_C;
+ return MixHrtfBlend_<CTag>;
}
ResamplerFunc SelectResampler(Resampler resampler)