diff options
author | Chris Robinson <[email protected]> | 2019-08-31 15:49:34 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-08-31 15:49:34 -0700 |
commit | 3973334a64f0aa428c9cbd06c89cfb60951810c8 (patch) | |
tree | 654595d4e772011a218e3405c81a8fe15d070f1b /alc/mixer | |
parent | a546343148ad87786b1a199e9ca91ffc50da4e81 (diff) |
Store the voice fraction offset as unsigned
Diffstat (limited to 'alc/mixer')
-rw-r--r-- | alc/mixer/defs.h | 2 | ||||
-rw-r--r-- | alc/mixer/mixer_c.cpp | 27 | ||||
-rw-r--r-- | alc/mixer/mixer_neon.cpp | 36 | ||||
-rw-r--r-- | alc/mixer/mixer_sse.cpp | 9 | ||||
-rw-r--r-- | alc/mixer/mixer_sse2.cpp | 9 | ||||
-rw-r--r-- | alc/mixer/mixer_sse41.cpp | 9 |
6 files changed, 43 insertions, 49 deletions
diff --git a/alc/mixer/defs.h b/alc/mixer/defs.h index bb5ca56e..4aa3c6b6 100644 --- a/alc/mixer/defs.h +++ b/alc/mixer/defs.h @@ -27,7 +27,7 @@ enum ResampleType { }; template<ResampleType TypeTag, InstSetType InstTag> -const ALfloat *Resample_(const InterpState *state, const ALfloat *RESTRICT src, ALsizei frac, +const ALfloat *Resample_(const InterpState *state, const ALfloat *RESTRICT src, ALuint frac, ALint increment, const al::span<float> dst); template<InstSetType InstTag> diff --git a/alc/mixer/mixer_c.cpp b/alc/mixer/mixer_c.cpp index dbdbf16d..7a79d1e2 100644 --- a/alc/mixer/mixer_c.cpp +++ b/alc/mixer/mixer_c.cpp @@ -13,23 +13,23 @@ namespace { -inline ALfloat do_point(const InterpState&, const ALfloat *RESTRICT vals, const ALsizei) +inline ALfloat do_point(const InterpState&, const ALfloat *RESTRICT vals, const ALuint) { return vals[0]; } -inline ALfloat do_lerp(const InterpState&, const ALfloat *RESTRICT vals, const ALsizei frac) +inline ALfloat do_lerp(const InterpState&, const ALfloat *RESTRICT vals, const ALuint frac) { return lerp(vals[0], vals[1], frac * (1.0f/FRACTIONONE)); } -inline ALfloat do_cubic(const InterpState&, const ALfloat *RESTRICT vals, const ALsizei frac) +inline ALfloat do_cubic(const InterpState&, const ALfloat *RESTRICT vals, const ALuint frac) { return cubic(vals[0], vals[1], vals[2], vals[3], frac * (1.0f/FRACTIONONE)); } -inline ALfloat do_bsinc(const InterpState &istate, const ALfloat *RESTRICT vals, const ALsizei frac) +inline ALfloat do_bsinc(const InterpState &istate, const ALfloat *RESTRICT vals, const ALuint frac) { ASSUME(istate.bsinc.m > 0); // Calculate the phase index and factor. #define FRAC_PHASE_BITDIFF (FRACTIONBITS-BSINC_PHASE_BITS) - const ALsizei pi{frac >> FRAC_PHASE_BITDIFF}; + const ALuint pi{frac >> FRAC_PHASE_BITDIFF}; const ALfloat pf{(frac & ((1<<FRAC_PHASE_BITDIFF)-1)) * (1.0f/(1<<FRAC_PHASE_BITDIFF))}; #undef FRAC_PHASE_BITDIFF - const ALfloat *fil{istate.bsinc.filter + istate.bsinc.m*pi*4}; + const ALfloat *fil{istate.bsinc.filter + ptrdiff_t{istate.bsinc.m}*pi*4}; const ALfloat *scd{fil + istate.bsinc.m}; const ALfloat *phd{scd + istate.bsinc.m}; const ALfloat *spd{phd + istate.bsinc.m}; @@ -41,13 +41,12 @@ inline ALfloat do_bsinc(const InterpState &istate, const ALfloat *RESTRICT vals, return r; } -using SamplerT = ALfloat(const InterpState&, const ALfloat*RESTRICT, const ALsizei); +using SamplerT = ALfloat(const InterpState&, const ALfloat*RESTRICT, const ALuint); template<SamplerT &Sampler> const ALfloat *DoResample(const InterpState *state, const ALfloat *RESTRICT src, - ALsizei frac, ALint increment, const al::span<float> dst) + ALuint frac, ALint increment, const al::span<float> dst) { ASSUME(increment > 0); - ASSUME(frac >= 0); const InterpState istate{*state}; auto proc_sample = [&src,&frac,istate,increment]() -> ALfloat @@ -68,7 +67,7 @@ const ALfloat *DoResample(const InterpState *state, const ALfloat *RESTRICT src, } // namespace template<> -const ALfloat *Resample_<CopyTag,CTag>(const InterpState*, const ALfloat *RESTRICT src, ALsizei, +const ALfloat *Resample_<CopyTag,CTag>(const InterpState*, const ALfloat *RESTRICT src, ALuint, ALint, const al::span<float> dst) { #if defined(HAVE_SSE) || defined(HAVE_NEON) @@ -82,22 +81,22 @@ const ALfloat *Resample_<CopyTag,CTag>(const InterpState*, const ALfloat *RESTRI template<> const ALfloat *Resample_<PointTag,CTag>(const InterpState *state, const ALfloat *RESTRICT src, - ALsizei frac, ALint increment, const al::span<float> dst) + ALuint frac, ALint increment, const al::span<float> dst) { return DoResample<do_point>(state, src, frac, increment, dst); } template<> const ALfloat *Resample_<LerpTag,CTag>(const InterpState *state, const ALfloat *RESTRICT src, - ALsizei frac, ALint increment, const al::span<float> dst) + ALuint frac, ALint increment, const al::span<float> dst) { return DoResample<do_lerp>(state, src, frac, increment, dst); } template<> const ALfloat *Resample_<CubicTag,CTag>(const InterpState *state, const ALfloat *RESTRICT src, - ALsizei frac, ALint increment, const al::span<float> dst) + ALuint frac, ALint increment, const al::span<float> dst) { return DoResample<do_cubic>(state, src-1, frac, increment, dst); } template<> const ALfloat *Resample_<BSincTag,CTag>(const InterpState *state, const ALfloat *RESTRICT src, - ALsizei frac, ALint increment, const al::span<float> dst) + ALuint frac, ALint increment, const al::span<float> dst) { return DoResample<do_bsinc>(state, src-state->bsinc.l, frac, increment, dst); } diff --git a/alc/mixer/mixer_neon.cpp b/alc/mixer/mixer_neon.cpp index 472eae1b..d3e89aec 100644 --- a/alc/mixer/mixer_neon.cpp +++ b/alc/mixer/mixer_neon.cpp @@ -16,7 +16,7 @@ template<> const ALfloat *Resample_<LerpTag,NEONTag>(const InterpState*, const ALfloat *RESTRICT src, - ALsizei frac, ALint increment, const al::span<float> dst) + ALuint frac, ALint increment, const al::span<float> dst) { const int32x4_t increment4 = vdupq_n_s32(increment*4); const float32x4_t fracOne4 = vdupq_n_f32(1.0f/FRACTIONONE); @@ -24,7 +24,6 @@ const ALfloat *Resample_<LerpTag,NEONTag>(const InterpState*, const ALfloat *RES alignas(16) ALsizei pos_[4], frac_[4]; int32x4_t pos4, frac4; - ASSUME(frac >= 0); ASSUME(increment > 0); InitiatePositionArrays(frac, increment, frac_, pos_, 4); @@ -35,17 +34,17 @@ const ALfloat *Resample_<LerpTag,NEONTag>(const InterpState*, const ALfloat *RES const auto aligned_end = (dst.size()&~3) + dst_iter; while(dst_iter != aligned_end) { - const int pos0 = vgetq_lane_s32(pos4, 0); - const int pos1 = vgetq_lane_s32(pos4, 1); - const int pos2 = vgetq_lane_s32(pos4, 2); - const int pos3 = vgetq_lane_s32(pos4, 3); - const float32x4_t val1 = (float32x4_t){src[pos0], src[pos1], src[pos2], src[pos3]}; - const float32x4_t val2 = (float32x4_t){src[pos0+1], src[pos1+1], src[pos2+1], src[pos3+1]}; + const int pos0{vgetq_lane_s32(pos4, 0)}; + const int pos1{vgetq_lane_s32(pos4, 1)}; + const int pos2{vgetq_lane_s32(pos4, 2)}; + const int pos3{vgetq_lane_s32(pos4, 3)}; + const float32x4_t val1{src[pos0], src[pos1], src[pos2], src[pos3]}; + const float32x4_t val2{src[pos0+1], src[pos1+1], src[pos2+1], src[pos3+1]}; /* val1 + (val2-val1)*mu */ - const float32x4_t r0 = vsubq_f32(val2, val1); - const float32x4_t mu = vmulq_f32(vcvtq_f32_s32(frac4), fracOne4); - const float32x4_t out = vmlaq_f32(val1, mu, r0); + const float32x4_t r0{vsubq_f32(val2, val1)}; + const float32x4_t mu{vmulq_f32(vcvtq_f32_s32(frac4), fracOne4)}; + const float32x4_t out{vmlaq_f32(val1, mu, r0)}; vst1q_f32(dst_iter, out); dst_iter += 4; @@ -58,15 +57,15 @@ const ALfloat *Resample_<LerpTag,NEONTag>(const InterpState*, const ALfloat *RES /* NOTE: These four elements represent the position *after* the last four * samples, so the lowest element is the next position to resample. */ - ALsizei pos{vgetq_lane_s32(pos4, 0)}; + src += static_cast<ALuint>(vgetq_lane_s32(pos4, 0)); frac = vgetq_lane_s32(frac4, 0); while(dst_iter != dst.end()) { - *(dst_iter++) = lerp(src[pos], src[pos+1], frac * (1.0f/FRACTIONONE)); + *(dst_iter++) = lerp(src[0], src[1], frac * (1.0f/FRACTIONONE)); frac += increment; - pos += frac>>FRACTIONBITS; + src += frac>>FRACTIONBITS; frac &= FRACTIONMASK; } return dst.begin(); @@ -74,22 +73,21 @@ const ALfloat *Resample_<LerpTag,NEONTag>(const InterpState*, const ALfloat *RES template<> const ALfloat *Resample_<BSincTag,NEONTag>(const InterpState *state, const ALfloat *RESTRICT src, - ALsizei frac, ALint increment, const al::span<float> dst) + ALuint frac, ALint increment, const al::span<float> dst) { const ALfloat *const filter{state->bsinc.filter}; const float32x4_t sf4{vdupq_n_f32(state->bsinc.sf)}; - const ALsizei m{state->bsinc.m}; + const ptrdiff_t m{state->bsinc.m}; ASSUME(m > 0); ASSUME(increment > 0); - ASSUME(frac >= 0); src -= state->bsinc.l; for(float &out_sample : dst) { // Calculate the phase index and factor. #define FRAC_PHASE_BITDIFF (FRACTIONBITS-BSINC_PHASE_BITS) - const ALsizei pi{frac >> FRAC_PHASE_BITDIFF}; + const ALuint pi{frac >> FRAC_PHASE_BITDIFF}; const ALfloat pf{(frac & ((1<<FRAC_PHASE_BITDIFF)-1)) * (1.0f/(1<<FRAC_PHASE_BITDIFF))}; #undef FRAC_PHASE_BITDIFF @@ -101,7 +99,7 @@ const ALfloat *Resample_<BSincTag,NEONTag>(const InterpState *state, const ALflo const float *scd{fil + m}; const float *phd{scd + m}; const float *spd{phd + m}; - ALsizei td{m >> 2}; + ptrdiff_t td{m >> 2}; size_t j{0u}; do { diff --git a/alc/mixer/mixer_sse.cpp b/alc/mixer/mixer_sse.cpp index 8d2abc88..05ebe26f 100644 --- a/alc/mixer/mixer_sse.cpp +++ b/alc/mixer/mixer_sse.cpp @@ -15,22 +15,21 @@ template<> const ALfloat *Resample_<BSincTag,SSETag>(const InterpState *state, const ALfloat *RESTRICT src, - ALsizei frac, ALint increment, const al::span<float> dst) + ALuint frac, ALint increment, const al::span<float> dst) { const ALfloat *const filter{state->bsinc.filter}; const __m128 sf4{_mm_set1_ps(state->bsinc.sf)}; - const ALsizei m{state->bsinc.m}; + const ptrdiff_t m{state->bsinc.m}; ASSUME(m > 0); ASSUME(increment > 0); - ASSUME(frac >= 0); src -= state->bsinc.l; for(float &out_sample : dst) { // Calculate the phase index and factor. #define FRAC_PHASE_BITDIFF (FRACTIONBITS-BSINC_PHASE_BITS) - const ALsizei pi{frac >> FRAC_PHASE_BITDIFF}; + const ALuint pi{frac >> FRAC_PHASE_BITDIFF}; const ALfloat pf{(frac & ((1<<FRAC_PHASE_BITDIFF)-1)) * (1.0f/(1<<FRAC_PHASE_BITDIFF))}; #undef FRAC_PHASE_BITDIFF @@ -42,7 +41,7 @@ const ALfloat *Resample_<BSincTag,SSETag>(const InterpState *state, const ALfloa const float *scd{fil + m}; const float *phd{scd + m}; const float *spd{phd + m}; - ALsizei td{m >> 2}; + ptrdiff_t td{m >> 2}; size_t j{0u}; #define MLA4(x, y, z) _mm_add_ps(x, _mm_mul_ps(y, z)) diff --git a/alc/mixer/mixer_sse2.cpp b/alc/mixer/mixer_sse2.cpp index e3443f4e..b126cd25 100644 --- a/alc/mixer/mixer_sse2.cpp +++ b/alc/mixer/mixer_sse2.cpp @@ -29,13 +29,12 @@ template<> const ALfloat *Resample_<LerpTag,SSE2Tag>(const InterpState*, const ALfloat *RESTRICT src, - ALsizei frac, ALint increment, const al::span<float> dst) + ALuint frac, ALint increment, const al::span<float> dst) { const __m128i increment4{_mm_set1_epi32(increment*4)}; const __m128 fracOne4{_mm_set1_ps(1.0f/FRACTIONONE)}; const __m128i fracMask4{_mm_set1_epi32(FRACTIONMASK)}; - ASSUME(frac >= 0); ASSUME(increment > 0); alignas(16) ALsizei pos_[4], frac_[4]; @@ -70,15 +69,15 @@ const ALfloat *Resample_<LerpTag,SSE2Tag>(const InterpState*, const ALfloat *RES /* NOTE: These four elements represent the position *after* the last four * samples, so the lowest element is the next position to resample. */ - ALsizei pos{_mm_cvtsi128_si32(pos4)}; + src += static_cast<ALuint>(_mm_cvtsi128_si32(pos4)); frac = _mm_cvtsi128_si32(frac4); while(dst_iter != dst.end()) { - *(dst_iter++) = lerp(src[pos], src[pos+1], frac * (1.0f/FRACTIONONE)); + *(dst_iter++) = lerp(src[0], src[1], frac * (1.0f/FRACTIONONE)); frac += increment; - pos += frac>>FRACTIONBITS; + src += frac>>FRACTIONBITS; frac &= FRACTIONMASK; } return dst.begin(); diff --git a/alc/mixer/mixer_sse41.cpp b/alc/mixer/mixer_sse41.cpp index 424b9b5f..06c51e6a 100644 --- a/alc/mixer/mixer_sse41.cpp +++ b/alc/mixer/mixer_sse41.cpp @@ -30,13 +30,12 @@ template<> const ALfloat *Resample_<LerpTag,SSE4Tag>(const InterpState*, const ALfloat *RESTRICT src, - ALsizei frac, ALint increment, const al::span<float> dst) + ALuint frac, ALint increment, const al::span<float> dst) { const __m128i increment4{_mm_set1_epi32(increment*4)}; const __m128 fracOne4{_mm_set1_ps(1.0f/FRACTIONONE)}; const __m128i fracMask4{_mm_set1_epi32(FRACTIONMASK)}; - ASSUME(frac >= 0); ASSUME(increment > 0); alignas(16) ALsizei pos_[4], frac_[4]; @@ -71,15 +70,15 @@ const ALfloat *Resample_<LerpTag,SSE4Tag>(const InterpState*, const ALfloat *RES /* NOTE: These four elements represent the position *after* the last four * samples, so the lowest element is the next position to resample. */ - ALsizei pos{_mm_cvtsi128_si32(pos4)}; + src += static_cast<ALuint>(_mm_cvtsi128_si32(pos4)); frac = _mm_cvtsi128_si32(frac4); while(dst_iter != dst.end()) { - *(dst_iter++) = lerp(src[pos], src[pos+1], frac * (1.0f/FRACTIONONE)); + *(dst_iter++) = lerp(src[0], src[1], frac * (1.0f/FRACTIONONE)); frac += increment; - pos += frac>>FRACTIONBITS; + src += frac>>FRACTIONBITS; frac &= FRACTIONMASK; } return dst.begin(); |