From c1690178ec0b020018857ed0b666ff9b16e01c21 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 13 Sep 2019 03:25:13 -0700 Subject: Make the resampler increment unsigned --- alc/mixer/mixer_sse41.cpp | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) (limited to 'alc/mixer/mixer_sse41.cpp') diff --git a/alc/mixer/mixer_sse41.cpp b/alc/mixer/mixer_sse41.cpp index 06c51e6a..0a87f76f 100644 --- a/alc/mixer/mixer_sse41.cpp +++ b/alc/mixer/mixer_sse41.cpp @@ -30,21 +30,21 @@ template<> const ALfloat *Resample_(const InterpState*, const ALfloat *RESTRICT src, - ALuint frac, ALint increment, const al::span dst) + ALuint frac, ALuint increment, const al::span dst) { - const __m128i increment4{_mm_set1_epi32(increment*4)}; + const __m128i increment4{_mm_set1_epi32(static_cast(increment*4))}; const __m128 fracOne4{_mm_set1_ps(1.0f/FRACTIONONE)}; const __m128i fracMask4{_mm_set1_epi32(FRACTIONMASK)}; - ASSUME(increment > 0); - - alignas(16) ALsizei pos_[4], frac_[4]; - InitiatePositionArrays(frac, increment, frac_, pos_, 4); - __m128i frac4{_mm_setr_epi32(frac_[0], frac_[1], frac_[2], frac_[3])}; - __m128i pos4{_mm_setr_epi32(pos_[0], pos_[1], pos_[2], pos_[3])}; + alignas(16) ALuint pos_[4], frac_[4]; + InitPosArrays(frac, increment, frac_, pos_, 4); + __m128i frac4{_mm_setr_epi32(static_cast(frac_[0]), static_cast(frac_[1]), + static_cast(frac_[2]), static_cast(frac_[3]))}; + __m128i pos4{_mm_setr_epi32(static_cast(pos_[0]), static_cast(pos_[1]), + static_cast(pos_[2]), static_cast(pos_[3]))}; auto dst_iter = dst.begin(); - const auto aligned_end = (dst.size()&~3) + dst_iter; + const auto aligned_end = (dst.size()&~3u) + dst_iter; while(dst_iter != aligned_end) { const int pos0{_mm_extract_epi32(pos4, 0)}; @@ -67,19 +67,22 @@ const ALfloat *Resample_(const InterpState*, const ALfloat *RES frac4 = _mm_and_si128(frac4, fracMask4); } - /* NOTE: These four elements represent the position *after* the last four - * samples, so the lowest element is the next position to resample. - */ - src += static_cast(_mm_cvtsi128_si32(pos4)); - frac = _mm_cvtsi128_si32(frac4); - - while(dst_iter != dst.end()) + if(dst_iter != dst.end()) { - *(dst_iter++) = lerp(src[0], src[1], frac * (1.0f/FRACTIONONE)); + /* NOTE: These four elements represent the position *after* the last + * four samples, so the lowest element is the next position to + * resample. + */ + src += static_cast(_mm_cvtsi128_si32(pos4)); + frac = static_cast(_mm_cvtsi128_si32(frac4)); + + do { + *(dst_iter++) = lerp(src[0], src[1], frac * (1.0f/FRACTIONONE)); - frac += increment; - src += frac>>FRACTIONBITS; - frac &= FRACTIONMASK; + frac += increment; + src += frac>>FRACTIONBITS; + frac &= FRACTIONMASK; + } while(dst_iter != dst.end()); } return dst.begin(); } -- cgit v1.2.3