mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
audioconvert: tweak more conversion constants
Tweak some more constants to make lossless conversions work. Add some tests for lossless conversion. Add some more tests.
This commit is contained in:
parent
22317da685
commit
f62244d7a9
2 changed files with 145 additions and 8 deletions
|
|
@ -39,22 +39,22 @@
|
|||
|
||||
#define U8_MIN 0u
|
||||
#define U8_MAX 255u
|
||||
#define U8_SCALE 127.5f
|
||||
#define U8_SCALE 128.f
|
||||
#define U8_OFFS 128.f
|
||||
#define U8_TO_F32(v) ((((uint8_t)(v)) * (1.0f / U8_OFFS)) - 1.0f)
|
||||
#define F32_TO_U8(v) (uint8_t)SPA_CLAMP((v) * U8_SCALE + U8_OFFS, U8_MIN, U8_MAX)
|
||||
#define F32_TO_U8_D(v,d) (uint8_t)SPA_CLAMP((v) * U8_SCALE + U8_OFFS + (d), U8_MIN, U8_MAX)
|
||||
|
||||
#define S8_MIN -127
|
||||
#define S8_MIN -128
|
||||
#define S8_MAX 127
|
||||
#define S8_SCALE 127.0f
|
||||
#define S8_SCALE 128.0f
|
||||
#define S8_TO_F32(v) (((int8_t)(v)) * (1.0f / S8_SCALE))
|
||||
#define F32_TO_S8(v) (int8_t)SPA_CLAMP((v) * S8_SCALE, S8_MIN, S8_MAX)
|
||||
#define F32_TO_S8_D(v,d) (int8_t)SPA_CLAMP((v) * S8_SCALE + (d), S8_MIN, S8_MAX)
|
||||
|
||||
#define U16_MIN 0u
|
||||
#define U16_MAX 65535u
|
||||
#define U16_SCALE 32767.5f
|
||||
#define U16_SCALE 32768.f
|
||||
#define U16_OFFS 32768.f
|
||||
#define U16_TO_F32(v) ((((uint16_t)(v)) * (1.0f / U16_OFFS)) - 1.0f)
|
||||
#define U16S_TO_F32(v) (((uint16_t)bswap_16((uint16_t)(v)) * (1.0f / U16_OFFS)) - 1.0f)
|
||||
|
|
@ -75,7 +75,7 @@
|
|||
|
||||
#define U24_MIN 0u
|
||||
#define U24_MAX 16777215u
|
||||
#define U24_SCALE 8388607.5f
|
||||
#define U24_SCALE 8388608.f
|
||||
#define U24_OFFS 8388608.f
|
||||
#define U24_TO_F32(v) ((u24_to_u32(v) * (1.0f / U24_OFFS)) - 1.0f)
|
||||
#define F32_TO_U24(v) u32_to_u24(SPA_CLAMP((v) * U24_SCALE + U24_OFFS, U24_MIN, U24_MAX))
|
||||
|
|
@ -92,7 +92,7 @@
|
|||
|
||||
#define U32_MIN 0u
|
||||
#define U32_MAX 4294967295
|
||||
#define U32_SCALE 2147483647.5f
|
||||
#define U32_SCALE 2147483648.f
|
||||
#define U32_OFFS 2147483648.f
|
||||
#define U32_TO_F32(v) ((((uint32_t)(v)) * (1.0f / U32_OFFS)) - 1.0f)
|
||||
#define F32_TO_U32(v) (uint32_t)SPA_CLAMP((v) * U32_SCALE + U32_OFFS, U32_MIN, U32_MAX)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue