From 90349b384fe538b0d160b5ff0485d6235b1c6f9d Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 25 Oct 2015 14:07:58 -0700 Subject: Use the correct position in the SSE resamplers for left-over processing --- Alc/mixer_sse.c | 4 ++++ Alc/mixer_sse2.c | 5 ++++- Alc/mixer_sse3.c | 11 +++++++---- Alc/mixer_sse41.c | 13 ++++++++----- 4 files changed, 23 insertions(+), 10 deletions(-) (limited to 'Alc') diff --git a/Alc/mixer_sse.c b/Alc/mixer_sse.c index c618f966..e67c9cca 100644 --- a/Alc/mixer_sse.c +++ b/Alc/mixer_sse.c @@ -182,6 +182,10 @@ void Mix_SSE(const ALfloat *data, ALuint OutChans, ALfloat (*restrict OutBuffer) _mm_store_ps(&OutBuffer[c][OutPos+pos], dry4); pos += 4; } while(minsize-pos > 3); + /* NOTE: gain4 now represents the next four gains after the + * last four mixed samples, so the lowest element represents + * the next gain to apply. + */ gain = _mm_cvtss_f32(gain4); } /* Mix with applying left over gain steps that aren't aligned multiples of 4. */ diff --git a/Alc/mixer_sse2.c b/Alc/mixer_sse2.c index 1787c196..a134b9a6 100644 --- a/Alc/mixer_sse2.c +++ b/Alc/mixer_sse2.c @@ -63,7 +63,10 @@ const ALfloat *Resample_lerp32_SSE2(const ALfloat *src, ALuint frac, ALuint incr _mm_store_ps(pos_.f, _mm_castsi128_ps(pos4)); } - pos = pos_.i[3]; + /* NOTE: These four elements represent the position *after* the last four + * samples, so the lowest element is the next position to resample. + */ + pos = pos_.i[0]; frac = _mm_cvtsi128_si32(frac4); for(;i < numsamples;i++) diff --git a/Alc/mixer_sse3.c b/Alc/mixer_sse3.c index acb0338a..b673315b 100644 --- a/Alc/mixer_sse3.c +++ b/Alc/mixer_sse3.c @@ -78,8 +78,11 @@ const ALfloat *Resample_fir4_32_SSE3(const ALfloat *src, ALuint frac, ALuint inc _mm_store_ps(frac_.f, _mm_castsi128_ps(frac4)); } - pos = pos_.i[3]; - frac = frac_.i[3]; + /* NOTE: These four elements represent the position *after* the last four + * samples, so the lowest element is the next position to resample. + */ + pos = pos_.i[0]; + frac = frac_.i[0]; for(;i < numsamples;i++) { @@ -143,8 +146,8 @@ const ALfloat *Resample_fir8_32_SSE3(const ALfloat *src, ALuint frac, ALuint inc _mm_store_ps(frac_.f, _mm_castsi128_ps(frac4)); } - pos = pos_.i[3]; - frac = frac_.i[3]; + pos = pos_.i[0]; + frac = frac_.i[0]; for(;i < numsamples;i++) { diff --git a/Alc/mixer_sse41.c b/Alc/mixer_sse41.c index 4b347d32..59b99b2b 100644 --- a/Alc/mixer_sse41.c +++ b/Alc/mixer_sse41.c @@ -67,7 +67,10 @@ const ALfloat *Resample_lerp32_SSE41(const ALfloat *src, ALuint frac, ALuint inc pos_.i[3] = _mm_extract_epi32(pos4, 3); } - pos = pos_.i[3]; + /* NOTE: These four elements represent the position *after* the last four + * samples, so the lowest element is the next position to resample. + */ + pos = pos_.i[0]; frac = _mm_cvtsi128_si32(frac4); for(;i < numsamples;i++) @@ -134,8 +137,8 @@ const ALfloat *Resample_fir4_32_SSE41(const ALfloat *src, ALuint frac, ALuint in frac_.i[3] = _mm_extract_epi32(frac4, 3); } - pos = pos_.i[3]; - frac = frac_.i[3]; + pos = pos_.i[0]; + frac = frac_.i[0]; for(;i < numsamples;i++) { @@ -205,8 +208,8 @@ const ALfloat *Resample_fir8_32_SSE41(const ALfloat *src, ALuint frac, ALuint in frac_.i[3] = _mm_extract_epi32(frac4, 3); } - pos = pos_.i[3]; - frac = frac_.i[3]; + pos = pos_.i[0]; + frac = frac_.i[0]; for(;i < numsamples;i++) { -- cgit v1.2.3