From: <sl...@ke...> - 2008-05-30 11:04:03
|
CVS Root: /cvs/gstreamer Module: gst-plugins-good Changes by: slomo Date: Fri May 30 2008 11:04:11 UTC Log message: * gst/equalizer/gstiirequalizer.c: (gst_iir_equalizer_band_set_property), (gst_iir_equalizer_init), (setup_filter), (set_passthrough), (update_coefficients), (gst_iir_equalizer_compute_frequencies), (gst_iir_equalizer_transform_ip): * gst/equalizer/gstiirequalizer.h: Update the filter coefficients only when needed in the transform_ip function and correctly set the element into passthrough mode if the gain of all bands is 0. Modified files: . : ChangeLog gst/equalizer : gstiirequalizer.c gstiirequalizer.h Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/ChangeLog.diff?r1=1.3501&r2=1.3502 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/equalizer/gstiirequalizer.c.diff?r1=1.26&r2=1.27 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/equalizer/gstiirequalizer.h.diff?r1=1.4&r2=1.5 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-plugins-good/ChangeLog,v retrieving revision 1.3501 retrieving revision 1.3502 diff -u -d -r1.3501 -r1.3502 --- ChangeLog 29 May 2008 11:30:14 -0000 1.3501 +++ ChangeLog 30 May 2008 11:03:55 -0000 1.3502 @@ -1,3 +1,15 @@ +2008-05-30 Sebastian Dröge <sl...@ci...> + + * gst/equalizer/gstiirequalizer.c: + (gst_iir_equalizer_band_set_property), (gst_iir_equalizer_init), + (setup_filter), (set_passthrough), (update_coefficients), + (gst_iir_equalizer_compute_frequencies), + (gst_iir_equalizer_transform_ip): + * gst/equalizer/gstiirequalizer.h: + Update the filter coefficients only when needed in the transform_ip + function and correctly set the element into passthrough mode if the + gain of all bands is 0. 2008-05-29 Wim Taymans <wim...@co...> Based on patch by: Sebastian Keller <sebastian-keller at gmx dot de> Index: gstiirequalizer.c RCS file: /cvs/gstreamer/gst-plugins-good/gst/equalizer/gstiirequalizer.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- gstiirequalizer.c 20 May 2008 10:47:10 -0000 1.26 +++ gstiirequalizer.c 30 May 2008 11:03:57 -0000 1.27 @@ -120,8 +120,11 @@ }; static GType gst_iir_equalizer_band_get_type (void); static void setup_filter (GstIirEqualizer * equ, GstIirEqualizerBand * band); +static void set_passthrough (GstIirEqualizer * equ); static void gst_iir_equalizer_band_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) @@ -138,10 +141,10 @@ GstIirEqualizer *equ = GST_IIR_EQUALIZER (gst_object_get_parent (GST_OBJECT (band))); + equ->need_new_coefficients = equ->need_new_coefficients || + (band->gain != gain); band->gain = gain; - if (GST_AUDIO_FILTER (equ)->format.rate) { - setup_filter (equ, band); - } gst_object_unref (equ); GST_DEBUG_OBJECT (band, "changed gain = %lf ", band->gain); } @@ -156,10 +159,9 @@ + (band->freq != freq); band->freq = freq; GST_DEBUG_OBJECT (band, "changed freq = %lf ", band->freq); @@ -174,10 +176,9 @@ + (band->width != width); band->width = width; GST_DEBUG_OBJECT (band, "changed width = %lf ", band->width); @@ -310,6 +311,7 @@ gst_iir_equalizer_base_init (gpointer g_class) { GstAudioFilterClass *audiofilter_class = GST_AUDIO_FILTER_CLASS (g_class); GstCaps *caps; caps = gst_caps_from_string (ALLOWED_CAPS); @@ -321,7 +323,9 @@ gst_iir_equalizer_class_init (GstIirEqualizerClass * klass) GstAudioFilterClass *audio_filter_class = (GstAudioFilterClass *) klass; GstBaseTransformClass *btrans_class = (GstBaseTransformClass *) klass; GObjectClass *gobject_class = (GObjectClass *) klass; gobject_class->finalize = gst_iir_equalizer_finalize; @@ -333,13 +337,14 @@ gst_iir_equalizer_init (GstIirEqualizer * eq, GstIirEqualizerClass * g_class) - /* nothing to do here */ + eq->need_new_coefficients = TRUE; } gst_iir_equalizer_finalize (GObject * object) GstIirEqualizer *equ = GST_IIR_EQUALIZER (object); gint i; for (i = 0; i < equ->freq_band_count; i++) { @@ -385,7 +390,9 @@ */ { gdouble gain, omega, bw; gdouble edge_gain, gamma; gdouble alpha, beta; @@ -414,6 +421,7 @@ band->a2 = 0.0; band->b1 = 0.0; band->b2 = 0.0; + gain = 1.0; goto out; } else { bw = 2.0 * M_PI * (band->width / GST_AUDIO_FILTER (equ)->format.rate); @@ -439,11 +447,38 @@ } +static void +set_passthrough (GstIirEqualizer * equ) +{ + gint i; + gboolean passthrough = TRUE; + for (i = 0; i < equ->freq_band_count; i++) { + passthrough = passthrough && (equ->bands[i]->gain == 0.0); + } + gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (equ), passthrough); + GST_DEBUG ("Passthrough mode: %d\n", passthrough); +} +update_coefficients (GstIirEqualizer * equ) + setup_filter (equ, equ->bands[i]); void gst_iir_equalizer_compute_frequencies (GstIirEqualizer * equ, guint new_count) guint old_count, i; gdouble freq0, freq1, step; gchar name[20]; old_count = equ->freq_band_count; @@ -503,12 +538,7 @@ freq0 = freq1; - - if (GST_AUDIO_FILTER (equ)->format.rate) { - for (i = 0; i < new_count; i++) { - setup_filter (equ, equ->bands[i]); - } - } + equ->need_new_coefficients = TRUE; /* start of code that is type specific */ @@ -572,7 +602,9 @@ gst_iir_equalizer_transform_ip (GstBaseTransform * btrans, GstBuffer * buf) GstAudioFilter *filter = GST_AUDIO_FILTER (btrans); GstIirEqualizer *equ = GST_IIR_EQUALIZER (btrans); GstClockTime timestamp; if (gst_base_transform_is_passthrough (btrans)) @@ -581,6 +613,11 @@ if (G_UNLIKELY (filter->format.channels < 1 || equ->process == NULL)) return GST_FLOW_NOT_NEGOTIATED; + if (equ->need_new_coefficients) { + update_coefficients (equ); + set_passthrough (equ); timestamp = GST_BUFFER_TIMESTAMP (buf); timestamp = gst_segment_to_stream_time (&btrans->segment, GST_FORMAT_TIME, timestamp); Index: gstiirequalizer.h RCS file: /cvs/gstreamer/gst-plugins-good/gst/equalizer/gstiirequalizer.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- gstiirequalizer.h 18 Oct 2007 06:14:42 -0000 1.4 +++ gstiirequalizer.h 30 May 2008 11:03:57 -0000 1.5 @@ -60,6 +60,8 @@ gpointer history; guint history_size; + gboolean need_new_coefficients; ProcessFunc process; |