shithub: sox

Download patch

ref: 53c591f0bbcb0b91e5470b1f600137d389e60696
parent: ce8890345b99bc622658c7f3476340645a29b9ca
author: robs <robs>
date: Sat Mar 7 09:19:49 EST 2009

fix rounding

--- a/src/dcshift.c
+++ b/src/dcshift.c
@@ -124,17 +124,9 @@
                 *obuf++ = sample;
             }
     }
-    else
-    {
-        /* quite basic, with clipping */
-        for (;len>0; len--)
-        {
-                double f;
-
-                f = dcshift * SOX_SAMPLE_MAX + *ibuf++;
-                SOX_SAMPLE_CLIP_COUNT(f, dcs->clipped);
-                *obuf++ = f;
-        }
+    else for (; len > 0; --len) {            /* quite basic, with clipping */
+      double d = dcshift * (SOX_SAMPLE_MAX + 1.) + *ibuf++;
+      *obuf++ = SOX_ROUND_CLIP_COUNT(d, effp->clips);
     }
     return SOX_SUCCESS;
 }