summaryrefslogtreecommitdiff
path: root/gst/equalizer/gstiirequalizer.c
diff options
context:
space:
mode:
authorStefan Kost <ensonic@users.sf.net>2009-10-05 22:43:11 +0300
committerStefan Kost <ensonic@users.sf.net>2009-10-05 23:04:39 +0300
commit7b6e594b69fe298ab746a50cf8ebe892338935f9 (patch)
treec4f04b43a68970c0c211f4c77639c0ad72d1ed40 /gst/equalizer/gstiirequalizer.c
parent0040d01265ca04f617493b28786bb45378168a31 (diff)
downloadgstreamer-plugins-good-7b6e594b69fe298ab746a50cf8ebe892338935f9.tar.gz
equalizer: fix filter history usage. Fixes #597397
The process functions where overwriting the history for each channel. Also pull some static things out of the inner loop.
Diffstat (limited to 'gst/equalizer/gstiirequalizer.c')
-rw-r--r--gst/equalizer/gstiirequalizer.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/gst/equalizer/gstiirequalizer.c b/gst/equalizer/gstiirequalizer.c
index 060441a3e..b671b247f 100644
--- a/gst/equalizer/gstiirequalizer.c
+++ b/gst/equalizer/gstiirequalizer.c
@@ -577,17 +577,16 @@ gst_iir_equ_process_ ## TYPE (GstIirEqualizer *equ, guint8 *data, \
guint size, guint channels) \
{ \
guint frames = size / channels / sizeof (TYPE); \
- guint i, c, f; \
+ guint i, c, f, nf = equ->freq_band_count; \
BIG_TYPE cur; \
+ GstIirEqualizerBand **filters = equ->bands; \
\
for (i = 0; i < frames; i++) { \
+ SecondOrderHistory ## TYPE *history = equ->history; \
for (c = 0; c < channels; c++) { \
- SecondOrderHistory ## TYPE *history = equ->history; \
cur = *((TYPE *) data); \
- for (f = 0; f < equ->freq_band_count; f++) { \
- GstIirEqualizerBand *filter = equ->bands[f]; \
- \
- cur = one_step_ ## TYPE (filter, history, cur); \
+ for (f = 0; f < nf; f++) { \
+ cur = one_step_ ## TYPE (filters[f], history, cur); \
history++; \
} \
cur = CLAMP (cur, MIN_VAL, MAX_VAL); \
@@ -597,18 +596,18 @@ guint size, guint channels) \
} \
}
-#define CREATE_OPTIMIZED_FUNCTIONS(TYPE) \
+#define CREATE_OPTIMIZED_FUNCTIONS(TYPE) \
typedef struct { \
TYPE x1, x2; /* history of input values for a filter */ \
TYPE y1, y2; /* history of output values for a filter */ \
} SecondOrderHistory ## TYPE; \
\
-static inline TYPE \
+static inline TYPE \
one_step_ ## TYPE (GstIirEqualizerBand *filter, \
- SecondOrderHistory ## TYPE *history, TYPE input) \
+ SecondOrderHistory ## TYPE *history, TYPE input) \
{ \
/* calculate output */ \
- TYPE output = filter->a0 * input + filter->a1 * history->x1 + \
+ TYPE output = filter->a0 * input + filter->a1 * history->x1 + \
filter->a2 * history->x2 + filter->b1 * history->y1 + \
filter->b2 * history->y2; \
/* update history */ \
@@ -628,17 +627,16 @@ gst_iir_equ_process_ ## TYPE (GstIirEqualizer *equ, guint8 *data, \
guint size, guint channels) \
{ \
guint frames = size / channels / sizeof (TYPE); \
- guint i, c, f; \
- TYPE cur; \
+ guint i, c, f, nf = equ->freq_band_count; \
+ TYPE cur; \
+ GstIirEqualizerBand **filters = equ->bands; \
\
for (i = 0; i < frames; i++) { \
+ SecondOrderHistory ## TYPE *history = equ->history; \
for (c = 0; c < channels; c++) { \
- SecondOrderHistory ## TYPE *history = equ->history; \
cur = *((TYPE *) data); \
- for (f = 0; f < equ->freq_band_count; f++) { \
- GstIirEqualizerBand *filter = equ->bands[f]; \
- \
- cur = one_step_ ## TYPE (filter, history, cur); \
+ for (f = 0; f < nf; f++) { \
+ cur = one_step_ ## TYPE (filters[f], history, cur); \
history++; \
} \
*((TYPE *) data) = (TYPE) cur; \