audioconvert: somewhat avoid precision loss in F32 to S32 conversion

At the very least, we should go through s25_32 intermediate
instead of s24_32, to avoid needlessly loosing 1 LSB precision bit.

FIXME: the noise codepath is not covered with tests.
This commit is contained in:
Roman Lebedev 2024-06-14 04:48:03 +03:00
parent 2a035ac49e
commit 175d533b56
No known key found for this signature in database
GPG key ID: 083C3EBB4A1689E0
4 changed files with 66 additions and 71 deletions

View file

@ -123,8 +123,8 @@
#define S32_MAX (S24_MAX * 256)
#define S32_TO_F32(v) ITOF(int32_t, S32_TO_S24_32(v), S24_SCALE, 0.0f)
#define S32S_TO_F32(v) S32_TO_F32(bswap_32(v))
#define F32_TO_S32(v) S24_32_TO_S32(F32_TO_S24_32(v))
#define F32_TO_S32_D(v,d) S24_32_TO_S32(F32_TO_S24_32_D(v,d))
#define F32_TO_S32_D(v,d) S25_32_TO_S32(F32_TO_S25_32_D(v,d))
#define F32_TO_S32(v) F32_TO_S32_D(v, 0.0f)
#define F32_TO_S32S(v) bswap_32(F32_TO_S32(v))
#define F32_TO_S32S_D(v,d) bswap_32(F32_TO_S32_D(v,d))