diff options
Diffstat (limited to 'gst/equalizer')
-rw-r--r-- | gst/equalizer/gstiirequalizer.c | 115 |
1 files changed, 57 insertions, 58 deletions
diff --git a/gst/equalizer/gstiirequalizer.c b/gst/equalizer/gstiirequalizer.c index c7819792..0a4a24dc 100644 --- a/gst/equalizer/gstiirequalizer.c +++ b/gst/equalizer/gstiirequalizer.c @@ -219,8 +219,7 @@ static void setup_filter (GstIirEqualizer * equ, SecondOrderFilter * filter, gdouble gain, gdouble frequency) { - gdouble q = - pow (HIGHEST_FREQ / LOWEST_FREQ, + gdouble q = pow (HIGHEST_FREQ / LOWEST_FREQ, 1.0 / (equ->freq_count - 1)) * equ->bandwidth; gdouble theta = frequency * 2 * M_PI; @@ -341,64 +340,64 @@ gst_iir_equalizer_get_property (GObject * object, guint prop_id, /* start of code that is type specific */ -#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 */ \ -} SecondOrderHistory ## TYPE; \ - \ -static inline TYPE \ -one_step_ ## TYPE (SecondOrderFilter *filter, \ - SecondOrderHistory ## TYPE *history, TYPE input) \ -{ \ - /* calculate output */ \ - TYPE output = filter->alpha * (input - history->x2) + \ - filter->gamma * history->y1 - filter->beta * history->y2; \ - /* update history */ \ - history->y2 = history->y1; \ - history->y1 = output; \ - history->x2 = history->x1; \ - history->x1 = input; \ - \ - return output; \ -} \ - \ -static const guint history_size_ ## TYPE = sizeof (SecondOrderHistory ## TYPE); \ - \ -static void \ -gst_iir_equ_process_ ## TYPE (GstIirEqualizer *equ, guint8 *data, guint size, \ - guint channels) \ -{ \ - guint frames = size / channels / sizeof (TYPE); \ - guint i, c, f; \ - BIG_TYPE cur; \ - TYPE val; \ - \ - for (i = 0; i < frames; i++) { \ - for (c = 0; c < channels; c++) { \ - SecondOrderHistory ## TYPE *history = equ->history; \ - val = *((TYPE *) data); \ - cur = 0; \ - for (f = 0; f < equ->freq_count; f++) { \ - SecondOrderFilter *filter = &equ->filter[f]; \ - \ - cur += one_step_ ## TYPE (filter, history, val); \ - history++; \ - } \ - cur += val * 0.25; \ - cur = CLAMP (cur, MIN_VAL, MAX_VAL); \ - *((TYPE *) data) = (TYPE) cur; \ - data += sizeof (TYPE); \ - } \ - } \ +#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 */ \ +} SecondOrderHistory ## TYPE; \ + \ +static inline TYPE \ +one_step_ ## TYPE (SecondOrderFilter *filter, \ + SecondOrderHistory ## TYPE *history, TYPE input) \ +{ \ + /* calculate output */ \ + TYPE output = filter->alpha * (input - history->x2) + \ + filter->gamma * history->y1 - filter->beta * history->y2; \ + /* update history */ \ + history->y2 = history->y1; \ + history->y1 = output; \ + history->x2 = history->x1; \ + history->x1 = input; \ + \ + return output; \ +} \ + \ +static const guint \ +history_size_ ## TYPE = sizeof (SecondOrderHistory ## TYPE); \ + \ +static void \ +gst_iir_equ_process_ ## TYPE (GstIirEqualizer *equ, guint8 *data, \ +guint size, guint channels) \ +{ \ + guint frames = size / channels / sizeof (TYPE); \ + guint i, c, f; \ + BIG_TYPE cur; \ + TYPE val; \ + \ + for (i = 0; i < frames; i++) { \ + for (c = 0; c < channels; c++) { \ + SecondOrderHistory ## TYPE *history = equ->history; \ + val = *((TYPE *) data); \ + cur = 0; \ + for (f = 0; f < equ->freq_count; f++) { \ + SecondOrderFilter *filter = &equ->filter[f]; \ + \ + cur += one_step_ ## TYPE (filter, history, val); \ + history++; \ + } \ + cur += val * 0.25; \ + cur = CLAMP (cur, MIN_VAL, MAX_VAL); \ + *((TYPE *) data) = (TYPE) cur; \ + data += sizeof (TYPE); \ + } \ + } \ } -CREATE_OPTIMIZED_FUNCTIONS (gint16, gint, -32768, 32767) - CREATE_OPTIMIZED_FUNCTIONS (gfloat, gfloat, -1.0, 1.0) +CREATE_OPTIMIZED_FUNCTIONS (gint16, gint, -32768, 32767); +CREATE_OPTIMIZED_FUNCTIONS (gfloat, gfloat, -1.0, 1.0); - static void - gst_iir_equalizer_filter_inplace (GstAudiofilter * filter, - GstBuffer * buf) +static void +gst_iir_equalizer_filter_inplace (GstAudiofilter * filter, GstBuffer * buf) { GstIirEqualizer *equ = GST_IIR_EQUALIZER (filter); @@ -435,6 +434,6 @@ plugin_init (GstPlugin * plugin) GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR, - "gstequalizer", + "equalizer", "GStreamer equalizers", plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN) |