audioconvert: avoid unaligned writes

See #3572
This commit is contained in:
Wim Taymans 2023-10-15 21:03:52 +02:00
parent 80572a6fbc
commit 20b336b1d7

View file

@ -532,12 +532,17 @@ 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;
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);
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);
}
}
/* 32 bit xorshift PRNG, see https://en.wikipedia.org/wiki/Xorshift */