Use template declarations for the HRTF mixers
This commit is contained in:
+4
-5
@@ -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>;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+6
-41
@@ -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 */
|
||||
|
||||
+16
-15
@@ -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);
|
||||
|
||||
+25
-3
@@ -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],
|
||||
|
||||
@@ -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],
|
||||
|
||||
+25
-3
@@ -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],
|
||||
|
||||
+8
-8
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user