audioconvert: fix s24_32 to float

s24_32 needs to be sign extended before converting to float because the
upper bits are undefined and might be anything.

Fixes #1393
This commit is contained in:
Wim Taymans 2021-07-06 12:42:39 +02:00
parent aab72ded6e
commit 3a879e8b1a
2 changed files with 13 additions and 9 deletions

View file

@ -414,7 +414,7 @@ conv_s24_32d_to_f32d_c(struct convert *conv, void * SPA_RESTRICT dst[], const vo
float *d = dst[i];
for (j = 0; j < n_samples; j++)
d[j] = S24_TO_F32(s[j]);
d[j] = S24_32_TO_F32(s[j]);
}
}
@ -428,8 +428,9 @@ conv_s24_32_to_f32_c(struct convert *conv, void * SPA_RESTRICT dst[], const void
n_samples *= n_channels;
for (i = 0; i < n_samples; i++)
d[i] = S24_TO_F32(s[i]);
for (i = 0; i < n_samples; i++) {
d[i] = S24_32_TO_F32(s[i]);
}
}
void
@ -442,7 +443,7 @@ conv_s24_32_to_f32d_c(struct convert *conv, void * SPA_RESTRICT dst[], const voi
for (j = 0; j < n_samples; j++) {
for (i = 0; i < n_channels; i++)
d[i][j] = S24_TO_F32(*s++);
d[i][j] = S24_32_TO_F32(*s++);
}
}
@ -456,7 +457,7 @@ conv_s24_32d_to_f32_c(struct convert *conv, void * SPA_RESTRICT dst[], const voi
for (j = 0; j < n_samples; j++) {
for (i = 0; i < n_channels; i++)
*d++ = S24_TO_F32(s[i][j]);
*d++ = S24_32_TO_F32(s[i][j]);
}
}
@ -782,7 +783,7 @@ conv_f32d_to_s24_32d_c(struct convert *conv, void * SPA_RESTRICT dst[], const vo
int32_t *d = dst[i];
for (j = 0; j < n_samples; j++)
d[j] = F32_TO_S24(s[j]);
d[j] = F32_TO_S24_32(s[j]);
}
}
@ -797,7 +798,7 @@ conv_f32_to_s24_32_c(struct convert *conv, void * SPA_RESTRICT dst[], const void
n_samples *= n_channels;
for (i = 0; i < n_samples; i++)
d[i] = F32_TO_S24(s[i]);
d[i] = F32_TO_S24_32(s[i]);
}
void
@ -810,7 +811,7 @@ conv_f32_to_s24_32d_c(struct convert *conv, void * SPA_RESTRICT dst[], const voi
for (j = 0; j < n_samples; j++) {
for (i = 0; i < n_channels; i++)
d[i][j] = F32_TO_S24(*s++);
d[i][j] = F32_TO_S24_32(*s++);
}
}
@ -824,7 +825,7 @@ conv_f32d_to_s24_32_c(struct convert *conv, void * SPA_RESTRICT dst[], const voi
for (j = 0; j < n_samples; j++) {
for (i = 0; i < n_channels; i++)
*d++ = F32_TO_S24(s[i][j]);
*d++ = F32_TO_S24_32(s[i][j]);
}
}

View file

@ -60,6 +60,9 @@
#define S32_TO_F32(v) S24_TO_F32((v) >> 8)
#define F32_TO_S32(v) (F32_TO_S24(v) << 8)
#define S24_32_TO_F32(v) S32_TO_F32((v)<<8)
#define F32_TO_S24_32(v) F32_TO_S24(v)
static inline int32_t read_s24(const void *src)
{
const int8_t *s = src;