diff options
author | Tim-Philipp Müller <tim@centricular.net> | 2005-07-20 16:41:02 +0000 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.net> | 2005-07-20 16:41:02 +0000 |
commit | 5f8339431cdf566030798340486a048c85d29795 (patch) | |
tree | c3eb9d7133fafcd3cd9fe22dc6229f9297319780 | |
parent | e006aac6807ea1cb3c130e5290499129ec78a1fd (diff) | |
download | gst-plugins-bad-5f8339431cdf566030798340486a048c85d29795.tar.gz gst-plugins-bad-5f8339431cdf566030798340486a048c85d29795.tar.bz2 gst-plugins-bad-5f8339431cdf566030798340486a048c85d29795.zip |
gst/spectrum/gstspectrum.*: Handle mono streams.
Original commit message from CVS:
Reviewed by: Tim-Philipp Müller <tim at centricular dot net>
* gst/spectrum/gstspectrum.c: (gst_spectrum_init),
(gst_spectrum_link), (gst_spectrum_chain):
* gst/spectrum/gstspectrum.h:
Handle mono streams.
-rw-r--r-- | ChangeLog | 9 | ||||
m--------- | common | 0 | ||||
-rw-r--r-- | gst/spectrum/gstspectrum.c | 29 | ||||
-rw-r--r-- | gst/spectrum/gstspectrum.h | 2 |
4 files changed, 34 insertions, 6 deletions
@@ -1,3 +1,12 @@ +2005-07-20 Paolo Borelli <pborelli at katamail dot com> + + Reviewed by: Tim-Philipp Müller <tim at centricular dot net> + + * gst/spectrum/gstspectrum.c: (gst_spectrum_init), + (gst_spectrum_link), (gst_spectrum_chain): + * gst/spectrum/gstspectrum.h: + Handle mono streams. + 2005-07-16 Arwed v. Merkatz <v.merkatz@gmx.net> * ext/pango/gsttextrender.c: (gst_text_renderer_bitmap_to_ayuv), diff --git a/common b/common -Subproject ac7272b7af934c2294a44ac1c0f3fac3f8d17ec +Subproject 694de4dbf4827f372321f0634643a254d7edd98 diff --git a/gst/spectrum/gstspectrum.c b/gst/spectrum/gstspectrum.c index 41765253..6be89af0 100644 --- a/gst/spectrum/gstspectrum.c +++ b/gst/spectrum/gstspectrum.c @@ -52,6 +52,7 @@ static void gst_spectrum_init (GstSpectrum * spectrum); static void gst_spectrum_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); +static GstPadLinkReturn gst_spectrum_link (GstPad * pad, const GstCaps * caps); static void gst_spectrum_chain (GstPad * pad, GstData * _data); #define fixed short @@ -97,6 +98,7 @@ gst_spectrum_base_init (gpointer g_class) gst_element_class_set_details (element_class, &gst_spectrum_details); } + static void gst_spectrum_class_init (GstSpectrumClass * klass) { @@ -116,6 +118,7 @@ gst_spectrum_init (GstSpectrum * spectrum) { spectrum->sinkpad = gst_pad_new ("sink", GST_PAD_SINK); gst_element_add_pad (GST_ELEMENT (spectrum), spectrum->sinkpad); + gst_pad_set_link_function (spectrum->sinkpad, gst_spectrum_link); gst_pad_set_chain_function (spectrum->sinkpad, gst_spectrum_chain); spectrum->srcpad = gst_pad_new ("src", GST_PAD_SRC); gst_element_add_pad (GST_ELEMENT (spectrum), spectrum->srcpad); @@ -142,6 +145,19 @@ gst_spectrum_set_property (GObject * object, guint prop_id, } } +static GstPadLinkReturn +gst_spectrum_link (GstPad * pad, const GstCaps * caps) +{ + GstSpectrum *spectrum = GST_SPECTRUM (gst_pad_get_parent (pad)); + GstStructure *structure; + + structure = gst_caps_get_structure (caps, 0); + + gst_structure_get_int (structure, "channels", &spectrum->channels); + + return GST_PAD_LINK_OK; +} + static void gst_spectrum_chain (GstPad * pad, GstData * _data) { @@ -171,12 +187,13 @@ gst_spectrum_chain (GstPad * pad, GstData * _data) g_return_if_fail (loud != NULL); memset (im, 0, spec_len * sizeof (gint16)); - /*if (spectrum->meta->channels == 2) { */ - re = g_malloc (spec_len * sizeof (gint16)); - for (i = 0; i < spec_len; i++) - re[i] = (samples[(i * 2)] + samples[(i * 2) + 1]) >> 1; - /*} else */ - /* re = samples; */ + if (spectrum->channels == 2) { + re = g_malloc (spec_len * sizeof (gint16)); + for (i = 0; i < spec_len; i++) + re[i] = (samples[(i * 2)] + samples[(i * 2) + 1]) >> 1; + } else + re = samples; + gst_spectrum_window (re, spec_len); gst_spectrum_fix_fft (re, im, spec_base, FALSE); gst_spectrum_fix_loud (loud, re, im, spec_len, 0); diff --git a/gst/spectrum/gstspectrum.h b/gst/spectrum/gstspectrum.h index 8cc546ec..20c6d982 100644 --- a/gst/spectrum/gstspectrum.h +++ b/gst/spectrum/gstspectrum.h @@ -49,6 +49,8 @@ struct _GstSpectrum { GstPad *sinkpad,*srcpad; + gint channels; + gint width; }; |