From f09734b707c3036345d602cc187cc21248a54abd Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 13 Sep 2019 11:19:11 -0700 Subject: [PATCH] Pass IrSize to the HRTF mixers as unsigned --- alc/alu.h | 4 ++-- alc/mixer/defs.h | 4 ++-- alc/mixer/hrtfbase.h | 8 ++++---- alc/mixer/mixer_c.cpp | 8 ++++---- alc/mixer/mixer_neon.cpp | 8 ++++---- alc/mixer/mixer_sse.cpp | 10 +++++----- alc/mixvoice.cpp | 8 ++++---- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/alc/alu.h b/alc/alu.h index aca7790e..cf021285 100644 --- a/alc/alu.h +++ b/alc/alu.h @@ -322,10 +322,10 @@ using MixerFunc = void(*)(const al::span InSamples, using RowMixerFunc = void(*)(const al::span OutBuffer, const al::span Gains, const float *InSamples, const size_t InStride); using HrtfMixerFunc = void(*)(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, - const ALfloat *InSamples, float2 *AccumSamples, const size_t OutPos, const ALsizei IrSize, + const ALfloat *InSamples, float2 *AccumSamples, const size_t OutPos, const ALuint IrSize, MixHrtfFilter *hrtfparams, const size_t BufferSize); using HrtfMixerBlendFunc = void(*)(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, - const ALfloat *InSamples, float2 *AccumSamples, const size_t OutPos, const ALsizei IrSize, + const ALfloat *InSamples, float2 *AccumSamples, const size_t OutPos, const ALuint IrSize, const HrtfFilter *oldparams, MixHrtfFilter *newparams, const size_t BufferSize); using HrtfDirectMixerFunc = void(*)(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const al::span InSamples, float2 *AccumSamples, DirectHrtfState *State, diff --git a/alc/mixer/defs.h b/alc/mixer/defs.h index a6e07bd4..62e7d3ba 100644 --- a/alc/mixer/defs.h +++ b/alc/mixer/defs.h @@ -38,9 +38,9 @@ void MixRow_(const al::span OutBuffer, const al::span Gains, const float *InSamples, const size_t InStride); template -void MixHrtf_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const ALfloat *InSamples, float2 *AccumSamples, const size_t OutPos, const ALsizei IrSize, MixHrtfFilter *hrtfparams, const size_t BufferSize); +void MixHrtf_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const ALfloat *InSamples, float2 *AccumSamples, const size_t OutPos, const ALuint IrSize, MixHrtfFilter *hrtfparams, const size_t BufferSize); template -void MixHrtfBlend_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const ALfloat *InSamples, float2 *AccumSamples, const size_t OutPos, const ALsizei IrSize, const HrtfFilter *oldparams, MixHrtfFilter *newparams, const size_t BufferSize); +void MixHrtfBlend_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const ALfloat *InSamples, float2 *AccumSamples, const size_t OutPos, const ALuint IrSize, const HrtfFilter *oldparams, MixHrtfFilter *newparams, const size_t BufferSize); template void MixDirectHrtf_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const al::span InSamples, float2 *AccumSamples, DirectHrtfState *State, const size_t BufferSize); diff --git a/alc/mixer/hrtfbase.h b/alc/mixer/hrtfbase.h index dd33ce2d..d2432e90 100644 --- a/alc/mixer/hrtfbase.h +++ b/alc/mixer/hrtfbase.h @@ -8,13 +8,13 @@ #include "opthelpers.h" -using ApplyCoeffsT = void(size_t Offset, float2 *RESTRICT Values, const ALsizei irSize, +using ApplyCoeffsT = void(size_t Offset, float2 *RESTRICT Values, const ALuint irSize, const HrirArray &Coeffs, const ALfloat left, const ALfloat right); template inline void MixHrtfBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const ALfloat *InSamples, float2 *RESTRICT AccumSamples, const size_t OutPos, - const ALsizei IrSize, MixHrtfFilter *hrtfparams, const size_t BufferSize) + const ALuint IrSize, MixHrtfFilter *hrtfparams, const size_t BufferSize) { ASSUME(BufferSize > 0); @@ -48,7 +48,7 @@ inline void MixHrtfBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, template inline void MixHrtfBlendBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, const ALfloat *InSamples, float2 *RESTRICT AccumSamples, const size_t OutPos, - const ALsizei IrSize, const HrtfFilter *oldparams, MixHrtfFilter *newparams, + const ALuint IrSize, const HrtfFilter *oldparams, MixHrtfFilter *newparams, const size_t BufferSize) { const auto &OldCoeffs = oldparams->Coeffs; @@ -103,7 +103,7 @@ inline void MixDirectHrtfBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOu { ASSUME(BufferSize > 0); - const auto IrSize = static_cast(State->IrSize); + const ALuint IrSize{State->IrSize}; auto accum_iter = std::copy_n(State->Values.begin(), State->Values.size(), AccumSamples); std::fill_n(accum_iter, BufferSize, float2{}); diff --git a/alc/mixer/mixer_c.cpp b/alc/mixer/mixer_c.cpp index c5e712f9..720b264b 100644 --- a/alc/mixer/mixer_c.cpp +++ b/alc/mixer/mixer_c.cpp @@ -98,11 +98,11 @@ const ALfloat *Resample_(const InterpState *state, const ALfloat { return DoResample(state, src-state->bsinc.l, frac, increment, dst); } -static inline void ApplyCoeffs(size_t /*Offset*/, float2 *RESTRICT Values, const ALsizei IrSize, +static inline void ApplyCoeffs(size_t /*Offset*/, float2 *RESTRICT Values, const ALuint IrSize, const HrirArray &Coeffs, const ALfloat left, const ALfloat right) { ASSUME(IrSize >= 4); - for(ALsizei c{0};c < IrSize;++c) + for(ALuint c{0};c < IrSize;++c) { Values[c][0] += Coeffs[c][0] * left; Values[c][1] += Coeffs[c][1] * right; @@ -111,7 +111,7 @@ static inline void ApplyCoeffs(size_t /*Offset*/, float2 *RESTRICT Values, const template<> void MixHrtf_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, - const ALfloat *InSamples, float2 *AccumSamples, const size_t OutPos, const ALsizei IrSize, + const ALfloat *InSamples, float2 *AccumSamples, const size_t OutPos, const ALuint IrSize, MixHrtfFilter *hrtfparams, const size_t BufferSize) { MixHrtfBase(LeftOut, RightOut, InSamples, AccumSamples, OutPos, IrSize, @@ -120,7 +120,7 @@ void MixHrtf_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, template<> void MixHrtfBlend_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, - const ALfloat *InSamples, float2 *AccumSamples, const size_t OutPos, const ALsizei IrSize, + const ALfloat *InSamples, float2 *AccumSamples, const size_t OutPos, const ALuint IrSize, const HrtfFilter *oldparams, MixHrtfFilter *newparams, const size_t BufferSize) { MixHrtfBlendBase(LeftOut, RightOut, InSamples, AccumSamples, OutPos, IrSize, diff --git a/alc/mixer/mixer_neon.cpp b/alc/mixer/mixer_neon.cpp index c0a8e628..852bef38 100644 --- a/alc/mixer/mixer_neon.cpp +++ b/alc/mixer/mixer_neon.cpp @@ -121,7 +121,7 @@ const ALfloat *Resample_(const InterpState *state, const ALflo } -static inline void ApplyCoeffs(size_t /*Offset*/, float2 *RESTRICT Values, const ALsizei IrSize, +static inline void ApplyCoeffs(size_t /*Offset*/, float2 *RESTRICT Values, const ALuint IrSize, const HrirArray &Coeffs, const ALfloat left, const ALfloat right) { ASSUME(IrSize >= 4); @@ -134,7 +134,7 @@ static inline void ApplyCoeffs(size_t /*Offset*/, float2 *RESTRICT Values, const leftright4 = vcombine_f32(leftright2, leftright2); } - for(ALsizei c{0};c < IrSize;c += 2) + for(ALuint c{0};c < IrSize;c += 2) { float32x4_t vals = vld1q_f32(&Values[c][0]); float32x4_t coefs = vld1q_f32(&Coeffs[c][0]); @@ -147,7 +147,7 @@ static inline void ApplyCoeffs(size_t /*Offset*/, float2 *RESTRICT Values, const template<> void MixHrtf_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, - const ALfloat *InSamples, float2 *AccumSamples, const size_t OutPos, const ALsizei IrSize, + const ALfloat *InSamples, float2 *AccumSamples, const size_t OutPos, const ALuint IrSize, MixHrtfFilter *hrtfparams, const size_t BufferSize) { MixHrtfBase(LeftOut, RightOut, InSamples, AccumSamples, OutPos, IrSize, @@ -156,7 +156,7 @@ void MixHrtf_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, template<> void MixHrtfBlend_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, - const ALfloat *InSamples, float2 *AccumSamples, const size_t OutPos, const ALsizei IrSize, + const ALfloat *InSamples, float2 *AccumSamples, const size_t OutPos, const ALuint IrSize, const HrtfFilter *oldparams, MixHrtfFilter *newparams, const size_t BufferSize) { MixHrtfBlendBase(LeftOut, RightOut, InSamples, AccumSamples, OutPos, IrSize, diff --git a/alc/mixer/mixer_sse.cpp b/alc/mixer/mixer_sse.cpp index 82e2bfbe..368b8dfe 100644 --- a/alc/mixer/mixer_sse.cpp +++ b/alc/mixer/mixer_sse.cpp @@ -68,7 +68,7 @@ const ALfloat *Resample_(const InterpState *state, const ALfloa } -static inline void ApplyCoeffs(size_t Offset, float2 *RESTRICT Values, const ALsizei IrSize, +static inline void ApplyCoeffs(size_t Offset, float2 *RESTRICT Values, const ALuint IrSize, const HrirArray &Coeffs, const ALfloat left, const ALfloat right) { const __m128 lrlr{_mm_setr_ps(left, right, left, right)}; @@ -83,7 +83,7 @@ static inline void ApplyCoeffs(size_t Offset, float2 *RESTRICT Values, const ALs imp0 = _mm_mul_ps(lrlr, coeffs); vals = _mm_add_ps(imp0, vals); _mm_storel_pi(reinterpret_cast<__m64*>(&Values[0][0]), vals); - ALsizei i{1}; + ALuint i{1}; for(;i < IrSize-1;i += 2) { coeffs = _mm_load_ps(&Coeffs[i+1][0]); @@ -101,7 +101,7 @@ static inline void ApplyCoeffs(size_t Offset, float2 *RESTRICT Values, const ALs } else { - for(ALsizei i{0};i < IrSize;i += 2) + for(ALuint i{0};i < IrSize;i += 2) { __m128 coeffs{_mm_load_ps(&Coeffs[i][0])}; __m128 vals{_mm_load_ps(&Values[i][0])}; @@ -113,7 +113,7 @@ static inline void ApplyCoeffs(size_t Offset, float2 *RESTRICT Values, const ALs template<> void MixHrtf_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, - const ALfloat *InSamples, float2 *AccumSamples, const size_t OutPos, const ALsizei IrSize, + const ALfloat *InSamples, float2 *AccumSamples, const size_t OutPos, const ALuint IrSize, MixHrtfFilter *hrtfparams, const size_t BufferSize) { MixHrtfBase(LeftOut, RightOut, InSamples, AccumSamples, OutPos, IrSize, @@ -122,7 +122,7 @@ void MixHrtf_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, template<> void MixHrtfBlend_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, - const ALfloat *InSamples, float2 *AccumSamples, const size_t OutPos, const ALsizei IrSize, + const ALfloat *InSamples, float2 *AccumSamples, const size_t OutPos, const ALuint IrSize, const HrtfFilter *oldparams, MixHrtfFilter *newparams, const size_t BufferSize) { MixHrtfBlendBase(LeftOut, RightOut, InSamples, AccumSamples, OutPos, IrSize, diff --git a/alc/mixvoice.cpp b/alc/mixvoice.cpp index c3598612..7bdeea5e 100644 --- a/alc/mixvoice.cpp +++ b/alc/mixvoice.cpp @@ -698,8 +698,8 @@ void ALvoice::mix(State vstate, ALCcontext *Context, const ALuint SamplesToDo) hrtfparams.GainStep = gain / static_cast(fademix); MixHrtfBlendSamples(mDirect.Buffer[OutLIdx], mDirect.Buffer[OutRIdx], - HrtfSamples, AccumSamples, OutPos, static_cast(IrSize), - &parms.Hrtf.Old, &hrtfparams, fademix); + HrtfSamples, AccumSamples, OutPos, IrSize, &parms.Hrtf.Old, + &hrtfparams, fademix); /* Update the old parameters with the result. */ parms.Hrtf.Old = parms.Hrtf.Target; if(fademix < Counter) @@ -731,8 +731,8 @@ void ALvoice::mix(State vstate, ALCcontext *Context, const ALuint SamplesToDo) hrtfparams.GainStep = (gain - parms.Hrtf.Old.Gain) / static_cast(todo); MixHrtfSamples(mDirect.Buffer[OutLIdx], mDirect.Buffer[OutRIdx], - HrtfSamples+fademix, AccumSamples+fademix, OutPos+fademix, - static_cast(IrSize), &hrtfparams, todo); + HrtfSamples+fademix, AccumSamples+fademix, OutPos+fademix, IrSize, + &hrtfparams, todo); /* Store the interpolated gain or the final target gain * depending if the fade is done. */ -- 2.11.4.GIT