[gst-cvs] gst-plugins-good: equalizer: Use floating point arithmetic internally for the int16 mode
Sebastian Dröge
slomo at kemper.freedesktop.org
Thu May 28 03:42:03 PDT 2009
Module: gst-plugins-good
Branch: master
Commit: 9507cdc84c968dc142356157c861e8d216b85716
URL: http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=9507cdc84c968dc142356157c861e8d216b85716
Author: Ghislain 'Aus' Lacroix <aus at songbirdnest.com>
Date: Thu May 28 12:39:46 2009 +0200
equalizer: Use floating point arithmetic internally for the int16 mode
By using int32 arithmetic we will introduce distortions as the
IIR filter is very sensitive to rounding errors. Fixes bug #580214.
---
gst/equalizer/gstiirequalizer.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/gst/equalizer/gstiirequalizer.c b/gst/equalizer/gstiirequalizer.c
index 4d21a87..060441a 100644
--- a/gst/equalizer/gstiirequalizer.c
+++ b/gst/equalizer/gstiirequalizer.c
@@ -392,9 +392,9 @@ setup_filter (GstIirEqualizer * equ, GstIirEqualizerBand * band)
gain = arg_to_scale (band->gain);
- if (band->freq / GST_AUDIO_FILTER (equ)->format.rate > 0.5)
+ if (band->freq / GST_AUDIO_FILTER (equ)->format.rate >= 0.5)
omega = M_PI;
- else if (band->freq < 0.0)
+ else if (band->freq <= 0.0)
omega = 0.0;
else
omega = 2.0 * M_PI * (band->freq / GST_AUDIO_FILTER (equ)->format.rate);
@@ -557,9 +557,9 @@ one_step_ ## TYPE (GstIirEqualizerBand *filter, \
SecondOrderHistory ## TYPE *history, BIG_TYPE input) \
{ \
/* calculate output */ \
- BIG_TYPE output = floor (filter->a0 * input + \
+ BIG_TYPE output = filter->a0 * input + \
filter->a1 * history->x1 + filter->a2 * history->x2 + \
- filter->b1 * history->y1 + filter->b2 * history->y2 + 0.5); \
+ filter->b1 * history->y1 + filter->b2 * history->y2; \
/* update history */ \
history->y2 = history->y1; \
history->y1 = output; \
@@ -591,7 +591,7 @@ guint size, guint channels) \
history++; \
} \
cur = CLAMP (cur, MIN_VAL, MAX_VAL); \
- *((TYPE *) data) = (TYPE) cur; \
+ *((TYPE *) data) = (TYPE) floor (cur); \
data += sizeof (TYPE); \
} \
} \
@@ -647,7 +647,7 @@ guint size, guint channels) \
} \
}
-CREATE_OPTIMIZED_FUNCTIONS_INT (gint16, gint32, -32768, 32767);
+CREATE_OPTIMIZED_FUNCTIONS_INT (gint16, gfloat, -32768.0, 32767.0);
CREATE_OPTIMIZED_FUNCTIONS (gfloat);
CREATE_OPTIMIZED_FUNCTIONS (gdouble);
More information about the Gstreamer-commits
mailing list