shithub: sox

Download patch

ref: d24b42abd6b43b227fbe108a0c2e67c809435c32
parent: 2f6742e2a0cae307d5f76c3a6bd003b3bc35263e
author: Ulrich Klauer <ulrich@chirlu.de>
date: Sun Mar 18 23:25:31 EDT 2012

dft_filter: use 64-bit numbers to count samples

(cherry picked from commit c276b0f734215afa7b5ce25086900552b06aad76)

Backported, as it fixes (the dft_filter part of) tracker item 3594822.

--- a/src/dft_filter.c
+++ b/src/dft_filter.c
@@ -89,7 +89,7 @@
 
   if (*isamp && odone < *osamp) {
     double * t = fifo_write(&p->input_fifo, (int)*isamp, NULL);
-    p->samples_in += (int)*isamp;
+    p->samples_in += *isamp;
 
     for (i = *isamp; i; --i)
       *t++ = SOX_SAMPLE_TO_FLOAT_64BIT(*ibuf++, effp->clips);
@@ -104,11 +104,11 @@
 {
   priv_t * p = (priv_t *)effp->priv;
   static size_t isamp = 0;
-  size_t samples_out = p->samples_in;
-  size_t remaining = samples_out - p->samples_out;
+  size_t remaining = p->samples_in > p->samples_out ?
+      (size_t)(p->samples_in - p->samples_out) : 0;
   double * buff = lsx_calloc(1024, sizeof(*buff));
 
-  if ((int)remaining > 0) {
+  if (remaining > 0) {
     while ((size_t)fifo_occupancy(&p->output_fifo) < remaining) {
       fifo_write(&p->input_fifo, 1024, buff);
       p->samples_in += 1024;
--- a/src/dft_filter.h
+++ b/src/dft_filter.h
@@ -8,7 +8,7 @@
 } dft_filter_t;
 
 typedef struct {
-  size_t     samples_in, samples_out;
+  uint64_t   samples_in, samples_out;
   fifo_t     input_fifo, output_fifo;
   dft_filter_t   filter, * filter_ptr;
 } dft_filter_priv_t;