diff options
author | Chris Robinson <[email protected]> | 2019-08-20 11:39:39 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-08-20 11:39:39 -0700 |
commit | 3fa83547e9d3857ad034fa29bd991111a3753259 (patch) | |
tree | 5fa8d76652b86cfcd3445addcdb2de8a4e81f8ce /alc | |
parent | a19f65f2c8e092e2314295cea5b72e3576490d45 (diff) |
Use size_t for HrtfMixer functions' buffer size
Diffstat (limited to 'alc')
-rw-r--r-- | alc/alu.cpp | 1 | ||||
-rw-r--r-- | alc/alu.h | 6 | ||||
-rw-r--r-- | alc/mixer/defs.h | 6 | ||||
-rw-r--r-- | alc/mixer/hrtfbase.h | 28 | ||||
-rw-r--r-- | alc/mixer/mixer_c.cpp | 8 | ||||
-rw-r--r-- | alc/mixer/mixer_neon.cpp | 14 | ||||
-rw-r--r-- | alc/mixer/mixer_sse.cpp | 8 |
7 files changed, 35 insertions, 36 deletions
diff --git a/alc/alu.cpp b/alc/alu.cpp index 4a0ea8f9..a7d7cd70 100644 --- a/alc/alu.cpp +++ b/alc/alu.cpp @@ -159,6 +159,7 @@ void ALCdevice::ProcessHrtf(const ALsizei SamplesToDo) const int ridx{RealOut.ChannelIndex[FrontRight]}; ASSUME(lidx >= 0 && ridx >= 0); + ASSUME(SamplesToDo >= 0); MixDirectHrtf(RealOut.Buffer[lidx], RealOut.Buffer[ridx], Dry.Buffer, HrtfAccumData, mHrtfState.get(), SamplesToDo); } @@ -320,13 +320,13 @@ using RowMixerFunc = void(*)(const al::span<float> OutBuffer, const al::span<con const float *InSamples, const size_t InStride); using HrtfMixerFunc = void(*)(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize, - MixHrtfFilter *hrtfparams, const ALsizei BufferSize); + MixHrtfFilter *hrtfparams, const size_t BufferSize); using HrtfMixerBlendFunc = void(*)(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize, - const HrtfFilter *oldparams, MixHrtfFilter *newparams, const ALsizei BufferSize); + const HrtfFilter *oldparams, MixHrtfFilter *newparams, const size_t BufferSize); using HrtfDirectMixerFunc = void(*)(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const al::span<const FloatBufferLine> InSamples, float2 *AccumSamples, DirectHrtfState *State, - const ALsizei BufferSize); + const size_t BufferSize); #define GAIN_MIX_MAX (1000.0f) /* +60dB */ diff --git a/alc/mixer/defs.h b/alc/mixer/defs.h index bdb208c4..1a949ef3 100644 --- a/alc/mixer/defs.h +++ b/alc/mixer/defs.h @@ -37,11 +37,11 @@ void MixRow_(const al::span<float> OutBuffer, const al::span<const float> Gains, const float *InSamples, const size_t InStride); template<InstSetType InstTag> -void MixHrtf_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize, MixHrtfFilter *hrtfparams, const ALsizei BufferSize); +void MixHrtf_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize, MixHrtfFilter *hrtfparams, const size_t BufferSize); template<InstSetType InstTag> -void MixHrtfBlend_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize, const HrtfFilter *oldparams, MixHrtfFilter *newparams, const ALsizei BufferSize); +void MixHrtfBlend_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize, const HrtfFilter *oldparams, MixHrtfFilter *newparams, const size_t BufferSize); template<InstSetType InstTag> -void MixDirectHrtf_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const al::span<const FloatBufferLine> InSamples, float2 *AccumSamples, DirectHrtfState *State, const ALsizei BufferSize); +void MixDirectHrtf_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const al::span<const FloatBufferLine> InSamples, float2 *AccumSamples, DirectHrtfState *State, const size_t BufferSize); /* Vectorized resampler helpers */ inline void InitiatePositionArrays(ALsizei frac, ALint increment, ALsizei *RESTRICT frac_arr, ALsizei *RESTRICT pos_arr, ALsizei size) diff --git a/alc/mixer/hrtfbase.h b/alc/mixer/hrtfbase.h index 3c8208f3..741e17d0 100644 --- a/alc/mixer/hrtfbase.h +++ b/alc/mixer/hrtfbase.h @@ -8,13 +8,13 @@ #include "opthelpers.h" -using ApplyCoeffsT = void(ALsizei Offset, float2 *RESTRICT Values, const ALsizei irSize, +using ApplyCoeffsT = void(size_t Offset, float2 *RESTRICT Values, const ALsizei irSize, const HrirArray &Coeffs, const ALfloat left, const ALfloat right); template<ApplyCoeffsT &ApplyCoeffs> inline void MixHrtfBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const ALfloat *InSamples, float2 *RESTRICT AccumSamples, const ALsizei OutPos, - const ALsizei IrSize, MixHrtfFilter *hrtfparams, const ALsizei BufferSize) + const ALsizei IrSize, MixHrtfFilter *hrtfparams, const size_t BufferSize) { ASSUME(OutPos >= 0); ASSUME(IrSize >= 4); @@ -29,7 +29,7 @@ inline void MixHrtfBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, HRTF_HISTORY_LENGTH - hrtfparams->Delay[1] }; ASSUME(Delay[0] >= 0 && Delay[1] >= 0); ALfloat stepcount{0.0f}; - for(ALsizei i{0};i < BufferSize;++i) + for(size_t i{0u};i < BufferSize;++i) { const ALfloat g{gain + gainstep*stepcount}; const ALfloat left{InSamples[Delay[0]++] * g}; @@ -39,9 +39,9 @@ inline void MixHrtfBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, stepcount += 1.0f; } - for(ALsizei i{0};i < BufferSize;++i) + for(size_t i{0u};i < BufferSize;++i) LeftOut[OutPos+i] += AccumSamples[i][0]; - for(ALsizei i{0};i < BufferSize;++i) + for(size_t i{0u};i < BufferSize;++i) RightOut[OutPos+i] += AccumSamples[i][1]; hrtfparams->Gain = gain + gainstep*stepcount; @@ -51,7 +51,7 @@ template<ApplyCoeffsT &ApplyCoeffs> inline void MixHrtfBlendBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const ALfloat *InSamples, float2 *RESTRICT AccumSamples, const ALsizei OutPos, const ALsizei IrSize, const HrtfFilter *oldparams, MixHrtfFilter *newparams, - const ALsizei BufferSize) + const size_t BufferSize) { const auto &OldCoeffs = oldparams->Coeffs; const ALfloat oldGain{oldparams->Gain}; @@ -68,7 +68,7 @@ inline void MixHrtfBlendBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOut HRTF_HISTORY_LENGTH - oldparams->Delay[1] }; ASSUME(Delay[0] >= 0 && Delay[1] >= 0); ALfloat stepcount{0.0f}; - for(ALsizei i{0};i < BufferSize;++i) + for(size_t i{0u};i < BufferSize;++i) { const ALfloat g{oldGain + oldGainStep*stepcount}; const ALfloat left{InSamples[Delay[0]++] * g}; @@ -82,7 +82,7 @@ inline void MixHrtfBlendBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOut Delay[1] = HRTF_HISTORY_LENGTH - newparams->Delay[1]; ASSUME(Delay[0] >= 0 && Delay[1] >= 0); stepcount = 0.0f; - for(ALsizei i{0};i < BufferSize;++i) + for(size_t i{0u};i < BufferSize;++i) { const ALfloat g{newGainStep*stepcount}; const ALfloat left{InSamples[Delay[0]++] * g}; @@ -92,9 +92,9 @@ inline void MixHrtfBlendBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOut stepcount += 1.0f; } - for(ALsizei i{0};i < BufferSize;++i) + for(size_t i{0u};i < BufferSize;++i) LeftOut[OutPos+i] += AccumSamples[i][0]; - for(ALsizei i{0};i < BufferSize;++i) + for(size_t i{0u};i < BufferSize;++i) RightOut[OutPos+i] += AccumSamples[i][1]; newparams->Gain = newGainStep*stepcount; @@ -103,7 +103,7 @@ inline void MixHrtfBlendBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOut template<ApplyCoeffsT &ApplyCoeffs> inline void MixDirectHrtfBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const al::span<const FloatBufferLine> InSamples, float2 *RESTRICT AccumSamples, - DirectHrtfState *State, const ALsizei BufferSize) + DirectHrtfState *State, const size_t BufferSize) { ASSUME(BufferSize > 0); @@ -119,14 +119,14 @@ inline void MixDirectHrtfBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOu chanstate->Values.size(), AccumSamples); std::fill_n(accum_iter, BufferSize, float2{}); - for(ALsizei i{0};i < BufferSize;++i) + for(size_t i{0u};i < BufferSize;++i) { const ALfloat insample{input[i]}; ApplyCoeffs(i, AccumSamples+i, IrSize, Coeffs, insample, insample); } - for(ALsizei i{0};i < BufferSize;++i) + for(size_t i{0u};i < BufferSize;++i) LeftOut[i] += AccumSamples[i][0]; - for(ALsizei i{0};i < BufferSize;++i) + for(size_t i{0u};i < BufferSize;++i) RightOut[i] += AccumSamples[i][1]; std::copy_n(AccumSamples + BufferSize, chanstate->Values.size(), diff --git a/alc/mixer/mixer_c.cpp b/alc/mixer/mixer_c.cpp index 743431da..4af88fec 100644 --- a/alc/mixer/mixer_c.cpp +++ b/alc/mixer/mixer_c.cpp @@ -101,7 +101,7 @@ const ALfloat *Resample_<BSincTag,CTag>(const InterpState *state, const ALfloat { return DoResample<do_bsinc>(state, src-state->bsinc.l, frac, increment, dst); } -static inline void ApplyCoeffs(ALsizei /*Offset*/, float2 *RESTRICT Values, const ALsizei IrSize, +static inline void ApplyCoeffs(size_t /*Offset*/, float2 *RESTRICT Values, const ALsizei IrSize, const HrirArray &Coeffs, const ALfloat left, const ALfloat right) { ASSUME(IrSize >= 2); @@ -115,7 +115,7 @@ static inline void ApplyCoeffs(ALsizei /*Offset*/, float2 *RESTRICT Values, cons template<> void MixHrtf_<CTag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize, - MixHrtfFilter *hrtfparams, const ALsizei BufferSize) + MixHrtfFilter *hrtfparams, const size_t BufferSize) { MixHrtfBase<ApplyCoeffs>(LeftOut, RightOut, InSamples, AccumSamples, OutPos, IrSize, hrtfparams, BufferSize); @@ -124,7 +124,7 @@ void MixHrtf_<CTag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, template<> void MixHrtfBlend_<CTag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize, - const HrtfFilter *oldparams, MixHrtfFilter *newparams, const ALsizei BufferSize) + const HrtfFilter *oldparams, MixHrtfFilter *newparams, const size_t BufferSize) { MixHrtfBlendBase<ApplyCoeffs>(LeftOut, RightOut, InSamples, AccumSamples, OutPos, IrSize, oldparams, newparams, BufferSize); @@ -133,7 +133,7 @@ void MixHrtfBlend_<CTag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, template<> void MixDirectHrtf_<CTag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const al::span<const FloatBufferLine> InSamples, float2 *AccumSamples, DirectHrtfState *State, - const ALsizei BufferSize) + const size_t BufferSize) { MixDirectHrtfBase<ApplyCoeffs>(LeftOut, RightOut, InSamples, AccumSamples, State, BufferSize); } diff --git a/alc/mixer/mixer_neon.cpp b/alc/mixer/mixer_neon.cpp index 9a3722ab..bbf1d9f1 100644 --- a/alc/mixer/mixer_neon.cpp +++ b/alc/mixer/mixer_neon.cpp @@ -134,7 +134,7 @@ const ALfloat *Resample_<BSincTag,NEONTag>(const InterpState *state, const ALflo } -static inline void ApplyCoeffs(ALsizei /*Offset*/, float2 *RESTRICT Values, const ALsizei IrSize, +static inline void ApplyCoeffs(size_t /*Offset*/, float2 *RESTRICT Values, const ALsizei IrSize, const HrirArray &Coeffs, const ALfloat left, const ALfloat right) { ASSUME(IrSize >= 2); @@ -149,21 +149,19 @@ static inline void ApplyCoeffs(ALsizei /*Offset*/, float2 *RESTRICT Values, cons for(ALsizei c{0};c < IrSize;c += 2) { - float32x4_t vals = vcombine_f32(vld1_f32((float32_t*)&Values[c ][0]), - vld1_f32((float32_t*)&Values[c+1][0])); + float32x4_t vals = vld1q_f32((float32_t*)&Values[c][0]); float32x4_t coefs = vld1q_f32((float32_t*)&Coeffs[c][0]); vals = vmlaq_f32(vals, coefs, leftright4); - vst1_f32((float32_t*)&Values[c ][0], vget_low_f32(vals)); - vst1_f32((float32_t*)&Values[c+1][0], vget_high_f32(vals)); + vst1_f32((float32_t*)&Values[c][0], vals); } } template<> void MixHrtf_<NEONTag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize, - MixHrtfFilter *hrtfparams, const ALsizei BufferSize) + MixHrtfFilter *hrtfparams, const size_t BufferSize) { MixHrtfBase<ApplyCoeffs>(LeftOut, RightOut, InSamples, AccumSamples, OutPos, IrSize, hrtfparams, BufferSize); @@ -172,7 +170,7 @@ void MixHrtf_<NEONTag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, template<> void MixHrtfBlend_<NEONTag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize, - const HrtfFilter *oldparams, MixHrtfFilter *newparams, const ALsizei BufferSize) + const HrtfFilter *oldparams, MixHrtfFilter *newparams, const size_t BufferSize) { MixHrtfBlendBase<ApplyCoeffs>(LeftOut, RightOut, InSamples, AccumSamples, OutPos, IrSize, oldparams, newparams, BufferSize); @@ -181,7 +179,7 @@ void MixHrtfBlend_<NEONTag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, template<> void MixDirectHrtf_<NEONTag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const al::span<const FloatBufferLine> InSamples, float2 *AccumSamples, DirectHrtfState *State, - const ALsizei BufferSize) + const size_t BufferSize) { MixDirectHrtfBase<ApplyCoeffs>(LeftOut, RightOut, InSamples, AccumSamples, State, BufferSize); } diff --git a/alc/mixer/mixer_sse.cpp b/alc/mixer/mixer_sse.cpp index c154eeef..b7503118 100644 --- a/alc/mixer/mixer_sse.cpp +++ b/alc/mixer/mixer_sse.cpp @@ -73,7 +73,7 @@ const ALfloat *Resample_<BSincTag,SSETag>(const InterpState *state, const ALfloa } -static inline void ApplyCoeffs(ALsizei Offset, float2 *RESTRICT Values, const ALsizei IrSize, +static inline void ApplyCoeffs(size_t Offset, float2 *RESTRICT Values, const ALsizei IrSize, const HrirArray &Coeffs, const ALfloat left, const ALfloat right) { const __m128 lrlr{_mm_setr_ps(left, right, left, right)}; @@ -119,7 +119,7 @@ static inline void ApplyCoeffs(ALsizei Offset, float2 *RESTRICT Values, const AL template<> void MixHrtf_<SSETag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize, - MixHrtfFilter *hrtfparams, const ALsizei BufferSize) + MixHrtfFilter *hrtfparams, const size_t BufferSize) { MixHrtfBase<ApplyCoeffs>(LeftOut, RightOut, InSamples, AccumSamples, OutPos, IrSize, hrtfparams, BufferSize); @@ -128,7 +128,7 @@ void MixHrtf_<SSETag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, template<> void MixHrtfBlend_<SSETag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const ALfloat *InSamples, float2 *AccumSamples, const ALsizei OutPos, const ALsizei IrSize, - const HrtfFilter *oldparams, MixHrtfFilter *newparams, const ALsizei BufferSize) + const HrtfFilter *oldparams, MixHrtfFilter *newparams, const size_t BufferSize) { MixHrtfBlendBase<ApplyCoeffs>(LeftOut, RightOut, InSamples, AccumSamples, OutPos, IrSize, oldparams, newparams, BufferSize); @@ -137,7 +137,7 @@ void MixHrtfBlend_<SSETag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, template<> void MixDirectHrtf_<SSETag>(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const al::span<const FloatBufferLine> InSamples, float2 *AccumSamples, DirectHrtfState *State, - const ALsizei BufferSize) + const size_t BufferSize) { MixDirectHrtfBase<ApplyCoeffs>(LeftOut, RightOut, InSamples, AccumSamples, State, BufferSize); } |