shithub: sox

Download patch

ref: 1bd16615aff22ee3b4308dc141023b12d9503002
parent: 8571a527440a5ae5fef0cc5ac49cb129a9d82d4b
author: Ulrich Klauer <ulrich@chirlu.de>
date: Mon Jan 2 03:44:57 EST 2012

vol/dcshift effects: use 64-bit limiting/clipping counters

Use 64-bit numbers for counting limited and total samples in vol and
dcshift. For dcshift, use the general clipping counter (already uint64_t)
instead of a proprietary one.

--- a/src/dcshift.c
+++ b/src/dcshift.c
@@ -17,9 +17,8 @@
     int uselimiter; /* boolean: are we using the limiter? */
     double limiterthreshhold;
     double limitergain; /* limiter gain. */
-    int limited; /* number of limited values to report. */
-    int totalprocessed;
-    int clipped;    /* number of clipped values to report. */
+    uint64_t limited; /* number of limited values to report. */
+    uint64_t totalprocessed;
 } priv_t;
 
 /*
@@ -66,7 +65,6 @@
     if (dcs->dcshift == 0)
       return SOX_EFF_NULL;
 
-    dcs->clipped = 0;
     dcs->limited = 0;
     dcs->totalprocessed = 0;
 
@@ -120,7 +118,7 @@
                         sample = dcshift * SOX_SAMPLE_MAX + sample;
                 }
 
-                SOX_SAMPLE_CLIP_COUNT(sample, dcs->clipped);
+                SOX_SAMPLE_CLIP_COUNT(sample, effp->clips);
                 *obuf++ = sample;
             }
     }
@@ -141,21 +139,8 @@
 
     if (dcs->limited)
     {
-        lsx_warn("DCSHIFT limited %d values (%d percent).",
+        lsx_warn("DCSHIFT limited %" PRIu64 " values (%d percent).",
              dcs->limited, (int) (dcs->limited * 100.0 / dcs->totalprocessed));
-    }
-    if (dcs->clipped)
-    {
-        if (dcs->dcshift > 0)
-        {
-             lsx_warn("DCSHIFT clipped %d values, dcshift=%f too high...",
-                  dcs->clipped, dcs->dcshift);
-        }
-        else
-        {
-             lsx_warn("DCSHIFT clipped %d values, dcshift=%f too low...",
-                  dcs->clipped, dcs->dcshift);
-        }
     }
     return SOX_SUCCESS;
 }
--- a/src/vol.c
+++ b/src/vol.c
@@ -20,8 +20,8 @@
   sox_bool  uselimiter;
   double    limiterthreshhold;
   double    limitergain;
-  int       limited; /* number of limited values to report. */
-  int       totalprocessed;
+  uint64_t  limited; /* number of limited values to report. */
+  uint64_t  totalprocessed;
 } priv_t;
 
 enum {vol_amplitude, vol_dB, vol_power};
@@ -169,7 +169,7 @@
 {
   priv_t * vol = (priv_t *) effp->priv;
   if (vol->limited) {
-    lsx_warn("limited %d values (%d percent).",
+    lsx_warn("limited %" PRIu64 " values (%d percent).",
          vol->limited, (int) (vol->limited * 100.0 / vol->totalprocessed));
   }
   return SOX_SUCCESS;