shithub: sox

Download patch

ref: a21ca54128f8579863009f04b536c3da3ad75e31
parent: f0574854aff841d3be65f82bf74eb46272cd8588
author: Mans Rullgard <mans@mansr.com>
date: Mon Aug 3 18:08:21 EDT 2020

drop rounding in SOX_SAMPLE_TO_FLOAT_32BIT [bug #317]

The rounding of values to 24-bit integer precision serves no useful
purpose.  Drop it, allowing conversion of as many values as possible
without loss of precision.

--- a/src/sox.h
+++ b/src/sox.h
@@ -1009,14 +1009,9 @@
 Client API:
 Converts SoX native sample to a 32-bit float.
 @param d Input sample to be converted.
-@param clips Variable to increment if input sample is too large.
+@param clips The parameter is not used.
 */
-#define SOX_SAMPLE_TO_FLOAT_32BIT(d,clips) (                            \
-  LSX_USE_VAR(sox_macro_temp_double),                                   \
-  sox_macro_temp_sample = (d),                                          \
-  sox_macro_temp_sample > SOX_SAMPLE_MAX - 64 ?                         \
-    ++(clips), 1 :                                                      \
-    (((sox_macro_temp_sample + 64) & ~127) * (1.0 / (SOX_SAMPLE_MAX + 1.0))))
+#define SOX_SAMPLE_TO_FLOAT_32BIT(d,clips) ((d)*(1.0 / (SOX_SAMPLE_MAX + 1.0)))
 
 /**
 Client API: