ref: f064ffb0d54974009c04c0001aa1ac55e02423e3
parent: 7b31db37bb4ee734cea03d8587a24b428e6d59b8
author: Rob Sykes <robs@users.sourceforge.net>
date: Wed Mar 7 16:21:21 EST 2012
fix floating point precisions to take account of sign bit
--- a/src/formats.c
+++ b/src/formats.c
@@ -186,8 +186,8 @@
case SOX_ENCODING_LPC10: return !bits_per_sample? 16: 0;
case SOX_ENCODING_WAVPACKF:
- case SOX_ENCODING_FLOAT: return bits_per_sample == 32 ? 24: bits_per_sample == 64 ? 53: 0;
- case SOX_ENCODING_FLOAT_TEXT: return !bits_per_sample? 53: 0;
+ case SOX_ENCODING_FLOAT: return bits_per_sample == 32 ? 25: bits_per_sample == 64 ? 54: 0;
+ case SOX_ENCODING_FLOAT_TEXT: return !bits_per_sample? 54: 0;
case SOX_ENCODINGS:
case SOX_ENCODING_UNKNOWN: break;
--- a/src/sox.h
+++ b/src/sox.h
@@ -976,7 +976,8 @@
@param d Input sample to be converted.
@param clips Variable to increment if input sample is too large.
*/
-#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-128?++(clips),1:(((sox_macro_temp_sample+128)&~255)*(1./(SOX_SAMPLE_MAX+1.))))
+#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./(SOX_SAMPLE_MAX+1.))))
+#define SOX_SAMPLE_TO_FLOAT_64BIT(d,clips) ((d)*(1./(SOX_SAMPLE_MAX+1.)))
/**
Client API: