mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-19 08:57:14 -05:00
audioconvert: avoid unaligned writes and left shift of neagtives
See #3572
This commit is contained in:
parent
20b336b1d7
commit
cc109843e5
2 changed files with 12 additions and 7 deletions
|
|
@ -692,12 +692,17 @@ conv_f32d_to_s32_avx2(struct convert *conv, void * SPA_RESTRICT dst[], const voi
|
||||||
int32_t *d = dst[0];
|
int32_t *d = dst[0];
|
||||||
uint32_t i = 0, n_channels = conv->n_channels;
|
uint32_t i = 0, n_channels = conv->n_channels;
|
||||||
|
|
||||||
for(; i + 3 < n_channels; i += 4)
|
if ((n_channels & 3) == 0) {
|
||||||
conv_f32d_to_s32_4s_avx2(conv, &d[i], &src[i], n_channels, n_samples);
|
for(; i + 3 < n_channels; i += 4)
|
||||||
for(; i + 1 < n_channels; i += 2)
|
conv_f32d_to_s32_4s_avx2(conv, &d[i], &src[i], n_channels, n_samples);
|
||||||
conv_f32d_to_s32_2s_avx2(conv, &d[i], &src[i], n_channels, n_samples);
|
}
|
||||||
for(; i < n_channels; i++)
|
else if ((n_channels & 1) == 0) {
|
||||||
conv_f32d_to_s32_1s_avx2(conv, &d[i], &src[i], n_channels, n_samples);
|
for(; i + 1 < n_channels; i += 2)
|
||||||
|
conv_f32d_to_s32_2s_avx2(conv, &d[i], &src[i], n_channels, n_samples);
|
||||||
|
} else {
|
||||||
|
for(; i < n_channels; i++)
|
||||||
|
conv_f32d_to_s32_1s_avx2(conv, &d[i], &src[i], n_channels, n_samples);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ static inline uint24_t u32_to_u24(uint32_t src)
|
||||||
|
|
||||||
static inline int32_t s24_to_s32(int24_t src)
|
static inline int32_t s24_to_s32(int24_t src)
|
||||||
{
|
{
|
||||||
return ((int32_t)src.v1 << 16) | ((uint32_t)src.v2 << 8) | (uint32_t)src.v3;
|
return ((uint32_t)((int32_t)src.v1 & 0xFFFF) << 16) | ((uint32_t)src.v2 << 8) | (uint32_t)src.v3;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define S32_TO_S24(s) (int24_t) { .v1 = (int8_t)(((int32_t)s) >> 16), \
|
#define S32_TO_S24(s) (int24_t) { .v1 = (int8_t)(((int32_t)s) >> 16), \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue