From 7ecea07a6385ff5e3971032281717891b0f5371d Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 16 Oct 2023 12:59:41 +0200 Subject: [PATCH] audioconvert: use alternative store to avoid ASAN errors See #3572 --- spa/plugins/audioconvert/fmt-ops-sse2.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/spa/plugins/audioconvert/fmt-ops-sse2.c b/spa/plugins/audioconvert/fmt-ops-sse2.c index 7e3677340..d5f191cd0 100644 --- a/spa/plugins/audioconvert/fmt-ops-sse2.c +++ b/spa/plugins/audioconvert/fmt-ops-sse2.c @@ -448,10 +448,10 @@ conv_f32d_to_s32_2s_sse2(void *data, void * SPA_RESTRICT dst, const void * SPA_R t[0] = _mm_unpacklo_epi32(out[0], out[1]); t[1] = _mm_unpackhi_epi32(out[0], out[1]); - _mm_storel_pd((double*)(d + 0*n_channels), (__m128d)t[0]); - _mm_storeh_pd((double*)(d + 1*n_channels), (__m128d)t[0]); - _mm_storel_pd((double*)(d + 2*n_channels), (__m128d)t[1]); - _mm_storeh_pd((double*)(d + 3*n_channels), (__m128d)t[1]); + _mm_storel_pi((__m64*)(d + 0*n_channels), (__m128)t[0]); + _mm_storeh_pi((__m64*)(d + 1*n_channels), (__m128)t[0]); + _mm_storel_pi((__m64*)(d + 2*n_channels), (__m128)t[1]); + _mm_storeh_pi((__m64*)(d + 3*n_channels), (__m128)t[1]); d += 4*n_channels; } for(; n < n_samples; n++) { @@ -544,17 +544,12 @@ conv_f32d_to_s32_sse2(struct convert *conv, void * SPA_RESTRICT dst[], const voi int32_t *d = dst[0]; uint32_t i = 0, n_channels = conv->n_channels; - if ((n_channels & 0x3) == 0) { - for(; i + 3 < n_channels; i += 4) - conv_f32d_to_s32_4s_sse2(conv, &d[i], &src[i], n_channels, n_samples); - } - else if ((n_channels & 0x1) == 0) { - for(; i + 1 < n_channels; i += 2) - conv_f32d_to_s32_2s_sse2(conv, &d[i], &src[i], n_channels, n_samples); - } else { - for(; i < n_channels; i++) - conv_f32d_to_s32_1s_sse2(conv, &d[i], &src[i], n_channels, n_samples); - } + for(; i + 3 < n_channels; i += 4) + conv_f32d_to_s32_4s_sse2(conv, &d[i], &src[i], n_channels, n_samples); + for(; i + 1 < n_channels; i += 2) + conv_f32d_to_s32_2s_sse2(conv, &d[i], &src[i], n_channels, n_samples); + for(; i < n_channels; i++) + conv_f32d_to_s32_1s_sse2(conv, &d[i], &src[i], n_channels, n_samples); } /* 32 bit xorshift PRNG, see https://en.wikipedia.org/wiki/Xorshift */