audioconvert: change multiplier for int<->float conversion

Use (1 << 31) as the multiplier for int<->float conversions. This makes
sure that int->float conversions always end up with floats between
[-1.0, 1.0].
For the conversion from float to int, this multiplier will give the complete
int range after we perform clipping.
Change the unit test to take this into consideration.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=755301
This commit is contained in:
Wim Taymans 2015-11-03 11:44:54 +01:00
parent fe62e797d5
commit 9e15c89564
2 changed files with 8 additions and 8 deletions

View file

@ -4,14 +4,14 @@
.temp 8 t1
convld t1, s1
divd d1, t1, 0x41DFFFFFFFC00000L
divd d1, t1, 2147483648.0L
.function audio_convert_orc_double_to_s32
.dest 4 d1 gint32
.source 8 s1 gdouble
.temp 8 t1
muld t1, s1, 0x41DFFFFFFFC00000L
muld t1, s1, 2147483648.0L
convdl d1, t1
.function audio_convert_orc_int_bias

View file

@ -747,9 +747,9 @@ GST_START_TEST (test_float_conversion)
{
gint16 in[] = { 0, -32768, 16384, -16384 };
gdouble out[] = { 0.0,
(gdouble) (-32768L << 16) / 2147483647.0, /* ~ -1.0 */
(gdouble) (16384L << 16) / 2147483647.0, /* ~ 0.5 */
(gdouble) (-16384L << 16) / 2147483647.0, /* ~ -0.5 */
(gdouble) (-32768L << 16) / 2147483648.0, /* ~ -1.0 */
(gdouble) (16384L << 16) / 2147483648.0, /* ~ 0.5 */
(gdouble) (-16384L << 16) / 2147483648.0, /* ~ -0.5 */
};
RUN_CONVERSION ("16 signed to 64 float",
@ -759,9 +759,9 @@ GST_START_TEST (test_float_conversion)
{
gint32 in[] = { 0, (-1L << 31), (1L << 30), (-1L << 30) };
gdouble out[] = { 0.0,
(gdouble) (-1L << 31) / 2147483647.0, /* ~ -1.0 */
(gdouble) (1L << 30) / 2147483647.0, /* ~ 0.5 */
(gdouble) (-1L << 30) / 2147483647.0, /* ~ -0.5 */
(gdouble) (-1L << 31) / 2147483648.0, /* ~ -1.0 */
(gdouble) (1L << 30) / 2147483648.0, /* ~ 0.5 */
(gdouble) (-1L << 30) / 2147483648.0, /* ~ -0.5 */
};
RUN_CONVERSION ("32 signed to 64 float",