diff options
author | Chris Robinson <[email protected]> | 2021-01-02 17:37:09 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2021-01-02 17:37:09 -0800 |
commit | 04cd0bc576947879525005b11abcd5230e215360 (patch) | |
tree | 3c14af02fb6cadcc0966b32263aade5c2816b8e3 /core | |
parent | 1f51de9983956732bdf63bff91258096eed84544 (diff) |
Return non-const from the resampler function
Diffstat (limited to 'core')
-rw-r--r-- | core/mixer/defs.h | 13 | ||||
-rw-r--r-- | core/mixer/mixer_c.cpp | 26 | ||||
-rw-r--r-- | core/mixer/mixer_neon.cpp | 18 | ||||
-rw-r--r-- | core/mixer/mixer_sse.cpp | 8 | ||||
-rw-r--r-- | core/mixer/mixer_sse2.cpp | 4 | ||||
-rw-r--r-- | core/mixer/mixer_sse41.cpp | 4 |
6 files changed, 36 insertions, 37 deletions
diff --git a/core/mixer/defs.h b/core/mixer/defs.h index 9dcf395f..acf60350 100644 --- a/core/mixer/defs.h +++ b/core/mixer/defs.h @@ -59,15 +59,15 @@ union InterpState { BsincState bsinc; }; -using ResamplerFunc = const float*(*)(const InterpState *state, const float *RESTRICT src, - uint frac, uint increment, const al::span<float> dst); +using ResamplerFunc = float*(*)(const InterpState *state, float *RESTRICT src, uint frac, + uint increment, const al::span<float> dst); ResamplerFunc PrepareResampler(Resampler resampler, uint increment, InterpState *state); template<typename TypeTag, typename InstTag> -const float *Resample_(const InterpState *state, const float *RESTRICT src, uint frac, - uint increment, const al::span<float> dst); +float *Resample_(const InterpState *state, float *RESTRICT src, uint frac, uint increment, + const al::span<float> dst); template<typename InstTag> void Mix_(const al::span<const float> InSamples, const al::span<FloatBufferLine> OutBuffer, @@ -85,11 +85,12 @@ void MixDirectHrtf_(FloatBufferLine &LeftOut, FloatBufferLine &RightOut, float *TempBuf, HrtfChannelState *ChanState, const size_t IrSize, const size_t BufferSize); /* Vectorized resampler helpers */ -inline void InitPosArrays(uint frac, uint increment, uint *frac_arr, uint *pos_arr, size_t size) +template<size_t N> +inline void InitPosArrays(uint frac, uint increment, uint (&frac_arr)[N], uint (&pos_arr)[N]) { pos_arr[0] = 0; frac_arr[0] = frac; - for(size_t i{1};i < size;i++) + for(size_t i{1};i < N;i++) { const uint frac_tmp{frac_arr[i-1] + increment}; pos_arr[i] = pos_arr[i-1] + (frac_tmp>>MixerFracBits); diff --git a/core/mixer/mixer_c.cpp b/core/mixer/mixer_c.cpp index 6d4909f4..ff9538a4 100644 --- a/core/mixer/mixer_c.cpp +++ b/core/mixer/mixer_c.cpp @@ -68,8 +68,8 @@ inline float do_fastbsinc(const InterpState &istate, const float *RESTRICT vals, using SamplerT = float(&)(const InterpState&, const float*RESTRICT, const uint); template<SamplerT Sampler> -const float *DoResample(const InterpState *state, const float *RESTRICT src, uint frac, - uint increment, const al::span<float> dst) +float *DoResample(const InterpState *state, float *RESTRICT src, uint frac, uint increment, + const al::span<float> dst) { const InterpState istate{*state}; for(float &out : dst) @@ -97,7 +97,7 @@ inline void ApplyCoeffs(float2 *RESTRICT Values, const size_t IrSize, const Hrir } // namespace template<> -const float *Resample_<CopyTag,CTag>(const InterpState*, const float *RESTRICT src, uint, uint, +float *Resample_<CopyTag,CTag>(const InterpState*, float *RESTRICT src, uint, uint, const al::span<float> dst) { #if defined(HAVE_SSE) || defined(HAVE_NEON) @@ -110,28 +110,28 @@ const float *Resample_<CopyTag,CTag>(const InterpState*, const float *RESTRICT s } template<> -const float *Resample_<PointTag,CTag>(const InterpState *state, const float *RESTRICT src, - uint frac, uint increment, const al::span<float> dst) +float *Resample_<PointTag,CTag>(const InterpState *state, float *RESTRICT src, uint frac, + uint increment, const al::span<float> dst) { return DoResample<do_point>(state, src, frac, increment, dst); } template<> -const float *Resample_<LerpTag,CTag>(const InterpState *state, const float *RESTRICT src, - uint frac, uint increment, const al::span<float> dst) +float *Resample_<LerpTag,CTag>(const InterpState *state, float *RESTRICT src, uint frac, + uint increment, const al::span<float> dst) { return DoResample<do_lerp>(state, src, frac, increment, dst); } template<> -const float *Resample_<CubicTag,CTag>(const InterpState *state, const float *RESTRICT src, - uint frac, uint increment, const al::span<float> dst) +float *Resample_<CubicTag,CTag>(const InterpState *state, float *RESTRICT src, uint frac, + uint increment, const al::span<float> dst) { return DoResample<do_cubic>(state, src-1, frac, increment, dst); } template<> -const float *Resample_<BSincTag,CTag>(const InterpState *state, const float *RESTRICT src, - uint frac, uint increment, const al::span<float> dst) +float *Resample_<BSincTag,CTag>(const InterpState *state, float *RESTRICT src, uint frac, + uint increment, const al::span<float> dst) { return DoResample<do_bsinc>(state, src-state->bsinc.l, frac, increment, dst); } template<> -const float *Resample_<FastBSincTag,CTag>(const InterpState *state, const float *RESTRICT src, - uint frac, uint increment, const al::span<float> dst) +float *Resample_<FastBSincTag,CTag>(const InterpState *state, float *RESTRICT src, uint frac, + uint increment, const al::span<float> dst) { return DoResample<do_fastbsinc>(state, src-state->bsinc.l, frac, increment, dst); } diff --git a/core/mixer/mixer_neon.cpp b/core/mixer/mixer_neon.cpp index 6ecb25fe..f3e5f130 100644 --- a/core/mixer/mixer_neon.cpp +++ b/core/mixer/mixer_neon.cpp @@ -24,8 +24,7 @@ namespace { inline float32x4_t set_f4(float l0, float l1, float l2, float l3) { - float32x4_t ret{}; - ret = vsetq_lane_f32(l0, ret, 0); + float32x4_t ret{vmovq_n_f32(l0)}; ret = vsetq_lane_f32(l1, ret, 1); ret = vsetq_lane_f32(l2, ret, 2); ret = vsetq_lane_f32(l3, ret, 3); @@ -40,8 +39,7 @@ inline void ApplyCoeffs(float2 *RESTRICT Values, const size_t IrSize, const Hrir { float32x4_t leftright4; { - float32x2_t leftright2 = vdup_n_f32(0.0); - leftright2 = vset_lane_f32(left, leftright2, 0); + float32x2_t leftright2{vmov_n_f32(left)}; leftright2 = vset_lane_f32(right, leftright2, 1); leftright4 = vcombine_f32(leftright2, leftright2); } @@ -61,7 +59,7 @@ inline void ApplyCoeffs(float2 *RESTRICT Values, const size_t IrSize, const Hrir } // namespace template<> -const float *Resample_<LerpTag,NEONTag>(const InterpState*, const float *RESTRICT src, uint frac, +float *Resample_<LerpTag,NEONTag>(const InterpState*, float *RESTRICT src, uint frac, uint increment, const al::span<float> dst) { const int32x4_t increment4 = vdupq_n_s32(static_cast<int>(increment*4)); @@ -70,7 +68,7 @@ const float *Resample_<LerpTag,NEONTag>(const InterpState*, const float *RESTRIC alignas(16) uint pos_[4], frac_[4]; int32x4_t pos4, frac4; - InitPosArrays(frac, increment, frac_, pos_, 4); + InitPosArrays(frac, increment, frac_, pos_); frac4 = vld1q_s32(reinterpret_cast<int*>(frac_)); pos4 = vld1q_s32(reinterpret_cast<int*>(pos_)); @@ -114,8 +112,8 @@ const float *Resample_<LerpTag,NEONTag>(const InterpState*, const float *RESTRIC } template<> -const float *Resample_<BSincTag,NEONTag>(const InterpState *state, const float *RESTRICT src, - uint frac, uint increment, const al::span<float> dst) +float *Resample_<BSincTag,NEONTag>(const InterpState *state, float *RESTRICT src, uint frac, + uint increment, const al::span<float> dst) { const float *const filter{state->bsinc.filter}; const float32x4_t sf4{vdupq_n_f32(state->bsinc.sf)}; @@ -160,8 +158,8 @@ const float *Resample_<BSincTag,NEONTag>(const InterpState *state, const float * } template<> -const float *Resample_<FastBSincTag,NEONTag>(const InterpState *state, - const float *RESTRICT src, uint frac, uint increment, const al::span<float> dst) +float *Resample_<FastBSincTag,NEONTag>(const InterpState *state, float *RESTRICT src, uint frac, + uint increment, const al::span<float> dst) { const float *const filter{state->bsinc.filter}; const size_t m{state->bsinc.m}; diff --git a/core/mixer/mixer_sse.cpp b/core/mixer/mixer_sse.cpp index 3ecac384..23caf797 100644 --- a/core/mixer/mixer_sse.cpp +++ b/core/mixer/mixer_sse.cpp @@ -77,8 +77,8 @@ inline void ApplyCoeffs(float2 *RESTRICT Values, const size_t IrSize, const Hrir } // namespace template<> -const float *Resample_<BSincTag,SSETag>(const InterpState *state, const float *RESTRICT src, - uint frac, uint increment, const al::span<float> dst) +float *Resample_<BSincTag,SSETag>(const InterpState *state, float *RESTRICT src, uint frac, + uint increment, const al::span<float> dst) { const float *const filter{state->bsinc.filter}; const __m128 sf4{_mm_set1_ps(state->bsinc.sf)}; @@ -124,8 +124,8 @@ const float *Resample_<BSincTag,SSETag>(const InterpState *state, const float *R } template<> -const float *Resample_<FastBSincTag,SSETag>(const InterpState *state, const float *RESTRICT src, - uint frac, uint increment, const al::span<float> dst) +float *Resample_<FastBSincTag,SSETag>(const InterpState *state, float *RESTRICT src, uint frac, + uint increment, const al::span<float> dst) { const float *const filter{state->bsinc.filter}; const size_t m{state->bsinc.m}; diff --git a/core/mixer/mixer_sse2.cpp b/core/mixer/mixer_sse2.cpp index a93a33f9..f91d5dcd 100644 --- a/core/mixer/mixer_sse2.cpp +++ b/core/mixer/mixer_sse2.cpp @@ -35,7 +35,7 @@ struct LerpTag; #endif template<> -const float *Resample_<LerpTag,SSE2Tag>(const InterpState*, const float *RESTRICT src, uint frac, +float *Resample_<LerpTag,SSE2Tag>(const InterpState*, float *RESTRICT src, uint frac, uint increment, const al::span<float> dst) { const __m128i increment4{_mm_set1_epi32(static_cast<int>(increment*4))}; @@ -43,7 +43,7 @@ const float *Resample_<LerpTag,SSE2Tag>(const InterpState*, const float *RESTRIC const __m128i fracMask4{_mm_set1_epi32(MixerFracMask)}; alignas(16) uint pos_[4], frac_[4]; - InitPosArrays(frac, increment, frac_, pos_, 4); + InitPosArrays(frac, increment, frac_, pos_); __m128i frac4{_mm_setr_epi32(static_cast<int>(frac_[0]), static_cast<int>(frac_[1]), static_cast<int>(frac_[2]), static_cast<int>(frac_[3]))}; __m128i pos4{_mm_setr_epi32(static_cast<int>(pos_[0]), static_cast<int>(pos_[1]), diff --git a/core/mixer/mixer_sse41.cpp b/core/mixer/mixer_sse41.cpp index f7839b78..032e5d54 100644 --- a/core/mixer/mixer_sse41.cpp +++ b/core/mixer/mixer_sse41.cpp @@ -36,7 +36,7 @@ struct LerpTag; #endif template<> -const float *Resample_<LerpTag,SSE4Tag>(const InterpState*, const float *RESTRICT src, uint frac, +float *Resample_<LerpTag,SSE4Tag>(const InterpState*, float *RESTRICT src, uint frac, uint increment, const al::span<float> dst) { const __m128i increment4{_mm_set1_epi32(static_cast<int>(increment*4))}; @@ -44,7 +44,7 @@ const float *Resample_<LerpTag,SSE4Tag>(const InterpState*, const float *RESTRIC const __m128i fracMask4{_mm_set1_epi32(MixerFracMask)}; alignas(16) uint pos_[4], frac_[4]; - InitPosArrays(frac, increment, frac_, pos_, 4); + InitPosArrays(frac, increment, frac_, pos_); __m128i frac4{_mm_setr_epi32(static_cast<int>(frac_[0]), static_cast<int>(frac_[1]), static_cast<int>(frac_[2]), static_cast<int>(frac_[3]))}; __m128i pos4{_mm_setr_epi32(static_cast<int>(pos_[0]), static_cast<int>(pos_[1]), |