]> code.delx.au - pulseaudio/commit
sconv: Change/fix conversion to/from float32
authorPeter Meerwald <p.meerwald@bct-electronic.com>
Mon, 4 Feb 2013 00:30:19 +0000 (01:30 +0100)
committerTanu Kaskinen <tanuk@iki.fi>
Mon, 4 Feb 2013 10:07:14 +0000 (12:07 +0200)
commite66e8464183e9916b248a9dedd4d6dcf3e1a38fa
treeaf6be17e578e0f7b57da722d0f9a9ba483766234
parent596d9aa740a66e84366fc42b6fd7156cde280a68
sconv: Change/fix conversion to/from float32

use (1<<15) instead of 0x7fff as a factor when converting from s16 to float32
use (1<<31) instead of 0x7fffffff as a factor when converting from s32 to float32

the change is motivated by the following desireable properties:
* s16_from_f32(f32_from_s16(x)) == x for all possible s16 values
* x / (1.0f << 15) == x * (1.0f / (1 << 15)) for all x in s16

above changes enable easier optimization while guaranteeing bit-exact results

further, other audio sample conversion code (libavresample) does it the same way

v3 (comments Tanu):
* fix saturation in pa_sconv_s16le_from_f32ne_neon(), use vqrshrn
v2 (comments Tanu):
* fix comments in ARM NEON code
* use llrintf() in pa_sconv_s32le_from_float32ne()

Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
Cc: Tanu Kaskinen <tanuk@iki.fi>
src/pulsecore/sconv-s16le.c
src/pulsecore/sconv_neon.c
src/pulsecore/sconv_sse.c