Pass a span to MixDirectHrtf instead of a pointer+size

This commit is contained in:
Chris Robinson 2019-05-29 17:32:16 -07:00
parent d0f0a5fdca
commit ba449d2b08
7 changed files with 28 additions and 26 deletions

View File

@ -134,7 +134,8 @@ void ProcessHrtf(ALCdevice *device, const ALsizei SamplesToDo)
DirectHrtfState *state{device->mHrtfState.get()}; DirectHrtfState *state{device->mHrtfState.get()};
MixDirectHrtf(device->RealOut.Buffer[lidx], device->RealOut.Buffer[ridx], MixDirectHrtf(device->RealOut.Buffer[lidx], device->RealOut.Buffer[ridx],
device->Dry.Buffer, device->HrtfAccumData, state, device->Dry.NumChannels, SamplesToDo); {device->Dry.Buffer,device->Dry.Buffer+device->Dry.NumChannels}, device->HrtfAccumData,
state, SamplesToDo);
} }
void ProcessAmbiDec(ALCdevice *device, const ALsizei SamplesToDo) void ProcessAmbiDec(ALCdevice *device, const ALsizei SamplesToDo)

View File

@ -6,6 +6,8 @@
#include "alMain.h" #include "alMain.h"
#include "alu.h" #include "alu.h"
#include "alspan.h"
struct MixGains; struct MixGains;
struct MixHrtfParams; struct MixHrtfParams;
@ -39,7 +41,7 @@ void MixHrtf_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const ALfloat
template<typename InstTag> template<typename InstTag>
void MixHrtfBlend_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize, const HrtfParams *oldparams, MixHrtfParams *newparams, const ALsizei BufferSize); void MixHrtfBlend_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize, const HrtfParams *oldparams, MixHrtfParams *newparams, const ALsizei BufferSize);
template<typename InstTag> template<typename InstTag>
void MixDirectHrtf_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const FloatBufferLine *InSamples, float2 *AccumSamples, DirectHrtfState *State, const ALsizei NumChans, const ALsizei BufferSize); void MixDirectHrtf_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const al::span<const FloatBufferLine> InSamples, float2 *AccumSamples, DirectHrtfState *State, const ALsizei BufferSize);
/* Vectorized resampler helpers */ /* Vectorized resampler helpers */
inline void InitiatePositionArrays(ALsizei frac, ALint increment, ALsizei *RESTRICT frac_arr, ALsizei *RESTRICT pos_arr, ALsizei size) inline void InitiatePositionArrays(ALsizei frac, ALint increment, ALsizei *RESTRICT frac_arr, ALsizei *RESTRICT pos_arr, ALsizei size)

View File

@ -102,22 +102,21 @@ inline void MixHrtfBlendBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOut
template<ApplyCoeffsT &ApplyCoeffs> template<ApplyCoeffsT &ApplyCoeffs>
inline void MixDirectHrtfBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, inline void MixDirectHrtfBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
const FloatBufferLine *InSamples, float2 *RESTRICT AccumSamples, DirectHrtfState *State, const al::span<const FloatBufferLine> InSamples, float2 *RESTRICT AccumSamples,
const ALsizei NumChans, const ALsizei BufferSize) DirectHrtfState *State, const ALsizei BufferSize)
{ {
ASSUME(NumChans > 0);
ASSUME(BufferSize > 0); ASSUME(BufferSize > 0);
const ALsizei IrSize{State->IrSize}; const ALsizei IrSize{State->IrSize};
ASSUME(IrSize >= 4); ASSUME(IrSize >= 4);
for(ALsizei c{0};c < NumChans;++c) auto chanstate = State->Chan.begin();
for(const FloatBufferLine &input : InSamples)
{ {
const FloatBufferLine &input = InSamples[c]; const auto &Coeffs = chanstate->Coeffs;
const auto &Coeffs = State->Chan[c].Coeffs;
auto accum_iter = std::copy_n(State->Chan[c].Values.begin(), auto accum_iter = std::copy_n(chanstate->Values.begin(),
State->Chan[c].Values.size(), AccumSamples); chanstate->Values.size(), AccumSamples);
std::fill_n(accum_iter, BufferSize, float2{}); std::fill_n(accum_iter, BufferSize, float2{});
for(ALsizei i{0};i < BufferSize;++i) for(ALsizei i{0};i < BufferSize;++i)
@ -130,8 +129,9 @@ inline void MixDirectHrtfBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOu
for(ALsizei i{0};i < BufferSize;++i) for(ALsizei i{0};i < BufferSize;++i)
RightOut[i] += AccumSamples[i][1]; RightOut[i] += AccumSamples[i][1];
std::copy_n(AccumSamples + BufferSize, State->Chan[c].Values.size(), std::copy_n(AccumSamples + BufferSize, chanstate->Values.size(),
State->Chan[c].Values.begin()); chanstate->Values.begin());
++chanstate;
} }
} }

View File

@ -136,11 +136,10 @@ void MixHrtfBlend_<CTag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
template<> template<>
void MixDirectHrtf_<CTag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, void MixDirectHrtf_<CTag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
const FloatBufferLine *InSamples, float2 *AccumSamples, DirectHrtfState *State, const al::span<const FloatBufferLine> InSamples, float2 *AccumSamples, DirectHrtfState *State,
const ALsizei NumChans, const ALsizei BufferSize) const ALsizei BufferSize)
{ {
MixDirectHrtfBase<ApplyCoeffs>(LeftOut, RightOut, InSamples, AccumSamples, State, NumChans, MixDirectHrtfBase<ApplyCoeffs>(LeftOut, RightOut, InSamples, AccumSamples, State, BufferSize);
BufferSize);
} }

View File

@ -182,11 +182,10 @@ void MixHrtfBlend_<NEONTag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
template<> template<>
void MixDirectHrtf_<NEONTag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, void MixDirectHrtf_<NEONTag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
const FloatBufferLine *InSamples, float2 *AccumSamples, DirectHrtfState *State, const al::span<const FloatBufferLine> InSamples, float2 *AccumSamples, DirectHrtfState *State,
const ALsizei NumChans, const ALsizei BufferSize) const ALsizei BufferSize)
{ {
MixDirectHrtfBase<ApplyCoeffs>(LeftOut, RightOut, InSamples, AccumSamples, State, NumChans, MixDirectHrtfBase<ApplyCoeffs>(LeftOut, RightOut, InSamples, AccumSamples, State, BufferSize);
BufferSize);
} }

View File

@ -139,11 +139,10 @@ void MixHrtfBlend_<SSETag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
template<> template<>
void MixDirectHrtf_<SSETag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, void MixDirectHrtf_<SSETag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
const FloatBufferLine *InSamples, float2 *AccumSamples, DirectHrtfState *State, const al::span<const FloatBufferLine> InSamples, float2 *AccumSamples, DirectHrtfState *State,
const ALsizei NumChans, const ALsizei BufferSize) const ALsizei BufferSize)
{ {
MixDirectHrtfBase<ApplyCoeffs>(LeftOut, RightOut, InSamples, AccumSamples, State, NumChans, MixDirectHrtfBase<ApplyCoeffs>(LeftOut, RightOut, InSamples, AccumSamples, State, BufferSize);
BufferSize);
} }

View File

@ -22,8 +22,10 @@
#include "filters/biquad.h" #include "filters/biquad.h"
#include "filters/splitter.h" #include "filters/splitter.h"
#include "filters/nfc.h" #include "filters/nfc.h"
#include "almalloc.h" #include "almalloc.h"
#include "alnumeric.h" #include "alnumeric.h"
#include "alspan.h"
enum class DistanceModel; enum class DistanceModel;
@ -304,8 +306,8 @@ using HrtfMixerBlendFunc = void(*)(FloatBufferLine &LeftOut, FloatBufferLine &Ri
const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize, const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize,
const HrtfParams *oldparams, MixHrtfParams *newparams, const ALsizei BufferSize); const HrtfParams *oldparams, MixHrtfParams *newparams, const ALsizei BufferSize);
using HrtfDirectMixerFunc = void(*)(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, using HrtfDirectMixerFunc = void(*)(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
const FloatBufferLine *InSamples, float2 *RESTRICT AccumSamples, DirectHrtfState *State, const al::span<const FloatBufferLine> InSamples, float2 *AccumSamples, DirectHrtfState *State,
const ALsizei NumChans, const ALsizei BufferSize); const ALsizei BufferSize);
#define GAIN_MIX_MAX (1000.0f) /* +60dB */ #define GAIN_MIX_MAX (1000.0f) /* +60dB */