[prev in list] [next in list] [prev in thread] [next in thread]
List: sox-commits
Subject: [SoX-commits] [git] 22af69d50f dither: remove -t/-r options and scale parameter
From: "Ulrich Klauer" <uklauer () users ! sourceforge ! net>
Date: 2012-03-19 10:24:35
Message-ID: E1S9ZlX-0000mp-VB () sfs-ml-3 ! v29 ! ch3 ! sourceforge ! com
[Download RAW message or body]
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "sox".
The branch, master has been updated
via 22af69d50f0ecd7fd19acdea3df9292bf720eb4c (commit)
via 4a7da1a2ffeb475912e7c3d94812af27dd421468 (commit)
via b1720d247188415baf55bdc0f9b9d295a739ad6c (commit)
via c276b0f734215afa7b5ce25086900552b06aad76 (commit)
from e2abf7923a3bda6aee470b57f5bf6ed19e2f4357 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 22af69d50f0ecd7fd19acdea3df9292bf720eb4c
Author: Ulrich Klauer <ulrich@chirlu.de>
Date: Mon Mar 19 11:16:45 2012 +0100
dither: remove -t/-r options and scale parameter
Remove unused -t and -r options to dither, as well as the dither scale
parameter. The related functionality had already been removed in
version 14.3.0.
diff --git a/src/dither.c b/src/dither.c
index cd5ecf4..3e884ee 100644
--- a/src/dither.c
+++ b/src/dither.c
@@ -335,12 +335,11 @@ static int getopts(sox_effect_t * effp, int argc, char * * \
argv) priv_t * p = (priv_t *)effp->priv;
int c;
lsx_getopt_t optstate;
- lsx_getopt_init(argc, argv, "+aSsf:p:rt", NULL, lsx_getopt_flag_none, 1, \
&optstate); + lsx_getopt_init(argc, argv, "+aSsf:p:", NULL, lsx_getopt_flag_none, 1, \
&optstate);
while ((c = lsx_getopt(&optstate)) != -1) switch (c) {
case 'a': p->auto_detect = sox_true; break;
case 'S': p->alt_tpdf = sox_true; break;
- case 'r': case 't': break; /* No longer in use */
case 's': p->filter_name = Shape_shibata; break;
case 'f':
p->filter_name = lsx_enum_option(c, optstate.arg, filter_names);
@@ -351,7 +350,6 @@ static int getopts(sox_effect_t * effp, int argc, char * * argv)
default: lsx_fail("invalid option `-%c'", optstate.opt); return lsx_usage(effp);
}
argc -= optstate.ind, argv += optstate.ind;
- do {NUMERIC_PARAMETER(dummy, 0.5, 1)} while (0); /* No longer in use */
return argc? lsx_usage(effp) : SOX_SUCCESS;
}
commit 4a7da1a2ffeb475912e7c3d94812af27dd421468
Author: Ulrich Klauer <ulrich@chirlu.de>
Date: Mon Mar 19 10:59:29 2012 +0100
dither: separate -a code from main logic
Make the code layout of "dither" cleaner by separating the automatic
start/stop code (-a option) from the main logic. No functional changes.
diff --git a/src/dither.c b/src/dither.c
index 3175736..cd5ecf4 100644
--- a/src/dither.c
+++ b/src/dither.c
@@ -262,7 +262,7 @@ typedef struct {
int32_t history, ranqd1, r;
double const * coefs;
sox_bool dither_off;
- int (*flow)(sox_effect_t *, const sox_sample_t *, sox_sample_t *, size_t \
*, size_t *); + sox_effect_handler_flow flow;
} priv_t;
#define CONVOLVE _ _ _ _
@@ -299,7 +299,19 @@ static int flow_no_shape(sox_effect_t * effp, const sox_sample_t \
* ibuf, size_t len = *isamp = *osamp = min(*isamp, *osamp);
while (len--) {
- if (!p->auto_detect || (p->history = ((p->history << 1) + !!(*ibuf & \
(((unsigned)-1) >> p->prec))))) { + if (p->auto_detect) {
+ p->history = (p->history << 1) +
+ !!(*ibuf & (((unsigned)-1) >> p->prec));
+ if (p->history && p->dither_off) {
+ p->dither_off = sox_false;
+ lsx_debug("flow %" PRIuPTR ": on @ %" PRIu64, effp->flow, p->num_output);
+ } else if (!p->history && !p->dither_off) {
+ p->dither_off = sox_true;
+ lsx_debug("flow %" PRIuPTR ": off @ %" PRIu64, effp->flow, p->num_output);
+ }
+ }
+
+ if (!p->dither_off) {
int32_t r = RANQD1 >> p->prec;
double d = ((double)*ibuf++ + r + (p->alt_tpdf? -p->r : (RANQD1 >> p->prec))) \
/ (1 << (32 - p->prec)); int i = d < 0? d - .5 : d + .5;
@@ -310,16 +322,9 @@ static int flow_no_shape(sox_effect_t * effp, const sox_sample_t \
* ibuf, ++effp->clips, *obuf = SOX_INT_MAX(p->prec) << (32 - p->prec);
else *obuf = i << (32 - p->prec);
++obuf;
- if (p->dither_off)
- lsx_debug("flow %" PRIuPTR ": on @ %" PRIu64, effp->flow, p->num_output);
- p->dither_off = sox_false;
}
- else {
+ else
*obuf++ = *ibuf++;
- if (!p->dither_off)
- lsx_debug("flow %" PRIuPTR ": off @ %" PRIu64, effp->flow, p->num_output);
- p->dither_off = sox_true;
- }
++p->num_output;
}
return SOX_SUCCESS;
diff --git a/src/dither.h b/src/dither.h
index 4654eb0..c34b6c3 100644
--- a/src/dither.h
+++ b/src/dither.h
@@ -11,7 +11,21 @@ static int NAME(sox_effect_t * effp, const sox_sample_t * ibuf,
size_t len = *isamp = *osamp = min(*isamp, *osamp);
while (len--) {
- if (!p->auto_detect || (p->history = ((p->history << 1) + !!(*ibuf & \
(((unsigned)-1) >> p->prec))))) { + if (p->auto_detect) {
+ p->history = (p->history << 1) +
+ !!(*ibuf & (((unsigned)-1) >> p->prec));
+ if (p->history && p->dither_off) {
+ p->dither_off = sox_false;
+ lsx_debug("flow %" PRIuPTR ": on @ %" PRIu64, effp->flow, p->num_output);
+ } else if (!p->history && !p->dither_off) {
+ p->dither_off = sox_true;
+ memset(p->previous_errors, 0, sizeof(p->previous_errors));
+ memset(p->previous_outputs, 0, sizeof(p->previous_outputs));
+ lsx_debug("flow %" PRIuPTR ": off @ %" PRIu64, effp->flow, p->num_output);
+ }
+ }
+
+ if (!p->dither_off) {
int32_t r1 = RANQD1 >> p->prec, r2 = RANQD1 >> p->prec; /* Defer add! */
#ifdef IIR
double d1, d, output = 0;
@@ -36,20 +50,9 @@ static int NAME(sox_effect_t * effp, const sox_sample_t * ibuf,
++effp->clips, *obuf = SOX_INT_MAX(p->prec) << (32 - p->prec);
else *obuf = i << (32 - p->prec);
++obuf;
-
- if (p->dither_off)
- lsx_debug("flow %" PRIuPTR ": on @ %" PRIu64, effp->flow, p->num_output);
- p->dither_off = sox_false;
}
- else {
+ else
*obuf++ = *ibuf++;
- if (!p->dither_off) {
- lsx_debug("flow %" PRIuPTR ": off @ %" PRIu64, effp->flow, p->num_output);
- memset(p->previous_errors, 0, sizeof(p->previous_errors));
- memset(p->previous_outputs, 0, sizeof(p->previous_outputs));
- }
- p->dither_off = sox_true;
- }
++p->num_output;
}
return SOX_SUCCESS;
commit b1720d247188415baf55bdc0f9b9d295a739ad6c
Author: Ulrich Klauer <ulrich@chirlu.de>
Date: Mon Mar 19 03:44:12 2012 +0100
dither: use 64-bit numbers to count samples
diff --git a/src/dither.c b/src/dither.c
index b66a3a1..3175736 100644
--- a/src/dither.c
+++ b/src/dither.c
@@ -257,7 +257,8 @@ typedef struct {
double previous_errors[MAX_N * 2];
double previous_outputs[MAX_N * 2];
- size_t pos, prec, num_output;
+ size_t pos, prec;
+ uint64_t num_output;
int32_t history, ranqd1, r;
double const * coefs;
sox_bool dither_off;
@@ -310,13 +311,13 @@ static int flow_no_shape(sox_effect_t * effp, const \
sox_sample_t * ibuf, else *obuf = i << (32 - p->prec);
++obuf;
if (p->dither_off)
- lsx_debug("flow %u: on @ %u", (unsigned)effp->flow, \
(unsigned)p->num_output); + lsx_debug("flow %" PRIuPTR ": on @ %" PRIu64, \
effp->flow, p->num_output); p->dither_off = sox_false;
}
else {
*obuf++ = *ibuf++;
if (!p->dither_off)
- lsx_debug("flow %u: off @ %u", (unsigned)effp->flow, \
(unsigned)p->num_output); + lsx_debug("flow %" PRIuPTR ": off @ %" PRIu64, \
effp->flow, p->num_output); p->dither_off = sox_true;
}
++p->num_output;
diff --git a/src/dither.h b/src/dither.h
index 979c506..4654eb0 100644
--- a/src/dither.h
+++ b/src/dither.h
@@ -38,13 +38,13 @@ static int NAME(sox_effect_t * effp, const sox_sample_t * ibuf,
++obuf;
if (p->dither_off)
- lsx_debug("flow %u: on @ %u", (unsigned)effp->flow, \
(unsigned)p->num_output); + lsx_debug("flow %" PRIuPTR ": on @ %" PRIu64, \
effp->flow, p->num_output); p->dither_off = sox_false;
}
else {
*obuf++ = *ibuf++;
if (!p->dither_off) {
- lsx_debug("flow %u: off @ %u", (unsigned)effp->flow, \
(unsigned)p->num_output); + lsx_debug("flow %" PRIuPTR ": off @ %" PRIu64, \
effp->flow, p->num_output); memset(p->previous_errors, 0, \
sizeof(p->previous_errors)); memset(p->previous_outputs, 0, \
sizeof(p->previous_outputs)); }
commit c276b0f734215afa7b5ce25086900552b06aad76
Author: Ulrich Klauer <ulrich@chirlu.de>
Date: Mon Mar 19 03:25:31 2012 +0100
dft_filter: use 64-bit numbers to count samples
diff --git a/src/dft_filter.c b/src/dft_filter.c
index ee4ea02..f8eea97 100644
--- a/src/dft_filter.c
+++ b/src/dft_filter.c
@@ -89,7 +89,7 @@ static int flow(sox_effect_t * effp, const sox_sample_t * ibuf,
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 @@ static int drain(sox_effect_t * effp, sox_sample_t * obuf, \
size_t * osamp) {
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;
diff --git a/src/dft_filter.h b/src/dft_filter.h
index 6e8a5db..b8b2599 100644
--- a/src/dft_filter.h
+++ b/src/dft_filter.h
@@ -8,7 +8,7 @@ typedef struct {
} 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;
-----------------------------------------------------------------------
Summary of changes:
src/dft_filter.c | 8 ++++----
src/dft_filter.h | 2 +-
src/dither.c | 32 ++++++++++++++++++--------------
src/dither.h | 29 ++++++++++++++++-------------
4 files changed, 39 insertions(+), 32 deletions(-)
hooks/post-receive
--
sox
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
SoX-commits mailing list
SoX-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-commits
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic