shithub: sox

Download patch

ref: 97bea98f87382d6abf885bd2e671dee845cad43b
parent: 9f65df887ce6d6b3c8b5d6595f596e4a3eac61b5
author: Guido Aulisi <guido.aulisi@gmail.com>
date: Mon Nov 26 10:38:07 EST 2012

mcompand: fix bad clipping due to overflow of band summing.

When summing bands in mcompand I got some bad unnoticed clipping,
and the samples wrapped from positive to negative and viceversa.
With many bands sox_sample_t intergers get wrapped before being cast
to double.

--- a/ChangeLog
+++ b/ChangeLog
@@ -38,6 +38,7 @@
   o Improved pink noise frequency response in synth. (robs)
   o Extended syntax for specifying audio positions to several
     effects. (Ulrich Klauer)
+  o Fix integer overflow in mcompand. [3590093] (Guido Aulisi)
 
 Other new features:
 
--- a/src/mcompand.c
+++ b/src/mcompand.c
@@ -395,7 +395,7 @@
     (void)sox_mcompand_flow_1(effp, c,l,bbuf,abuf,len, (size_t)effp->out_signal.channels);
     for (i=0;i<len;++i)
     {
-      out = obuf[i] + abuf[i];
+      out = (double)obuf[i] + (double)abuf[i];
       SOX_SAMPLE_CLIP_COUNT(out, effp->clips);
       obuf[i] = out;
     }