From a1c029bab56c826d5311132e8d303c8ef502ec36 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 12 Aug 2007 12:46:20 +0000 Subject: [PATCH] gst/filter/: Reset the residue in BaseTransform::start to get a clean residue on stream changes. Original commit message from CVS: * gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init), (bpwsinc_start): * gst/filter/gstlpwsinc.c: (gst_lpwsinc_class_init), (lpwsinc_start): Reset the residue in BaseTransform::start to get a clean residue on stream changes. --- gst/audiofx/audiowsincband.c | 21 ++++++++++++++++++++- gst/audiofx/audiowsinclimit.c | 20 +++++++++++++++++++- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/gst/audiofx/audiowsincband.c b/gst/audiofx/audiowsincband.c index 9d550ba..f2bfda7 100644 --- a/gst/audiofx/audiowsincband.c +++ b/gst/audiofx/audiowsincband.c @@ -148,6 +148,8 @@ static GstFlowReturn bpwsinc_transform (GstBaseTransform * base, GstBuffer * inbuf, GstBuffer * outbuf); static gboolean bpwsinc_get_unit_size (GstBaseTransform * base, GstCaps * caps, guint * size); +static gboolean bpwsinc_start (GstBaseTransform * base); + static gboolean bpwsinc_setup (GstAudioFilter * base, GstRingBufferSpec * format); @@ -190,9 +192,11 @@ gst_bpwsinc_class_init (GstBPWSincClass * klass) { GObjectClass *gobject_class; GstBaseTransformClass *trans_class; + GstAudioFilterClass *filter_class; gobject_class = (GObjectClass *) klass; trans_class = (GstBaseTransformClass *) klass; + filter_class = (GstAudioFilterClass *) klass; gobject_class->set_property = bpwsinc_set_property; gobject_class->get_property = bpwsinc_get_property; @@ -223,7 +227,8 @@ gst_bpwsinc_class_init (GstBPWSincClass * klass) trans_class->transform = GST_DEBUG_FUNCPTR (bpwsinc_transform); trans_class->get_unit_size = GST_DEBUG_FUNCPTR (bpwsinc_get_unit_size); - GST_AUDIO_FILTER_CLASS (klass)->setup = GST_DEBUG_FUNCPTR (bpwsinc_setup); + trans_class->start = GST_DEBUG_FUNCPTR (bpwsinc_start); + filter_class->setup = GST_DEBUG_FUNCPTR (bpwsinc_setup); } static void @@ -508,6 +513,20 @@ bpwsinc_transform (GstBaseTransform * base, GstBuffer * inbuf, return GST_FLOW_OK; } +static gboolean +bpwsinc_start (GstBaseTransform * base) +{ + GstBPWSinc *self = GST_BPWSINC (base); + gint channels = GST_AUDIO_FILTER (self)->format.channels; + + /* Reset the residue if already existing */ + if (channels && self->residue) + memset (self->residue, 0, channels * + self->kernel_length * sizeof (gdouble)); + + return TRUE; +} + static void bpwsinc_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) diff --git a/gst/audiofx/audiowsinclimit.c b/gst/audiofx/audiowsinclimit.c index 54ebc2a..55daaf7 100644 --- a/gst/audiofx/audiowsinclimit.c +++ b/gst/audiofx/audiowsinclimit.c @@ -146,6 +146,7 @@ static GstFlowReturn lpwsinc_transform (GstBaseTransform * base, GstBuffer * inbuf, GstBuffer * outbuf); static gboolean lpwsinc_get_unit_size (GstBaseTransform * base, GstCaps * caps, guint * size); +static gboolean lpwsinc_start (GstBaseTransform * base); static gboolean lpwsinc_setup (GstAudioFilter * base, GstRingBufferSpec * format); @@ -188,9 +189,11 @@ gst_lpwsinc_class_init (GstLPWSincClass * klass) { GObjectClass *gobject_class; GstBaseTransformClass *trans_class; + GstAudioFilterClass *filter_class; gobject_class = (GObjectClass *) klass; trans_class = (GstBaseTransformClass *) klass; + filter_class = (GstAudioFilterClass *) klass; gobject_class->set_property = lpwsinc_set_property; gobject_class->get_property = lpwsinc_get_property; @@ -218,7 +221,8 @@ gst_lpwsinc_class_init (GstLPWSincClass * klass) trans_class->transform = GST_DEBUG_FUNCPTR (lpwsinc_transform); trans_class->get_unit_size = GST_DEBUG_FUNCPTR (lpwsinc_get_unit_size); - GST_AUDIO_FILTER_CLASS (klass)->setup = GST_DEBUG_FUNCPTR (lpwsinc_setup); + trans_class->start = GST_DEBUG_FUNCPTR (lpwsinc_start); + filter_class->setup = GST_DEBUG_FUNCPTR (lpwsinc_setup); } static void @@ -444,6 +448,20 @@ lpwsinc_transform (GstBaseTransform * base, GstBuffer * inbuf, return GST_FLOW_OK; } +static gboolean +lpwsinc_start (GstBaseTransform * base) +{ + GstLPWSinc *self = GST_LPWSINC (base); + gint channels = GST_AUDIO_FILTER (self)->format.channels; + + /* Reset the residue if already existing */ + if (channels && self->residue) + memset (self->residue, 0, channels * + self->kernel_length * sizeof (gdouble)); + + return TRUE; +} + static void lpwsinc_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) -- 2.7.4