diff options
author | Thomas Vander Stichele <thomas@apestaart.org> | 2004-03-14 22:34:33 +0000 |
---|---|---|
committer | Thomas Vander Stichele <thomas@apestaart.org> | 2004-03-14 22:34:33 +0000 |
commit | 5d25c00e4b613b9cdf2c04fa3a68dffa03834a68 (patch) | |
tree | 74a5b1eaf3a324b520e64e87404fd0b3018a7829 /gst/law | |
parent | 1e83b097f7b732ae49e294a5a398bdc3e88854a8 (diff) |
gst-indent
Original commit message from CVS:
gst-indent
Diffstat (limited to 'gst/law')
-rw-r--r-- | gst/law/alaw-decode.c | 172 | ||||
-rw-r--r-- | gst/law/alaw-decode.h | 33 | ||||
-rw-r--r-- | gst/law/alaw-encode.c | 213 | ||||
-rw-r--r-- | gst/law/alaw-encode.h | 33 | ||||
-rw-r--r-- | gst/law/alaw.c | 56 | ||||
-rw-r--r-- | gst/law/mulaw-conversion.c | 104 | ||||
-rw-r--r-- | gst/law/mulaw-conversion.h | 6 | ||||
-rw-r--r-- | gst/law/mulaw-decode.c | 136 | ||||
-rw-r--r-- | gst/law/mulaw-decode.h | 33 | ||||
-rw-r--r-- | gst/law/mulaw-encode.c | 135 | ||||
-rw-r--r-- | gst/law/mulaw-encode.h | 33 | ||||
-rw-r--r-- | gst/law/mulaw.c | 60 |
12 files changed, 530 insertions, 484 deletions
diff --git a/gst/law/alaw-decode.c b/gst/law/alaw-decode.c index 00108948..4bae398e 100644 --- a/gst/law/alaw-decode.c +++ b/gst/law/alaw-decode.c @@ -36,100 +36,108 @@ static GstElementDetails alawdec_details = { }; /* Stereo signals and args */ -enum { +enum +{ /* FILL ME */ LAST_SIGNAL }; -enum { +enum +{ ARG_0 }; -static void gst_alawdec_class_init (GstALawDecClass *klass); -static void gst_alawdec_base_init (GstALawDecClass *klass); -static void gst_alawdec_init (GstALawDec *alawdec); +static void gst_alawdec_class_init (GstALawDecClass * klass); +static void gst_alawdec_base_init (GstALawDecClass * klass); +static void gst_alawdec_init (GstALawDec * alawdec); -static void gst_alawdec_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void gst_alawdec_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); +static void gst_alawdec_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_alawdec_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static void gst_alawdec_chain (GstPad *pad, GstData *_data); +static void gst_alawdec_chain (GstPad * pad, GstData * _data); static GstElementClass *parent_class = NULL; + /*static guint gst_stereo_signals[LAST_SIGNAL] = { 0 }; */ /* * alaw_to_s16() - Convert an A-law value to 16-bit linear PCM * */ -static gint alaw_to_s16(guint8 a_val) +static gint +alaw_to_s16 (guint8 a_val) { - gint t; - gint seg; - - a_val ^= 0x55; - t = a_val & 0x7f; - if (t < 16) - t = (t << 4) + 8; - else { - seg = (t >> 4) & 0x07; - t = ((t & 0x0f) << 4) + 0x108; - t <<= seg -1; - } - return ((a_val & 0x80) ? t : -t); + gint t; + gint seg; + + a_val ^= 0x55; + t = a_val & 0x7f; + if (t < 16) + t = (t << 4) + 8; + else { + seg = (t >> 4) & 0x07; + t = ((t & 0x0f) << 4) + 0x108; + t <<= seg - 1; + } + return ((a_val & 0x80) ? t : -t); } static GstPadLinkReturn -alawdec_link (GstPad *pad, const GstCaps *caps) +alawdec_link (GstPad * pad, const GstCaps * caps) { - GstCaps* tempcaps; + GstCaps *tempcaps; gint rate, channels; GstStructure *structure; gboolean ret; - - GstALawDec* alawdec = GST_ALAWDEC (GST_OBJECT_PARENT (pad)); - + + GstALawDec *alawdec = GST_ALAWDEC (GST_OBJECT_PARENT (pad)); + structure = gst_caps_get_structure (caps, 0); ret = gst_structure_get_int (structure, "rate", &rate); ret &= gst_structure_get_int (structure, "channels", &channels); - if (!ret) return GST_PAD_LINK_REFUSED; - - tempcaps = gst_caps_new_simple ( "audio/x-raw-int", - "depth", G_TYPE_INT, 16, - "width", G_TYPE_INT, 16, - "signed", G_TYPE_BOOLEAN, TRUE, - "endianness", G_TYPE_INT, G_BYTE_ORDER, - "rate", G_TYPE_INT, rate, - "channels", G_TYPE_INT, channels, - NULL); - + if (!ret) + return GST_PAD_LINK_REFUSED; + + tempcaps = gst_caps_new_simple ("audio/x-raw-int", + "depth", G_TYPE_INT, 16, + "width", G_TYPE_INT, 16, + "signed", G_TYPE_BOOLEAN, TRUE, + "endianness", G_TYPE_INT, G_BYTE_ORDER, + "rate", G_TYPE_INT, rate, "channels", G_TYPE_INT, channels, NULL); + return gst_pad_try_set_caps (alawdec->srcpad, tempcaps); } GType -gst_alawdec_get_type(void) { +gst_alawdec_get_type (void) +{ static GType alawdec_type = 0; if (!alawdec_type) { static const GTypeInfo alawdec_info = { - sizeof(GstALawDecClass), - (GBaseInitFunc)gst_alawdec_base_init, + sizeof (GstALawDecClass), + (GBaseInitFunc) gst_alawdec_base_init, NULL, - (GClassInitFunc)gst_alawdec_class_init, + (GClassInitFunc) gst_alawdec_class_init, NULL, NULL, - sizeof(GstALawDec), + sizeof (GstALawDec), 0, - (GInstanceInitFunc)gst_alawdec_init, + (GInstanceInitFunc) gst_alawdec_init, }; - alawdec_type = g_type_register_static(GST_TYPE_ELEMENT, "GstALawDec", &alawdec_info, 0); + alawdec_type = + g_type_register_static (GST_TYPE_ELEMENT, "GstALawDec", &alawdec_info, + 0); } return alawdec_type; } static void -gst_alawdec_base_init (GstALawDecClass *klass) +gst_alawdec_base_init (GstALawDecClass * klass) { GstElementClass *element_class = GST_ELEMENT_CLASS (klass); @@ -139,74 +147,75 @@ gst_alawdec_base_init (GstALawDecClass *klass) } static void -gst_alawdec_class_init (GstALawDecClass *klass) +gst_alawdec_class_init (GstALawDecClass * klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; - gobject_class = (GObjectClass*)klass; - gstelement_class = (GstElementClass*)klass; + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; - parent_class = g_type_class_ref(GST_TYPE_ELEMENT); + parent_class = g_type_class_ref (GST_TYPE_ELEMENT); gobject_class->set_property = gst_alawdec_set_property; gobject_class->get_property = gst_alawdec_get_property; } static void -gst_alawdec_init (GstALawDec *alawdec) +gst_alawdec_init (GstALawDec * alawdec) { - alawdec->sinkpad = gst_pad_new_from_template(alawdec_sink_template,"sink"); - alawdec->srcpad = gst_pad_new_from_template(alawdec_src_template,"src"); - gst_pad_set_link_function(alawdec->sinkpad, alawdec_link); + alawdec->sinkpad = gst_pad_new_from_template (alawdec_sink_template, "sink"); + alawdec->srcpad = gst_pad_new_from_template (alawdec_src_template, "src"); + gst_pad_set_link_function (alawdec->sinkpad, alawdec_link); - gst_element_add_pad(GST_ELEMENT(alawdec),alawdec->sinkpad); - gst_pad_set_chain_function(alawdec->sinkpad,gst_alawdec_chain); - gst_element_add_pad(GST_ELEMENT(alawdec),alawdec->srcpad); + gst_element_add_pad (GST_ELEMENT (alawdec), alawdec->sinkpad); + gst_pad_set_chain_function (alawdec->sinkpad, gst_alawdec_chain); + gst_element_add_pad (GST_ELEMENT (alawdec), alawdec->srcpad); } static void -gst_alawdec_chain (GstPad *pad,GstData *_data) +gst_alawdec_chain (GstPad * pad, GstData * _data) { GstBuffer *buf = GST_BUFFER (_data); GstALawDec *alawdec; gint16 *linear_data; guint8 *alaw_data; - GstBuffer* outbuf; + GstBuffer *outbuf; gint i; - g_return_if_fail(pad != NULL); - g_return_if_fail(GST_IS_PAD(pad)); - g_return_if_fail(buf != NULL); + g_return_if_fail (pad != NULL); + g_return_if_fail (GST_IS_PAD (pad)); + g_return_if_fail (buf != NULL); - alawdec = GST_ALAWDEC(GST_OBJECT_PARENT (pad)); - g_return_if_fail(alawdec != NULL); - g_return_if_fail(GST_IS_ALAWDEC(alawdec)); + alawdec = GST_ALAWDEC (GST_OBJECT_PARENT (pad)); + g_return_if_fail (alawdec != NULL); + g_return_if_fail (GST_IS_ALAWDEC (alawdec)); - alaw_data = (guint8 *)GST_BUFFER_DATA(buf); - outbuf=gst_buffer_new(); - GST_BUFFER_DATA(outbuf) = (gchar*)g_new(gint16,GST_BUFFER_SIZE(buf)); - GST_BUFFER_SIZE(outbuf) = GST_BUFFER_SIZE(buf)*2; + alaw_data = (guint8 *) GST_BUFFER_DATA (buf); + outbuf = gst_buffer_new (); + GST_BUFFER_DATA (outbuf) = (gchar *) g_new (gint16, GST_BUFFER_SIZE (buf)); + GST_BUFFER_SIZE (outbuf) = GST_BUFFER_SIZE (buf) * 2; - linear_data = (gint16*)GST_BUFFER_DATA(outbuf); - for (i = 0; i < GST_BUFFER_SIZE(buf); i++) { + linear_data = (gint16 *) GST_BUFFER_DATA (outbuf); + for (i = 0; i < GST_BUFFER_SIZE (buf); i++) { *linear_data = alaw_to_s16 (*alaw_data); linear_data++; alaw_data++; } - - gst_buffer_unref(buf); - gst_pad_push(alawdec->srcpad,GST_DATA (outbuf)); + + gst_buffer_unref (buf); + gst_pad_push (alawdec->srcpad, GST_DATA (outbuf)); } static void -gst_alawdec_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +gst_alawdec_set_property (GObject * object, guint prop_id, const GValue * value, + GParamSpec * pspec) { GstALawDec *alawdec; /* it's not null if we got it, but it might not be ours */ - g_return_if_fail(GST_IS_ALAWDEC(object)); - alawdec = GST_ALAWDEC(object); + g_return_if_fail (GST_IS_ALAWDEC (object)); + alawdec = GST_ALAWDEC (object); switch (prop_id) { default: @@ -215,13 +224,14 @@ gst_alawdec_set_property (GObject *object, guint prop_id, const GValue *value, G } static void -gst_alawdec_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +gst_alawdec_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstALawDec *alawdec; /* it's not null if we got it, but it might not be ours */ - g_return_if_fail(GST_IS_ALAWDEC(object)); - alawdec = GST_ALAWDEC(object); + g_return_if_fail (GST_IS_ALAWDEC (object)); + alawdec = GST_ALAWDEC (object); switch (prop_id) { default: @@ -229,5 +239,3 @@ gst_alawdec_get_property (GObject *object, guint prop_id, GValue *value, GParamS break; } } - - diff --git a/gst/law/alaw-decode.h b/gst/law/alaw-decode.h index aa3a418c..8a6ac61b 100644 --- a/gst/law/alaw-decode.h +++ b/gst/law/alaw-decode.h @@ -27,8 +27,9 @@ #ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +extern "C" +{ +#endif /* __cplusplus */ #define GST_TYPE_ALAWDEC \ @@ -42,27 +43,29 @@ extern "C" { #define GST_IS_ALAWDEC_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ALAWDEC)) -typedef struct _GstALawDec GstALawDec; -typedef struct _GstALawDecClass GstALawDecClass; + typedef struct _GstALawDec GstALawDec; + typedef struct _GstALawDecClass GstALawDecClass; -struct _GstALawDec { - GstElement element; + struct _GstALawDec + { + GstElement element; - GstPad *sinkpad,*srcpad; + GstPad *sinkpad, *srcpad; - /*MetaAudioRaw meta; */ + /*MetaAudioRaw meta; */ -}; + }; -struct _GstALawDecClass { - GstElementClass parent_class; -}; + struct _GstALawDecClass + { + GstElementClass parent_class; + }; -GType gst_alawdec_get_type(void); + GType gst_alawdec_get_type (void); #ifdef __cplusplus } -#endif /* __cplusplus */ +#endif /* __cplusplus */ -#endif /* __GST_STEREO_H__ */ +#endif /* __GST_STEREO_H__ */ diff --git a/gst/law/alaw-encode.c b/gst/law/alaw-encode.c index 6efdb64f..052f2e00 100644 --- a/gst/law/alaw-encode.c +++ b/gst/law/alaw-encode.c @@ -36,23 +36,27 @@ static GstElementDetails alawenc_details = { }; /* Stereo signals and args */ -enum { +enum +{ /* FILL ME */ LAST_SIGNAL }; -enum { +enum +{ ARG_0 }; -static void gst_alawenc_class_init (GstALawEncClass *klass); -static void gst_alawenc_base_init (GstALawEncClass *klass); -static void gst_alawenc_init (GstALawEnc *alawenc); +static void gst_alawenc_class_init (GstALawEncClass * klass); +static void gst_alawenc_base_init (GstALawEncClass * klass); +static void gst_alawenc_init (GstALawEnc * alawenc); -static void gst_alawenc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void gst_alawenc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); +static void gst_alawenc_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_alawenc_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static void gst_alawenc_chain (GstPad *pad, GstData *_data); +static void gst_alawenc_chain (GstPad * pad, GstData * _data); /* * s16_to_alaw() - Convert a 16-bit linear PCM value to 8-bit A-law @@ -74,102 +78,108 @@ static void gst_alawenc_chain (GstPad *pad, GstData *_data); * John Wiley & Sons, pps 98-111 and 472-476. */ -static inline gint val_seg(gint val) +static inline gint +val_seg (gint val) { - gint r = 1; - val >>= 8; - if (val & 0xf0) { - val >>= 4; - r += 4; - } - if (val & 0x0c) { - val >>= 2; - r += 2; - } - if (val & 0x02) - r += 1; - return r; + gint r = 1; + + val >>= 8; + if (val & 0xf0) { + val >>= 4; + r += 4; + } + if (val & 0x0c) { + val >>= 2; + r += 2; + } + if (val & 0x02) + r += 1; + return r; } -static guint8 s16_to_alaw(gint pcm_val) +static guint8 +s16_to_alaw (gint pcm_val) { - gint seg; - guint8 mask; - guint8 aval; - - if (pcm_val >= 0) { - mask = 0xD5; - } else { - mask = 0x55; - pcm_val = -pcm_val; - if (pcm_val > 0x7fff) - pcm_val = 0x7fff; - } - - if (pcm_val < 256) - aval = pcm_val >> 4; - else { - /* Convert the scaled magnitude to segment number. */ - seg = val_seg(pcm_val); - aval = (seg << 4) | ((pcm_val >> (seg + 3)) & 0x0f); - } - return aval ^ mask; + gint seg; + guint8 mask; + guint8 aval; + + if (pcm_val >= 0) { + mask = 0xD5; + } else { + mask = 0x55; + pcm_val = -pcm_val; + if (pcm_val > 0x7fff) + pcm_val = 0x7fff; + } + + if (pcm_val < 256) + aval = pcm_val >> 4; + else { + /* Convert the scaled magnitude to segment number. */ + seg = val_seg (pcm_val); + aval = (seg << 4) | ((pcm_val >> (seg + 3)) & 0x0f); + } + return aval ^ mask; } static GstElementClass *parent_class = NULL; + /*static guint gst_stereo_signals[LAST_SIGNAL] = { 0 }; */ static GstPadLinkReturn -alawenc_link (GstPad *pad, const GstCaps *caps) +alawenc_link (GstPad * pad, const GstCaps * caps) { - GstCaps* tempcaps; + GstCaps *tempcaps; gint rate, channels; GstStructure *structure; gboolean ret; - - GstALawEnc* alawenc = GST_ALAWENC (GST_OBJECT_PARENT (pad)); - + + GstALawEnc *alawenc = GST_ALAWENC (GST_OBJECT_PARENT (pad)); + structure = gst_caps_get_structure (caps, 0); ret = gst_structure_get_int (structure, "rate", &rate); ret &= gst_structure_get_int (structure, "channels", &channels); - if (!ret) return GST_PAD_LINK_REFUSED; - + if (!ret) + return GST_PAD_LINK_REFUSED; + tempcaps = gst_caps_new_simple ("audio/x-alaw", - "depth", G_TYPE_INT, 8, - "width", G_TYPE_INT, 8, - "signed", G_TYPE_BOOLEAN, FALSE, - "rate", G_TYPE_INT, rate, - "channels", G_TYPE_INT, channels, - NULL); - + "depth", G_TYPE_INT, 8, + "width", G_TYPE_INT, 8, + "signed", G_TYPE_BOOLEAN, FALSE, + "rate", G_TYPE_INT, rate, "channels", G_TYPE_INT, channels, NULL); + return gst_pad_try_set_caps (alawenc->srcpad, tempcaps); -} +} GType -gst_alawenc_get_type(void) { +gst_alawenc_get_type (void) +{ static GType alawenc_type = 0; if (!alawenc_type) { static const GTypeInfo alawenc_info = { - sizeof(GstALawEncClass), - (GBaseInitFunc)gst_alawenc_base_init, + sizeof (GstALawEncClass), + (GBaseInitFunc) gst_alawenc_base_init, NULL, - (GClassInitFunc)gst_alawenc_class_init, + (GClassInitFunc) gst_alawenc_class_init, NULL, NULL, - sizeof(GstALawEnc), + sizeof (GstALawEnc), 0, - (GInstanceInitFunc)gst_alawenc_init, + (GInstanceInitFunc) gst_alawenc_init, }; - alawenc_type = g_type_register_static(GST_TYPE_ELEMENT, "GstALawEnc", &alawenc_info, 0); + alawenc_type = + g_type_register_static (GST_TYPE_ELEMENT, "GstALawEnc", &alawenc_info, + 0); } return alawenc_type; } static void -gst_alawenc_base_init (GstALawEncClass *klass) +gst_alawenc_base_init (GstALawEncClass * klass) { GstElementClass *element_class = GST_ELEMENT_CLASS (klass); @@ -179,74 +189,76 @@ gst_alawenc_base_init (GstALawEncClass *klass) } static void -gst_alawenc_class_init (GstALawEncClass *klass) +gst_alawenc_class_init (GstALawEncClass * klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; - gobject_class = (GObjectClass*)klass; - gstelement_class = (GstElementClass*)klass; + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; - parent_class = g_type_class_ref(GST_TYPE_ELEMENT); + parent_class = g_type_class_ref (GST_TYPE_ELEMENT); gobject_class->set_property = gst_alawenc_set_property; gobject_class->get_property = gst_alawenc_get_property; } static void -gst_alawenc_init (GstALawEnc *alawenc) +gst_alawenc_init (GstALawEnc * alawenc) { - alawenc->sinkpad = gst_pad_new_from_template(alawenc_sink_template,"sink"); - alawenc->srcpad = gst_pad_new_from_template(alawenc_src_template,"src"); + alawenc->sinkpad = gst_pad_new_from_template (alawenc_sink_template, "sink"); + alawenc->srcpad = gst_pad_new_from_template (alawenc_src_template, "src"); gst_pad_set_link_function (alawenc->sinkpad, alawenc_link); - gst_element_add_pad(GST_ELEMENT(alawenc),alawenc->sinkpad); - gst_pad_set_chain_function(alawenc->sinkpad,gst_alawenc_chain); - gst_element_add_pad(GST_ELEMENT(alawenc),alawenc->srcpad); + gst_element_add_pad (GST_ELEMENT (alawenc), alawenc->sinkpad); + gst_pad_set_chain_function (alawenc->sinkpad, gst_alawenc_chain); + gst_element_add_pad (GST_ELEMENT (alawenc), alawenc->srcpad); } static void -gst_alawenc_chain (GstPad *pad,GstData *_data) +gst_alawenc_chain (GstPad * pad, GstData * _data) { GstBuffer *buf = GST_BUFFER (_data); GstALawEnc *alawenc; gint16 *linear_data; guint8 *alaw_data; - GstBuffer* outbuf; + GstBuffer *outbuf; gint i; - g_return_if_fail(pad != NULL); - g_return_if_fail(GST_IS_PAD(pad)); - g_return_if_fail(buf != NULL); + g_return_if_fail (pad != NULL); + g_return_if_fail (GST_IS_PAD (pad)); + g_return_if_fail (buf != NULL); + + alawenc = GST_ALAWENC (GST_OBJECT_PARENT (pad)); + g_return_if_fail (alawenc != NULL); + g_return_if_fail (GST_IS_ALAWENC (alawenc)); - alawenc = GST_ALAWENC(GST_OBJECT_PARENT (pad)); - g_return_if_fail(alawenc != NULL); - g_return_if_fail(GST_IS_ALAWENC(alawenc)); + linear_data = (gint16 *) GST_BUFFER_DATA (buf); + outbuf = gst_buffer_new (); + GST_BUFFER_DATA (outbuf) = + (gchar *) g_new (guint8, GST_BUFFER_SIZE (buf) / 2); + GST_BUFFER_SIZE (outbuf) = GST_BUFFER_SIZE (buf) / 2; - linear_data = (gint16 *)GST_BUFFER_DATA(buf); - outbuf=gst_buffer_new(); - GST_BUFFER_DATA(outbuf) = (gchar*)g_new(guint8,GST_BUFFER_SIZE(buf)/2); - GST_BUFFER_SIZE(outbuf) = GST_BUFFER_SIZE(buf)/2; - - alaw_data = (guint8*)GST_BUFFER_DATA(outbuf); - for (i = 0; i < GST_BUFFER_SIZE(outbuf); i++) { + alaw_data = (guint8 *) GST_BUFFER_DATA (outbuf); + for (i = 0; i < GST_BUFFER_SIZE (outbuf); i++) { *alaw_data = s16_to_alaw (*linear_data); alaw_data++; linear_data++; } - gst_buffer_unref(buf); - gst_pad_push(alawenc->srcpad,GST_DATA (outbuf)); + gst_buffer_unref (buf); + gst_pad_push (alawenc->srcpad, GST_DATA (outbuf)); } static void -gst_alawenc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +gst_alawenc_set_property (GObject * object, guint prop_id, const GValue * value, + GParamSpec * pspec) { GstALawEnc *alawenc; /* it's not null if we got it, but it might not be ours */ - g_return_if_fail(GST_IS_ALAWENC(object)); - alawenc = GST_ALAWENC(object); + g_return_if_fail (GST_IS_ALAWENC (object)); + alawenc = GST_ALAWENC (object); switch (prop_id) { default: @@ -255,13 +267,14 @@ gst_alawenc_set_property (GObject *object, guint prop_id, const GValue *value, G } static void -gst_alawenc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +gst_alawenc_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstALawEnc *alawenc; /* it's not null if we got it, but it might not be ours */ - g_return_if_fail(GST_IS_ALAWENC(object)); - alawenc = GST_ALAWENC(object); + g_return_if_fail (GST_IS_ALAWENC (object)); + alawenc = GST_ALAWENC (object); switch (prop_id) { default: diff --git a/gst/law/alaw-encode.h b/gst/law/alaw-encode.h index e0801036..907fa3d8 100644 --- a/gst/law/alaw-encode.h +++ b/gst/law/alaw-encode.h @@ -27,8 +27,9 @@ #ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +extern "C" +{ +#endif /* __cplusplus */ #define GST_TYPE_ALAWENC \ @@ -42,27 +43,29 @@ extern "C" { #define GST_IS_ALAWENC_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ALAWENC)) -typedef struct _GstALawEnc GstALawEnc; -typedef struct _GstALawEncClass GstALawEncClass; + typedef struct _GstALawEnc GstALawEnc; + typedef struct _GstALawEncClass GstALawEncClass; -struct _GstALawEnc { - GstElement element; + struct _GstALawEnc + { + GstElement element; - GstPad *sinkpad,*srcpad; + GstPad *sinkpad, *srcpad; - /*MetaAudioRaw meta; */ + /*MetaAudioRaw meta; */ -}; + }; -struct _GstALawEncClass { - GstElementClass parent_class; -}; + struct _GstALawEncClass + { + GstElementClass parent_class; + }; -GType gst_alawenc_get_type(void); + GType gst_alawenc_get_type (void); #ifdef __cplusplus } -#endif /* __cplusplus */ +#endif /* __cplusplus */ -#endif /* __GST_STEREO_H__ */ +#endif /* __GST_STEREO_H__ */ diff --git a/gst/law/alaw.c b/gst/law/alaw.c index be0559bb..05ac2d23 100644 --- a/gst/law/alaw.c +++ b/gst/law/alaw.c @@ -4,62 +4,58 @@ #include "alaw-encode.h" #include "alaw-decode.h" -static GstCaps* +static GstCaps * alaw_factory (void) { return gst_caps_new_simple ("audio/x-alaw", - "rate", GST_TYPE_INT_RANGE, 8000, 192000, - "channels", GST_TYPE_INT_RANGE, 1, 2, - NULL); + "rate", GST_TYPE_INT_RANGE, 8000, 192000, + "channels", GST_TYPE_INT_RANGE, 1, 2, NULL); } -static GstCaps* +static GstCaps * linear_factory (void) { return gst_caps_new_simple ("audio/x-raw-int", - "width", G_TYPE_INT, 16, - "depth", G_TYPE_INT, 16, + "width", G_TYPE_INT, 16, + "depth", G_TYPE_INT, 16, "endianness", G_TYPE_INT, G_BYTE_ORDER, - "signed", G_TYPE_BOOLEAN, TRUE, - "rate", GST_TYPE_INT_RANGE, 8000, 192000, - "channels", GST_TYPE_INT_RANGE, 1, 2, - NULL); + "signed", G_TYPE_BOOLEAN, TRUE, + "rate", GST_TYPE_INT_RANGE, 8000, 192000, + "channels", GST_TYPE_INT_RANGE, 1, 2, NULL); } GstPadTemplate *alawenc_src_template, *alawenc_sink_template; GstPadTemplate *alawdec_src_template, *alawdec_sink_template; static gboolean -plugin_init (GstPlugin *plugin) +plugin_init (GstPlugin * plugin) { - GstCaps* alaw_caps, *linear_caps; + GstCaps *alaw_caps, *linear_caps; alaw_caps = alaw_factory (); linear_caps = linear_factory (); - alawenc_src_template = gst_pad_template_new ("src",GST_PAD_SRC,GST_PAD_ALWAYS,alaw_caps); - alawenc_sink_template = gst_pad_template_new ("sink",GST_PAD_SINK,GST_PAD_ALWAYS,linear_caps); + alawenc_src_template = + gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, alaw_caps); + alawenc_sink_template = + gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, linear_caps); - alawdec_src_template = gst_pad_template_new ("src",GST_PAD_SRC,GST_PAD_ALWAYS,linear_caps); - alawdec_sink_template = gst_pad_template_new ("sink",GST_PAD_SINK,GST_PAD_ALWAYS,alaw_caps); + alawdec_src_template = + gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, linear_caps); + alawdec_sink_template = + gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, alaw_caps); if (!gst_element_register (plugin, "alawenc", - GST_RANK_NONE, GST_TYPE_ALAWENC) || + GST_RANK_NONE, GST_TYPE_ALAWENC) || !gst_element_register (plugin, "alawdec", - GST_RANK_PRIMARY, GST_TYPE_ALAWENC)) + GST_RANK_PRIMARY, GST_TYPE_ALAWENC)) return FALSE; return TRUE; } -GST_PLUGIN_DEFINE ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "alaw", - "ALaw audio conversion routines", - plugin_init, - VERSION, - GST_LICENSE, - GST_PACKAGE, - GST_ORIGIN -) +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "alaw", + "ALaw audio conversion routines", + plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN) diff --git a/gst/law/mulaw-conversion.c b/gst/law/mulaw-conversion.c index e921fb88..fa4db3cb 100644 --- a/gst/law/mulaw-conversion.c +++ b/gst/law/mulaw-conversion.c @@ -25,49 +25,53 @@ #include <glib.h> -#define ZEROTRAP /* turn on the trap as per the MIL-STD */ -#define BIAS 0x84 /* define the add-in bias for 16 bit samples */ +#define ZEROTRAP /* turn on the trap as per the MIL-STD */ +#define BIAS 0x84 /* define the add-in bias for 16 bit samples */ #define CLIP 32635 void -mulaw_encode(gint16* in, guint8* out, gint numsamples) +mulaw_encode (gint16 * in, guint8 * out, gint numsamples) { - static gint16 exp_lut[256] = {0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3, - 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, - 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, - 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7}; - gint16 sign, exponent, mantissa,i; - gint16 sample; - guint8 ulawbyte; + static gint16 exp_lut[256] = { 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 + }; + gint16 sign, exponent, mantissa, i; + gint16 sample; + guint8 ulawbyte; - for(i=0;i<numsamples;i++) { - sample=in[i]; + for (i = 0; i < numsamples; i++) { + sample = in[i]; /** get the sample into sign-magnitude **/ - sign = (sample >> 8) & 0x80; /* set aside the sign */ - if (sign != 0) sample = -sample; /* get magnitude */ - if (sample > CLIP) sample = CLIP; /* clip the magnitude */ + sign = (sample >> 8) & 0x80; /* set aside the sign */ + if (sign != 0) + sample = -sample; /* get magnitude */ + if (sample > CLIP) + sample = CLIP; /* clip the magnitude */ /** convert from 16 bit linear to ulaw **/ - sample = sample + BIAS; - exponent = exp_lut[(sample>>7) & 0xFF]; - mantissa = (sample >> (exponent+3)) & 0x0F; - ulawbyte = ~(sign | (exponent << 4) | mantissa); + sample = sample + BIAS; + exponent = exp_lut[(sample >> 7) & 0xFF]; + mantissa = (sample >> (exponent + 3)) & 0x0F; + ulawbyte = ~(sign | (exponent << 4) | mantissa); #ifdef ZEROTRAP - if (ulawbyte == 0 ) ulawbyte = 0x02; /* optional CCITT trap */ + if (ulawbyte == 0) + ulawbyte = 0x02; /* optional CCITT trap */ #endif - out[i]=ulawbyte; - } + out[i] = ulawbyte; + } } /* @@ -87,20 +91,22 @@ mulaw_encode(gint16* in, guint8* out, gint numsamples) */ void -mulaw_decode(guint8* in,gint16* out,gint numsamples) +mulaw_decode (guint8 * in, gint16 * out, gint numsamples) { - static gint16 exp_lut[8]={0,132,396,924,1980,4092,8316,16764}; - gint16 sign, exponent, mantissa; - guint8 ulawbyte; - gint16 linear,i; - for(i=0;i<numsamples;i++) { - ulawbyte=in[i]; - ulawbyte = ~ulawbyte; - sign = (ulawbyte & 0x80); - exponent = (ulawbyte >> 4) & 0x07; - mantissa = ulawbyte & 0x0F; - linear = exp_lut[exponent] + (mantissa << (exponent+3)); - if (sign != 0) linear = -linear; - out[i]=linear; - } + static gint16 exp_lut[8] = { 0, 132, 396, 924, 1980, 4092, 8316, 16764 }; + gint16 sign, exponent, mantissa; + guint8 ulawbyte; + gint16 linear, i; + + for (i = 0; i < numsamples; i++) { + ulawbyte = in[i]; + ulawbyte = ~ulawbyte; + sign = (ulawbyte & 0x80); + exponent = (ulawbyte >> 4) & 0x07; + mantissa = ulawbyte & 0x0F; + linear = exp_lut[exponent] + (mantissa << (exponent + 3)); + if (sign != 0) + linear = -linear; + out[i] = linear; + } } diff --git a/gst/law/mulaw-conversion.h b/gst/law/mulaw-conversion.h index 55180121..db07789d 100644 --- a/gst/law/mulaw-conversion.h +++ b/gst/law/mulaw-conversion.h @@ -3,8 +3,6 @@ #include <glib.h> -void -mulaw_encode(gint16* in, guint8* out, gint numsamples); -void -mulaw_decode(guint8* in,gint16* out,gint numsamples); +void mulaw_encode (gint16 * in, guint8 * out, gint numsamples); +void mulaw_decode (guint8 * in, gint16 * out, gint numsamples); #endif diff --git a/gst/law/mulaw-decode.c b/gst/law/mulaw-decode.c index fcf023c1..6a8f9e81 100644 --- a/gst/law/mulaw-decode.c +++ b/gst/law/mulaw-decode.c @@ -35,79 +35,86 @@ static GstElementDetails mulawdec_details = { }; /* Stereo signals and args */ -enum { +enum +{ /* FILL ME */ LAST_SIGNAL }; -enum { +enum +{ ARG_0 }; -static void gst_mulawdec_class_init (GstMuLawDecClass *klass); -static void gst_mulawdec_base_init (GstMuLawDecClass *klass); -static void gst_mulawdec_init (GstMuLawDec *mulawdec); +static void gst_mulawdec_class_init (GstMuLawDecClass * klass); +static void gst_mulawdec_base_init (GstMuLawDecClass * klass); +static void gst_mulawdec_init (GstMuLawDec * mulawdec); -static void gst_mulawdec_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void gst_mulawdec_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); +static void gst_mulawdec_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_mulawdec_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static void gst_mulawdec_chain (GstPad *pad, GstData *_data); +static void gst_mulawdec_chain (GstPad * pad, GstData * _data); static GstElementClass *parent_class = NULL; + /*static guint gst_stereo_signals[LAST_SIGNAL] = { 0 };*/ static GstPadLinkReturn -mulawdec_link (GstPad *pad, const GstCaps *caps) +mulawdec_link (GstPad * pad, const GstCaps * caps) { - GstCaps* tempcaps; + GstCaps *tempcaps; gint rate, channels; GstStructure *structure; gboolean ret; - - GstMuLawDec* mulawdec = GST_MULAWDEC (GST_OBJECT_PARENT (pad)); - + + GstMuLawDec *mulawdec = GST_MULAWDEC (GST_OBJECT_PARENT (pad)); + structure = gst_caps_get_structure (caps, 0); ret = gst_structure_get_int (structure, "rate", &rate); ret = gst_structure_get_int (structure, "channels", &channels); - if (!ret) return GST_PAD_LINK_REFUSED; + if (!ret) + return GST_PAD_LINK_REFUSED; tempcaps = gst_caps_new_simple ("audio/x-raw-int", - "depth", G_TYPE_INT, 16, - "width", G_TYPE_INT, 16, - "signed", G_TYPE_BOOLEAN, TRUE, - "endianness", G_TYPE_INT, G_BYTE_ORDER, - "rate", G_TYPE_INT, rate, - "channels", G_TYPE_INT, channels, - NULL); + "depth", G_TYPE_INT, 16, + "width", G_TYPE_INT, 16, + "signed", G_TYPE_BOOLEAN, TRUE, + "endianness", G_TYPE_INT, G_BYTE_ORDER, + "rate", G_TYPE_INT, rate, "channels", G_TYPE_INT, channels, NULL); return gst_pad_try_set_caps (mulawdec->srcpad, tempcaps); } GType -gst_mulawdec_get_type(void) { +gst_mulawdec_get_type (void) +{ static GType mulawdec_type = 0; if (!mulawdec_type) { static const GTypeInfo mulawdec_info = { - sizeof(GstMuLawDecClass), - (GBaseInitFunc)gst_mulawdec_base_init, + sizeof (GstMuLawDecClass), + (GBaseInitFunc) gst_mulawdec_base_init, NULL, - (GClassInitFunc)gst_mulawdec_class_init, + (GClassInitFunc) gst_mulawdec_class_init, NULL, NULL, - sizeof(GstMuLawDec), + sizeof (GstMuLawDec), 0, - (GInstanceInitFunc)gst_mulawdec_init, + (GInstanceInitFunc) gst_mulawdec_init, }; - mulawdec_type = g_type_register_static(GST_TYPE_ELEMENT, "GstMuLawDec", &mulawdec_info, 0); + mulawdec_type = + g_type_register_static (GST_TYPE_ELEMENT, "GstMuLawDec", &mulawdec_info, + 0); } return mulawdec_type; } static void -gst_mulawdec_base_init (GstMuLawDecClass *klass) +gst_mulawdec_base_init (GstMuLawDecClass * klass) { GstElementClass *element_class = GST_ELEMENT_CLASS (klass); @@ -117,69 +124,71 @@ gst_mulawdec_base_init (GstMuLawDecClass *klass) } static void -gst_mulawdec_class_init (GstMuLawDecClass *klass) +gst_mulawdec_class_init (GstMuLawDecClass * klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; - gobject_class = (GObjectClass*)klass; - gstelement_class = (GstElementClass*)klass; + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; - parent_class = g_type_class_ref(GST_TYPE_ELEMENT); + parent_class = g_type_class_ref (GST_TYPE_ELEMENT); gobject_class->set_property = gst_mulawdec_set_property; gobject_class->get_property = gst_mulawdec_get_property; } static void -gst_mulawdec_init (GstMuLawDec *mulawdec) +gst_mulawdec_init (GstMuLawDec * mulawdec) { - mulawdec->sinkpad = gst_pad_new_from_template(mulawdec_sink_template,"sink"); - mulawdec->srcpad = gst_pad_new_from_template(mulawdec_src_template,"src"); - gst_pad_set_link_function(mulawdec->sinkpad, mulawdec_link); - - gst_element_add_pad(GST_ELEMENT(mulawdec),mulawdec->sinkpad); - gst_pad_set_chain_function(mulawdec->sinkpad,gst_mulawdec_chain); - gst_element_add_pad(GST_ELEMENT(mulawdec),mulawdec->srcpad); + mulawdec->sinkpad = + gst_pad_new_from_template (mulawdec_sink_template, "sink"); + mulawdec->srcpad = gst_pad_new_from_template (mulawdec_src_template, "src"); + gst_pad_set_link_function (mulawdec->sinkpad, mulawdec_link); + + gst_element_add_pad (GST_ELEMENT (mulawdec), mulawdec->sinkpad); + gst_pad_set_chain_function (mulawdec->sinkpad, gst_mulawdec_chain); + gst_element_add_pad (GST_ELEMENT (mulawdec), mulawdec->srcpad); } static void -gst_mulawdec_chain (GstPad *pad,GstData *_data) +gst_mulawdec_chain (GstPad * pad, GstData * _data) { GstBuffer *buf = GST_BUFFER (_data); GstMuLawDec *mulawdec; gint16 *linear_data; guint8 *mulaw_data; - GstBuffer* outbuf; + GstBuffer *outbuf; - g_return_if_fail(pad != NULL); - g_return_if_fail(GST_IS_PAD(pad)); - g_return_if_fail(buf != NULL); + g_return_if_fail (pad != NULL); + g_return_if_fail (GST_IS_PAD (pad)); + g_return_if_fail (buf != NULL); - mulawdec = GST_MULAWDEC(GST_OBJECT_PARENT (pad)); - g_return_if_fail(mulawdec != NULL); - g_return_if_fail(GST_IS_MULAWDEC(mulawdec)); + mulawdec = GST_MULAWDEC (GST_OBJECT_PARENT (pad)); + g_return_if_fail (mulawdec != NULL); + g_return_if_fail (GST_IS_MULAWDEC (mulawdec)); - mulaw_data = (guint8 *)GST_BUFFER_DATA(buf); - outbuf=gst_buffer_new(); - GST_BUFFER_DATA(outbuf) = (gchar*)g_new(gint16,GST_BUFFER_SIZE(buf)); - GST_BUFFER_SIZE(outbuf) = GST_BUFFER_SIZE(buf)*2; + mulaw_data = (guint8 *) GST_BUFFER_DATA (buf); + outbuf = gst_buffer_new (); + GST_BUFFER_DATA (outbuf) = (gchar *) g_new (gint16, GST_BUFFER_SIZE (buf)); + GST_BUFFER_SIZE (outbuf) = GST_BUFFER_SIZE (buf) * 2; - linear_data = (gint16*)GST_BUFFER_DATA(outbuf); - mulaw_decode(mulaw_data,linear_data,GST_BUFFER_SIZE(buf)); + linear_data = (gint16 *) GST_BUFFER_DATA (outbuf); + mulaw_decode (mulaw_data, linear_data, GST_BUFFER_SIZE (buf)); - gst_buffer_unref(buf); - gst_pad_push(mulawdec->srcpad,GST_DATA (outbuf)); + gst_buffer_unref (buf); + gst_pad_push (mulawdec->srcpad, GST_DATA (outbuf)); } static void -gst_mulawdec_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +gst_mulawdec_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { GstMuLawDec *mulawdec; /* it's not null if we got it, but it might not be ours */ - g_return_if_fail(GST_IS_MULAWDEC(object)); - mulawdec = GST_MULAWDEC(object); + g_return_if_fail (GST_IS_MULAWDEC (object)); + mulawdec = GST_MULAWDEC (object); switch (prop_id) { default: @@ -188,13 +197,14 @@ gst_mulawdec_set_property (GObject *object, guint prop_id, const GValue *value, } static void -gst_mulawdec_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +gst_mulawdec_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstMuLawDec *mulawdec; /* it's not null if we got it, but it might not be ours */ - g_return_if_fail(GST_IS_MULAWDEC(object)); - mulawdec = GST_MULAWDEC(object); + g_return_if_fail (GST_IS_MULAWDEC (object)); + mulawdec = GST_MULAWDEC (object); switch (prop_id) { default: diff --git a/gst/law/mulaw-decode.h b/gst/law/mulaw-decode.h index d34c8c06..9fb32267 100644 --- a/gst/law/mulaw-decode.h +++ b/gst/law/mulaw-decode.h @@ -27,8 +27,9 @@ #ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +extern "C" +{ +#endif /* __cplusplus */ #define GST_TYPE_MULAWDEC \ @@ -42,27 +43,29 @@ extern "C" { #define GST_IS_MULAWDEC_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MULAWDEC)) -typedef struct _GstMuLawDec GstMuLawDec; -typedef struct _GstMuLawDecClass GstMuLawDecClass; + typedef struct _GstMuLawDec GstMuLawDec; + typedef struct _GstMuLawDecClass GstMuLawDecClass; -struct _GstMuLawDec { - GstElement element; + struct _GstMuLawDec + { + GstElement element; - GstPad *sinkpad,*srcpad; + GstPad *sinkpad, *srcpad; - /*MetaAudioRaw meta; */ + /*MetaAudioRaw meta; */ -}; + }; -struct _GstMuLawDecClass { - GstElementClass parent_class; -}; + struct _GstMuLawDecClass + { + GstElementClass parent_class; + }; -GType gst_mulawdec_get_type(void); + GType gst_mulawdec_get_type (void); #ifdef __cplusplus } -#endif /* __cplusplus */ +#endif /* __cplusplus */ -#endif /* __GST_STEREO_H__ */ +#endif /* __GST_STEREO_H__ */ diff --git a/gst/law/mulaw-encode.c b/gst/law/mulaw-encode.c index b15815a1..db65e169 100644 --- a/gst/law/mulaw-encode.c +++ b/gst/law/mulaw-encode.c @@ -35,77 +35,84 @@ static GstElementDetails mulawenc_details = { }; /* Stereo signals and args */ -enum { +enum +{ /* FILL ME */ LAST_SIGNAL }; -enum { +enum +{ ARG_0 }; -static void gst_mulawenc_class_init (GstMuLawEncClass *klass); -static void gst_mulawenc_base_init (GstMuLawEncClass *klass); -static void gst_mulawenc_init (GstMuLawEnc *mulawenc); +static void gst_mulawenc_class_init (GstMuLawEncClass * klass); +static void gst_mulawenc_base_init (GstMuLawEncClass * klass); +static void gst_mulawenc_init (GstMuLawEnc * mulawenc); -static void gst_mulawenc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void gst_mulawenc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); +static void gst_mulawenc_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_mulawenc_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static void gst_mulawenc_chain (GstPad *pad, GstData *_data); +static void gst_mulawenc_chain (GstPad * pad, GstData * _data); static GstElementClass *parent_class = NULL; + /*static guint gst_stereo_signals[LAST_SIGNAL] = { 0 }; */ static GstPadLinkReturn -mulawenc_link (GstPad *pad, const GstCaps *caps) +mulawenc_link (GstPad * pad, const GstCaps * caps) { - GstCaps* tempcaps; + GstCaps *tempcaps; gint rate, channels; GstStructure *structure; gboolean ret; - - GstMuLawEnc* mulawenc = GST_MULAWENC (GST_OBJECT_PARENT (pad)); - + + GstMuLawEnc *mulawenc = GST_MULAWENC (GST_OBJECT_PARENT (pad)); + structure = gst_caps_get_structure (caps, 0); ret = gst_structure_get_int (structure, "rate", &rate); ret = gst_structure_get_int (structure, "channels", &channels); - if (!ret) return GST_PAD_LINK_REFUSED; - + if (!ret) + return GST_PAD_LINK_REFUSED; + tempcaps = gst_caps_new_simple ("audio/x-mulaw", - "depth", G_TYPE_INT, 8, - "width", G_TYPE_INT, 8, - "signed", G_TYPE_BOOLEAN, FALSE, - "rate", G_TYPE_INT, rate, - "channels", G_TYPE_INT, channels, - NULL); - + "depth", G_TYPE_INT, 8, + "width", G_TYPE_INT, 8, + "signed", G_TYPE_BOOLEAN, FALSE, + "rate", G_TYPE_INT, rate, "channels", G_TYPE_INT, channels, NULL); + return gst_pad_try_set_caps (mulawenc->srcpad, tempcaps); } GType -gst_mulawenc_get_type(void) { +gst_mulawenc_get_type (void) +{ static GType mulawenc_type = 0; if (!mulawenc_type) { static const GTypeInfo mulawenc_info = { - sizeof(GstMuLawEncClass), - (GBaseInitFunc)gst_mulawenc_base_init, + sizeof (GstMuLawEncClass), + (GBaseInitFunc) gst_mulawenc_base_init, NULL, - (GClassInitFunc)gst_mulawenc_class_init, + (GClassInitFunc) gst_mulawenc_class_init, NULL, NULL, - sizeof(GstMuLawEnc), + sizeof (GstMuLawEnc), 0, - (GInstanceInitFunc)gst_mulawenc_init, + (GInstanceInitFunc) gst_mulawenc_init, }; - mulawenc_type = g_type_register_static(GST_TYPE_ELEMENT, "GstMuLawEnc", &mulawenc_info, 0); + mulawenc_type = + g_type_register_static (GST_TYPE_ELEMENT, "GstMuLawEnc", &mulawenc_info, + 0); } return mulawenc_type; } static void -gst_mulawenc_base_init (GstMuLawEncClass *klass) +gst_mulawenc_base_init (GstMuLawEncClass * klass) { GstElementClass *element_class = GST_ELEMENT_CLASS (klass); @@ -115,69 +122,72 @@ gst_mulawenc_base_init (GstMuLawEncClass *klass) } static void -gst_mulawenc_class_init (GstMuLawEncClass *klass) +gst_mulawenc_class_init (GstMuLawEncClass * klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; - gobject_class = (GObjectClass*)klass; - gstelement_class = (GstElementClass*)klass; + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; - parent_class = g_type_class_ref(GST_TYPE_ELEMENT); + parent_class = g_type_class_ref (GST_TYPE_ELEMENT); gobject_class->set_property = gst_mulawenc_set_property; gobject_class->get_property = gst_mulawenc_get_property; } static void -gst_mulawenc_init (GstMuLawEnc *mulawenc) +gst_mulawenc_init (GstMuLawEnc * mulawenc) { - mulawenc->sinkpad = gst_pad_new_from_template(mulawenc_sink_template,"sink"); - mulawenc->srcpad = gst_pad_new_from_template(mulawenc_src_template,"src"); + mulawenc->sinkpad = + gst_pad_new_from_template (mulawenc_sink_template, "sink"); + mulawenc->srcpad = gst_pad_new_from_template (mulawenc_src_template, "src"); gst_pad_set_link_function (mulawenc->sinkpad, mulawenc_link); - gst_element_add_pad(GST_ELEMENT(mulawenc),mulawenc->sinkpad); - gst_pad_set_chain_function(mulawenc->sinkpad,gst_mulawenc_chain); - gst_element_add_pad(GST_ELEMENT(mulawenc),mulawenc->srcpad); + gst_element_add_pad (GST_ELEMENT (mulawenc), mulawenc->sinkpad); + gst_pad_set_chain_function (mulawenc->sinkpad, gst_mulawenc_chain); + gst_element_add_pad (GST_ELEMENT (mulawenc), mulawenc->srcpad); } static void -gst_mulawenc_chain (GstPad *pad,GstData *_data) +gst_mulawenc_chain (GstPad * pad, GstData * _data) { GstBuffer *buf = GST_BUFFER (_data); GstMuLawEnc *mulawenc; gint16 *linear_data; guint8 *mulaw_data; - GstBuffer* outbuf; + GstBuffer *outbuf; - g_return_if_fail(pad != NULL); - g_return_if_fail(GST_IS_PAD(pad)); - g_return_if_fail(buf != NULL); + g_return_if_fail (pad != NULL); + g_return_if_fail (GST_IS_PAD (pad)); + g_return_if_fail (buf != NULL); - mulawenc = GST_MULAWENC(GST_OBJECT_PARENT (pad)); - g_return_if_fail(mulawenc != NULL); - g_return_if_fail(GST_IS_MULAWENC(mulawenc)); + mulawenc = GST_MULAWENC (GST_OBJECT_PARENT (pad)); + g_return_if_fail (mulawenc != NULL); + g_return_if_fail (GST_IS_MULAWENC (mulawenc)); - linear_data = (gint16 *)GST_BUFFER_DATA(buf); - outbuf=gst_buffer_new(); - GST_BUFFER_DATA(outbuf) = (gchar*)g_new(gint16,GST_BUFFER_SIZE(buf)/4); - GST_BUFFER_SIZE(outbuf) = GST_BUFFER_SIZE(buf)/2; + linear_data = (gint16 *) GST_BUFFER_DATA (buf); + outbuf = gst_buffer_new (); + GST_BUFFER_DATA (outbuf) = + (gchar *) g_new (gint16, GST_BUFFER_SIZE (buf) / 4); + GST_BUFFER_SIZE (outbuf) = GST_BUFFER_SIZE (buf) / 2; - mulaw_data = (gint8*)GST_BUFFER_DATA(outbuf); - mulaw_encode(linear_data,mulaw_data,GST_BUFFER_SIZE(outbuf)); + mulaw_data = (gint8 *) GST_BUFFER_DATA (outbuf); + mulaw_encode (linear_data, mulaw_data, GST_BUFFER_SIZE (outbuf)); - gst_buffer_unref(buf); - gst_pad_push(mulawenc->srcpad,GST_DATA (outbuf)); + gst_buffer_unref (buf); + gst_pad_push (mulawenc->srcpad, GST_DATA (outbuf)); } static void -gst_mulawenc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +gst_mulawenc_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { GstMuLawEnc *mulawenc; /* it's not null if we got it, but it might not be ours */ - g_return_if_fail(GST_IS_MULAWENC(object)); - mulawenc = GST_MULAWENC(object); + g_return_if_fail (GST_IS_MULAWENC (object)); + mulawenc = GST_MULAWENC (object); switch (prop_id) { default: @@ -186,13 +196,14 @@ gst_mulawenc_set_property (GObject *object, guint prop_id, const GValue *value, } static void -gst_mulawenc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +gst_mulawenc_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstMuLawEnc *mulawenc; /* it's not null if we got it, but it might not be ours */ - g_return_if_fail(GST_IS_MULAWENC(object)); - mulawenc = GST_MULAWENC(object); + g_return_if_fail (GST_IS_MULAWENC (object)); + mulawenc = GST_MULAWENC (object); switch (prop_id) { default: diff --git a/gst/law/mulaw-encode.h b/gst/law/mulaw-encode.h index 6d99759b..2ef39d23 100644 --- a/gst/law/mulaw-encode.h +++ b/gst/law/mulaw-encode.h @@ -27,8 +27,9 @@ #ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +extern "C" +{ +#endif /* __cplusplus */ #define GST_TYPE_MULAWENC \ @@ -42,27 +43,29 @@ extern "C" { #define GST_IS_MULAWENC_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MULAWENC)) -typedef struct _GstMuLawEnc GstMuLawEnc; -typedef struct _GstMuLawEncClass GstMuLawEncClass; + typedef struct _GstMuLawEnc GstMuLawEnc; + typedef struct _GstMuLawEncClass GstMuLawEncClass; -struct _GstMuLawEnc { - GstElement element; + struct _GstMuLawEnc + { + GstElement element; - GstPad *sinkpad,*srcpad; + GstPad *sinkpad, *srcpad; - /*MetaAudioRaw meta; */ + /*MetaAudioRaw meta; */ -}; + }; -struct _GstMuLawEncClass { - GstElementClass parent_class; -}; + struct _GstMuLawEncClass + { + GstElementClass parent_class; + }; -GType gst_mulawenc_get_type(void); + GType gst_mulawenc_get_type (void); #ifdef __cplusplus } -#endif /* __cplusplus */ +#endif /* __cplusplus */ -#endif /* __GST_STEREO_H__ */ +#endif /* __GST_STEREO_H__ */ diff --git a/gst/law/mulaw.c b/gst/law/mulaw.c index 632aa03f..3702aaa6 100644 --- a/gst/law/mulaw.c +++ b/gst/law/mulaw.c @@ -4,66 +4,58 @@ #include "mulaw-encode.h" #include "mulaw-decode.h" -static GstCaps* +static GstCaps * mulaw_factory (void) { return gst_caps_new_simple ("audio/x-mulaw", - "rate", GST_TYPE_INT_RANGE, 8000, 192000, - "channels", GST_TYPE_INT_RANGE, 1, 2, - NULL); + "rate", GST_TYPE_INT_RANGE, 8000, 192000, + "channels", GST_TYPE_INT_RANGE, 1, 2, NULL); } -static GstCaps* +static GstCaps * linear_factory (void) { return gst_caps_new_simple ("audio/x-raw-int", - "width", G_TYPE_INT, 16, - "depth", G_TYPE_INT, 16, + "width", G_TYPE_INT, 16, + "depth", G_TYPE_INT, 16, "endianness", G_TYPE_INT, G_BYTE_ORDER, - "signed", G_TYPE_BOOLEAN, TRUE, - "rate", GST_TYPE_INT_RANGE, 8000, 192000, - "channels", GST_TYPE_INT_RANGE, 1, 2, - NULL); + "signed", G_TYPE_BOOLEAN, TRUE, + "rate", GST_TYPE_INT_RANGE, 8000, 192000, + "channels", GST_TYPE_INT_RANGE, 1, 2, NULL); } GstPadTemplate *mulawenc_src_template, *mulawenc_sink_template; GstPadTemplate *mulawdec_src_template, *mulawdec_sink_template; static gboolean -plugin_init (GstPlugin *plugin) +plugin_init (GstPlugin * plugin) { - GstCaps* mulaw_caps, *linear_caps; + GstCaps *mulaw_caps, *linear_caps; mulaw_caps = mulaw_factory (); linear_caps = linear_factory (); - mulawenc_src_template = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - mulaw_caps); - mulawenc_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - linear_caps); + mulawenc_src_template = + gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, mulaw_caps); + mulawenc_sink_template = + gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, linear_caps); - mulawdec_src_template = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - linear_caps); - mulawdec_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - mulaw_caps); + mulawdec_src_template = + gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, linear_caps); + mulawdec_sink_template = + gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, mulaw_caps); if (!gst_element_register (plugin, "mulawenc", - GST_RANK_NONE, GST_TYPE_MULAWENC) || + GST_RANK_NONE, GST_TYPE_MULAWENC) || !gst_element_register (plugin, "mulawdec", - GST_RANK_PRIMARY, GST_TYPE_MULAWDEC)) + GST_RANK_PRIMARY, GST_TYPE_MULAWDEC)) return FALSE; return TRUE; } -GST_PLUGIN_DEFINE ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "mulaw", - "MuLaw audio conversion routines", - plugin_init, - VERSION, - GST_LICENSE, - GST_PACKAGE, - GST_ORIGIN -) +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "mulaw", + "MuLaw audio conversion routines", + plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN) |