audioconvert: avoid unaligned writes and left shift of neagtives

See #3572
This commit is contained in:
Wim Taymans 2023-10-15 21:11:54 +02:00
parent 20b336b1d7
commit cc109843e5
2 changed files with 12 additions and 7 deletions

View file

@ -43,7 +43,7 @@ static inline uint24_t u32_to_u24(uint32_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), \