From 3d3f7cd6dafbf0b5a49f94627fa638e493e6ca8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 20 May 2008 10:47:10 +0000 Subject: [PATCH] gst/equalizer/gstiirequalizer.c: Use a bigger type in integer mode for the intermediate results to prevent overflows.... Original commit message from CVS: * gst/equalizer/gstiirequalizer.c: Use a bigger type in integer mode for the intermediate results to prevent overflows. This fixes the crippled sound when using the equalizer in integer mode. Fixes bug #510865. --- ChangeLog | 7 +++++++ gst/equalizer/gstiirequalizer.c | 12 ++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index d0113fd8fa..930511d9b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-05-20 Sebastian Dröge + + * gst/equalizer/gstiirequalizer.c: + Use a bigger type in integer mode for the intermediate results to + prevent overflows. This fixes the crippled sound when using the + equalizer in integer mode. Fixes bug #510865. + 2008-05-20 Jan Schmidt * gst/videomixer/videomixer.c: diff --git a/gst/equalizer/gstiirequalizer.c b/gst/equalizer/gstiirequalizer.c index 684e8843f8..1cde32474f 100644 --- a/gst/equalizer/gstiirequalizer.c +++ b/gst/equalizer/gstiirequalizer.c @@ -515,16 +515,16 @@ gst_iir_equalizer_compute_frequencies (GstIirEqualizer * equ, guint new_count) #define CREATE_OPTIMIZED_FUNCTIONS(TYPE,BIG_TYPE,MIN_VAL,MAX_VAL) \ typedef struct { \ - TYPE x1, x2; /* history of input values for a filter */ \ - TYPE y1, y2; /* history of output values for a filter */ \ + BIG_TYPE x1, x2; /* history of input values for a filter */ \ + BIG_TYPE y1, y2; /* history of output values for a filter */ \ } SecondOrderHistory ## TYPE; \ \ -static inline TYPE \ +static inline BIG_TYPE \ one_step_ ## TYPE (GstIirEqualizerBand *filter, \ - SecondOrderHistory ## TYPE *history, TYPE input) \ + SecondOrderHistory ## TYPE *history, BIG_TYPE input) \ { \ /* calculate output */ \ - TYPE output = filter->a0 * input + filter->a1 * history->x1 + \ + BIG_TYPE output = filter->a0 * input + filter->a1 * history->x1 + \ filter->a2 * history->x2 + filter->b1 * history->y1 + \ filter->b2 * history->y2; \ /* update history */ \ @@ -564,7 +564,7 @@ guint size, guint channels) \ } \ } -CREATE_OPTIMIZED_FUNCTIONS (gint16, gint, -32768, 32767); +CREATE_OPTIMIZED_FUNCTIONS (gint16, gint32, -32768, 32767); CREATE_OPTIMIZED_FUNCTIONS (gfloat, gfloat, -1.0, 1.0); CREATE_OPTIMIZED_FUNCTIONS (gdouble, gdouble, -1.0, 1.0);