summaryrefslogtreecommitdiffstats
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/arts/gst_arts.c129
-rw-r--r--ext/arts/gst_arts.h31
-rw-r--r--ext/arts/gst_artsio_impl.h14
-rw-r--r--ext/artsd/gstartsdsink.c194
-rw-r--r--ext/artsd/gstartsdsink.h56
-rw-r--r--ext/audiofile/gstaf.c18
-rw-r--r--ext/audiofile/gstafparse.c414
-rw-r--r--ext/audiofile/gstafparse.h104
-rw-r--r--ext/audiofile/gstafsink.c252
-rw-r--r--ext/audiofile/gstafsink.h82
-rw-r--r--ext/audiofile/gstafsrc.c214
-rw-r--r--ext/audiofile/gstafsrc.h86
-rw-r--r--ext/cdaudio/gstcdaudio.c226
-rw-r--r--ext/divx/gstdivxdec.h49
-rw-r--r--ext/divx/gstdivxenc.h65
-rw-r--r--ext/faac/gstfaac.c356
-rw-r--r--ext/faac/gstfaac.h23
-rw-r--r--ext/faad/gstfaad.c259
-rw-r--r--ext/faad/gstfaad.h13
-rw-r--r--ext/gsm/gstgsm.c20
-rw-r--r--ext/gsm/gstgsmdec.c130
-rw-r--r--ext/gsm/gstgsmdec.h39
-rw-r--r--ext/gsm/gstgsmenc.c116
-rw-r--r--ext/gsm/gstgsmenc.h47
-rw-r--r--ext/hermes/gsthermescolorspace.c383
-rw-r--r--ext/ivorbis/vorbis.c24
-rw-r--r--ext/ivorbis/vorbisenc.h82
-rw-r--r--ext/ivorbis/vorbisfile.c694
-rw-r--r--ext/jack/gstjack.c656
-rw-r--r--ext/jack/gstjack.h72
-rw-r--r--ext/jack/gstjackbin.c476
-rw-r--r--ext/ladspa/gstladspa.c820
-rw-r--r--ext/ladspa/gstladspa.h78
-rw-r--r--ext/ladspa/load.c121
-rw-r--r--ext/ladspa/search.c92
-rw-r--r--ext/ladspa/utils.h18
-rw-r--r--ext/lcs/gstcolorspace.c255
-rw-r--r--ext/libfame/gstlibfame.c293
-rw-r--r--ext/libfame/gstlibfame.h69
-rw-r--r--ext/musicbrainz/gsttrm.c230
-rw-r--r--ext/musicbrainz/gsttrm.h59
-rw-r--r--ext/nas/nassink.c604
-rw-r--r--ext/nas/nassink.h68
-rw-r--r--ext/sdl/sdlvideosink.c390
-rw-r--r--ext/sdl/sdlvideosink.h18
-rw-r--r--ext/shout/gstshout.c314
-rw-r--r--ext/shout/gstshout.h67
-rw-r--r--ext/smoothwave/demo-osssrc.c57
-rw-r--r--ext/smoothwave/gstsmoothwave.c202
-rw-r--r--ext/smoothwave/gstsmoothwave.h39
-rw-r--r--ext/snapshot/gstsnapshot.c275
-rw-r--r--ext/snapshot/gstsnapshot.h51
-rw-r--r--ext/sndfile/gstsf.c503
-rw-r--r--ext/sndfile/gstsf.h29
-rw-r--r--ext/swfdec/gstswfdec.c544
-rw-r--r--ext/swfdec/gstswfdec.h65
-rw-r--r--ext/tarkin/bitcoder.h152
-rw-r--r--ext/tarkin/golomb.h134
-rw-r--r--ext/tarkin/gsttarkin.c23
-rw-r--r--ext/tarkin/gsttarkindec.c161
-rw-r--r--ext/tarkin/gsttarkindec.h59
-rw-r--r--ext/tarkin/gsttarkinenc.c166
-rw-r--r--ext/tarkin/gsttarkinenc.h61
-rw-r--r--ext/tarkin/info.c784
-rw-r--r--ext/tarkin/mem.c192
-rw-r--r--ext/tarkin/mem.h9
-rw-r--r--ext/tarkin/rle.h146
-rw-r--r--ext/tarkin/tarkin.c638
-rw-r--r--ext/tarkin/tarkin.h273
-rw-r--r--ext/tarkin/wavelet.c181
-rw-r--r--ext/tarkin/wavelet.h53
-rw-r--r--ext/tarkin/wavelet_coeff.c737
-rw-r--r--ext/tarkin/wavelet_xform.c582
-rw-r--r--ext/tarkin/yuv.c308
-rw-r--r--ext/tarkin/yuv.h17
-rw-r--r--ext/xine/gstxine.h43
-rw-r--r--ext/xine/xine.c65
-rw-r--r--ext/xine/xineaudiodec.c335
-rw-r--r--ext/xine/xineaudiosink.c175
-rw-r--r--ext/xine/xinecaps.c24
-rw-r--r--ext/xine/xineinput.c205
-rw-r--r--ext/xvid/gstxvid.c296
-rw-r--r--ext/xvid/gstxvid.h14
-rw-r--r--ext/xvid/gstxviddec.c251
-rw-r--r--ext/xvid/gstxviddec.h45
-rw-r--r--ext/xvid/gstxvidenc.c346
-rw-r--r--ext/xvid/gstxvidenc.h65
87 files changed, 8554 insertions, 8571 deletions
diff --git a/ext/arts/gst_arts.c b/ext/arts/gst_arts.c
index 196bd7c1..16906e69 100644
--- a/ext/arts/gst_arts.c
+++ b/ext/arts/gst_arts.c
@@ -34,52 +34,46 @@ static GstElementDetails gst_arts_details = {
"Filter/Audio",
"aRts wrapper filter",
"Erik Walthinsen <omega@temple-baptist.com,\n"
- "Stefan Westerfeld <stefan@space.twc.de>",
+ "Stefan Westerfeld <stefan@space.twc.de>",
};
-static GstStaticPadTemplate sink_temp =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ( "audio/x-raw-int, "
- "depth = (int) 16, "
- "width = (int) 16, "
- "signed = (boolean) true, "
- "channels = (int) 2, "
- "endianness = (int) byte_order"
- )
-);
-
-static GstStaticPadTemplate src_temp =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
- "depth = (int) 16, "
- "width = (int) 16, "
- "signed = (boolean) true, "
- "channels = (int) 2, "
- "rate = (int) 44100, "
- "endianness = (int) byte_order"
- )
-);
-
-enum {
+static GstStaticPadTemplate sink_temp = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "depth = (int) 16, "
+ "width = (int) 16, "
+ "signed = (boolean) true, "
+ "channels = (int) 2, " "endianness = (int) byte_order")
+ );
+
+static GstStaticPadTemplate src_temp = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "depth = (int) 16, "
+ "width = (int) 16, "
+ "signed = (boolean) true, "
+ "channels = (int) 2, "
+ "rate = (int) 44100, " "endianness = (int) byte_order")
+ );
+
+enum
+{
ARG_0,
ARG_LAST,
};
-static void gst_arts_base_init (gpointer g_class);
-static void gst_arts_class_init (GstARTSClass *klass);
-static void gst_arts_init (GstARTS *arts);
+static void gst_arts_base_init (gpointer g_class);
+static void gst_arts_class_init (GstARTSClass * klass);
+static void gst_arts_init (GstARTS * arts);
-static void gst_arts_loop (GstElement *element);
+static void gst_arts_loop (GstElement * element);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_arts_signals[LAST_SIGNAL] = { 0 }; */
GType
@@ -89,26 +83,27 @@ gst_arts_get_type (void)
if (!gst_arts_type) {
static const GTypeInfo gst_arts_info = {
- sizeof(GstARTSClass),
+ sizeof (GstARTSClass),
gst_arts_base_init,
NULL,
- (GClassInitFunc)gst_arts_class_init,
+ (GClassInitFunc) gst_arts_class_init,
NULL,
NULL,
- sizeof(GstARTS),
+ sizeof (GstARTS),
0,
- (GInstanceInitFunc)gst_arts_init,
+ (GInstanceInitFunc) gst_arts_init,
};
- gst_arts_type = g_type_register_static(GST_TYPE_ELEMENT, "GstArts", &gst_arts_info, 0);
+ gst_arts_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstArts", &gst_arts_info, 0);
}
return gst_arts_type;
-}
+}
static void
gst_arts_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sink_temp));
gst_element_class_add_pad_template (element_class,
@@ -117,45 +112,47 @@ gst_arts_base_init (gpointer g_class)
}
static void
-gst_arts_class_init (GstARTSClass *klass)
+gst_arts_class_init (GstARTSClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
+ parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
}
static void
-gst_arts_init (GstARTS *arts)
+gst_arts_init (GstARTS * arts)
{
- arts->sinkpad = gst_pad_new_from_template(
- gst_element_get_pad_template (GST_ELEMENT (arts), "sink"), "sink");
- gst_element_add_pad(GST_ELEMENT(arts),arts->sinkpad);
+ arts->sinkpad =
+ gst_pad_new_from_template (gst_element_get_pad_template (GST_ELEMENT
+ (arts), "sink"), "sink");
+ gst_element_add_pad (GST_ELEMENT (arts), arts->sinkpad);
- arts->srcpad = gst_pad_new_from_template(
- gst_element_get_pad_template (GST_ELEMENT (arts), "src"), "src");
- gst_element_add_pad(GST_ELEMENT(arts),arts->srcpad);
+ arts->srcpad =
+ gst_pad_new_from_template (gst_element_get_pad_template (GST_ELEMENT
+ (arts), "src"), "src");
+ gst_element_add_pad (GST_ELEMENT (arts), arts->srcpad);
gst_element_set_loop_function (GST_ELEMENT (arts), gst_arts_loop);
- arts->wrapper = gst_arts_wrapper_new(arts->sinkpad,arts->srcpad);
+ arts->wrapper = gst_arts_wrapper_new (arts->sinkpad, arts->srcpad);
}
static void
-gst_arts_loop (GstElement *element)
+gst_arts_loop (GstElement * element)
{
- GstARTS *arts = (GstARTS*)element;
+ GstARTS *arts = (GstARTS *) element;
g_return_if_fail (arts != NULL);
- gst_arts_wrapper_do(arts->wrapper);
+ gst_arts_wrapper_do (arts->wrapper);
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
if (!gst_element_register (plugin, "gstarts", GST_RANK_NONE, GST_TYPE_ARTS))
return FALSE;
@@ -163,14 +160,8 @@ plugin_init (GstPlugin *plugin)
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "gst_arts",
- "arTs filter wrapper",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "gst_arts",
+ "arTs filter wrapper",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
diff --git a/ext/arts/gst_arts.h b/ext/arts/gst_arts.h
index cf0ead06..ace4f14e 100644
--- a/ext/arts/gst_arts.h
+++ b/ext/arts/gst_arts.h
@@ -28,8 +28,9 @@
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_ARTS \
(gst_arts_get_type())
@@ -42,24 +43,26 @@ extern "C" {
#define GST_IS_ARTS_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ARTS))
-typedef struct _GstARTS GstARTS;
-typedef struct _GstARTSClass GstARTSClass;
+ typedef struct _GstARTS GstARTS;
+ typedef struct _GstARTSClass GstARTSClass;
-struct _GstARTS {
- GstElement element;
+ struct _GstARTS
+ {
+ GstElement element;
- GstPad *sinkpad, *srcpad;
- void *wrapper;
-};
+ GstPad *sinkpad, *srcpad;
+ void *wrapper;
+ };
-struct _GstARTSClass {
- GstElementClass parent_class;
-};
+ struct _GstARTSClass
+ {
+ GstElementClass parent_class;
+ };
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_ARTS_H__ */
+#endif /* __GST_ARTS_H__ */
diff --git a/ext/arts/gst_artsio_impl.h b/ext/arts/gst_artsio_impl.h
index 8ffb29b6..c67fbd2b 100644
--- a/ext/arts/gst_artsio_impl.h
+++ b/ext/arts/gst_artsio_impl.h
@@ -1,14 +1,14 @@
#include <gst/gst.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
-void *gst_arts_wrapper_new(GstPad *sinkpad, GstPad *sourcepad);
-void gst_arts_wrapper_free(void *wrapper);
-void gst_arts_wrapper_do(void *wrapper);
+ void *gst_arts_wrapper_new (GstPad * sinkpad, GstPad * sourcepad);
+ void gst_arts_wrapper_free (void *wrapper);
+ void gst_arts_wrapper_do (void *wrapper);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
-
+#endif /* __cplusplus */
diff --git a/ext/artsd/gstartsdsink.c b/ext/artsd/gstartsdsink.c
index 25ff80c4..8a2f7a32 100644
--- a/ext/artsd/gstartsdsink.c
+++ b/ext/artsd/gstartsdsink.c
@@ -35,42 +35,43 @@ static GstElementDetails artsdsink_details = {
};
/* Signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_MUTE,
ARG_NAME,
};
-static GstStaticPadTemplate sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_AUDIO_INT_PAD_TEMPLATE_CAPS)
-);
-
-static void gst_artsdsink_base_init (gpointer g_class);
-static void gst_artsdsink_class_init (GstArtsdsinkClass *klass);
-static void gst_artsdsink_init (GstArtsdsink *artsdsink);
-
-static gboolean gst_artsdsink_open_audio (GstArtsdsink *sink);
-static void gst_artsdsink_close_audio (GstArtsdsink *sink);
-static GstElementStateReturn gst_artsdsink_change_state (GstElement *element);
-static gboolean gst_artsdsink_sync_parms (GstArtsdsink *artsdsink);
-static GstPadLinkReturn gst_artsdsink_link (GstPad *pad, const GstCaps *caps);
-static void gst_artsdsink_chain (GstPad *pad, GstData *_data);
-
-static void gst_artsdsink_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_artsdsink_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_AUDIO_INT_PAD_TEMPLATE_CAPS)
+ );
+
+static void gst_artsdsink_base_init (gpointer g_class);
+static void gst_artsdsink_class_init (GstArtsdsinkClass * klass);
+static void gst_artsdsink_init (GstArtsdsink * artsdsink);
+
+static gboolean gst_artsdsink_open_audio (GstArtsdsink * sink);
+static void gst_artsdsink_close_audio (GstArtsdsink * sink);
+static GstElementStateReturn gst_artsdsink_change_state (GstElement * element);
+static gboolean gst_artsdsink_sync_parms (GstArtsdsink * artsdsink);
+static GstPadLinkReturn gst_artsdsink_link (GstPad * pad, const GstCaps * caps);
+static void gst_artsdsink_chain (GstPad * pad, GstData * _data);
+
+static void gst_artsdsink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_artsdsink_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_artsdsink_signals[LAST_SIGNAL] = { 0 }; */
GType
@@ -80,17 +81,19 @@ gst_artsdsink_get_type (void)
if (!artsdsink_type) {
static const GTypeInfo artsdsink_info = {
- sizeof(GstArtsdsinkClass),
+ sizeof (GstArtsdsinkClass),
gst_artsdsink_base_init,
NULL,
- (GClassInitFunc)gst_artsdsink_class_init,
+ (GClassInitFunc) gst_artsdsink_class_init,
NULL,
NULL,
- sizeof(GstArtsdsink),
+ sizeof (GstArtsdsink),
0,
- (GInstanceInitFunc)gst_artsdsink_init,
+ (GInstanceInitFunc) gst_artsdsink_init,
};
- artsdsink_type = g_type_register_static(GST_TYPE_ELEMENT, "GstArtsdsink", &artsdsink_info, 0);
+ artsdsink_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstArtsdsink",
+ &artsdsink_info, 0);
}
return artsdsink_type;
}
@@ -106,23 +109,19 @@ gst_artsdsink_base_init (gpointer g_class)
}
static void
-gst_artsdsink_class_init (GstArtsdsinkClass *klass)
+gst_artsdsink_class_init (GstArtsdsinkClass * 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);
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_MUTE,
- g_param_spec_boolean("mute","mute","mute",
- TRUE,G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MUTE, g_param_spec_boolean ("mute", "mute", "mute", TRUE, G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_NAME,
- g_param_spec_string("name","name","name",
- NULL, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NAME, g_param_spec_string ("name", "name", "name", NULL, G_PARAM_READWRITE)); /* CHECKME */
gobject_class->set_property = gst_artsdsink_set_property;
gobject_class->get_property = gst_artsdsink_get_property;
@@ -131,13 +130,14 @@ gst_artsdsink_class_init (GstArtsdsinkClass *klass)
}
static void
-gst_artsdsink_init(GstArtsdsink *artsdsink)
+gst_artsdsink_init (GstArtsdsink * artsdsink)
{
- artsdsink->sinkpad = gst_pad_new_from_template (
- gst_element_get_pad_template (GST_ELEMENT (artsdsink), "sink"), "sink");
- gst_element_add_pad(GST_ELEMENT(artsdsink), artsdsink->sinkpad);
- gst_pad_set_chain_function(artsdsink->sinkpad, gst_artsdsink_chain);
- gst_pad_set_link_function(artsdsink->sinkpad, gst_artsdsink_link);
+ artsdsink->sinkpad =
+ gst_pad_new_from_template (gst_element_get_pad_template (GST_ELEMENT
+ (artsdsink), "sink"), "sink");
+ gst_element_add_pad (GST_ELEMENT (artsdsink), artsdsink->sinkpad);
+ gst_pad_set_chain_function (artsdsink->sinkpad, gst_artsdsink_chain);
+ gst_pad_set_link_function (artsdsink->sinkpad, gst_artsdsink_link);
artsdsink->connected = FALSE;
artsdsink->mute = FALSE;
@@ -145,12 +145,13 @@ gst_artsdsink_init(GstArtsdsink *artsdsink)
}
static gboolean
-gst_artsdsink_sync_parms (GstArtsdsink *artsdsink)
+gst_artsdsink_sync_parms (GstArtsdsink * artsdsink)
{
g_return_val_if_fail (artsdsink != NULL, FALSE);
g_return_val_if_fail (GST_IS_ARTSDSINK (artsdsink), FALSE);
- if (!artsdsink->connected) return TRUE;
+ if (!artsdsink->connected)
+ return TRUE;
/* Need to set stream to use new parameters: only way to do this is to reopen. */
gst_artsdsink_close_audio (artsdsink);
@@ -158,7 +159,7 @@ gst_artsdsink_sync_parms (GstArtsdsink *artsdsink)
}
static GstPadLinkReturn
-gst_artsdsink_link (GstPad *pad, const GstCaps *caps)
+gst_artsdsink_link (GstPad * pad, const GstCaps * caps)
{
GstArtsdsink *artsdsink = GST_ARTSDSINK (gst_pad_get_parent (pad));
GstStructure *structure;
@@ -176,30 +177,32 @@ gst_artsdsink_link (GstPad *pad, const GstCaps *caps)
}
static void
-gst_artsdsink_chain (GstPad *pad, GstData *_data)
+gst_artsdsink_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstArtsdsink *artsdsink;
- 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);
artsdsink = GST_ARTSDSINK (gst_pad_get_parent (pad));
if (GST_BUFFER_DATA (buf) != NULL) {
- gst_trace_add_entry(NULL, 0, GPOINTER_TO_INT(buf), "artsdsink: writing to server");
+ gst_trace_add_entry (NULL, 0, GPOINTER_TO_INT (buf),
+ "artsdsink: writing to server");
if (!artsdsink->mute && artsdsink->connected) {
int bytes;
- void * bufptr = GST_BUFFER_DATA (buf);
+ void *bufptr = GST_BUFFER_DATA (buf);
int bufsize = GST_BUFFER_SIZE (buf);
+
GST_DEBUG ("artsdsink: stream=%p data=%p size=%d",
- artsdsink->stream, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
+ artsdsink->stream, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
do {
bytes = arts_write (artsdsink->stream, bufptr, bufsize);
- if(bytes < 0) {
- fprintf(stderr,"arts_write error: %s\n", arts_error_text(bytes));
+ if (bytes < 0) {
+ fprintf (stderr, "arts_write error: %s\n", arts_error_text (bytes));
gst_buffer_unref (buf);
return;
}
@@ -212,24 +215,26 @@ gst_artsdsink_chain (GstPad *pad, GstData *_data)
}
static void
-gst_artsdsink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_artsdsink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstArtsdsink *artsdsink;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_ARTSDSINK(object));
- artsdsink = GST_ARTSDSINK(object);
+ g_return_if_fail (GST_IS_ARTSDSINK (object));
+ artsdsink = GST_ARTSDSINK (object);
switch (prop_id) {
case ARG_MUTE:
artsdsink->mute = g_value_get_boolean (value);
break;
case ARG_NAME:
- if (artsdsink->connect_name != NULL) g_free(artsdsink->connect_name);
+ if (artsdsink->connect_name != NULL)
+ g_free (artsdsink->connect_name);
if (g_value_get_string (value) == NULL)
- artsdsink->connect_name = NULL;
+ artsdsink->connect_name = NULL;
else
- artsdsink->connect_name = g_strdup (g_value_get_string (value));
+ artsdsink->connect_name = g_strdup (g_value_get_string (value));
break;
default:
break;
@@ -237,13 +242,14 @@ gst_artsdsink_set_property (GObject *object, guint prop_id, const GValue *value,
}
static void
-gst_artsdsink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_artsdsink_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstArtsdsink *artsdsink;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_ARTSDSINK(object));
- artsdsink = GST_ARTSDSINK(object);
+ g_return_if_fail (GST_IS_ARTSDSINK (object));
+ artsdsink = GST_ARTSDSINK (object);
switch (prop_id) {
case ARG_MUTE:
@@ -259,46 +265,42 @@ gst_artsdsink_get_property (GObject *object, guint prop_id, GValue *value, GPara
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- if (!gst_element_register (plugin, "artsdsink", GST_RANK_NONE, GST_TYPE_ARTSDSINK))
+ if (!gst_element_register (plugin, "artsdsink", GST_RANK_NONE,
+ GST_TYPE_ARTSDSINK))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "artsdsink",
- "Plays audio to an aRts server",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "artsdsink",
+ "Plays audio to an aRts server",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
-static gboolean
-gst_artsdsink_open_audio (GstArtsdsink *sink)
+ static gboolean gst_artsdsink_open_audio (GstArtsdsink * sink)
{
- const char * connname = "gstreamer";
+ const char *connname = "gstreamer";
int errcode;
/* Name used by aRtsd for this connection. */
- if (sink->connect_name != NULL) connname = sink->connect_name;
+ if (sink->connect_name != NULL)
+ connname = sink->connect_name;
/* FIXME: this should only ever happen once per process. */
/* Really, artsc needs to be made thread safe to fix this (and other related */
/* problems). */
- errcode = arts_init();
- if(errcode < 0) {
- fprintf(stderr,"arts_init error: %s\n", arts_error_text(errcode));
- return FALSE;
+ errcode = arts_init ();
+ if (errcode < 0) {
+ fprintf (stderr, "arts_init error: %s\n", arts_error_text (errcode));
+ return FALSE;
}
GST_DEBUG ("artsdsink: attempting to open connection to aRtsd server");
- sink->stream = arts_play_stream(sink->frequency, sink->depth,
- sink->channels, connname);
+ sink->stream = arts_play_stream (sink->frequency, sink->depth,
+ sink->channels, connname);
/* FIXME: check connection */
/* GST_DEBUG ("artsdsink: can't open connection to aRtsd server"); */
@@ -309,20 +311,21 @@ gst_artsdsink_open_audio (GstArtsdsink *sink)
}
static void
-gst_artsdsink_close_audio (GstArtsdsink *sink)
+gst_artsdsink_close_audio (GstArtsdsink * sink)
{
- if (!sink->connected) return;
+ if (!sink->connected)
+ return;
- arts_close_stream(sink->stream);
- arts_free();
+ arts_close_stream (sink->stream);
+ arts_free ();
GST_FLAG_UNSET (sink, GST_ARTSDSINK_OPEN);
sink->connected = FALSE;
- g_print("artsdsink: closed connection\n");
+ g_print ("artsdsink: closed connection\n");
}
static GstElementStateReturn
-gst_artsdsink_change_state (GstElement *element)
+gst_artsdsink_change_state (GstElement * element)
{
g_return_val_if_fail (GST_IS_ARTSDSINK (element), FALSE);
@@ -342,4 +345,3 @@ gst_artsdsink_change_state (GstElement *element)
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
return GST_STATE_SUCCESS;
}
-
diff --git a/ext/artsd/gstartsdsink.h b/ext/artsd/gstartsdsink.h
index 6cece273..53968568 100644
--- a/ext/artsd/gstartsdsink.h
+++ b/ext/artsd/gstartsdsink.h
@@ -25,8 +25,9 @@
#include <artsc.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_ARTSDSINK \
@@ -40,39 +41,42 @@ extern "C" {
#define GST_IS_ARTSDSINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ARTSDSINK))
-typedef enum {
- GST_ARTSDSINK_OPEN = GST_ELEMENT_FLAG_LAST,
- GST_ARTSDSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST+2,
-} GstArtsdSinkFlags;
+ typedef enum
+ {
+ GST_ARTSDSINK_OPEN = GST_ELEMENT_FLAG_LAST,
+ GST_ARTSDSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
+ } GstArtsdSinkFlags;
-typedef struct _GstArtsdsink GstArtsdsink;
-typedef struct _GstArtsdsinkClass GstArtsdsinkClass;
+ typedef struct _GstArtsdsink GstArtsdsink;
+ typedef struct _GstArtsdsinkClass GstArtsdsinkClass;
-struct _GstArtsdsink {
- GstElement element;
+ struct _GstArtsdsink
+ {
+ GstElement element;
- GstPad *sinkpad;
+ GstPad *sinkpad;
- gboolean connected;
- arts_stream_t stream;
- gboolean mute;
- gboolean signd;
- gint depth;
- gint channels;
- gint frequency;
- gchar* connect_name;
-};
+ gboolean connected;
+ arts_stream_t stream;
+ gboolean mute;
+ gboolean signd;
+ gint depth;
+ gint channels;
+ gint frequency;
+ gchar *connect_name;
+ };
-struct _GstArtsdsinkClass {
- GstElementClass parent_class;
-};
+ struct _GstArtsdsinkClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_artsdsink_get_type(void);
+ GType gst_artsdsink_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_ARTSDSINK_H__ */
+#endif /* __GST_ARTSDSINK_H__ */
diff --git a/ext/audiofile/gstaf.c b/ext/audiofile/gstaf.c
index 188caf42..79979a22 100644
--- a/ext/audiofile/gstaf.c
+++ b/ext/audiofile/gstaf.c
@@ -25,10 +25,10 @@
#include "gstafsink.h"
#include "gstafparse.h"
-gboolean gst_aftypes_plugin_init (GstPlugin *plugin);
+gboolean gst_aftypes_plugin_init (GstPlugin * plugin);
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
if (!gst_library_load ("gstbytestream"))
return FALSE;
@@ -40,13 +40,7 @@ plugin_init (GstPlugin *plugin)
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "gstaf",
- "Audiofile plugin",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "gstaf",
+ "Audiofile plugin", plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
diff --git a/ext/audiofile/gstafparse.c b/ext/audiofile/gstafparse.c
index 179dd849..00c9fd81 100644
--- a/ext/audiofile/gstafparse.c
+++ b/ext/audiofile/gstafparse.c
@@ -39,65 +39,64 @@ static GstElementDetails afparse_details = {
/* AFParse signals and args */
-enum {
+enum
+{
/* FILL ME */
SIGNAL_HANDOFF,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
};
/* added a src factory function to force audio/raw MIME type */
static GstStaticPadTemplate afparse_src_factory =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "audio/x-raw-int, "
- "rate = (int) [ 1, MAX ], "
- "channels = (int) [ 1, MAX ], "
- "endianness = (int) BYTE_ORDER, "
- "width = (int) { 8, 16 }, "
- "depth = (int) { 8, 16 }, "
- "signed = (boolean) { true, false }, "
- "buffer-frames = (int) [ 1, MAX ]"
- )
-);
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "rate = (int) [ 1, MAX ], "
+ "channels = (int) [ 1, MAX ], "
+ "endianness = (int) BYTE_ORDER, "
+ "width = (int) { 8, 16 }, "
+ "depth = (int) { 8, 16 }, "
+ "signed = (boolean) { true, false }, "
+ "buffer-frames = (int) [ 1, MAX ]")
+ );
static GstStaticPadTemplate afparse_sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "audio/x-aiff; "
- "audio/x-wav; "
- "audio/x-au"
- )
-);
+ GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-aiff; " "audio/x-wav; " "audio/x-au")
+ );
static void gst_afparse_base_init (gpointer g_class);
-static void gst_afparse_class_init(GstAFParseClass *klass);
-static void gst_afparse_init (GstAFParse *afparse);
-
-static gboolean gst_afparse_open_file(GstAFParse *afparse);
-static void gst_afparse_close_file(GstAFParse *afparse);
-
-static void gst_afparse_loop(GstElement *element);
-static void gst_afparse_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_afparse_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
-static ssize_t gst_afparse_vf_read (AFvirtualfile *vfile, void *data, size_t nbytes);
-static long gst_afparse_vf_length (AFvirtualfile *vfile);
-static ssize_t gst_afparse_vf_write (AFvirtualfile *vfile, const void *data, size_t nbytes);
-static void gst_afparse_vf_destroy(AFvirtualfile *vfile);
-static long gst_afparse_vf_seek (AFvirtualfile *vfile, long offset, int is_relative);
-static long gst_afparse_vf_tell (AFvirtualfile *vfile);
+static void gst_afparse_class_init (GstAFParseClass * klass);
+static void gst_afparse_init (GstAFParse * afparse);
+
+static gboolean gst_afparse_open_file (GstAFParse * afparse);
+static void gst_afparse_close_file (GstAFParse * afparse);
+
+static void gst_afparse_loop (GstElement * element);
+static void gst_afparse_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_afparse_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+static ssize_t gst_afparse_vf_read (AFvirtualfile * vfile, void *data,
+ size_t nbytes);
+static long gst_afparse_vf_length (AFvirtualfile * vfile);
+static ssize_t gst_afparse_vf_write (AFvirtualfile * vfile, const void *data,
+ size_t nbytes);
+static void gst_afparse_vf_destroy (AFvirtualfile * vfile);
+static long gst_afparse_vf_seek (AFvirtualfile * vfile, long offset,
+ int is_relative);
+static long gst_afparse_vf_tell (AFvirtualfile * vfile);
GType
-gst_afparse_get_type (void)
+gst_afparse_get_type (void)
{
static GType afparse_type = 0;
@@ -113,7 +112,9 @@ gst_afparse_get_type (void)
0,
(GInstanceInitFunc) gst_afparse_init,
};
- afparse_type = g_type_register_static (GST_TYPE_ELEMENT, "GstAFParse", &afparse_info, 0);
+ afparse_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstAFParse", &afparse_info,
+ 0);
}
return afparse_type;
}
@@ -132,34 +133,36 @@ gst_afparse_base_init (gpointer g_class)
}
static void
-gst_afparse_class_init (GstAFParseClass *klass)
+gst_afparse_class_init (GstAFParseClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
gobject_class->set_property = gst_afparse_set_property;
gobject_class->get_property = gst_afparse_get_property;
}
-static void
-gst_afparse_init (GstAFParse *afparse)
+static void
+gst_afparse_init (GstAFParse * afparse)
{
- afparse->srcpad = gst_pad_new_from_template (
- gst_element_get_pad_template (GST_ELEMENT (afparse), "src"), "src");
+ afparse->srcpad =
+ gst_pad_new_from_template (gst_element_get_pad_template (GST_ELEMENT
+ (afparse), "src"), "src");
gst_pad_use_explicit_caps (afparse->srcpad);
gst_element_add_pad (GST_ELEMENT (afparse), afparse->srcpad);
- afparse->sinkpad = gst_pad_new_from_template (
- gst_element_get_pad_template (GST_ELEMENT (afparse), "sink"), "sink");
+ afparse->sinkpad =
+ gst_pad_new_from_template (gst_element_get_pad_template (GST_ELEMENT
+ (afparse), "sink"), "sink");
gst_element_add_pad (GST_ELEMENT (afparse), afparse->sinkpad);
gst_element_set_loop_function (GST_ELEMENT (afparse), gst_afparse_loop);
- afparse->vfile = af_virtual_file_new();
+ afparse->vfile = af_virtual_file_new ();
afparse->vfile->closure = NULL;
afparse->vfile->read = gst_afparse_vf_read;
afparse->vfile->length = gst_afparse_vf_length;
@@ -184,7 +187,7 @@ gst_afparse_init (GstAFParse *afparse)
}
static void
-gst_afparse_loop(GstElement *element)
+gst_afparse_loop (GstElement * element)
{
GstAFParse *afparse;
GstBuffer *buf;
@@ -194,14 +197,14 @@ gst_afparse_loop(GstElement *element)
GstByteStream *bs;
int s_format, v_format, s_width, v_width;
- afparse = GST_AFPARSE(element);
+ afparse = GST_AFPARSE (element);
afparse->vfile->closure = bs = gst_bytestream_new (afparse->sinkpad);
/* just stop if we cannot open the file */
- if (!gst_afparse_open_file (afparse)){
+ if (!gst_afparse_open_file (afparse)) {
gst_bytestream_destroy ((GstByteStream *) afparse->vfile->closure);
- gst_pad_push (afparse->srcpad, GST_DATA(gst_event_new (GST_EVENT_EOS)));
+ gst_pad_push (afparse->srcpad, GST_DATA (gst_event_new (GST_EVENT_EOS)));
gst_element_set_eos (GST_ELEMENT (afparse));
return;
}
@@ -209,91 +212,91 @@ gst_afparse_loop(GstElement *element)
/* if audiofile changes the data in any way, we have to access
* the audio data via afReadFrames. Otherwise we can just access
* the data directly. */
- afGetSampleFormat(afparse->file, AF_DEFAULT_TRACK, &s_format, &s_width);
- afGetVirtualSampleFormat(afparse->file, AF_DEFAULT_TRACK, &v_format, &v_width);
- if (afGetCompression != AF_COMPRESSION_NONE ||
- afGetByteOrder(afparse->file, AF_DEFAULT_TRACK) != afGetVirtualByteOrder(afparse->file, AF_DEFAULT_TRACK) ||
- s_format != v_format ||
- s_width != v_width) {
+ afGetSampleFormat (afparse->file, AF_DEFAULT_TRACK, &s_format, &s_width);
+ afGetVirtualSampleFormat (afparse->file, AF_DEFAULT_TRACK, &v_format,
+ &v_width);
+ if (afGetCompression != AF_COMPRESSION_NONE
+ || afGetByteOrder (afparse->file,
+ AF_DEFAULT_TRACK) != afGetVirtualByteOrder (afparse->file,
+ AF_DEFAULT_TRACK) || s_format != v_format || s_width != v_width) {
bypass_afread = FALSE;
}
- if (bypass_afread){
- GST_DEBUG("will bypass afReadFrames\n");
+ if (bypass_afread) {
+ GST_DEBUG ("will bypass afReadFrames\n");
}
-
+
frames_to_bytes = afparse->channels * afparse->width / 8;
frames_per_read = afparse->frames_per_read;
bytes_per_read = frames_per_read * frames_to_bytes;
-
- afSeekFrame(afparse->file, AF_DEFAULT_TRACK, 0);
- if (bypass_afread){
- GstEvent *event = NULL;
- guint32 waiting;
- guint32 got_bytes;
+ afSeekFrame (afparse->file, AF_DEFAULT_TRACK, 0);
+
+ if (bypass_afread) {
+ GstEvent *event = NULL;
+ guint32 waiting;
+ guint32 got_bytes;
do {
got_bytes = gst_bytestream_read (bs, &buf, bytes_per_read);
if (got_bytes == 0) {
- /* we need to check for an event. */
- gst_bytestream_get_status (bs, &waiting, &event);
- if (event && GST_EVENT_TYPE(event) == GST_EVENT_EOS) {
- gst_pad_push (afparse->srcpad,
- GST_DATA (gst_event_new (GST_EVENT_EOS)));
- gst_element_set_eos (GST_ELEMENT (afparse));
- break;
- }
- }
- else {
- GST_BUFFER_TIMESTAMP(buf) = afparse->timestamp;
- gst_pad_push (afparse->srcpad, GST_DATA (buf));
- if (got_bytes != bytes_per_read){
+ /* we need to check for an event. */
+ gst_bytestream_get_status (bs, &waiting, &event);
+ if (event && GST_EVENT_TYPE (event) == GST_EVENT_EOS) {
+ gst_pad_push (afparse->srcpad,
+ GST_DATA (gst_event_new (GST_EVENT_EOS)));
+ gst_element_set_eos (GST_ELEMENT (afparse));
+ break;
+ }
+ } else {
+ GST_BUFFER_TIMESTAMP (buf) = afparse->timestamp;
+ gst_pad_push (afparse->srcpad, GST_DATA (buf));
+ if (got_bytes != bytes_per_read) {
/* this shouldn't happen very often */
/* FIXME calculate the timestamps based on the fewer bytes received */
- }
- else {
- afparse->timestamp += frames_per_read * 1E9 / afparse->rate;
+ } else {
+ afparse->timestamp += frames_per_read * 1E9 / afparse->rate;
}
}
}
while (TRUE);
- }
- else {
+ } else {
do {
buf = gst_buffer_new_and_alloc (bytes_per_read);
- GST_BUFFER_TIMESTAMP(buf) = afparse->timestamp;
- data = GST_BUFFER_DATA(buf);
- numframes = afReadFrames (afparse->file, AF_DEFAULT_TRACK, data, frames_per_read);
+ GST_BUFFER_TIMESTAMP (buf) = afparse->timestamp;
+ data = GST_BUFFER_DATA (buf);
+ numframes =
+ afReadFrames (afparse->file, AF_DEFAULT_TRACK, data, frames_per_read);
/* events are handled in gst_afparse_vf_read so if there are no
* frames it must be EOS */
- if (numframes < 1){
- gst_buffer_unref(buf);
+ if (numframes < 1) {
+ gst_buffer_unref (buf);
- gst_pad_push (afparse->srcpad, GST_DATA(gst_event_new (GST_EVENT_EOS)));
- gst_element_set_eos (GST_ELEMENT (afparse));
- break;
+ gst_pad_push (afparse->srcpad,
+ GST_DATA (gst_event_new (GST_EVENT_EOS)));
+ gst_element_set_eos (GST_ELEMENT (afparse));
+ break;
}
- GST_BUFFER_SIZE(buf) = numframes * frames_to_bytes;
+ GST_BUFFER_SIZE (buf) = numframes * frames_to_bytes;
gst_pad_push (afparse->srcpad, GST_DATA (buf));
afparse->timestamp += numframes * 1E9 / afparse->rate;
}
while (TRUE);
}
gst_afparse_close_file (afparse);
-
- gst_bytestream_destroy ((GstByteStream*) afparse->vfile->closure);
+
+ gst_bytestream_destroy ((GstByteStream *) afparse->vfile->closure);
}
static void
-gst_afparse_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
+gst_afparse_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstAFParse *afparse;
@@ -306,16 +309,16 @@ gst_afparse_set_property (GObject *object, guint prop_id,
}
}
-static void
-gst_afparse_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+static void
+gst_afparse_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
GstAFParse *afparse;
-
+
g_return_if_fail (GST_IS_AFPARSE (object));
-
+
afparse = GST_AFPARSE (object);
-
+
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -324,13 +327,14 @@ gst_afparse_get_property (GObject *object, guint prop_id,
}
gboolean
-gst_afparse_plugin_init (GstPlugin *plugin)
+gst_afparse_plugin_init (GstPlugin * plugin)
{
- /* load audio support library */
+ /* load audio support library */
if (!gst_library_load ("gstaudio"))
return FALSE;
- if (!gst_element_register (plugin, "afparse", GST_RANK_NONE, GST_TYPE_AFPARSE))
+ if (!gst_element_register (plugin, "afparse", GST_RANK_NONE,
+ GST_TYPE_AFPARSE))
return FALSE;
return TRUE;
@@ -338,60 +342,56 @@ gst_afparse_plugin_init (GstPlugin *plugin)
/* this is where we open the audiofile */
static gboolean
-gst_afparse_open_file (GstAFParse *afparse)
+gst_afparse_open_file (GstAFParse * afparse)
{
g_return_val_if_fail (!GST_FLAG_IS_SET (afparse, GST_AFPARSE_OPEN), FALSE);
/* open the file */
- GST_DEBUG("opening vfile %p\n", afparse->vfile);
+ GST_DEBUG ("opening vfile %p\n", afparse->vfile);
afparse->file = afOpenVirtualFile (afparse->vfile, "r", AF_NULL_FILESETUP);
- if (afparse->file == AF_NULL_FILEHANDLE)
- {
+ if (afparse->file == AF_NULL_FILEHANDLE) {
/* this should never happen */
g_warning ("ERROR: gstafparse: Could not open virtual file for reading\n");
return FALSE;
}
- GST_DEBUG("vfile opened\n");
+ GST_DEBUG ("vfile opened\n");
/* get the audiofile audio parameters */
{
int sampleFormat, sampleWidth;
+
afparse->channels = afGetChannels (afparse->file, AF_DEFAULT_TRACK);
- afGetSampleFormat (afparse->file, AF_DEFAULT_TRACK,
- &sampleFormat, &sampleWidth);
- switch (sampleFormat)
- {
+ afGetSampleFormat (afparse->file, AF_DEFAULT_TRACK,
+ &sampleFormat, &sampleWidth);
+ switch (sampleFormat) {
case AF_SAMPFMT_TWOSCOMP:
- afparse->is_signed = TRUE;
- break;
+ afparse->is_signed = TRUE;
+ break;
case AF_SAMPFMT_UNSIGNED:
- afparse->is_signed = FALSE;
- break;
+ afparse->is_signed = FALSE;
+ break;
case AF_SAMPFMT_FLOAT:
case AF_SAMPFMT_DOUBLE:
- GST_DEBUG ("ERROR: float data not supported yet !\n");
+ GST_DEBUG ("ERROR: float data not supported yet !\n");
}
afparse->rate = (guint) afGetRate (afparse->file, AF_DEFAULT_TRACK);
afparse->width = sampleWidth;
- GST_DEBUG (
- "input file: %d channels, %d width, %d rate, signed %s\n",
- afparse->channels, afparse->width, afparse->rate,
- afparse->is_signed ? "yes" : "no");
+ GST_DEBUG ("input file: %d channels, %d width, %d rate, signed %s\n",
+ afparse->channels, afparse->width, afparse->rate,
+ afparse->is_signed ? "yes" : "no");
}
-
+
/* set caps on src */
- /*FIXME: add all the possible formats, especially float ! */
- gst_pad_set_explicit_caps (afparse->srcpad,
- gst_caps_new_simple (
- "audio/x-raw-int",
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "signed", G_TYPE_BOOLEAN, afparse->is_signed,
- "width", G_TYPE_INT, afparse->width,
- "depth", G_TYPE_INT, afparse->width,
- "rate", G_TYPE_INT, afparse->rate,
- "channels", G_TYPE_INT, afparse->channels,
- NULL));
+ /*FIXME: add all the possible formats, especially float ! */
+ gst_pad_set_explicit_caps (afparse->srcpad,
+ gst_caps_new_simple ("audio/x-raw-int",
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "signed", G_TYPE_BOOLEAN, afparse->is_signed,
+ "width", G_TYPE_INT, afparse->width,
+ "depth", G_TYPE_INT, afparse->width,
+ "rate", G_TYPE_INT, afparse->rate,
+ "channels", G_TYPE_INT, afparse->channels, NULL));
GST_FLAG_SET (afparse, GST_AFPARSE_OPEN);
@@ -399,126 +399,124 @@ gst_afparse_open_file (GstAFParse *afparse)
}
static void
-gst_afparse_close_file (GstAFParse *afparse)
+gst_afparse_close_file (GstAFParse * afparse)
{
g_return_if_fail (GST_FLAG_IS_SET (afparse, GST_AFPARSE_OPEN));
- if (afCloseFile (afparse->file) != 0)
- {
+ if (afCloseFile (afparse->file) != 0) {
g_warning ("afparse: oops, error closing !\n");
- }
- else {
+ } else {
GST_FLAG_UNSET (afparse, GST_AFPARSE_OPEN);
}
}
-static ssize_t
-gst_afparse_vf_read (AFvirtualfile *vfile, void *data, size_t nbytes)
+static ssize_t
+gst_afparse_vf_read (AFvirtualfile * vfile, void *data, size_t nbytes)
{
- GstByteStream *bs = (GstByteStream*)vfile->closure;
- guint8 *bytes = NULL;
- GstEvent *event = NULL;
- guint32 waiting;
- guint32 got_bytes;
- /*gchar *debug_str;*/
-
- got_bytes = gst_bytestream_peek_bytes(bs, &bytes, nbytes);
-
- while (got_bytes != nbytes){
+ GstByteStream *bs = (GstByteStream *) vfile->closure;
+ guint8 *bytes = NULL;
+ GstEvent *event = NULL;
+ guint32 waiting;
+ guint32 got_bytes;
+
+ /*gchar *debug_str; */
+
+ got_bytes = gst_bytestream_peek_bytes (bs, &bytes, nbytes);
+
+ while (got_bytes != nbytes) {
/* handle events */
gst_bytestream_get_status (bs, &waiting, &event);
/* FIXME this event handling isn't right yet */
- if (!event){
- /*g_print("no event found with %u bytes\n", got_bytes);*/
+ if (!event) {
+ /*g_print("no event found with %u bytes\n", got_bytes); */
return 0;
}
- switch (GST_EVENT_TYPE(event)) {
+ switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
- return 0;
+ return 0;
case GST_EVENT_FLUSH:
- GST_DEBUG("flush");
- break;
+ GST_DEBUG ("flush");
+ break;
case GST_EVENT_DISCONTINUOUS:
- GST_DEBUG("seek done");
- got_bytes = gst_bytestream_peek_bytes(bs, &bytes, nbytes);
- break;
+ GST_DEBUG ("seek done");
+ got_bytes = gst_bytestream_peek_bytes (bs, &bytes, nbytes);
+ break;
default:
- g_warning("unknown event %d", GST_EVENT_TYPE(event));
- got_bytes = gst_bytestream_peek_bytes(bs, &bytes, nbytes);
+ g_warning ("unknown event %d", GST_EVENT_TYPE (event));
+ got_bytes = gst_bytestream_peek_bytes (bs, &bytes, nbytes);
}
}
-
- memcpy(data, bytes, got_bytes);
- gst_bytestream_flush_fast(bs, got_bytes);
+
+ memcpy (data, bytes, got_bytes);
+ gst_bytestream_flush_fast (bs, got_bytes);
/* debug_str = g_strndup((gchar*)bytes, got_bytes);
- g_print("read %u bytes: %s\n", got_bytes, debug_str);
- */
+ g_print("read %u bytes: %s\n", got_bytes, debug_str);
+ */
return got_bytes;
}
-static long
-gst_afparse_vf_seek (AFvirtualfile *vfile, long offset, int is_relative)
+static long
+gst_afparse_vf_seek (AFvirtualfile * vfile, long offset, int is_relative)
{
- GstByteStream *bs = (GstByteStream*)vfile->closure;
+ GstByteStream *bs = (GstByteStream *) vfile->closure;
GstSeekType method;
- guint64 current_offset = gst_bytestream_tell(bs);
+ guint64 current_offset = gst_bytestream_tell (bs);
- if (!is_relative){
- if ((guint64)offset == current_offset) {
+ if (!is_relative) {
+ if ((guint64) offset == current_offset) {
/* this seems to happen before every read - bad audiofile */
return offset;
}
method = GST_SEEK_METHOD_SET;
+ } else {
+ if (offset == 0)
+ return current_offset;
+ method = GST_SEEK_METHOD_CUR;
}
- else {
- if (offset == 0) return current_offset;
- method = GST_SEEK_METHOD_CUR;
- }
-
- if (gst_bytestream_seek(bs, (gint64)offset, method)){
- GST_DEBUG("doing seek to %d", (gint)offset);
+
+ if (gst_bytestream_seek (bs, (gint64) offset, method)) {
+ GST_DEBUG ("doing seek to %d", (gint) offset);
return offset;
}
return 0;
}
-static long
-gst_afparse_vf_length (AFvirtualfile *vfile)
+static long
+gst_afparse_vf_length (AFvirtualfile * vfile)
{
- GstByteStream *bs = (GstByteStream*)vfile->closure;
+ GstByteStream *bs = (GstByteStream *) vfile->closure;
guint64 length;
- length = gst_bytestream_length(bs);
- GST_DEBUG("doing length: %" G_GUINT64_FORMAT, length);
+ length = gst_bytestream_length (bs);
+ GST_DEBUG ("doing length: %" G_GUINT64_FORMAT, length);
return length;
}
-static ssize_t
-gst_afparse_vf_write (AFvirtualfile *vfile, const void *data, size_t nbytes)
+static ssize_t
+gst_afparse_vf_write (AFvirtualfile * vfile, const void *data, size_t nbytes)
{
- /* GstByteStream *bs = (GstByteStream*)vfile->closure;*/
- g_warning("shouldn't write to a readonly pad");
+ /* GstByteStream *bs = (GstByteStream*)vfile->closure; */
+ g_warning ("shouldn't write to a readonly pad");
return 0;
}
-static void
-gst_afparse_vf_destroy(AFvirtualfile *vfile)
+static void
+gst_afparse_vf_destroy (AFvirtualfile * vfile)
{
- /* GstByteStream *bs = (GstByteStream*)vfile->closure;*/
+ /* GstByteStream *bs = (GstByteStream*)vfile->closure; */
- GST_DEBUG("doing destroy");
+ GST_DEBUG ("doing destroy");
}
-static long
-gst_afparse_vf_tell (AFvirtualfile *vfile)
+static long
+gst_afparse_vf_tell (AFvirtualfile * vfile)
{
- GstByteStream *bs = (GstByteStream*)vfile->closure;
+ GstByteStream *bs = (GstByteStream *) vfile->closure;
guint64 offset;
- offset = gst_bytestream_tell(bs);
- GST_DEBUG("doing tell: %" G_GUINT64_FORMAT, offset);
+ offset = gst_bytestream_tell (bs);
+ GST_DEBUG ("doing tell: %" G_GUINT64_FORMAT, offset);
return offset;
}
-
diff --git a/ext/audiofile/gstafparse.h b/ext/audiofile/gstafparse.h
index 0f636dcd..941b427b 100644
--- a/ext/audiofile/gstafparse.h
+++ b/ext/audiofile/gstafparse.h
@@ -27,13 +27,14 @@
#include <gst/gst.h>
#include <gst/bytestream/bytestream.h>
-#include <audiofile.h> /* what else are we to do */
+#include <audiofile.h> /* what else are we to do */
#include <af_vfs.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
/*GstElementDetails gst_afparse_details;*/
@@ -50,55 +51,58 @@ extern "C" {
#define GST_IS_AFPARSE_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AFPARSE))
-typedef struct _GstAFParse GstAFParse;
-typedef struct _GstAFParseClass GstAFParseClass;
-
-typedef enum {
- GST_AFPARSE_OPEN = GST_ELEMENT_FLAG_LAST,
-
- GST_AFPARSE_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
-} GstAFParseFlags;
-
-struct _GstAFParse {
- GstElement element;
- GstPad *srcpad;
- GstPad *sinkpad;
-
- AFvirtualfile *vfile;
- AFfilehandle file;
- int format;
- int channels;
- int width;
- unsigned int rate;
- gboolean is_signed;
- int type; /* type of output, compare to audiofile.h
- * RAW, AIFF, AIFFC, NEXTSND, WAVE
- */
- /* blocking */
- gulong curoffset;
- gulong bytes_per_read;
- gint frames_per_read;
-
- gulong seq;
- gint64 timestamp;
- /* FIXME : endianness is a little cryptic at this point */
- int endianness_data; /* 4321 or 1234 */
- int endianness_wanted; /* same thing, but what the output format wants */
- int endianness_output; /* what the output endianness will be */
-};
-
-struct _GstAFParseClass {
- GstElementClass parent_class;
-
- /* signals */
- void (*handoff) (GstElement *element,GstPad *pad);
-};
-
-gboolean gst_afparse_plugin_init (GstPlugin *plugin);
+ typedef struct _GstAFParse GstAFParse;
+ typedef struct _GstAFParseClass GstAFParseClass;
+
+ typedef enum
+ {
+ GST_AFPARSE_OPEN = GST_ELEMENT_FLAG_LAST,
+
+ GST_AFPARSE_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
+ } GstAFParseFlags;
+
+ struct _GstAFParse
+ {
+ GstElement element;
+ GstPad *srcpad;
+ GstPad *sinkpad;
+
+ AFvirtualfile *vfile;
+ AFfilehandle file;
+ int format;
+ int channels;
+ int width;
+ unsigned int rate;
+ gboolean is_signed;
+ int type; /* type of output, compare to audiofile.h
+ * RAW, AIFF, AIFFC, NEXTSND, WAVE
+ */
+ /* blocking */
+ gulong curoffset;
+ gulong bytes_per_read;
+ gint frames_per_read;
+
+ gulong seq;
+ gint64 timestamp;
+ /* FIXME : endianness is a little cryptic at this point */
+ int endianness_data; /* 4321 or 1234 */
+ int endianness_wanted; /* same thing, but what the output format wants */
+ int endianness_output; /* what the output endianness will be */
+ };
+
+ struct _GstAFParseClass
+ {
+ GstElementClass parent_class;
+
+ /* signals */
+ void (*handoff) (GstElement * element, GstPad * pad);
+ };
+
+ gboolean gst_afparse_plugin_init (GstPlugin * plugin);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_AFPARSE_H__ */
+#endif /* __GST_AFPARSE_H__ */
diff --git a/ext/audiofile/gstafsink.c b/ext/audiofile/gstafsink.c
index 515ae4e2..eeac509f 100644
--- a/ext/audiofile/gstafsink.c
+++ b/ext/audiofile/gstafsink.c
@@ -43,13 +43,15 @@ static GstElementDetails afsink_details = {
/* AFSink signals and args */
-enum {
+enum
+{
/* FILL ME */
SIGNAL_HANDOFF,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_TYPE,
ARG_OUTPUT_ENDIANNESS,
@@ -59,68 +61,66 @@ enum {
/* added a sink factory function to force audio/raw MIME type */
/* I think the caps can be broader, we need to change that somehow */
static GstStaticPadTemplate afsink_sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
- "rate = (int) [ 1, MAX ], "
- "channels = (int) [ 1, 2 ], "
- "endianness = (int) BYTE_ORDER, "
- "width = (int) { 8, 16 }, "
- "depth = (int) { 8, 16 }, "
- "signed = (boolean) { true, false }, "
- "buffer-frames = (int) [ 1, MAX ]"
- )
-);
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "rate = (int) [ 1, MAX ], "
+ "channels = (int) [ 1, 2 ], "
+ "endianness = (int) BYTE_ORDER, "
+ "width = (int) { 8, 16 }, "
+ "depth = (int) { 8, 16 }, "
+ "signed = (boolean) { true, false }, "
+ "buffer-frames = (int) [ 1, MAX ]")
+ );
/* we use an enum for the output type arg */
#define GST_TYPE_AFSINK_TYPES (gst_afsink_types_get_type())
/* FIXME: fix the string ints to be string-converted from the audiofile.h types */
static GType
-gst_afsink_types_get_type (void)
+gst_afsink_types_get_type (void)
{
static GType afsink_types_type = 0;
static GEnumValue afsink_types[] = {
{AF_FILE_RAWDATA, "0", "raw PCM"},
- {AF_FILE_AIFFC, "1", "AIFFC"},
- {AF_FILE_AIFF, "2", "AIFF"},
+ {AF_FILE_AIFFC, "1", "AIFFC"},
+ {AF_FILE_AIFF, "2", "AIFF"},
{AF_FILE_NEXTSND, "3", "Next/SND"},
- {AF_FILE_WAVE, "4", "Wave"},
+ {AF_FILE_WAVE, "4", "Wave"},
{0, NULL, NULL},
};
-
- if (!afsink_types_type)
- {
- afsink_types_type = g_enum_register_static ("GstAudiosinkTypes", afsink_types);
+
+ if (!afsink_types_type) {
+ afsink_types_type =
+ g_enum_register_static ("GstAudiosinkTypes", afsink_types);
}
return afsink_types_type;
}
-static void gst_afsink_base_init (gpointer g_class);
-static void gst_afsink_class_init (GstAFSinkClass *klass);
-static void gst_afsink_init (GstAFSink *afsink);
+static void gst_afsink_base_init (gpointer g_class);
+static void gst_afsink_class_init (GstAFSinkClass * klass);
+static void gst_afsink_init (GstAFSink * afsink);
-static gboolean gst_afsink_open_file (GstAFSink *sink);
-static void gst_afsink_close_file (GstAFSink *sink);
+static gboolean gst_afsink_open_file (GstAFSink * sink);
+static void gst_afsink_close_file (GstAFSink * sink);
-static void gst_afsink_chain (GstPad *pad,GstData *_data);
+static void gst_afsink_chain (GstPad * pad, GstData * _data);
-static void gst_afsink_set_property (GObject *object, guint prop_id, const GValue *value,
- GParamSpec *pspec);
-static void gst_afsink_get_property (GObject *object, guint prop_id, GValue *value,
- GParamSpec *pspec);
+static void gst_afsink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_afsink_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static gboolean gst_afsink_handle_event (GstPad *pad, GstEvent *event);
+static gboolean gst_afsink_handle_event (GstPad * pad, GstEvent * event);
-static GstElementStateReturn gst_afsink_change_state (GstElement *element);
+static GstElementStateReturn gst_afsink_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
static guint gst_afsink_signals[LAST_SIGNAL] = { 0 };
GType
-gst_afsink_get_type (void)
+gst_afsink_get_type (void)
{
static GType afsink_type = 0;
@@ -136,7 +136,8 @@ gst_afsink_get_type (void)
0,
(GInstanceInitFunc) gst_afsink_init,
};
- afsink_type = g_type_register_static (GST_TYPE_ELEMENT, "GstAFSink", &afsink_info, 0);
+ afsink_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstAFSink", &afsink_info, 0);
}
return afsink_type;
}
@@ -152,32 +153,26 @@ gst_afsink_base_init (gpointer g_class)
}
static void
-gst_afsink_class_init (GstAFSinkClass *klass)
+gst_afsink_class_init (GstAFSinkClass * 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);
- gst_element_class_install_std_props (
- GST_ELEMENT_CLASS (klass),
- "location", ARG_LOCATION, G_PARAM_READWRITE,
- NULL);
-
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_TYPE,
- g_param_spec_enum("type","type","type",
- GST_TYPE_AFSINK_TYPES,0,G_PARAM_READWRITE)); /* CHECKME! */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_OUTPUT_ENDIANNESS,
- g_param_spec_int("endianness","endianness","endianness",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */
-
+ gst_element_class_install_std_props (GST_ELEMENT_CLASS (klass),
+ "location", ARG_LOCATION, G_PARAM_READWRITE, NULL);
+
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TYPE, g_param_spec_enum ("type", "type", "type", GST_TYPE_AFSINK_TYPES, 0, G_PARAM_READWRITE)); /* CHECKME! */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_OUTPUT_ENDIANNESS, g_param_spec_int ("endianness", "endianness", "endianness", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
+
gst_afsink_signals[SIGNAL_HANDOFF] =
- g_signal_new ("handoff", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstAFSinkClass, handoff), NULL, NULL,
- g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstAFSinkClass, handoff), NULL, NULL,
+ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gobject_class->set_property = gst_afsink_set_property;
@@ -186,13 +181,14 @@ gst_afsink_class_init (GstAFSinkClass *klass)
gstelement_class->change_state = gst_afsink_change_state;
}
-static void
-gst_afsink_init (GstAFSink *afsink)
+static void
+gst_afsink_init (GstAFSink * afsink)
{
/* GstPad *pad; this is now done in the struct */
- afsink->sinkpad = gst_pad_new_from_template (
- gst_element_get_pad_template (GST_ELEMENT (afsink), "sink"), "sink");
+ afsink->sinkpad =
+ gst_pad_new_from_template (gst_element_get_pad_template (GST_ELEMENT
+ (afsink), "sink"), "sink");
gst_element_add_pad (GST_ELEMENT (afsink), afsink->sinkpad);
gst_pad_set_chain_function (afsink->sinkpad, gst_afsink_chain);
@@ -209,7 +205,8 @@ gst_afsink_init (GstAFSink *afsink)
}
static void
-gst_afsink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_afsink_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstAFSink *sink;
@@ -220,15 +217,14 @@ gst_afsink_set_property (GObject *object, guint prop_id, const GValue *value, GP
case ARG_LOCATION:
/* the element must be stopped or paused in order to do this */
g_return_if_fail ((GST_STATE (sink) < GST_STATE_PLAYING)
- || (GST_STATE (sink) == GST_STATE_PAUSED));
+ || (GST_STATE (sink) == GST_STATE_PAUSED));
if (sink->filename)
g_free (sink->filename);
sink->filename = g_strdup (g_value_get_string (value));
- if ( (GST_STATE (sink) == GST_STATE_PAUSED)
- && (sink->filename != NULL))
- {
- gst_afsink_close_file (sink);
- gst_afsink_open_file (sink);
+ if ((GST_STATE (sink) == GST_STATE_PAUSED)
+ && (sink->filename != NULL)) {
+ gst_afsink_close_file (sink);
+ gst_afsink_open_file (sink);
}
break;
@@ -236,27 +232,29 @@ gst_afsink_set_property (GObject *object, guint prop_id, const GValue *value, GP
sink->type = g_value_get_enum (value);
break;
case ARG_OUTPUT_ENDIANNESS:
- {
- int end = g_value_get_int (value);
- if (end == 1234 || end == 4321)
- sink->endianness_output = end;
- }
+ {
+ int end = g_value_get_int (value);
+
+ if (end == 1234 || end == 4321)
+ sink->endianness_output = end;
+ }
break;
default:
break;
}
}
-static void
-gst_afsink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+static void
+gst_afsink_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstAFSink *sink;
-
+
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_AFSINK (object));
-
+
sink = GST_AFSINK (object);
-
+
switch (prop_id) {
case ARG_LOCATION:
g_value_set_string (value, sink->filename);
@@ -274,7 +272,7 @@ gst_afsink_get_property (GObject *object, guint prop_id, GValue *value, GParamSp
}
gboolean
-gst_afsink_plugin_init (GstPlugin *plugin)
+gst_afsink_plugin_init (GstPlugin * plugin)
{
if (!gst_element_register (plugin, "afsink", GST_RANK_NONE, GST_TYPE_AFSINK))
return FALSE;
@@ -288,35 +286,34 @@ gst_afsink_plugin_init (GstPlugin *plugin)
/* this is where we open the audiofile */
static gboolean
-gst_afsink_open_file (GstAFSink *sink)
+gst_afsink_open_file (GstAFSink * sink)
{
AFfilesetup outfilesetup;
const GstCaps *caps;
GstStructure *structure;
- int sample_format; /* audiofile's sample format, look in audiofile.h */
- int byte_order = 0; /* audiofile's byte order defines */
-
+ int sample_format; /* audiofile's sample format, look in audiofile.h */
+ int byte_order = 0; /* audiofile's byte order defines */
+
g_return_val_if_fail (!GST_FLAG_IS_SET (sink, GST_AFSINK_OPEN), FALSE);
/* get the audio parameters */
g_return_val_if_fail (GST_IS_PAD (sink->sinkpad), FALSE);
caps = GST_PAD_CAPS (sink->sinkpad);
-
+
if (caps == NULL) {
g_critical ("gstafsink chain : Could not get caps of pad !\n");
} else {
structure = gst_caps_get_structure (caps, 0);
- gst_structure_get_int (structure, "channels", &sink->channels);
- gst_structure_get_int (structure, "width", &sink->width);
- gst_structure_get_int (structure, "rate", &sink->rate);
+ gst_structure_get_int (structure, "channels", &sink->channels);
+ gst_structure_get_int (structure, "width", &sink->width);
+ gst_structure_get_int (structure, "rate", &sink->rate);
gst_structure_get_boolean (structure, "signed", &sink->is_signed);
gst_structure_get_int (structure, "endianness", &sink->endianness_data);
}
GST_DEBUG ("channels %d, width %d, rate %d, signed %s",
- sink->channels, sink->width, sink->rate,
- sink->is_signed ? "yes" : "no");
- GST_DEBUG ("endianness: data %d, output %d",
- sink->endianness_data, sink->endianness_output);
+ sink->channels, sink->width, sink->rate, sink->is_signed ? "yes" : "no");
+ GST_DEBUG ("endianness: data %d, output %d",
+ sink->endianness_data, sink->endianness_output);
/* setup the output file */
if (sink->is_signed)
sample_format = AF_SAMPFMT_TWOSCOMP;
@@ -324,11 +321,11 @@ gst_afsink_open_file (GstAFSink *sink)
sample_format = AF_SAMPFMT_UNSIGNED;
/* FIXME : this check didn't seem to work, so let the output endianness be set */
/*
- if (sink->endianness_data == sink->endianness_wanted)
- byte_order = AF_BYTEORDER_LITTLEENDIAN;
- else
- byte_order = AF_BYTEORDER_BIGENDIAN;
- */
+ if (sink->endianness_data == sink->endianness_wanted)
+ byte_order = AF_BYTEORDER_LITTLEENDIAN;
+ else
+ byte_order = AF_BYTEORDER_BIGENDIAN;
+ */
if (sink->endianness_output == 1234)
byte_order = AF_BYTEORDER_LITTLEENDIAN;
else
@@ -338,41 +335,37 @@ gst_afsink_open_file (GstAFSink *sink)
afInitFileFormat (outfilesetup, sink->type);
afInitChannels (outfilesetup, AF_DEFAULT_TRACK, sink->channels);
afInitRate (outfilesetup, AF_DEFAULT_TRACK, sink->rate);
- afInitSampleFormat (outfilesetup, AF_DEFAULT_TRACK,
- sample_format, sink->width);
+ afInitSampleFormat (outfilesetup, AF_DEFAULT_TRACK,
+ sample_format, sink->width);
/* open it */
sink->file = afOpenFile (sink->filename, "w", outfilesetup);
- if (sink->file == AF_NULL_FILEHANDLE)
- {
- GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
- (_("Could not open file \"%s\" for writing."), sink->filename),
- ("system error: %s", strerror (errno)));
+ if (sink->file == AF_NULL_FILEHANDLE) {
+ GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
+ (_("Could not open file \"%s\" for writing."), sink->filename),
+ ("system error: %s", strerror (errno)));
return FALSE;
- }
+ }
afFreeFileSetup (outfilesetup);
/* afSetVirtualByteOrder (sink->file, AF_DEFAULT_TRACK, byte_order); */
-
+
GST_FLAG_SET (sink, GST_AFSINK_OPEN);
return TRUE;
}
static void
-gst_afsink_close_file (GstAFSink *sink)
+gst_afsink_close_file (GstAFSink * sink)
{
/* g_print ("DEBUG: closing sinkfile...\n"); */
g_return_if_fail (GST_FLAG_IS_SET (sink, GST_AFSINK_OPEN));
/* g_print ("DEBUG: past flag test\n"); */
/* if (fclose (sink->file) != 0) */
- if (afCloseFile (sink->file) != 0)
- {
+ if (afCloseFile (sink->file) != 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE,
- (_("Error closing file \"%s\"."), sink->filename),
- GST_ERROR_SYSTEM);
- }
- else {
+ (_("Error closing file \"%s\"."), sink->filename), GST_ERROR_SYSTEM);
+ } else {
GST_FLAG_UNSET (sink, GST_AFSINK_OPEN);
}
}
@@ -384,8 +377,8 @@ gst_afsink_close_file (GstAFSink *sink)
*
* take the buffer from the pad and write to file if it's open
*/
-static void
-gst_afsink_chain (GstPad *pad, GstData *_data)
+static void
+gst_afsink_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf;
GstAFSink *afsink;
@@ -413,24 +406,22 @@ gst_afsink_chain (GstPad *pad, GstData *_data)
}
*/
- if (!GST_FLAG_IS_SET (afsink, GST_AFSINK_OPEN))
- {
+ if (!GST_FLAG_IS_SET (afsink, GST_AFSINK_OPEN)) {
/* it's not open yet, open it */
if (!gst_afsink_open_file (afsink))
- g_print ("WARNING: gstafsink: can't open file !\n");
+ g_print ("WARNING: gstafsink: can't open file !\n");
/* return FALSE; Can't return value */
}
- if (GST_FLAG_IS_SET (afsink, GST_AFSINK_OPEN))
- {
+ if (GST_FLAG_IS_SET (afsink, GST_AFSINK_OPEN)) {
int frameCount = 0;
- frameCount = GST_BUFFER_SIZE (buf) / ((afsink->width / 8) * afsink->channels);
- /* g_print ("DEBUG: writing %d frames ", frameCount); */
- ret = afWriteFrames (afsink->file, AF_DEFAULT_TRACK,
- GST_BUFFER_DATA (buf), frameCount);
- if (ret == AF_BAD_WRITE || ret == AF_BAD_LSEEK)
- {
+ frameCount =
+ GST_BUFFER_SIZE (buf) / ((afsink->width / 8) * afsink->channels);
+ /* g_print ("DEBUG: writing %d frames ", frameCount); */
+ ret = afWriteFrames (afsink->file, AF_DEFAULT_TRACK,
+ GST_BUFFER_DATA (buf), frameCount);
+ if (ret == AF_BAD_WRITE || ret == AF_BAD_LSEEK) {
printf ("afsink : Warning : afWriteFrames returned an error (%d)\n", ret);
}
}
@@ -441,20 +432,18 @@ gst_afsink_chain (GstPad *pad, GstData *_data)
}
static GstElementStateReturn
-gst_afsink_change_state (GstElement *element)
+gst_afsink_change_state (GstElement * element)
{
g_return_val_if_fail (GST_IS_AFSINK (element), GST_STATE_FAILURE);
/* if going to NULL? then close the file */
- if (GST_STATE_PENDING (element) == GST_STATE_NULL)
- {
+ if (GST_STATE_PENDING (element) == GST_STATE_NULL) {
/* printf ("DEBUG: afsink state change: null pending\n"); */
- if (GST_FLAG_IS_SET (element, GST_AFSINK_OPEN))
- {
+ if (GST_FLAG_IS_SET (element, GST_AFSINK_OPEN)) {
/* g_print ("DEBUG: trying to close the sink file\n"); */
gst_afsink_close_file (GST_AFSINK (element));
}
- }
+ }
/*
else
@@ -483,7 +472,7 @@ gst_afsink_change_state (GstElement *element)
/* this function was copied from sinesrc */
static gboolean
-gst_afsink_handle_event (GstPad *pad, GstEvent *event)
+gst_afsink_handle_event (GstPad * pad, GstEvent * event)
{
GstAFSink *afsink;
@@ -515,4 +504,3 @@ gst_afsink_factory_init (GstElementFactory *factory)
}
*/
-
diff --git a/ext/audiofile/gstafsink.h b/ext/audiofile/gstafsink.h
index 76ce30af..4e894ee7 100644
--- a/ext/audiofile/gstafsink.h
+++ b/ext/audiofile/gstafsink.h
@@ -26,12 +26,13 @@
#include <gst/gst.h>
-#include <audiofile.h> /* what else are we to do */
+#include <audiofile.h> /* what else are we to do */
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
/*GstElementDetails gst_afsink_details;*/
@@ -48,53 +49,56 @@ extern "C" {
#define GST_IS_AFSINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AFSINK))
-typedef struct _GstAFSink GstAFSink;
-typedef struct _GstAFSinkClass GstAFSinkClass;
+ typedef struct _GstAFSink GstAFSink;
+ typedef struct _GstAFSinkClass GstAFSinkClass;
-typedef enum {
- GST_AFSINK_OPEN = GST_ELEMENT_FLAG_LAST,
+ typedef enum
+ {
+ GST_AFSINK_OPEN = GST_ELEMENT_FLAG_LAST,
- GST_AFSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
-} GstAFSinkFlags;
+ GST_AFSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
+ } GstAFSinkFlags;
-struct _GstAFSink {
- GstElement element;
- GstPad *sinkpad;
+ struct _GstAFSink
+ {
+ GstElement element;
+ GstPad *sinkpad;
- gchar *filename;
+ gchar *filename;
/* FILE *file; */
/* AFfilesetup outfilesetup; */
- AFfilehandle file;
- int format;
- int channels;
- int width;
- unsigned int rate;
- gboolean is_signed;
- int type; /* type of output, compare to audiofile.h
- * RAW, AIFF, AIFFC, NEXTSND, WAVE
- */
- /* FIXME : endianness is a little cryptic at this point */
- int endianness_data; /* 4321 or 1234 */
- int endianness_wanted; /* same thing, but what the output format wants */
- int endianness_output; /* what the output endianness will be */
-};
-
-struct _GstAFSinkClass {
- GstElementClass parent_class;
-
- /* signals */
- void (*handoff) (GstElement *element,GstPad *pad);
-};
-
-GType gst_afsink_get_type (void);
-gboolean gst_afsink_plugin_init (GstPlugin *plugin);
+ AFfilehandle file;
+ int format;
+ int channels;
+ int width;
+ unsigned int rate;
+ gboolean is_signed;
+ int type; /* type of output, compare to audiofile.h
+ * RAW, AIFF, AIFFC, NEXTSND, WAVE
+ */
+ /* FIXME : endianness is a little cryptic at this point */
+ int endianness_data; /* 4321 or 1234 */
+ int endianness_wanted; /* same thing, but what the output format wants */
+ int endianness_output; /* what the output endianness will be */
+ };
+
+ struct _GstAFSinkClass
+ {
+ GstElementClass parent_class;
+
+ /* signals */
+ void (*handoff) (GstElement * element, GstPad * pad);
+ };
+
+ GType gst_afsink_get_type (void);
+ gboolean gst_afsink_plugin_init (GstPlugin * plugin);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_AFSINK_H__ */
+#endif /* __GST_AFSINK_H__ */
diff --git a/ext/audiofile/gstafsrc.c b/ext/audiofile/gstafsrc.c
index 5d6bc1cd..98a2d38b 100644
--- a/ext/audiofile/gstafsrc.c
+++ b/ext/audiofile/gstafsrc.c
@@ -43,34 +43,33 @@ static GstElementDetails afsrc_details = {
/* AFSrc signals and args */
-enum {
+enum
+{
/* FILL ME */
SIGNAL_HANDOFF,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_LOCATION
};
/* added a src factory function to force audio/raw MIME type */
/* I think the caps can be broader, we need to change that somehow */
-static GstStaticPadTemplate afsrc_src_factory =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
- "rate = (int) [ 1, MAX ], "
- "channels = (int) [ 1, MAX ], "
- "endianness = (int) BYTE_ORDER, "
- "width = (int) { 8, 16 }, "
- "depth = (int) { 8, 16 }, "
- "signed = (boolean) { true, false }, "
- "buffer-frames = (int) [ 1, MAX ]"
- )
-);
+static GstStaticPadTemplate afsrc_src_factory = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "rate = (int) [ 1, MAX ], "
+ "channels = (int) [ 1, MAX ], "
+ "endianness = (int) BYTE_ORDER, "
+ "width = (int) { 8, 16 }, "
+ "depth = (int) { 8, 16 }, "
+ "signed = (boolean) { true, false }, "
+ "buffer-frames = (int) [ 1, MAX ]")
+ );
/* we use an enum for the output type arg */
@@ -98,27 +97,27 @@ gst_afsrc_types_get_type (void)
return afsrc_types_type;
}
*/
-static void gst_afsrc_base_init (gpointer g_class);
-static void gst_afsrc_class_init (GstAFSrcClass *klass);
-static void gst_afsrc_init (GstAFSrc *afsrc);
+static void gst_afsrc_base_init (gpointer g_class);
+static void gst_afsrc_class_init (GstAFSrcClass * klass);
+static void gst_afsrc_init (GstAFSrc * afsrc);
-static gboolean gst_afsrc_open_file (GstAFSrc *src);
-static void gst_afsrc_close_file (GstAFSrc *src);
+static gboolean gst_afsrc_open_file (GstAFSrc * src);
+static void gst_afsrc_close_file (GstAFSrc * src);
-static GstData* gst_afsrc_get (GstPad *pad);
+static GstData *gst_afsrc_get (GstPad * pad);
-static void gst_afsrc_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_afsrc_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_afsrc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_afsrc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static GstElementStateReturn gst_afsrc_change_state (GstElement *element);
+static GstElementStateReturn gst_afsrc_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
static guint gst_afsrc_signals[LAST_SIGNAL] = { 0 };
GType
-gst_afsrc_get_type (void)
+gst_afsrc_get_type (void)
{
static GType afsrc_type = 0;
@@ -134,7 +133,8 @@ gst_afsrc_get_type (void)
0,
(GInstanceInitFunc) gst_afsrc_init,
};
- afsrc_type = g_type_register_static (GST_TYPE_ELEMENT, "GstAFSrc", &afsrc_info, 0);
+ afsrc_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstAFSrc", &afsrc_info, 0);
}
return afsrc_type;
}
@@ -150,25 +150,23 @@ gst_afsrc_base_init (gpointer g_class)
}
static void
-gst_afsrc_class_init (GstAFSrcClass *klass)
+gst_afsrc_class_init (GstAFSrcClass * 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);
- gst_element_class_install_std_props (
- GST_ELEMENT_CLASS (klass),
- "location", ARG_LOCATION, G_PARAM_READWRITE,
- NULL);
-
+ gst_element_class_install_std_props (GST_ELEMENT_CLASS (klass),
+ "location", ARG_LOCATION, G_PARAM_READWRITE, NULL);
+
gst_afsrc_signals[SIGNAL_HANDOFF] =
- g_signal_new ("handoff", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstAFSrcClass, handoff), NULL, NULL,
- g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstAFSrcClass, handoff), NULL, NULL,
+ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gobject_class->set_property = gst_afsrc_set_property;
@@ -177,12 +175,13 @@ gst_afsrc_class_init (GstAFSrcClass *klass)
gstelement_class->change_state = gst_afsrc_change_state;
}
-static void
-gst_afsrc_init (GstAFSrc *afsrc)
+static void
+gst_afsrc_init (GstAFSrc * afsrc)
{
/* no need for a template, caps are set based on file, right ? */
- afsrc->srcpad = gst_pad_new_from_template (
- gst_element_get_pad_template (GST_ELEMENT (afsrc), "src"), "src");
+ afsrc->srcpad =
+ gst_pad_new_from_template (gst_element_get_pad_template (GST_ELEMENT
+ (afsrc), "src"), "src");
gst_element_add_pad (GST_ELEMENT (afsrc), afsrc->srcpad);
gst_pad_use_explicit_caps (afsrc->srcpad);
gst_pad_set_get_function (afsrc->srcpad, gst_afsrc_get);
@@ -204,7 +203,7 @@ gst_afsrc_init (GstAFSrc *afsrc)
}
static GstData *
-gst_afsrc_get (GstPad *pad)
+gst_afsrc_get (GstPad * pad)
{
GstAFSrc *src;
GstBuffer *buf;
@@ -217,21 +216,21 @@ gst_afsrc_get (GstPad *pad)
buf = gst_buffer_new ();
g_return_val_if_fail (buf, NULL);
-
+
GST_BUFFER_DATA (buf) = (gpointer) g_malloc (src->bytes_per_read);
-
+
/* calculate frameCount to read based on file info */
frameCount = src->bytes_per_read / (src->channels * src->width / 8);
/* g_print ("DEBUG: gstafsrc: going to read %ld frames\n", frameCount); */
readframes = afReadFrames (src->file, AF_DEFAULT_TRACK, GST_BUFFER_DATA (buf),
- frameCount);
+ frameCount);
readbytes = readframes * (src->channels * src->width / 8);
if (readbytes == 0) {
gst_element_set_eos (GST_ELEMENT (src));
- return GST_DATA (gst_event_new (GST_EVENT_EOS));
+ return GST_DATA (gst_event_new (GST_EVENT_EOS));
}
-
+
GST_BUFFER_SIZE (buf) = readbytes;
GST_BUFFER_OFFSET (buf) = src->curoffset;
@@ -239,16 +238,17 @@ gst_afsrc_get (GstPad *pad)
src->framestamp += gst_audio_frame_length (src->srcpad, buf);
GST_BUFFER_TIMESTAMP (buf) = src->framestamp * 1E9
- / gst_audio_frame_rate (src->srcpad);
+ / gst_audio_frame_rate (src->srcpad);
printf ("DEBUG: afsrc: timestamp set on output buffer: %f sec\n",
- GST_BUFFER_TIMESTAMP (buf) / 1E9);
+ GST_BUFFER_TIMESTAMP (buf) / 1E9);
/* g_print("DEBUG: gstafsrc: pushed buffer of %ld bytes\n", readbytes); */
return GST_DATA (buf);
}
static void
-gst_afsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_afsrc_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstAFSrc *src;
@@ -266,16 +266,17 @@ gst_afsrc_set_property (GObject *object, guint prop_id, const GValue *value, GPa
}
}
-static void
-gst_afsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+static void
+gst_afsrc_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstAFSrc *src;
-
+
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_AFSRC (object));
-
+
src = GST_AFSRC (object);
-
+
switch (prop_id) {
case ARG_LOCATION:
g_value_set_string (value, src->filename);
@@ -287,7 +288,7 @@ gst_afsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpe
}
gboolean
-gst_afsrc_plugin_init (GstPlugin *plugin)
+gst_afsrc_plugin_init (GstPlugin * plugin)
{
/* load audio support library */
if (!gst_library_load ("gstaudio"))
@@ -307,57 +308,52 @@ gst_afsrc_plugin_init (GstPlugin *plugin)
/* this is where we open the audiofile */
static gboolean
-gst_afsrc_open_file (GstAFSrc *src)
+gst_afsrc_open_file (GstAFSrc * src)
{
g_return_val_if_fail (!GST_FLAG_IS_SET (src, GST_AFSRC_OPEN), FALSE);
/* open the file */
src->file = afOpenFile (src->filename, "r", AF_NULL_FILESETUP);
- if (src->file == AF_NULL_FILEHANDLE)
- {
- GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
- (_("Could not open file \"%s\" for reading."), src->filename),
- ("system error: %s", strerror (errno)));
+ if (src->file == AF_NULL_FILEHANDLE) {
+ GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
+ (_("Could not open file \"%s\" for reading."), src->filename),
+ ("system error: %s", strerror (errno)));
return FALSE;
}
/* get the audiofile audio parameters */
{
int sampleFormat, sampleWidth;
+
src->channels = afGetChannels (src->file, AF_DEFAULT_TRACK);
- afGetSampleFormat (src->file, AF_DEFAULT_TRACK,
- &sampleFormat, &sampleWidth);
- switch (sampleFormat)
- {
- case AF_SAMPFMT_TWOSCOMP:
- src->is_signed = TRUE;
- break;
- case AF_SAMPFMT_UNSIGNED:
- src->is_signed = FALSE;
- break;
- case AF_SAMPFMT_FLOAT:
- case AF_SAMPFMT_DOUBLE:
- GST_DEBUG (
- "ERROR: float data not supported yet !\n");
- }
- src->rate = (guint) afGetRate (src->file, AF_DEFAULT_TRACK);
+ afGetSampleFormat (src->file, AF_DEFAULT_TRACK,
+ &sampleFormat, &sampleWidth);
+ switch (sampleFormat) {
+ case AF_SAMPFMT_TWOSCOMP:
+ src->is_signed = TRUE;
+ break;
+ case AF_SAMPFMT_UNSIGNED:
+ src->is_signed = FALSE;
+ break;
+ case AF_SAMPFMT_FLOAT:
+ case AF_SAMPFMT_DOUBLE:
+ GST_DEBUG ("ERROR: float data not supported yet !\n");
+ }
+ src->rate = (guint) afGetRate (src->file, AF_DEFAULT_TRACK);
src->width = sampleWidth;
- GST_DEBUG (
- "input file: %d channels, %d width, %d rate, signed %s\n",
- src->channels, src->width, src->rate,
- src->is_signed ? "yes" : "no");
+ GST_DEBUG ("input file: %d channels, %d width, %d rate, signed %s\n",
+ src->channels, src->width, src->rate, src->is_signed ? "yes" : "no");
}
-
+
/* set caps on src */
- gst_pad_set_explicit_caps (src->srcpad,
+ gst_pad_set_explicit_caps (src->srcpad,
gst_caps_new_simple ("audio/x-raw-int",
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "signed", G_TYPE_BOOLEAN, src->is_signed,
- "width", G_TYPE_INT, src->width,
- "depth", G_TYPE_INT, src->width,
- "rate", G_TYPE_INT, src->rate,
- "channels", G_TYPE_INT, src->channels,
- NULL));
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "signed", G_TYPE_BOOLEAN, src->is_signed,
+ "width", G_TYPE_INT, src->width,
+ "depth", G_TYPE_INT, src->width,
+ "rate", G_TYPE_INT, src->rate,
+ "channels", G_TYPE_INT, src->channels, NULL));
GST_FLAG_SET (src, GST_AFSRC_OPEN);
@@ -365,47 +361,39 @@ gst_afsrc_open_file (GstAFSrc *src)
}
static void
-gst_afsrc_close_file (GstAFSrc *src)
+gst_afsrc_close_file (GstAFSrc * src)
{
/* g_print ("DEBUG: closing srcfile...\n"); */
g_return_if_fail (GST_FLAG_IS_SET (src, GST_AFSRC_OPEN));
/* g_print ("DEBUG: past flag test\n"); */
/* if (fclose (src->file) != 0) */
- if (afCloseFile (src->file) != 0)
- {
+ if (afCloseFile (src->file) != 0) {
GST_ELEMENT_ERROR (src, RESOURCE, CLOSE,
- (_("Error closing file \"%s\"."), src->filename),
- GST_ERROR_SYSTEM);
+ (_("Error closing file \"%s\"."), src->filename), GST_ERROR_SYSTEM);
} else {
GST_FLAG_UNSET (src, GST_AFSRC_OPEN);
}
}
static GstElementStateReturn
-gst_afsrc_change_state (GstElement *element)
+gst_afsrc_change_state (GstElement * element)
{
g_return_val_if_fail (GST_IS_AFSRC (element), GST_STATE_FAILURE);
/* if going to NULL then close the file */
- if (GST_STATE_PENDING (element) == GST_STATE_NULL)
- {
+ if (GST_STATE_PENDING (element) == GST_STATE_NULL) {
/* printf ("DEBUG: afsrc state change: null pending\n"); */
- if (GST_FLAG_IS_SET (element, GST_AFSRC_OPEN))
- {
+ if (GST_FLAG_IS_SET (element, GST_AFSRC_OPEN)) {
/* g_print ("DEBUG: trying to close the src file\n"); */
gst_afsrc_close_file (GST_AFSRC (element));
}
- }
- else if (GST_STATE_PENDING (element) == GST_STATE_READY)
- {
+ } else if (GST_STATE_PENDING (element) == GST_STATE_READY) {
/* g_print ("DEBUG: afsrc: ready state pending. This shouldn't happen at the *end* of a stream\n"); */
- if (!GST_FLAG_IS_SET (element, GST_AFSRC_OPEN))
- {
+ if (!GST_FLAG_IS_SET (element, GST_AFSRC_OPEN)) {
/* g_print ("DEBUG: GST_AFSRC_OPEN not set\n"); */
- if (!gst_afsrc_open_file (GST_AFSRC (element)))
- {
+ if (!gst_afsrc_open_file (GST_AFSRC (element))) {
/* g_print ("DEBUG: element tries to open file\n"); */
- return GST_STATE_FAILURE;
+ return GST_STATE_FAILURE;
}
}
}
diff --git a/ext/audiofile/gstafsrc.h b/ext/audiofile/gstafsrc.h
index c96c20c3..ff607564 100644
--- a/ext/audiofile/gstafsrc.h
+++ b/ext/audiofile/gstafsrc.h
@@ -26,12 +26,13 @@
#include <gst/gst.h>
-#include <audiofile.h> /* what else are we to do */
+#include <audiofile.h> /* what else are we to do */
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
/*GstElementDetails gst_afsrc_details;*/
@@ -48,60 +49,63 @@ extern "C" {
#define GST_IS_AFSRC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AFSRC))
-typedef struct _GstAFSrc GstAFSrc;
-typedef struct _GstAFSrcClass GstAFSrcClass;
+ typedef struct _GstAFSrc GstAFSrc;
+ typedef struct _GstAFSrcClass GstAFSrcClass;
-typedef enum {
- GST_AFSRC_OPEN = GST_ELEMENT_FLAG_LAST,
+ typedef enum
+ {
+ GST_AFSRC_OPEN = GST_ELEMENT_FLAG_LAST,
- GST_AFSRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
-} GstAFSrcFlags;
+ GST_AFSRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
+ } GstAFSrcFlags;
-struct _GstAFSrc {
- GstElement element;
- GstPad *srcpad;
+ struct _GstAFSrc
+ {
+ GstElement element;
+ GstPad *srcpad;
- gchar *filename;
+ gchar *filename;
/* FILE *file; */
/* AFfilesetup outfilesetup; */
- AFfilehandle file;
- int format;
- int channels;
- int width;
- unsigned int rate;
- gboolean is_signed;
- int type; /* type of output, compare to audiofile.h
- * RAW, AIFF, AIFFC, NEXTSND, WAVE
- */
- /* blocking */
- gulong curoffset;
- gulong bytes_per_read;
+ AFfilehandle file;
+ int format;
+ int channels;
+ int width;
+ unsigned int rate;
+ gboolean is_signed;
+ int type; /* type of output, compare to audiofile.h
+ * RAW, AIFF, AIFFC, NEXTSND, WAVE
+ */
+ /* blocking */
+ gulong curoffset;
+ gulong bytes_per_read;
- gulong seq;
- guint64 framestamp;
- /* FIXME : endianness is a little cryptic at this point */
- int endianness_data; /* 4321 or 1234 */
- int endianness_wanted; /* same thing, but what the output format wants */
- int endianness_output; /* what the output endianness will be */
-};
+ gulong seq;
+ guint64 framestamp;
+ /* FIXME : endianness is a little cryptic at this point */
+ int endianness_data; /* 4321 or 1234 */
+ int endianness_wanted; /* same thing, but what the output format wants */
+ int endianness_output; /* what the output endianness will be */
+ };
-struct _GstAFSrcClass {
- GstElementClass parent_class;
+ struct _GstAFSrcClass
+ {
+ GstElementClass parent_class;
- /* signals */
- void (*handoff) (GstElement *element,GstPad *pad);
-};
+ /* signals */
+ void (*handoff) (GstElement * element, GstPad * pad);
+ };
-GType gst_afsrc_get_type (void);
-gboolean gst_afsrc_plugin_init (GstPlugin *plugin);
+ GType gst_afsrc_get_type (void);
+ gboolean gst_afsrc_plugin_init (GstPlugin * plugin);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_AFSRC_H__ */
+#endif /* __GST_AFSRC_H__ */
diff --git a/ext/cdaudio/gstcdaudio.c b/ext/cdaudio/gstcdaudio.c
index 0149e1ce..95bd30d0 100644
--- a/ext/cdaudio/gstcdaudio.c
+++ b/ext/cdaudio/gstcdaudio.c
@@ -33,29 +33,31 @@
typedef struct _GstCDAudio GstCDAudio;
typedef struct _GstCDAudioClass GstCDAudioClass;
-struct _GstCDAudio {
- GstBin element;
-
+struct _GstCDAudio
+{
+ GstBin element;
+
/* properties */
- gchar *device;
+ gchar *device;
- gint cd_desc;
- gulong discid;
+ gint cd_desc;
+ gulong discid;
- gboolean was_playing;
+ gboolean was_playing;
- struct disc_info info;
- struct disc_volume volume;
+ struct disc_info info;
+ struct disc_volume volume;
- GTimer *timer;
+ GTimer *timer;
};
-struct _GstCDAudioClass {
- GstBinClass parent_class;
+struct _GstCDAudioClass
+{
+ GstBinClass parent_class;
- void (*close_tray) (GstElement *element);
+ void (*close_tray) (GstElement * element);
/* signal callbacks */
- void (*track_change) (GstElement *element, guint track);
+ void (*track_change) (GstElement * element, guint track);
};
/* props */
@@ -77,30 +79,29 @@ enum
LAST_SIGNAL,
};
-static void gst_cdaudio_class_init (GstCDAudioClass *klass);
-static void gst_cdaudio_init (GstCDAudio *cdaudio);
-static void gst_cdaudio_dispose (GObject *object);
-
-static void gst_cdaudio_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *spec);
-static void gst_cdaudio_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *spec);
-static GstElementStateReturn
- gst_cdaudio_change_state (GstElement * element);
-
-static const GstEventMask* gst_cdaudio_get_event_masks (GstElement *element);
-static gboolean gst_cdaudio_send_event (GstElement *element, GstEvent *event);
-static const GstFormat* gst_cdaudio_get_formats (GstElement *element);
-static gboolean gst_cdaudio_convert (GstElement *element,
- GstFormat src_format, gint64 src_value,
- GstFormat *dest_format, gint64 *dest_value);
-static const GstQueryType* gst_cdaudio_get_query_types (GstElement *element);
-static gboolean gst_cdaudio_query (GstElement *element, GstQueryType type,
- GstFormat *format, gint64 *value);
+static void gst_cdaudio_class_init (GstCDAudioClass * klass);
+static void gst_cdaudio_init (GstCDAudio * cdaudio);
+static void gst_cdaudio_dispose (GObject * object);
+
+static void gst_cdaudio_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * spec);
+static void gst_cdaudio_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * spec);
+static GstElementStateReturn gst_cdaudio_change_state (GstElement * element);
+
+static const GstEventMask *gst_cdaudio_get_event_masks (GstElement * element);
+static gboolean gst_cdaudio_send_event (GstElement * element, GstEvent * event);
+static const GstFormat *gst_cdaudio_get_formats (GstElement * element);
+static gboolean gst_cdaudio_convert (GstElement * element,
+ GstFormat src_format, gint64 src_value,
+ GstFormat * dest_format, gint64 * dest_value);
+static const GstQueryType *gst_cdaudio_get_query_types (GstElement * element);
+static gboolean gst_cdaudio_query (GstElement * element, GstQueryType type,
+ GstFormat * format, gint64 * value);
static GstFormat track_format;
static GstFormat sector_format;
-
+
static GstElementClass *parent_class;
static guint gst_cdaudio_signals[LAST_SIGNAL] = { 0 };
@@ -133,7 +134,9 @@ gst_cdaudio_get_type (void)
(GInstanceInitFunc) gst_cdaudio_init,
NULL
};
- gst_cdaudio_type = g_type_register_static (GST_TYPE_BIN, "GstCDAudio", &gst_cdaudio_info, 0);
+ gst_cdaudio_type =
+ g_type_register_static (GST_TYPE_BIN, "GstCDAudio", &gst_cdaudio_info,
+ 0);
track_format = gst_format_register ("track", "CD track");
sector_format = gst_format_register ("sector", "CD sector");
@@ -159,38 +162,40 @@ gst_cdaudio_class_init (GstCDAudioClass * klass)
gobject_klass->get_property = gst_cdaudio_get_property;
g_object_class_install_property (gobject_klass, ARG_DEVICE,
- g_param_spec_string ("device", "Device", "CDROM device",
- NULL, G_PARAM_READWRITE));
+ g_param_spec_string ("device", "Device", "CDROM device",
+ NULL, G_PARAM_READWRITE));
g_object_class_install_property (gobject_klass, ARG_DISCID,
- g_param_spec_ulong ("discid", "Disc ID", "CDDB Disc ID",
- 0, G_MAXULONG, 0, G_PARAM_READABLE));
+ g_param_spec_ulong ("discid", "Disc ID", "CDDB Disc ID",
+ 0, G_MAXULONG, 0, G_PARAM_READABLE));
g_object_class_install_property (gobject_klass, ARG_VOLUME_FL,
- g_param_spec_int ("volume_fl", "Volume fl", "Front left volume",
- 0, 255, 255, G_PARAM_READWRITE));
+ g_param_spec_int ("volume_fl", "Volume fl", "Front left volume",
+ 0, 255, 255, G_PARAM_READWRITE));
g_object_class_install_property (gobject_klass, ARG_VOLUME_FR,
- g_param_spec_int ("volume_fr", "Volume fr", "Front right volume",
- 0, 255, 255, G_PARAM_READWRITE));
+ g_param_spec_int ("volume_fr", "Volume fr", "Front right volume",
+ 0, 255, 255, G_PARAM_READWRITE));
g_object_class_install_property (gobject_klass, ARG_VOLUME_BL,
- g_param_spec_int ("volume_bl", "Volume bl", "Back left volume",
- 0, 255, 255, G_PARAM_READWRITE));
+ g_param_spec_int ("volume_bl", "Volume bl", "Back left volume",
+ 0, 255, 255, G_PARAM_READWRITE));
g_object_class_install_property (gobject_klass, ARG_VOLUME_BR,
- g_param_spec_int ("volume_br", "Volume br", "Back right volume",
- 0, 255, 255, G_PARAM_READWRITE));
+ g_param_spec_int ("volume_br", "Volume br", "Back right volume",
+ 0, 255, 255, G_PARAM_READWRITE));
gst_cdaudio_signals[TRACK_CHANGE] =
- g_signal_new ("track-change", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstCDAudioClass, track_change), NULL, NULL,
- gst_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
+ g_signal_new ("track-change", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstCDAudioClass, track_change), NULL,
+ NULL, gst_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
gobject_klass->dispose = GST_DEBUG_FUNCPTR (gst_cdaudio_dispose);
- gstelement_klass->change_state = GST_DEBUG_FUNCPTR (gst_cdaudio_change_state);
- gstelement_klass->get_event_masks = GST_DEBUG_FUNCPTR (gst_cdaudio_get_event_masks);
- gstelement_klass->send_event = GST_DEBUG_FUNCPTR (gst_cdaudio_send_event);
- gstelement_klass->get_formats = GST_DEBUG_FUNCPTR (gst_cdaudio_get_formats);
- gstelement_klass->convert = GST_DEBUG_FUNCPTR (gst_cdaudio_convert);
- gstelement_klass->get_query_types = GST_DEBUG_FUNCPTR (gst_cdaudio_get_query_types);
- gstelement_klass->query = GST_DEBUG_FUNCPTR (gst_cdaudio_query);
+ gstelement_klass->change_state = GST_DEBUG_FUNCPTR (gst_cdaudio_change_state);
+ gstelement_klass->get_event_masks =
+ GST_DEBUG_FUNCPTR (gst_cdaudio_get_event_masks);
+ gstelement_klass->send_event = GST_DEBUG_FUNCPTR (gst_cdaudio_send_event);
+ gstelement_klass->get_formats = GST_DEBUG_FUNCPTR (gst_cdaudio_get_formats);
+ gstelement_klass->convert = GST_DEBUG_FUNCPTR (gst_cdaudio_convert);
+ gstelement_klass->get_query_types =
+ GST_DEBUG_FUNCPTR (gst_cdaudio_get_query_types);
+ gstelement_klass->query = GST_DEBUG_FUNCPTR (gst_cdaudio_query);
}
static void
@@ -219,7 +224,8 @@ gst_cdaudio_dispose (GObject * object)
}
static void
-gst_cdaudio_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * spec)
+gst_cdaudio_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * spec)
{
GstCDAudio *cdaudio;
@@ -244,7 +250,8 @@ gst_cdaudio_set_property (GObject * object, guint prop_id, const GValue * value,
}
static void
-gst_cdaudio_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * spec)
+gst_cdaudio_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * spec)
{
GstCDAudio *cdaudio;
@@ -277,16 +284,16 @@ gst_cdaudio_get_property (GObject * object, guint prop_id, GValue * value, GPara
}
static void
-print_track_info (GstCDAudio *cdaudio)
+print_track_info (GstCDAudio * cdaudio)
{
gint i;
for (i = 0; i < cdaudio->info.disc_total_tracks; i++) {
- g_print ("%d %d %d %d:%02d\n", i,
- cdaudio->info.disc_track[i].track_length.frames,
- cdaudio->info.disc_track[i].track_pos.frames,
- cdaudio->info.disc_track[i].track_length.minutes,
- cdaudio->info.disc_track[i].track_length.seconds);
+ g_print ("%d %d %d %d:%02d\n", i,
+ cdaudio->info.disc_track[i].track_length.frames,
+ cdaudio->info.disc_track[i].track_pos.frames,
+ cdaudio->info.disc_track[i].track_length.minutes,
+ cdaudio->info.disc_track[i].track_length.seconds);
}
}
@@ -301,8 +308,8 @@ gst_cdaudio_change_state (GstElement * element)
case GST_STATE_NULL_TO_READY:
break;
case GST_STATE_READY_TO_PAUSED:
- cdaudio->cd_desc = cd_init_device(cdaudio->device);
- if (cdaudio->cd_desc < 0)
+ cdaudio->cd_desc = cd_init_device (cdaudio->device);
+ if (cdaudio->cd_desc < 0)
return GST_STATE_FAILURE;
/* close tray */
@@ -324,11 +331,11 @@ gst_cdaudio_change_state (GstElement * element)
gint res;
if (cdaudio->was_playing)
- res = cd_resume (cdaudio->cd_desc);
+ res = cd_resume (cdaudio->cd_desc);
else
- res = cd_play (cdaudio->cd_desc, 1);
+ res = cd_play (cdaudio->cd_desc, 1);
- if (res < 0)
+ if (res < 0)
return GST_STATE_FAILURE;
cdaudio->was_playing = TRUE;
@@ -360,12 +367,16 @@ gst_cdaudio_change_state (GstElement * element)
}
GST_ELEMENT_EVENT_MASK_FUNCTION (gst_cdaudio_get_event_masks,
- { GST_EVENT_SEEK, GST_SEEK_FLAG_FLUSH },
- { GST_EVENT_SEEK_SEGMENT, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT_LOOP }
+ {
+ GST_EVENT_SEEK, GST_SEEK_FLAG_FLUSH}
+
+ , {
+ GST_EVENT_SEEK_SEGMENT, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT_LOOP}
+
)
-gboolean
-gst_cdaudio_send_event (GstElement *element, GstEvent *event)
+ gboolean
+gst_cdaudio_send_event (GstElement * element, GstEvent * event)
{
GstCDAudio *cdaudio;
gboolean res = TRUE;
@@ -376,13 +387,14 @@ gst_cdaudio_send_event (GstElement *element, GstEvent *event)
case GST_EVENT_SEEK:
switch (GST_EVENT_SEEK_FORMAT (event)) {
case GST_FORMAT_TIME:
- {
- cd_play_pos (cdaudio->cd_desc, 1, GST_EVENT_SEEK_OFFSET (event) / (60 * GST_SECOND));
- break;
+ {
+ cd_play_pos (cdaudio->cd_desc, 1,
+ GST_EVENT_SEEK_OFFSET (event) / (60 * GST_SECOND));
+ break;
}
- default:
- res = FALSE;
- break;
+ default:
+ res = FALSE;
+ break;
}
break;
default:
@@ -393,15 +405,15 @@ gst_cdaudio_send_event (GstElement *element, GstEvent *event)
return res;
}
-const GstFormat*
-gst_cdaudio_get_formats (GstElement *element)
+const GstFormat *
+gst_cdaudio_get_formats (GstElement * element)
{
static GstFormat formats[] = {
GST_FORMAT_TIME,
GST_FORMAT_BYTES,
GST_FORMAT_DEFAULT,
- 0, /* fillted below */
- 0, /* fillted below */
+ 0, /* fillted below */
+ 0, /* fillted below */
0,
};
@@ -412,15 +424,15 @@ gst_cdaudio_get_formats (GstElement *element)
}
gboolean
-gst_cdaudio_convert (GstElement *element,
- GstFormat src_format, gint64 src_value,
- GstFormat *dest_format, gint64 *dest_value)
+gst_cdaudio_convert (GstElement * element,
+ GstFormat src_format, gint64 src_value,
+ GstFormat * dest_format, gint64 * dest_value)
{
return FALSE;
}
-const GstQueryType*
-gst_cdaudio_get_query_types (GstElement *element)
+const GstQueryType *
+gst_cdaudio_get_query_types (GstElement * element)
{
static const GstQueryType query_types[] = {
GST_QUERY_TOTAL,
@@ -433,8 +445,8 @@ gst_cdaudio_get_query_types (GstElement *element)
}
gboolean
-gst_cdaudio_query (GstElement *element, GstQueryType type,
- GstFormat *format, gint64 *value)
+gst_cdaudio_query (GstElement * element, GstQueryType type,
+ GstFormat * format, gint64 * value)
{
GstCDAudio *cdaudio;
gboolean res = TRUE;
@@ -454,16 +466,15 @@ gst_cdaudio_query (GstElement *element, GstQueryType type,
case GST_QUERY_TOTAL:
switch (*format) {
case GST_FORMAT_TIME:
- *value = (cdaudio->info.disc_length.minutes * 60 +
- cdaudio->info.disc_length.seconds) * GST_SECOND;
+ *value = (cdaudio->info.disc_length.minutes * 60 +
+ cdaudio->info.disc_length.seconds) * GST_SECOND;
break;
default:
{
- if (*format == track_format) {
- *value = cdaudio->info.disc_total_tracks;
- }
- else {
- res = FALSE;
+ if (*format == track_format) {
+ *value = cdaudio->info.disc_total_tracks;
+ } else {
+ res = FALSE;
}
break;
}
@@ -472,16 +483,15 @@ gst_cdaudio_query (GstElement *element, GstQueryType type,
case GST_QUERY_POSITION:
switch (*format) {
case GST_FORMAT_TIME:
- *value = (cdaudio->info.disc_time.minutes * 60 +
- cdaudio->info.disc_time.seconds) * GST_SECOND;
+ *value = (cdaudio->info.disc_time.minutes * 60 +
+ cdaudio->info.disc_time.seconds) * GST_SECOND;
break;
default:
{
- if (*format == track_format) {
- *value = cdaudio->info.disc_current_track;
- }
- else {
- res = FALSE;
+ if (*format == track_format) {
+ *value = cdaudio->info.disc_current_track;
+ } else {
+ res = FALSE;
}
break;
}
@@ -499,7 +509,9 @@ plugin_init (GModule * module, GstPlugin * plugin)
{
GstElementFactory *factory;
- factory = gst_element_factory_new ("cdaudio", GST_TYPE_CDAUDIO, &gst_cdaudio_details);
+ factory =
+ gst_element_factory_new ("cdaudio", GST_TYPE_CDAUDIO,
+ &gst_cdaudio_details);
g_return_val_if_fail (factory != NULL, FALSE);
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
diff --git a/ext/divx/gstdivxdec.h b/ext/divx/gstdivxdec.h
index 0468ff0a..4bf2d364 100644
--- a/ext/divx/gstdivxdec.h
+++ b/ext/divx/gstdivxdec.h
@@ -24,8 +24,9 @@
#include <decore.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_DIVXDEC \
@@ -39,34 +40,36 @@ extern "C" {
#define GST_IS_DIVXDEC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_DIVXDEC))
-typedef struct _GstDivxDec GstDivxDec;
-typedef struct _GstDivxDecClass GstDivxDecClass;
+ typedef struct _GstDivxDec GstDivxDec;
+ typedef struct _GstDivxDecClass GstDivxDecClass;
-struct _GstDivxDec {
- GstElement element;
+ struct _GstDivxDec
+ {
+ GstElement element;
- /* pads */
- GstPad *sinkpad, *srcpad;
+ /* pads */
+ GstPad *sinkpad, *srcpad;
- /* divx handle */
- void *handle;
+ /* divx handle */
+ void *handle;
- /* video (output) settings */
- guint32 csp;
- int bitcnt, bpp;
- int version;
- int width, height;
- gdouble fps;
-};
+ /* video (output) settings */
+ guint32 csp;
+ int bitcnt, bpp;
+ int version;
+ int width, height;
+ gdouble fps;
+ };
-struct _GstDivxDecClass {
- GstElementClass parent_class;
-};
+ struct _GstDivxDecClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_divxdec_get_type(void);
+ GType gst_divxdec_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_DIVXDEC_H__ */
+#endif /* __GST_DIVXDEC_H__ */
diff --git a/ext/divx/gstdivxenc.h b/ext/divx/gstdivxenc.h
index 206659d3..906145bb 100644
--- a/ext/divx/gstdivxenc.h
+++ b/ext/divx/gstdivxenc.h
@@ -23,8 +23,9 @@
#include <gst/gst.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_DIVXENC \
@@ -38,46 +39,48 @@ extern "C" {
#define GST_IS_DIVXENC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_DIVXENC))
-typedef struct _GstDivxEnc GstDivxEnc;
-typedef struct _GstDivxEncClass GstDivxEncClass;
+ typedef struct _GstDivxEnc GstDivxEnc;
+ typedef struct _GstDivxEncClass GstDivxEncClass;
-struct _GstDivxEnc {
- GstElement element;
+ struct _GstDivxEnc
+ {
+ GstElement element;
- /* pads */
- GstPad *sinkpad, *srcpad;
+ /* pads */
+ GstPad *sinkpad, *srcpad;
- /* quality of encoded image */
- gulong bitrate;
+ /* quality of encoded image */
+ gulong bitrate;
- /* size of the buffers */
- gulong buffer_size;
+ /* size of the buffers */
+ gulong buffer_size;
- /* max key interval */
- gint max_key_interval;
+ /* max key interval */
+ gint max_key_interval;
- /* amount of motion estimation to do */
- gint quality;
+ /* amount of motion estimation to do */
+ gint quality;
- /* divx handle */
- void *handle;
- guint32 csp;
- gint bitcnt;
- gint width, height;
- gfloat fps;
-};
+ /* divx handle */
+ void *handle;
+ guint32 csp;
+ gint bitcnt;
+ gint width, height;
+ gfloat fps;
+ };
-struct _GstDivxEncClass {
- GstElementClass parent_class;
+ struct _GstDivxEncClass
+ {
+ GstElementClass parent_class;
- /* signals */
- void (*frame_encoded) (GstElement *element);
-};
+ /* signals */
+ void (*frame_encoded) (GstElement * element);
+ };
-GType gst_divxenc_get_type(void);
+ GType gst_divxenc_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_DIVXENC_H__ */
+#endif /* __GST_DIVXENC_H__ */
diff --git a/ext/faac/gstfaac.c b/ext/faac/gstfaac.c
index 7f536275..2241014b 100644
--- a/ext/faac/gstfaac.c
+++ b/ext/faac/gstfaac.c
@@ -23,82 +23,50 @@
#include "gstfaac.h"
-static GstStaticPadTemplate src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "audio/mpeg, "
- "mpegversion = (int) { 4, 2 }, "
- "channels = (int) [ 1, 6 ], "
- "rate = (int) [ 8000, 96000 ]"
- )
-);
-
-static GstStaticPadTemplate sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "audio/x-raw-int, "
- "endianness = (int) BYTE_ORDER, "
- "signed = (boolean) TRUE, "
- "width = (int) 16, "
- "depth = (int) 16, "
- "rate = (int) [ 8000, 96000 ], "
- "channels = (int) [ 1, 6]; "
- "audio/x-raw-int, "
- "endianness = (int) BYTE_ORDER, "
- "signed = (boolean) TRUE, "
- "width = (int) 32, "
- "depth = (int) 24, "
- "rate = (int) [ 8000, 96000], "
- "channels = (int) [ 1, 6]; "
- "audio/x-raw-float, "
- "endianness = (int) BYTE_ORDER, "
- "depth = (int) 32, " /* sizeof (gfloat) */
- "rate = (int) [ 8000, 96000], "
- "channels = (int) [ 1, 6]"
- )
-);
-
-enum {
+static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/mpeg, "
+ "mpegversion = (int) { 4, 2 }, "
+ "channels = (int) [ 1, 6 ], " "rate = (int) [ 8000, 96000 ]")
+ );
+
+static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, " "endianness = (int) BYTE_ORDER, " "signed = (boolean) TRUE, " "width = (int) 16, " "depth = (int) 16, " "rate = (int) [ 8000, 96000 ], " "channels = (int) [ 1, 6]; " "audio/x-raw-int, " "endianness = (int) BYTE_ORDER, " "signed = (boolean) TRUE, " "width = (int) 32, " "depth = (int) 24, " "rate = (int) [ 8000, 96000], " "channels = (int) [ 1, 6]; " "audio/x-raw-float, " "endianness = (int) BYTE_ORDER, " "depth = (int) 32, " /* sizeof (gfloat) */
+ "rate = (int) [ 8000, 96000], " "channels = (int) [ 1, 6]")
+ );
+
+enum
+{
ARG_0,
ARG_BITRATE,
ARG_PROFILE,
ARG_TNS,
ARG_MIDSIDE,
ARG_SHORTCTL
- /* FILL ME */
+ /* FILL ME */
};
-static void gst_faac_base_init (GstFaacClass *klass);
-static void gst_faac_class_init (GstFaacClass *klass);
-static void gst_faac_init (GstFaac *faac);
+static void gst_faac_base_init (GstFaacClass * klass);
+static void gst_faac_class_init (GstFaacClass * klass);
+static void gst_faac_init (GstFaac * faac);
-static void gst_faac_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gst_faac_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
+static void gst_faac_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_faac_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
static GstPadLinkReturn
- gst_faac_sinkconnect (GstPad *pad,
- const GstCaps *caps);
+gst_faac_sinkconnect (GstPad * pad, const GstCaps * caps);
static GstPadLinkReturn
- gst_faac_srcconnect (GstPad *pad,
- const GstCaps *caps);
-static void gst_faac_chain (GstPad *pad,
- GstData *data);
-static GstElementStateReturn
- gst_faac_change_state (GstElement *element);
+gst_faac_srcconnect (GstPad * pad, const GstCaps * caps);
+static void gst_faac_chain (GstPad * pad, GstData * data);
+static GstElementStateReturn gst_faac_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
+
/* static guint gst_faac_signals[LAST_SIGNAL] = { 0 }; */
GType
@@ -108,27 +76,26 @@ gst_faac_get_type (void)
if (!gst_faac_type) {
static const GTypeInfo gst_faac_info = {
- sizeof (GstFaacClass),
+ sizeof (GstFaacClass),
(GBaseInitFunc) gst_faac_base_init,
NULL,
(GClassInitFunc) gst_faac_class_init,
NULL,
NULL,
- sizeof(GstFaac),
+ sizeof (GstFaac),
0,
(GInstanceInitFunc) gst_faac_init,
};
gst_faac_type = g_type_register_static (GST_TYPE_ELEMENT,
- "GstFaac",
- &gst_faac_info, 0);
+ "GstFaac", &gst_faac_info, 0);
}
return gst_faac_type;
}
static void
-gst_faac_base_init (GstFaacClass *klass)
+gst_faac_base_init (GstFaacClass * klass)
{
GstElementDetails gst_faac_details = {
"Free AAC Encoder (FAAC)",
@@ -139,9 +106,9 @@ gst_faac_base_init (GstFaacClass *klass)
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&src_template));
+ gst_static_pad_template_get (&src_template));
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&sink_template));
+ gst_static_pad_template_get (&sink_template));
gst_element_class_set_details (element_class, &gst_faac_details);
}
@@ -154,15 +121,15 @@ gst_faac_profile_get_type (void)
if (!gst_faac_profile_type) {
static GEnumValue gst_faac_profile[] = {
- { MAIN, "MAIN", "Main profile" },
- { LOW, "LOW", "Low complexity profile" },
- { SSR, "SSR", "Scalable sampling rate profile" },
- { LTP, "LTP", "Long term prediction profile" },
- { 0, NULL, NULL },
+ {MAIN, "MAIN", "Main profile"},
+ {LOW, "LOW", "Low complexity profile"},
+ {SSR, "SSR", "Scalable sampling rate profile"},
+ {LTP, "LTP", "Long term prediction profile"},
+ {0, NULL, NULL},
};
gst_faac_profile_type = g_enum_register_static ("GstFaacProfile",
- gst_faac_profile);
+ gst_faac_profile);
}
return gst_faac_profile_type;
@@ -176,21 +143,21 @@ gst_faac_shortctl_get_type (void)
if (!gst_faac_shortctl_type) {
static GEnumValue gst_faac_shortctl[] = {
- { SHORTCTL_NORMAL, "SHORTCTL_NORMAL", "Normal block type" },
- { SHORTCTL_NOSHORT, "SHORTCTL_NOSHORT", "No short blocks" },
- { SHORTCTL_NOLONG, "SHORTCTL_NOLONG", "No long blocks" },
- { 0, NULL, NULL },
+ {SHORTCTL_NORMAL, "SHORTCTL_NORMAL", "Normal block type"},
+ {SHORTCTL_NOSHORT, "SHORTCTL_NOSHORT", "No short blocks"},
+ {SHORTCTL_NOLONG, "SHORTCTL_NOLONG", "No long blocks"},
+ {0, NULL, NULL},
};
gst_faac_shortctl_type = g_enum_register_static ("GstFaacShortCtl",
- gst_faac_shortctl);
+ gst_faac_shortctl);
}
return gst_faac_shortctl_type;
}
static void
-gst_faac_class_init (GstFaacClass *klass)
+gst_faac_class_init (GstFaacClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
@@ -199,21 +166,21 @@ gst_faac_class_init (GstFaacClass *klass)
/* properties */
g_object_class_install_property (gobject_class, ARG_BITRATE,
- g_param_spec_int ("bitrate", "Bitrate (bps)", "Bitrate in bits/sec",
- 8 * 1024, 320 * 1024, 128 * 1024, G_PARAM_READWRITE));
+ g_param_spec_int ("bitrate", "Bitrate (bps)", "Bitrate in bits/sec",
+ 8 * 1024, 320 * 1024, 128 * 1024, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_PROFILE,
- g_param_spec_enum ("profile", "Profile", "MPEG/AAC encoding profile",
- GST_TYPE_FAAC_PROFILE, MAIN, G_PARAM_READWRITE));
+ g_param_spec_enum ("profile", "Profile", "MPEG/AAC encoding profile",
+ GST_TYPE_FAAC_PROFILE, MAIN, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_TNS,
- g_param_spec_boolean ("tns", "TNS", "Use temporal noise shaping",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("tns", "TNS", "Use temporal noise shaping",
+ FALSE, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_MIDSIDE,
- g_param_spec_boolean ("midside", "Midside", "Allow mid/side encoding",
- TRUE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("midside", "Midside", "Allow mid/side encoding",
+ TRUE, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_SHORTCTL,
- g_param_spec_enum ("shortctl", "Block type",
- "Block type encorcing",
- GST_TYPE_FAAC_SHORTCTL, MAIN, G_PARAM_READWRITE));
+ g_param_spec_enum ("shortctl", "Block type",
+ "Block type encorcing",
+ GST_TYPE_FAAC_SHORTCTL, MAIN, G_PARAM_READWRITE));
/* virtual functions */
gstelement_class->change_state = gst_faac_change_state;
@@ -223,7 +190,7 @@ gst_faac_class_init (GstFaacClass *klass)
}
static void
-gst_faac_init (GstFaac *faac)
+gst_faac_init (GstFaac * faac)
{
faac->handle = NULL;
faac->samplerate = -1;
@@ -234,14 +201,16 @@ gst_faac_init (GstFaac *faac)
GST_FLAG_SET (faac, GST_ELEMENT_EVENT_AWARE);
- faac->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&sink_template), "sink");
+ faac->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&sink_template),
+ "sink");
gst_element_add_pad (GST_ELEMENT (faac), faac->sinkpad);
gst_pad_set_chain_function (faac->sinkpad, gst_faac_chain);
gst_pad_set_link_function (faac->sinkpad, gst_faac_sinkconnect);
- faac->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&src_template), "src");
+ faac->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&src_template),
+ "src");
gst_element_add_pad (GST_ELEMENT (faac), faac->srcpad);
gst_pad_set_link_function (faac->srcpad, gst_faac_srcconnect);
@@ -254,8 +223,7 @@ gst_faac_init (GstFaac *faac)
}
static GstPadLinkReturn
-gst_faac_sinkconnect (GstPad *pad,
- const GstCaps *caps)
+gst_faac_sinkconnect (GstPad * pad, const GstCaps * caps)
{
GstFaac *faac = GST_FAAC (gst_pad_get_parent (pad));
GstStructure *structure = gst_caps_get_structure (caps, 0);
@@ -280,8 +248,7 @@ gst_faac_sinkconnect (GstPad *pad,
gst_structure_get_int (structure, "depth", &depth);
/* open a new handle to the encoder */
- if (!(handle = faacEncOpen (samplerate, channels,
- &samples, &bytes)))
+ if (!(handle = faacEncOpen (samplerate, channels, &samples, &bytes)))
return GST_PAD_LINK_REFUSED;
switch (depth) {
@@ -290,11 +257,11 @@ gst_faac_sinkconnect (GstPad *pad,
bps = 2;
break;
case 24:
- fmt = FAAC_INPUT_32BIT; /* 24-in-32, actually */
+ fmt = FAAC_INPUT_32BIT; /* 24-in-32, actually */
bps = 4;
break;
case 32:
- fmt = FAAC_INPUT_FLOAT; /* see template, this is right */
+ fmt = FAAC_INPUT_FLOAT; /* see template, this is right */
bps = 4;
break;
}
@@ -315,27 +282,26 @@ gst_faac_sinkconnect (GstPad *pad,
/* if the other side was already set-up, redo that */
if (GST_PAD_CAPS (faac->srcpad))
return gst_faac_srcconnect (faac->srcpad,
- gst_pad_get_allowed_caps (faac->srcpad));
+ gst_pad_get_allowed_caps (faac->srcpad));
/* else, that'll be done later */
return GST_PAD_LINK_OK;
}
static GstPadLinkReturn
-gst_faac_srcconnect (GstPad *pad,
- const GstCaps *caps)
+gst_faac_srcconnect (GstPad * pad, const GstCaps * caps)
{
GstFaac *faac = GST_FAAC (gst_pad_get_parent (pad));
gint n;
- if (!faac->handle ||
- (faac->samplerate == -1 || faac->channels == -1)) {
+ if (!faac->handle || (faac->samplerate == -1 || faac->channels == -1)) {
return GST_PAD_LINK_DELAYED;
}
/* we do samplerate/channels ourselves */
for (n = 0; n < gst_caps_get_size (caps); n++) {
GstStructure *structure = gst_caps_get_structure (caps, n);
+
gst_structure_remove_field (structure, "rate");
gst_structure_remove_field (structure, "channels");
}
@@ -369,7 +335,7 @@ gst_faac_srcconnect (GstPad *pad,
* that (that the next element is filesink or any element
* that does want ADTS headers). */
- conf->outputFormat = 0; /* raw, no ADTS headers */
+ conf->outputFormat = 0; /* raw, no ADTS headers */
conf->shortctl = faac->shortctl;
if (!faacEncSetConfiguration (faac->handle, conf)) {
GST_WARNING ("Faac doesn't support the current conf");
@@ -377,20 +343,19 @@ gst_faac_srcconnect (GstPad *pad,
}
newcaps = gst_caps_new_simple ("audio/mpeg",
- "mpegversion", G_TYPE_INT, mpegversion,
- "channels", G_TYPE_INT, faac->channels,
- "rate", G_TYPE_INT, faac->samplerate,
- NULL);
+ "mpegversion", G_TYPE_INT, mpegversion,
+ "channels", G_TYPE_INT, faac->channels,
+ "rate", G_TYPE_INT, faac->samplerate, NULL);
ret = gst_pad_try_set_caps (faac->srcpad, newcaps);
switch (ret) {
case GST_PAD_LINK_OK:
case GST_PAD_LINK_DONE:
- return GST_PAD_LINK_DONE;
+ return GST_PAD_LINK_DONE;
case GST_PAD_LINK_DELAYED:
- return GST_PAD_LINK_DELAYED;
+ return GST_PAD_LINK_DELAYED;
default:
- break;
+ break;
}
}
@@ -398,8 +363,7 @@ gst_faac_srcconnect (GstPad *pad,
}
static void
-gst_faac_chain (GstPad *pad,
- GstData *data)
+gst_faac_chain (GstPad * pad, GstData * data)
{
GstFaac *faac = GST_FAAC (gst_pad_get_parent (pad));
GstBuffer *inbuf, *outbuf, *subbuf;
@@ -410,35 +374,33 @@ gst_faac_chain (GstPad *pad,
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
- /* flush first */
- while (1) {
- outbuf = gst_buffer_new_and_alloc (faac->bytes);
- if ((ret_size = faacEncEncode (faac->handle,
- NULL, 0,
- GST_BUFFER_DATA (outbuf),
- faac->bytes)) < 0) {
- GST_ELEMENT_ERROR (faac, LIBRARY, ENCODE, (NULL), (NULL));
- gst_event_unref (event);
- gst_buffer_unref (outbuf);
- return;
- }
-
- if (ret_size > 0) {
- GST_BUFFER_SIZE (outbuf) = ret_size;
- GST_BUFFER_TIMESTAMP (outbuf) = 0;
- GST_BUFFER_DURATION (outbuf) = 0;
- gst_pad_push (faac->srcpad, GST_DATA (outbuf));
- } else {
- break;
- }
- }
-
- gst_element_set_eos (GST_ELEMENT (faac));
- gst_pad_push (faac->srcpad, data);
- return;
+ /* flush first */
+ while (1) {
+ outbuf = gst_buffer_new_and_alloc (faac->bytes);
+ if ((ret_size = faacEncEncode (faac->handle,
+ NULL, 0, GST_BUFFER_DATA (outbuf), faac->bytes)) < 0) {
+ GST_ELEMENT_ERROR (faac, LIBRARY, ENCODE, (NULL), (NULL));
+ gst_event_unref (event);
+ gst_buffer_unref (outbuf);
+ return;
+ }
+
+ if (ret_size > 0) {
+ GST_BUFFER_SIZE (outbuf) = ret_size;
+ GST_BUFFER_TIMESTAMP (outbuf) = 0;
+ GST_BUFFER_DURATION (outbuf) = 0;
+ gst_pad_push (faac->srcpad, GST_DATA (outbuf));
+ } else {
+ break;
+ }
+ }
+
+ gst_element_set_eos (GST_ELEMENT (faac));
+ gst_pad_push (faac->srcpad, data);
+ return;
default:
gst_pad_event_default (pad, event);
- return;
+ return;
}
}
@@ -446,16 +408,16 @@ gst_faac_chain (GstPad *pad,
if (!faac->handle) {
GST_ELEMENT_ERROR (faac, CORE, NEGOTIATION, (NULL),
- ("format wasn't negotiated before chain function"));
+ ("format wasn't negotiated before chain function"));
gst_buffer_unref (inbuf);
return;
}
if (!GST_PAD_CAPS (faac->srcpad)) {
if (gst_faac_srcconnect (faac->srcpad,
- gst_pad_get_allowed_caps (faac->srcpad)) <= 0) {
+ gst_pad_get_allowed_caps (faac->srcpad)) <= 0) {
GST_ELEMENT_ERROR (faac, CORE, NEGOTIATION, (NULL),
- ("failed to negotiate MPEG/AAC format with next element"));
+ ("failed to negotiate MPEG/AAC format with next element"));
gst_buffer_unref (inbuf);
return;
}
@@ -472,38 +434,39 @@ gst_faac_chain (GstPad *pad,
if (in_size / faac->bps < faac->samples) {
if (in_size > size) {
GstBuffer *merge;
- /* this is panic! we got a buffer, but still don't have enough
- * data. Merge them and retry in the next cycle... */
- merge = gst_buffer_merge (faac->cache, inbuf);
+
+ /* this is panic! we got a buffer, but still don't have enough
+ * data. Merge them and retry in the next cycle... */
+ merge = gst_buffer_merge (faac->cache, inbuf);
gst_buffer_unref (faac->cache);
gst_buffer_unref (inbuf);
faac->cache = merge;
} else if (in_size == size) {
- /* this shouldn't happen, but still... */
- faac->cache = inbuf;
+ /* this shouldn't happen, but still... */
+ faac->cache = inbuf;
} else if (in_size > 0) {
- faac->cache = gst_buffer_create_sub (inbuf, size - in_size,
- in_size);
- GST_BUFFER_DURATION (faac->cache) =
- GST_BUFFER_DURATION (inbuf) * GST_BUFFER_SIZE (faac->cache) / size;
- GST_BUFFER_TIMESTAMP (faac->cache) =
- GST_BUFFER_TIMESTAMP (inbuf) + (GST_BUFFER_DURATION (inbuf) *
+ faac->cache = gst_buffer_create_sub (inbuf, size - in_size, in_size);
+ GST_BUFFER_DURATION (faac->cache) =
+ GST_BUFFER_DURATION (inbuf) * GST_BUFFER_SIZE (faac->cache) / size;
+ GST_BUFFER_TIMESTAMP (faac->cache) =
+ GST_BUFFER_TIMESTAMP (inbuf) + (GST_BUFFER_DURATION (inbuf) *
(size - in_size) / size);
- gst_buffer_unref (inbuf);
+ gst_buffer_unref (inbuf);
} else {
- gst_buffer_unref (inbuf);
+ gst_buffer_unref (inbuf);
}
-
+
return;
}
/* create the frame */
if (in_size > size) {
GstBuffer *merge;
+
/* merge */
subbuf = gst_buffer_create_sub (inbuf, 0, frame_size - (in_size - size));
GST_BUFFER_DURATION (subbuf) =
- GST_BUFFER_DURATION (inbuf) * GST_BUFFER_SIZE (subbuf) / size;
+ GST_BUFFER_DURATION (inbuf) * GST_BUFFER_SIZE (subbuf) / size;
merge = gst_buffer_merge (faac->cache, subbuf);
gst_buffer_unref (faac->cache);
gst_buffer_unref (subbuf);
@@ -512,18 +475,17 @@ gst_faac_chain (GstPad *pad,
} else {
subbuf = gst_buffer_create_sub (inbuf, size - in_size, frame_size);
GST_BUFFER_DURATION (subbuf) =
- GST_BUFFER_DURATION (inbuf) * GST_BUFFER_SIZE (subbuf) / size;
+ GST_BUFFER_DURATION (inbuf) * GST_BUFFER_SIZE (subbuf) / size;
GST_BUFFER_TIMESTAMP (subbuf) =
- GST_BUFFER_TIMESTAMP (inbuf) + (GST_BUFFER_DURATION (inbuf) *
+ GST_BUFFER_TIMESTAMP (inbuf) + (GST_BUFFER_DURATION (inbuf) *
(size - in_size) / size);
}
outbuf = gst_buffer_new_and_alloc (faac->bytes);
if ((ret_size = faacEncEncode (faac->handle,
- (gint32 *) GST_BUFFER_DATA (subbuf),
- GST_BUFFER_SIZE (subbuf) / faac->bps,
- GST_BUFFER_DATA (outbuf),
- faac->bytes)) < 0) {
+ (gint32 *) GST_BUFFER_DATA (subbuf),
+ GST_BUFFER_SIZE (subbuf) / faac->bps,
+ GST_BUFFER_DATA (outbuf), faac->bytes)) < 0) {
GST_ELEMENT_ERROR (faac, LIBRARY, ENCODE, (NULL), (NULL));
gst_buffer_unref (inbuf);
gst_buffer_unref (subbuf);
@@ -533,14 +495,14 @@ gst_faac_chain (GstPad *pad,
if (ret_size > 0) {
GST_BUFFER_SIZE (outbuf) = ret_size;
if (faac->cache_time != GST_CLOCK_TIME_NONE) {
- GST_BUFFER_TIMESTAMP (outbuf) = faac->cache_time;
- faac->cache_time = GST_CLOCK_TIME_NONE;
+ GST_BUFFER_TIMESTAMP (outbuf) = faac->cache_time;
+ faac->cache_time = GST_CLOCK_TIME_NONE;
} else
- GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (subbuf);
+ GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (subbuf);
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (subbuf);
if (faac->cache_duration) {
- GST_BUFFER_DURATION (outbuf) += faac->cache_duration;
- faac->cache_duration = 0;
+ GST_BUFFER_DURATION (outbuf) += faac->cache_duration;
+ faac->cache_duration = 0;
}
gst_pad_push (faac->srcpad, GST_DATA (outbuf));
} else {
@@ -554,7 +516,7 @@ gst_faac_chain (GstPad *pad,
gst_buffer_unref (outbuf);
if (faac->cache_time != GST_CLOCK_TIME_NONE)
- faac->cache_time = GST_BUFFER_TIMESTAMP (subbuf);
+ faac->cache_time = GST_BUFFER_TIMESTAMP (subbuf);
faac->cache_duration += GST_BUFFER_DURATION (subbuf);
}
@@ -564,10 +526,8 @@ gst_faac_chain (GstPad *pad,
}
static void
-gst_faac_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gst_faac_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstFaac *faac = GST_FAAC (object);
@@ -594,10 +554,8 @@ gst_faac_set_property (GObject *object,
}
static void
-gst_faac_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gst_faac_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
{
GstFaac *faac = GST_FAAC (object);
@@ -624,19 +582,19 @@ gst_faac_get_property (GObject *object,
}
static GstElementStateReturn
-gst_faac_change_state (GstElement *element)
+gst_faac_change_state (GstElement * element)
{
GstFaac *faac = GST_FAAC (element);
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_PAUSED_TO_READY:
if (faac->handle) {
- faacEncClose (faac->handle);
- faac->handle = NULL;
+ faacEncClose (faac->handle);
+ faac->handle = NULL;
}
if (faac->cache) {
- gst_buffer_unref (faac->cache);
- faac->cache = NULL;
+ gst_buffer_unref (faac->cache);
+ faac->cache = NULL;
}
faac->cache_time = GST_CLOCK_TIME_NONE;
faac->cache_duration = 0;
@@ -654,21 +612,13 @@ gst_faac_change_state (GstElement *element)
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- return gst_element_register (plugin, "faac",
- GST_RANK_NONE,
- GST_TYPE_FAAC);
+ return gst_element_register (plugin, "faac", GST_RANK_NONE, GST_TYPE_FAAC);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "faac",
- "Free AAC Encoder (FAAC)",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "faac",
+ "Free AAC Encoder (FAAC)",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
diff --git a/ext/faac/gstfaac.h b/ext/faac/gstfaac.h
index 55daea67..b888ed34 100644
--- a/ext/faac/gstfaac.h
+++ b/ext/faac/gstfaac.h
@@ -24,7 +24,6 @@
#include <faac.h>
G_BEGIN_DECLS
-
#define GST_TYPE_FAAC \
(gst_faac_get_type ())
#define GST_FAAC(obj) \
@@ -35,25 +34,17 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_FAAC))
#define GST_IS_FAAC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_FAAC))
-
-typedef struct _GstFaac {
+ typedef struct _GstFaac
+{
GstElement element;
/* pads */
GstPad *srcpad, *sinkpad;
/* stream properties */
- gint samplerate,
- channels,
- format,
- bps,
- bitrate,
- profile,
- shortctl;
- gboolean tns,
- midside;
- gulong bytes,
- samples;
+ gint samplerate, channels, format, bps, bitrate, profile, shortctl;
+ gboolean tns, midside;
+ gulong bytes, samples;
/* FAAC object */
faacEncHandle handle;
@@ -63,12 +54,12 @@ typedef struct _GstFaac {
guint64 cache_time, cache_duration;
} GstFaac;
-typedef struct _GstFaacClass {
+typedef struct _GstFaacClass
+{
GstElementClass parent_class;
} GstFaacClass;
GType gst_faac_get_type (void);
G_END_DECLS
-
#endif /* __GST_FAAC_H__ */
diff --git a/ext/faad/gstfaad.c b/ext/faad/gstfaad.c
index 6b10e26e..4ddc5ae7 100644
--- a/ext/faad/gstfaad.c
+++ b/ext/faad/gstfaad.c
@@ -25,52 +25,43 @@
#include "gstfaad.h"
-GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/mpeg, "
- "systemstream = (bool) FALSE, "
- "mpegversion = { (int) 2, (int) 4 }"
- )
-);
-
-GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
- "endianness = (int) BYTE_ORDER, "
- "signed = (bool) TRUE, "
- "width = (int) { 16, 24, 32 }, "
- "depth = (int) { 16, 24, 32 }, "
- "rate = (int) [ 8000, 96000 ], "
- "channels = (int) [ 1, 6 ]; "
- "audio/x-raw-float, "
- "endianness = (int) BYTE_ORDER, "
- "depth = (int) { 32, 64 }, "
- "rate = (int) [ 8000, 96000 ], "
- "channels = (int) [ 1, 6 ]"
- )
-);
-
-static void gst_faad_base_init (GstFaadClass *klass);
-static void gst_faad_class_init (GstFaadClass *klass);
-static void gst_faad_init (GstFaad *faad);
+GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/mpeg, "
+ "systemstream = (bool) FALSE, " "mpegversion = { (int) 2, (int) 4 }")
+ );
+
+GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "endianness = (int) BYTE_ORDER, "
+ "signed = (bool) TRUE, "
+ "width = (int) { 16, 24, 32 }, "
+ "depth = (int) { 16, 24, 32 }, "
+ "rate = (int) [ 8000, 96000 ], "
+ "channels = (int) [ 1, 6 ]; "
+ "audio/x-raw-float, "
+ "endianness = (int) BYTE_ORDER, "
+ "depth = (int) { 32, 64 }, "
+ "rate = (int) [ 8000, 96000 ], " "channels = (int) [ 1, 6 ]")
+ );
+
+static void gst_faad_base_init (GstFaadClass * klass);
+static void gst_faad_class_init (GstFaadClass * klass);
+static void gst_faad_init (GstFaad * faad);
static GstPadLinkReturn
- gst_faad_sinkconnect (GstPad *pad,
- const GstCaps *caps);
+gst_faad_sinkconnect (GstPad * pad, const GstCaps * caps);
static GstPadLinkReturn
- gst_faad_srcconnect (GstPad *pad,
- const GstCaps *caps);
-static GstCaps *gst_faad_srcgetcaps (GstPad *pad);
-static void gst_faad_chain (GstPad *pad,
- GstData *data);
-static GstElementStateReturn
- gst_faad_change_state (GstElement *element);
+gst_faad_srcconnect (GstPad * pad, const GstCaps * caps);
+static GstCaps *gst_faad_srcgetcaps (GstPad * pad);
+static void gst_faad_chain (GstPad * pad, GstData * data);
+static GstElementStateReturn gst_faad_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
+
/* static guint gst_faad_signals[LAST_SIGNAL] = { 0 }; */
GType
@@ -80,27 +71,26 @@ gst_faad_get_type (void)
if (!gst_faad_type) {
static const GTypeInfo gst_faad_info = {
- sizeof (GstFaadClass),
+ sizeof (GstFaadClass),
(GBaseInitFunc) gst_faad_base_init,
NULL,
(GClassInitFunc) gst_faad_class_init,
NULL,
NULL,
- sizeof(GstFaad),
+ sizeof (GstFaad),
0,
(GInstanceInitFunc) gst_faad_init,
};
gst_faad_type = g_type_register_static (GST_TYPE_ELEMENT,
- "GstFaad",
- &gst_faad_info, 0);
+ "GstFaad", &gst_faad_info, 0);
}
return gst_faad_type;
}
static void
-gst_faad_base_init (GstFaadClass *klass)
+gst_faad_base_init (GstFaadClass * klass)
{
GstElementDetails gst_faad_details = {
"Free AAC Decoder (FAAD)",
@@ -111,15 +101,15 @@ gst_faad_base_init (GstFaadClass *klass)
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&src_template));
+ gst_static_pad_template_get (&src_template));
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&sink_template));
+ gst_static_pad_template_get (&sink_template));
gst_element_class_set_details (element_class, &gst_faad_details);
}
static void
-gst_faad_class_init (GstFaadClass *klass)
+gst_faad_class_init (GstFaadClass * klass)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
@@ -129,7 +119,7 @@ gst_faad_class_init (GstFaadClass *klass)
}
static void
-gst_faad_init (GstFaad *faad)
+gst_faad_init (GstFaad * faad)
{
faad->handle = NULL;
faad->samplerate = -1;
@@ -137,14 +127,16 @@ gst_faad_init (GstFaad *faad)
GST_FLAG_SET (faad, GST_ELEMENT_EVENT_AWARE);
- faad->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&sink_template), "sink");
+ faad->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&sink_template),
+ "sink");
gst_element_add_pad (GST_ELEMENT (faad), faad->sinkpad);
gst_pad_set_chain_function (faad->sinkpad, gst_faad_chain);
gst_pad_set_link_function (faad->sinkpad, gst_faad_sinkconnect);
- faad->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&src_template), "src");
+ faad->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&src_template),
+ "src");
gst_element_add_pad (GST_ELEMENT (faad), faad->srcpad);
gst_pad_set_link_function (faad->srcpad, gst_faad_srcconnect);
@@ -152,8 +144,7 @@ gst_faad_init (GstFaad *faad)
}
static GstPadLinkReturn
-gst_faad_sinkconnect (GstPad *pad,
- const GstCaps *caps)
+gst_faad_sinkconnect (GstPad * pad, const GstCaps * caps)
{
/* oh, we really don't care what's in here. We'll
* get AAC audio (MPEG-2/4) anyway, so why bother? */
@@ -161,12 +152,11 @@ gst_faad_sinkconnect (GstPad *pad,
}
static GstCaps *
-gst_faad_srcgetcaps (GstPad *pad)
+gst_faad_srcgetcaps (GstPad * pad)
{
GstFaad *faad = GST_FAAD (gst_pad_get_parent (pad));
- if (faad->handle != NULL &&
- faad->channels != -1 && faad->samplerate != -1) {
+ if (faad->handle != NULL && faad->channels != -1 && faad->samplerate != -1) {
GstCaps *caps = gst_caps_new_empty ();
GstStructure *str;
gint fmt[] = {
@@ -176,71 +166,54 @@ gst_faad_srcgetcaps (GstPad *pad)
FAAD_FMT_FLOAT,
FAAD_FMT_DOUBLE,
-1
- }, n;
+ }
+ , n;
for (n = 0; fmt[n] != -1; n++) {
switch (n) {
- case FAAD_FMT_16BIT:
- str = gst_structure_new ("audio/x-raw-int",
- "signed", G_TYPE_BOOLEAN, TRUE,
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- NULL);
- break;
- case FAAD_FMT_24BIT:
- str = gst_structure_new ("audio/x-raw-int",
- "signed", G_TYPE_BOOLEAN, TRUE,
- "width", G_TYPE_INT, 24,
- "depth", G_TYPE_INT, 24,
- NULL);
- break;
- case FAAD_FMT_32BIT:
- str = gst_structure_new ("audio/x-raw-int",
- "signed", G_TYPE_BOOLEAN, TRUE,
- "width", G_TYPE_INT, 32,
- "depth", G_TYPE_INT, 32,
- NULL);
- break;
- case FAAD_FMT_FLOAT:
- str = gst_structure_new ("audio/x-raw-float",
- "depth", G_TYPE_INT, 32,
- NULL);
- break;
- case FAAD_FMT_DOUBLE:
- str = gst_structure_new ("audio/x-raw-float",
- "depth", G_TYPE_INT, 64,
- NULL);
- break;
- default:
- str = NULL;
- break;
+ case FAAD_FMT_16BIT:
+ str = gst_structure_new ("audio/x-raw-int",
+ "signed", G_TYPE_BOOLEAN, TRUE,
+ "width", G_TYPE_INT, 16, "depth", G_TYPE_INT, 16, NULL);
+ break;
+ case FAAD_FMT_24BIT:
+ str = gst_structure_new ("audio/x-raw-int",
+ "signed", G_TYPE_BOOLEAN, TRUE,
+ "width", G_TYPE_INT, 24, "depth", G_TYPE_INT, 24, NULL);
+ break;
+ case FAAD_FMT_32BIT:
+ str = gst_structure_new ("audio/x-raw-int",
+ "signed", G_TYPE_BOOLEAN, TRUE,
+ "width", G_TYPE_INT, 32, "depth", G_TYPE_INT, 32, NULL);
+ break;
+ case FAAD_FMT_FLOAT:
+ str = gst_structure_new ("audio/x-raw-float",
+ "depth", G_TYPE_INT, 32, NULL);
+ break;
+ case FAAD_FMT_DOUBLE:
+ str = gst_structure_new ("audio/x-raw-float",
+ "depth", G_TYPE_INT, 64, NULL);
+ break;
+ default:
+ str = NULL;
+ break;
}
if (!str)
- continue;
+ continue;
if (faad->samplerate != -1) {
- gst_structure_set (str,
- "rate", G_TYPE_INT, faad->samplerate,
- NULL);
+ gst_structure_set (str, "rate", G_TYPE_INT, faad->samplerate, NULL);
} else {
- gst_structure_set (str,
- "rate", GST_TYPE_INT_RANGE, 8000, 96000,
- NULL);
+ gst_structure_set (str, "rate", GST_TYPE_INT_RANGE, 8000, 96000, NULL);
}
if (faad->channels != -1) {
- gst_structure_set (str,
- "channels", G_TYPE_INT, faad->channels,
- NULL);
+ gst_structure_set (str, "channels", G_TYPE_INT, faad->channels, NULL);
} else {
- gst_structure_set (str,
- "channels", GST_TYPE_INT_RANGE, 1, 6,
- NULL);
+ gst_structure_set (str, "channels", GST_TYPE_INT_RANGE, 1, 6, NULL);
}
- gst_structure_set (str,
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- NULL);
+ gst_structure_set (str, "endianness", G_TYPE_INT, G_BYTE_ORDER, NULL);
gst_caps_append_structure (caps, str);
}
@@ -252,8 +225,7 @@ gst_faad_srcgetcaps (GstPad *pad)
}
static GstPadLinkReturn
-gst_faad_srcconnect (GstPad *pad,
- const GstCaps *caps)
+gst_faad_srcconnect (GstPad * pad, const GstCaps * caps)
{
GstStructure *structure;
const gchar *mimetype;
@@ -261,8 +233,7 @@ gst_faad_srcconnect (GstPad *pad,
gint depth, rate, channels;
GstFaad *faad = GST_FAAD (gst_pad_get_parent (pad));
- if (!faad->handle ||
- (faad->samplerate == -1 || faad->channels == -1)) {
+ if (!faad->handle || (faad->samplerate == -1 || faad->channels == -1)) {
return GST_PAD_LINK_DELAYED;
}
@@ -276,7 +247,7 @@ gst_faad_srcconnect (GstPad *pad,
rate != faad->samplerate || channels != faad->channels) {
return GST_PAD_LINK_REFUSED;
}
-
+
if (!strcmp (mimetype, "audio/x-raw-int")) {
gint width;
@@ -307,7 +278,7 @@ gst_faad_srcconnect (GstPad *pad,
break;
case 64:
fmt = FAAD_FMT_DOUBLE;
- break;
+ break;
}
}
@@ -327,8 +298,7 @@ gst_faad_srcconnect (GstPad *pad,
}
static void
-gst_faad_chain (GstPad *pad,
- GstData *data)
+gst_faad_chain (GstPad * pad, GstData * data)
{
GstFaad *faad = GST_FAAD (gst_pad_get_parent (pad));
GstBuffer *buf, *outbuf;
@@ -340,12 +310,12 @@ gst_faad_chain (GstPad *pad,
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
- gst_element_set_eos (GST_ELEMENT (faad));
- gst_pad_push (faad->srcpad, data);
- return;
+ gst_element_set_eos (GST_ELEMENT (faad));
+ gst_pad_push (faad->srcpad, data);
+ return;
default:
gst_pad_event_default (pad, event);
- return;
+ return;
}
}
@@ -357,8 +327,7 @@ gst_faad_chain (GstPad *pad,
guchar channels;
faacDecInit (faad->handle,
- GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf),
- &samplerate, &channels);
+ GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf), &samplerate, &channels);
faad->samplerate = samplerate;
faad->channels = channels;
ret = gst_pad_renegotiate (faad->srcpad);
@@ -370,17 +339,15 @@ gst_faad_chain (GstPad *pad,
}
out = faacDecDecode (faad->handle, &info,
- GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
+ GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
if (info.error) {
GST_ELEMENT_ERROR (faad, STREAM, DECODE, (NULL),
- ("Failed to decode buffer: %s",
- faacDecGetErrorMessage (info.error)));
+ ("Failed to decode buffer: %s", faacDecGetErrorMessage (info.error)));
gst_buffer_unref (buf);
return;
}
- if (info.samplerate != faad->samplerate ||
- info.channels != faad->channels) {
+ if (info.samplerate != faad->samplerate || info.channels != faad->channels) {
GstPadLinkReturn ret;
faad->samplerate = info.samplerate;
@@ -410,20 +377,20 @@ gst_faad_chain (GstPad *pad,
}
static GstElementStateReturn
-gst_faad_change_state (GstElement *element)
+gst_faad_change_state (GstElement * element)
{
GstFaad *faad = GST_FAAD (element);
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
if (!(faad->handle = faacDecOpen ()))
- return GST_STATE_FAILURE;
+ return GST_STATE_FAILURE;
else {
- faacDecConfiguration *conf;
+ faacDecConfiguration *conf;
- conf = faacDecGetCurrentConfiguration (faad->handle);
- conf->defObjectType = LC;
- faacDecSetConfiguration (faad->handle, conf);
+ conf = faacDecGetCurrentConfiguration (faad->handle);
+ conf->defObjectType = LC;
+ faacDecSetConfiguration (faad->handle, conf);
}
break;
case GST_STATE_PAUSED_TO_READY:
@@ -445,21 +412,13 @@ gst_faad_change_state (GstElement *element)
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- return gst_element_register (plugin, "faad",
- GST_RANK_PRIMARY,
- GST_TYPE_FAAD);
+ return gst_element_register (plugin, "faad", GST_RANK_PRIMARY, GST_TYPE_FAAD);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "faad",
- "Free AAC Decoder (FAAD)",
- plugin_init,
- VERSION,
- "GPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "faad",
+ "Free AAC Decoder (FAAD)",
+ plugin_init, VERSION, "GPL", GST_PACKAGE, GST_ORIGIN)
diff --git a/ext/faad/gstfaad.h b/ext/faad/gstfaad.h
index c834f098..394d90ac 100644
--- a/ext/faad/gstfaad.h
+++ b/ext/faad/gstfaad.h
@@ -24,7 +24,6 @@
#include <faad.h>
G_BEGIN_DECLS
-
#define GST_TYPE_FAAD \
(gst_faad_get_type ())
#define GST_FAAD(obj) \
@@ -35,28 +34,26 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_FAAD))
#define GST_IS_FAAD_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_FAAD))
-
-typedef struct _GstFaad {
+ typedef struct _GstFaad
+{
GstElement element;
/* pads */
GstPad *srcpad, *sinkpad;
/* cache for latest MPEG-frame */
- gint samplerate,
- channels,
- bps;
+ gint samplerate, channels, bps;
/* FAAD object */
faacDecHandle handle;
} GstFaad;
-typedef struct _GstFaadClass {
+typedef struct _GstFaadClass
+{
GstElementClass parent_class;
} GstFaadClass;
GType gst_faad_get_type (void);
G_END_DECLS
-
#endif /* __GST_FAAD_H__ */
diff --git a/ext/gsm/gstgsm.c b/ext/gsm/gstgsm.c
index 346cf219..25ee7c93 100644
--- a/ext/gsm/gstgsm.c
+++ b/ext/gsm/gstgsm.c
@@ -25,23 +25,19 @@
#include "gstgsmenc.h"
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
if (!gst_element_register (plugin, "gsmenc", GST_RANK_NONE, GST_TYPE_GSMENC))
return FALSE;
- if (!gst_element_register (plugin, "gsmdec", GST_RANK_PRIMARY, GST_TYPE_GSMDEC))
+ if (!gst_element_register (plugin, "gsmdec", GST_RANK_PRIMARY,
+ GST_TYPE_GSMDEC))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "gsm",
- "GSM Elements Plugin",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "gsm",
+ "GSM Elements Plugin",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
diff --git a/ext/gsm/gstgsmdec.c b/ext/gsm/gstgsmdec.c
index 1359ce97..0391a403 100644
--- a/ext/gsm/gstgsmdec.c
+++ b/ext/gsm/gstgsmdec.c
@@ -34,74 +34,72 @@ GstElementDetails gst_gsmdec_details = {
};
/* GSMDec signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
/* FILL ME */
};
-static void gst_gsmdec_base_init (gpointer g_class);
-static void gst_gsmdec_class_init (GstGSMDec *klass);
-static void gst_gsmdec_init (GstGSMDec *gsmdec);
+static void gst_gsmdec_base_init (gpointer g_class);
+static void gst_gsmdec_class_init (GstGSMDec * klass);
+static void gst_gsmdec_init (GstGSMDec * gsmdec);
-static void gst_gsmdec_chain (GstPad *pad, GstData *_data);
-static GstPadLinkReturn gst_gsmdec_sinkconnect (GstPad *pad, const GstCaps *caps);
+static void gst_gsmdec_chain (GstPad * pad, GstData * _data);
+static GstPadLinkReturn gst_gsmdec_sinkconnect (GstPad * pad,
+ const GstCaps * caps);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_gsmdec_signals[LAST_SIGNAL] = { 0 }; */
GType
-gst_gsmdec_get_type(void) {
+gst_gsmdec_get_type (void)
+{
static GType gsmdec_type = 0;
if (!gsmdec_type) {
static const GTypeInfo gsmdec_info = {
- sizeof(GstGSMDecClass),
+ sizeof (GstGSMDecClass),
gst_gsmdec_base_init,
NULL,
- (GClassInitFunc)gst_gsmdec_class_init,
+ (GClassInitFunc) gst_gsmdec_class_init,
NULL,
NULL,
- sizeof(GstGSMDec),
+ sizeof (GstGSMDec),
0,
- (GInstanceInitFunc)gst_gsmdec_init,
+ (GInstanceInitFunc) gst_gsmdec_init,
};
- gsmdec_type = g_type_register_static(GST_TYPE_ELEMENT, "GstGSMDec", &gsmdec_info, 0);
+ gsmdec_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstGSMDec", &gsmdec_info, 0);
}
return gsmdec_type;
}
static GstStaticPadTemplate gsmdec_sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
+GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "audio/x-gsm, "
- "rate = (int) [ 1000, 48000 ], "
- "channels = (int) 1"
- )
-);
+ GST_STATIC_CAPS ("audio/x-gsm, "
+ "rate = (int) [ 1000, 48000 ], " "channels = (int) 1")
+ );
static GstStaticPadTemplate gsmdec_src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
+GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "audio/x-raw-int, "
- "endianness = (int) BYTE_ORDER, "
- "signed = (boolean) true, "
- "width = (int) 16, "
- "depth = (int) 16, "
- "rate = (int) [ 1000, 48000 ], "
- "channels = (int) 1"
- )
-);
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "endianness = (int) BYTE_ORDER, "
+ "signed = (boolean) true, "
+ "width = (int) 16, "
+ "depth = (int) 16, "
+ "rate = (int) [ 1000, 48000 ], " "channels = (int) 1")
+ );
static void
gst_gsmdec_base_init (gpointer g_class)
@@ -116,29 +114,31 @@ gst_gsmdec_base_init (gpointer g_class)
}
static void
-gst_gsmdec_class_init (GstGSMDec *klass)
+gst_gsmdec_class_init (GstGSMDec * klass)
{
GstElementClass *gstelement_class;
- gstelement_class = (GstElementClass*)klass;
+ gstelement_class = (GstElementClass *) klass;
- parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
+ parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
}
static void
-gst_gsmdec_init (GstGSMDec *gsmdec)
+gst_gsmdec_init (GstGSMDec * gsmdec)
{
GST_DEBUG ("gst_gsmdec_init: initializing");
/* create the sink and src pads */
- gsmdec->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gsmdec_sink_template), "sink");
+ gsmdec->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gsmdec_sink_template), "sink");
gst_element_add_pad (GST_ELEMENT (gsmdec), gsmdec->sinkpad);
gst_pad_set_chain_function (gsmdec->sinkpad, gst_gsmdec_chain);
gst_pad_set_link_function (gsmdec->sinkpad, gst_gsmdec_sinkconnect);
- gsmdec->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gsmdec_src_template), "src");
+ gsmdec->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gsmdec_src_template), "src");
gst_element_add_pad (GST_ELEMENT (gsmdec), gsmdec->srcpad);
gsmdec->state = gsm_create ();
@@ -146,60 +146,59 @@ gst_gsmdec_init (GstGSMDec *gsmdec)
}
static GstPadLinkReturn
-gst_gsmdec_sinkconnect (GstPad *pad, const GstCaps *caps)
+gst_gsmdec_sinkconnect (GstPad * pad, const GstCaps * caps)
{
GstGSMDec *gsmdec;
gint rate;
GstStructure *structure;
-
+
gsmdec = GST_GSMDEC (gst_pad_get_parent (pad));
structure = gst_caps_get_structure (caps, 0);
- gst_structure_get_int (structure, "rate", &rate);
-
- if (gst_pad_try_set_caps (gsmdec->srcpad,
- gst_caps_new_simple ("audio/x-raw-int",
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "rate", G_TYPE_INT, rate,
- "channels", G_TYPE_INT, 1,
- NULL)) > 0)
- {
+ gst_structure_get_int (structure, "rate", &rate);
+
+ if (gst_pad_try_set_caps (gsmdec->srcpad,
+ gst_caps_new_simple ("audio/x-raw-int",
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "signed", G_TYPE_BOOLEAN, TRUE,
+ "width", G_TYPE_INT, 16,
+ "depth", G_TYPE_INT, 16,
+ "rate", G_TYPE_INT, rate, "channels", G_TYPE_INT, 1, NULL)) > 0) {
return GST_PAD_LINK_OK;
}
return GST_PAD_LINK_REFUSED;
}
static void
-gst_gsmdec_chain (GstPad *pad, GstData *_data)
+gst_gsmdec_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstGSMDec *gsmdec;
gsm_byte *data;
guint size;
- 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);
/*g_return_if_fail(GST_IS_BUFFER(buf)); */
gsmdec = GST_GSMDEC (gst_pad_get_parent (pad));
- data = (gsm_byte*) GST_BUFFER_DATA (buf);
+ data = (gsm_byte *) GST_BUFFER_DATA (buf);
size = GST_BUFFER_SIZE (buf);
if (gsmdec->bufsize && (gsmdec->bufsize + size >= 33)) {
GstBuffer *outbuf;
- memcpy (gsmdec->buffer + gsmdec->bufsize, data, (33 - gsmdec->bufsize) * sizeof (gsm_byte));
+ memcpy (gsmdec->buffer + gsmdec->bufsize, data,
+ (33 - gsmdec->bufsize) * sizeof (gsm_byte));
outbuf = gst_buffer_new ();
GST_BUFFER_DATA (outbuf) = g_malloc (160 * sizeof (gsm_signal));
GST_BUFFER_SIZE (outbuf) = 160 * sizeof (gsm_signal);
- gsm_decode (gsmdec->state, gsmdec->buffer, (gsm_signal *) GST_BUFFER_DATA (outbuf));
+ gsm_decode (gsmdec->state, gsmdec->buffer,
+ (gsm_signal *) GST_BUFFER_DATA (outbuf));
gst_pad_push (gsmdec->srcpad, GST_DATA (outbuf));
@@ -214,8 +213,8 @@ gst_gsmdec_chain (GstPad *pad, GstData *_data)
outbuf = gst_buffer_new ();
GST_BUFFER_DATA (outbuf) = g_malloc (160 * sizeof (gsm_signal));
GST_BUFFER_SIZE (outbuf) = 160 * sizeof (gsm_signal);
-
- gsm_decode (gsmdec->state, data, (gsm_signal *)GST_BUFFER_DATA (outbuf));
+
+ gsm_decode (gsmdec->state, data, (gsm_signal *) GST_BUFFER_DATA (outbuf));
gst_pad_push (gsmdec->srcpad, GST_DATA (outbuf));
@@ -228,6 +227,5 @@ gst_gsmdec_chain (GstPad *pad, GstData *_data)
gsmdec->bufsize += size;
}
- gst_buffer_unref(buf);
+ gst_buffer_unref (buf);
}
-
diff --git a/ext/gsm/gstgsmdec.h b/ext/gsm/gstgsmdec.h
index 0544128b..da2d4ca6 100644
--- a/ext/gsm/gstgsmdec.h
+++ b/ext/gsm/gstgsmdec.h
@@ -31,8 +31,9 @@
#endif
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_GSMDEC \
@@ -46,30 +47,32 @@ extern "C" {
#define GST_IS_GSMDEC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GSMDEC))
-typedef struct _GstGSMDec GstGSMDec;
-typedef struct _GstGSMDecClass GstGSMDecClass;
+ typedef struct _GstGSMDec GstGSMDec;
+ typedef struct _GstGSMDecClass GstGSMDecClass;
-struct _GstGSMDec {
- GstElement element;
+ struct _GstGSMDec
+ {
+ GstElement element;
- /* pads */
- GstPad *sinkpad,*srcpad;
+ /* pads */
+ GstPad *sinkpad, *srcpad;
- gsm state;
- gsm_byte buffer[33];
- gint bufsize;
-};
+ gsm state;
+ gsm_byte buffer[33];
+ gint bufsize;
+ };
-struct _GstGSMDecClass {
- GstElementClass parent_class;
-};
+ struct _GstGSMDecClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_gsmdec_get_type(void);
+ GType gst_gsmdec_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_GSMDEC_H__ */
+#endif /* __GST_GSMDEC_H__ */
diff --git a/ext/gsm/gstgsmenc.c b/ext/gsm/gstgsmenc.c
index 760c3bbc..c59a7c82 100644
--- a/ext/gsm/gstgsmenc.c
+++ b/ext/gsm/gstgsmenc.c
@@ -34,23 +34,26 @@ GstElementDetails gst_gsmenc_details = {
};
/* GSMEnc signals and args */
-enum {
+enum
+{
FRAME_ENCODED,
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
/* FILL ME */
};
-static void gst_gsmenc_base_init (gpointer g_class);
-static void gst_gsmenc_class_init (GstGSMEnc *klass);
-static void gst_gsmenc_init (GstGSMEnc *gsmenc);
+static void gst_gsmenc_base_init (gpointer g_class);
+static void gst_gsmenc_class_init (GstGSMEnc * klass);
+static void gst_gsmenc_init (GstGSMEnc * gsmenc);
-static void gst_gsmenc_chain (GstPad *pad,GstData *_data);
-static GstPadLinkReturn gst_gsmenc_sinkconnect (GstPad *pad, const GstCaps *caps);
+static void gst_gsmenc_chain (GstPad * pad, GstData * _data);
+static GstPadLinkReturn gst_gsmenc_sinkconnect (GstPad * pad,
+ const GstCaps * caps);
static GstElementClass *parent_class = NULL;
static guint gst_gsmenc_signals[LAST_SIGNAL] = { 0 };
@@ -63,7 +66,7 @@ gst_gsmenc_get_type (void)
if (!gsmenc_type) {
static const GTypeInfo gsmenc_info = {
sizeof (GstGSMEncClass),
- gst_gsmenc_base_init,
+ gst_gsmenc_base_init,
NULL,
(GClassInitFunc) gst_gsmenc_class_init,
NULL,
@@ -72,38 +75,31 @@ gst_gsmenc_get_type (void)
0,
(GInstanceInitFunc) gst_gsmenc_init,
};
- gsmenc_type = g_type_register_static (GST_TYPE_ELEMENT, "GstGSMEnc", &gsmenc_info, 0);
+ gsmenc_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstGSMEnc", &gsmenc_info, 0);
}
return gsmenc_type;
}
static GstStaticPadTemplate gsmenc_src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "audio/x-gsm, "
- "rate = (int) [ 1000, 48000 ], "
- "channels = (int) 1"
- )
-);
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-gsm, "
+ "rate = (int) [ 1000, 48000 ], " "channels = (int) 1")
+ );
static GstStaticPadTemplate gsmenc_sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "audio/x-raw-int, "
- "endianness = (int) BYTE_ORDER, "
- "signed = (boolean) true, "
- "width = (int) 16, "
- "depth = (int) 16, "
- "rate = (int) [ 1000, 48000 ], "
- "channels = (int) 1"
- )
-);
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "endianness = (int) BYTE_ORDER, "
+ "signed = (boolean) true, "
+ "width = (int) 16, "
+ "depth = (int) 16, "
+ "rate = (int) [ 1000, 48000 ], " "channels = (int) 1")
+ );
static void
gst_gsmenc_base_init (gpointer g_class)
@@ -116,37 +112,39 @@ gst_gsmenc_base_init (gpointer g_class)
gst_static_pad_template_get (&gsmenc_src_template));
gst_element_class_set_details (element_class, &gst_gsmenc_details);
}
-
+
static void
-gst_gsmenc_class_init (GstGSMEnc *klass)
+gst_gsmenc_class_init (GstGSMEnc * 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);
gst_gsmenc_signals[FRAME_ENCODED] =
- g_signal_new ("frame-encoded", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstGSMEncClass, frame_encoded), NULL, NULL,
- g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("frame-encoded", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstGSMEncClass, frame_encoded), NULL,
+ NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}
static void
-gst_gsmenc_init (GstGSMEnc *gsmenc)
+gst_gsmenc_init (GstGSMEnc * gsmenc)
{
/* create the sink and src pads */
- gsmenc->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gsmenc_sink_template), "sink");
+ gsmenc->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gsmenc_sink_template), "sink");
gst_element_add_pad (GST_ELEMENT (gsmenc), gsmenc->sinkpad);
gst_pad_set_chain_function (gsmenc->sinkpad, gst_gsmenc_chain);
gst_pad_set_link_function (gsmenc->sinkpad, gst_gsmenc_sinkconnect);
- gsmenc->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gsmenc_src_template), "src");
+ gsmenc->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gsmenc_src_template), "src");
gst_element_add_pad (GST_ELEMENT (gsmenc), gsmenc->srcpad);
gsmenc->state = gsm_create ();
@@ -156,7 +154,7 @@ gst_gsmenc_init (GstGSMEnc *gsmenc)
}
static GstPadLinkReturn
-gst_gsmenc_sinkconnect (GstPad *pad, const GstCaps *caps)
+gst_gsmenc_sinkconnect (GstPad * pad, const GstCaps * caps)
{
GstGSMEnc *gsmenc;
GstStructure *structure;
@@ -164,13 +162,11 @@ gst_gsmenc_sinkconnect (GstPad *pad, const GstCaps *caps)
gsmenc = GST_GSMENC (gst_pad_get_parent (pad));
structure = gst_caps_get_structure (caps, 0);
- gst_structure_get_int (structure, "rate", &gsmenc->rate);
+ gst_structure_get_int (structure, "rate", &gsmenc->rate);
if (gst_pad_try_set_caps (gsmenc->srcpad,
- gst_caps_new_simple("audio/x-gsm",
- "rate", G_TYPE_INT, gsmenc->rate,
- "channels", G_TYPE_INT, 1,
- NULL)) > 0)
- {
+ gst_caps_new_simple ("audio/x-gsm",
+ "rate", G_TYPE_INT, gsmenc->rate,
+ "channels", G_TYPE_INT, 1, NULL)) > 0) {
return GST_PAD_LINK_OK;
}
return GST_PAD_LINK_REFUSED;
@@ -178,7 +174,7 @@ gst_gsmenc_sinkconnect (GstPad *pad, const GstCaps *caps)
}
static void
-gst_gsmenc_chain (GstPad *pad, GstData *_data)
+gst_gsmenc_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstGSMEnc *gsmenc;
@@ -190,26 +186,28 @@ gst_gsmenc_chain (GstPad *pad, GstData *_data)
g_return_if_fail (buf != NULL);
gsmenc = GST_GSMENC (GST_OBJECT_PARENT (pad));
-
- data = (gsm_signal*) GST_BUFFER_DATA (buf);
+
+ data = (gsm_signal *) GST_BUFFER_DATA (buf);
size = GST_BUFFER_SIZE (buf) / sizeof (gsm_signal);
if (gsmenc->bufsize && (gsmenc->bufsize + size >= 160)) {
GstBuffer *outbuf;
- memcpy (gsmenc->buffer + gsmenc->bufsize, data, (160 - gsmenc->bufsize) * sizeof (gsm_signal));
+ memcpy (gsmenc->buffer + gsmenc->bufsize, data,
+ (160 - gsmenc->bufsize) * sizeof (gsm_signal));
outbuf = gst_buffer_new ();
GST_BUFFER_DATA (outbuf) = g_malloc (33 * sizeof (gsm_byte));
GST_BUFFER_SIZE (outbuf) = 33 * sizeof (gsm_byte);
- gsm_encode (gsmenc->state, gsmenc->buffer, (gsm_byte *) GST_BUFFER_DATA (outbuf));
+ gsm_encode (gsmenc->state, gsmenc->buffer,
+ (gsm_byte *) GST_BUFFER_DATA (outbuf));
GST_BUFFER_TIMESTAMP (outbuf) = gsmenc->next_ts;
gst_pad_push (gsmenc->srcpad, GST_DATA (outbuf));
gsmenc->next_ts += (160.0 / gsmenc->rate) * 1000000;
- size -= (160 - gsmenc->bufsize);
+ size -= (160 - gsmenc->bufsize);
data += (160 - gsmenc->bufsize);
gsmenc->bufsize = 0;
}
@@ -236,5 +234,5 @@ gst_gsmenc_chain (GstPad *pad, GstData *_data)
gsmenc->bufsize += size;
}
- gst_buffer_unref(buf);
+ gst_buffer_unref (buf);
}
diff --git a/ext/gsm/gstgsmenc.h b/ext/gsm/gstgsmenc.h
index 2366ed69..397ff633 100644
--- a/ext/gsm/gstgsmenc.h
+++ b/ext/gsm/gstgsmenc.h
@@ -31,8 +31,9 @@
#endif
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_GSMENC \
@@ -46,36 +47,38 @@ extern "C" {
#define GST_IS_GSMENC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GSMENC))
-typedef struct _GstGSMEnc GstGSMEnc;
-typedef struct _GstGSMEncClass GstGSMEncClass;
+ typedef struct _GstGSMEnc GstGSMEnc;
+ typedef struct _GstGSMEncClass GstGSMEncClass;
-struct _GstGSMEnc {
- GstElement element;
+ struct _GstGSMEnc
+ {
+ GstElement element;
- /* pads */
- GstPad *sinkpad,*srcpad;
+ /* pads */
+ GstPad *sinkpad, *srcpad;
- gsm state;
- gsm_signal buffer[160];
- gint bufsize;
+ gsm state;
+ gsm_signal buffer[160];
+ gint bufsize;
- guint64 next_ts;
- gint rate;
-};
+ guint64 next_ts;
+ gint rate;
+ };
-struct _GstGSMEncClass {
- GstElementClass parent_class;
+ struct _GstGSMEncClass
+ {
+ GstElementClass parent_class;
- /* signals */
- void (*frame_encoded) (GstElement *element);
-};
+ /* signals */
+ void (*frame_encoded) (GstElement * element);
+ };
-GType gst_gsmenc_get_type(void);
+ GType gst_gsmenc_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_GSMENC_H__ */
+#endif /* __GST_GSMENC_H__ */
diff --git a/ext/hermes/gsthermescolorspace.c b/ext/hermes/gsthermescolorspace.c
index f2d17471..d6cbe965 100644
--- a/ext/hermes/gsthermescolorspace.c
+++ b/ext/hermes/gsthermescolorspace.c
@@ -39,7 +39,8 @@
typedef struct _GstHermesColorspace GstHermesColorspace;
typedef struct _GstHermesColorspaceClass GstHermesColorspaceClass;
-typedef enum {
+typedef enum
+{
GST_HERMES_COLORSPACE_NONE,
GST_HERMES_COLORSPACE_HERMES,
GST_HERMES_COLORSPACE_YUV_RGB,
@@ -49,10 +50,11 @@ typedef enum {
GST_HERMES_COLORSPACE_420_SWAP,
} GstColorSpaceConverterType;
-struct _GstHermesColorspace {
+struct _GstHermesColorspace
+{
GstElement element;
- GstPad *sinkpad,*srcpad;
+ GstPad *sinkpad, *srcpad;
HermesHandle h_handle;
HermesFormat sink_format;
@@ -63,7 +65,7 @@ struct _GstHermesColorspace {
int src_size;
int sink_size;
-
+
int src_stride;
int sink_stride;
@@ -72,26 +74,28 @@ struct _GstHermesColorspace {
gboolean passthru;
};
-struct _GstHermesColorspaceClass {
+struct _GstHermesColorspaceClass
+{
GstElementClass parent_class;
};
-GType gst_hermes_colorspace_get_type(void);
+GType gst_hermes_colorspace_get_type (void);
-typedef struct _GstHermesColorspaceFormat {
+typedef struct _GstHermesColorspaceFormat
+{
GstStaticCaps caps;
} GstHermesColorspaceFormat;
static GstHermesColorspaceFormat gst_hermes_colorspace_formats[] = {
- { GST_STATIC_CAPS (GST_VIDEO_CAPS_xRGB) },
- { GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBx) },
- { GST_STATIC_CAPS (GST_VIDEO_CAPS_BGRx) },
- { GST_STATIC_CAPS (GST_VIDEO_CAPS_xBGR) },
- { GST_STATIC_CAPS (GST_VIDEO_CAPS_BGR) },
- { GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB) },
- { GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB_15) },
- { GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB_16) },
+ {GST_STATIC_CAPS (GST_VIDEO_CAPS_xRGB)},
+ {GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBx)},
+ {GST_STATIC_CAPS (GST_VIDEO_CAPS_BGRx)},
+ {GST_STATIC_CAPS (GST_VIDEO_CAPS_xBGR)},
+ {GST_STATIC_CAPS (GST_VIDEO_CAPS_BGR)},
+ {GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB)},
+ {GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB_15)},
+ {GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB_16)},
};
static GstElementDetails colorspace_details = {
@@ -103,39 +107,43 @@ static GstElementDetails colorspace_details = {
/* Stereo signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_SOURCE,
ARG_DEST,
};
-static void gst_hermes_colorspace_base_init (gpointer g_class);
-static void gst_hermes_colorspace_class_init (GstHermesColorspaceClass *klass);
-static void gst_hermes_colorspace_init (GstHermesColorspace *space);
+static void gst_hermes_colorspace_base_init (gpointer g_class);
+static void gst_hermes_colorspace_class_init (GstHermesColorspaceClass * klass);
+static void gst_hermes_colorspace_init (GstHermesColorspace * space);
-static void gst_hermes_colorspace_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_hermes_colorspace_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_hermes_colorspace_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_hermes_colorspace_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
static GstPadLinkReturn
- gst_hermes_colorspace_link (GstPad *pad, const GstCaps *caps);
-static void gst_hermes_colorspace_chain (GstPad *pad, GstData *_data);
+gst_hermes_colorspace_link (GstPad * pad, const GstCaps * caps);
+static void gst_hermes_colorspace_chain (GstPad * pad, GstData * _data);
static GstElementStateReturn
- gst_hermes_colorspace_change_state (GstElement *element);
+gst_hermes_colorspace_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_hermes_colorspace_signals[LAST_SIGNAL] = { 0 }; */
#if 0
-static gboolean
-colorspace_setup_converter (GstHermesColorspace *space, GstCaps *from_caps, GstCaps *to_caps)
+static gboolean
+colorspace_setup_converter (GstHermesColorspace * space, GstCaps * from_caps,
+ GstCaps * to_caps)
{
guint32 from_space, to_space;
GstStructure *from_struct;
@@ -147,138 +155,142 @@ colorspace_setup_converter (GstHermesColorspace *space, GstCaps *from_caps, GstC
from_struct = gst_caps_get_structure (from_caps, 0);
to_struct = gst_caps_get_structure (to_caps, 0);
- from_space = GST_MAKE_FOURCC ('R','G','B',' ');
+ from_space = GST_MAKE_FOURCC ('R', 'G', 'B', ' ');
gst_structure_get_fourcc (from_struct, "format", &from_space);
- to_space = GST_MAKE_FOURCC ('R','G','B',' ');
+ to_space = GST_MAKE_FOURCC ('R', 'G', 'B', ' ');
gst_structure_get_fourcc (to_struct, "format", &to_space);
- GST_INFO ("set up converter for " GST_FOURCC_FORMAT
- " (%08x) to " GST_FOURCC_FORMAT " (%08x)",
- GST_FOURCC_ARGS (from_space), from_space,
- GST_FOURCC_ARGS (to_space), to_space);
+ GST_INFO ("set up converter for " GST_FOURCC_FORMAT
+ " (%08x) to " GST_FOURCC_FORMAT " (%08x)",
+ GST_FOURCC_ARGS (from_space), from_space,
+ GST_FOURCC_ARGS (to_space), to_space);
switch (from_space) {
- case GST_MAKE_FOURCC ('R','G','B',' '):
+ case GST_MAKE_FOURCC ('R', 'G', 'B', ' '):
{
gint from_bpp;
-
+
gst_structure_get_int (from_struct, "bpp", &from_bpp);
switch (to_space) {
- case GST_MAKE_FOURCC ('R','G','B',' '):
+ case GST_MAKE_FOURCC ('R', 'G', 'B', ' '):
#ifdef HAVE_HERMES
- {
- gint to_bpp;
-
- gst_structure_get_int (to_struct, "bpp", &to_bpp);
+ {
+ gint to_bpp;
- gst_structure_get_int (from_struct, "red_mask", &space->source.r);
+ gst_structure_get_int (to_struct, "bpp", &to_bpp);
+
+ gst_structure_get_int (from_struct, "red_mask", &space->source.r);
gst_structure_get_int (from_struct, "green_mask", &space->source.g);
- gst_structure_get_int (from_struct, "blue_mask", &space->source.b);
+ gst_structure_get_int (from_struct, "blue_mask", &space->source.b);
space->source.a = 0;
space->srcbpp = space->source.bits = from_bpp;
space->source.indexed = 0;
space->source.has_colorkey = 0;
- GST_INFO ( "source red mask %08x", space->source.r);
- GST_INFO ( "source green mask %08x", space->source.g);
- GST_INFO ( "source blue mask %08x", space->source.b);
- GST_INFO ( "source bpp %08x", space->srcbpp);
+ GST_INFO ("source red mask %08x", space->source.r);
+ GST_INFO ("source green mask %08x", space->source.g);
+ GST_INFO ("source blue mask %08x", space->source.b);
+ GST_INFO ("source bpp %08x", space->srcbpp);
- gst_structure_get_int (to_struct, "red_mask", &space->dest.r);
+ gst_structure_get_int (to_struct, "red_mask", &space->dest.r);
gst_structure_get_int (to_struct, "green_mask", &space->dest.g);
- gst_structure_get_int (to_struct, "blue_mask", &space->dest.b);
+ gst_structure_get_int (to_struct, "blue_mask", &space->dest.b);
space->dest.a = 0;
space->destbpp = space->dest.bits = to_bpp;
space->dest.indexed = 0;
space->dest.has_colorkey = 0;
- GST_INFO ( "dest red mask %08x", space->dest.r);
- GST_INFO ( "dest green mask %08x", space->dest.g);
- GST_INFO ( "dest blue mask %08x", space->dest.b);
- GST_INFO ( "dest bpp %08x", space->destbpp);
+ GST_INFO ("dest red mask %08x", space->dest.r);
+ GST_INFO ("dest green mask %08x", space->dest.g);
+ GST_INFO ("dest blue mask %08x", space->dest.b);
+ GST_INFO ("dest bpp %08x", space->destbpp);
- if (!Hermes_ConverterRequest (space->h_handle, &space->source, &space->dest)) {
+ if (!Hermes_ConverterRequest (space->h_handle, &space->source,
+ &space->dest)) {
g_warning ("Hermes: could not get converter\n");
return FALSE;
}
- GST_INFO ( "converter set up");
- space->type = GST_HERMES_COLORSPACE_HERMES;
+ GST_INFO ("converter set up");
+ space->type = GST_HERMES_COLORSPACE_HERMES;
return TRUE;
}
#else
g_warning ("colorspace: compiled without hermes!");
return FALSE;
#endif
- case GST_MAKE_FOURCC ('Y','V','1','2'):
+ case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
if (from_bpp == 32) {
- space->type = GST_HERMES_COLORSPACE_RGB32_YV12;
+ space->type = GST_HERMES_COLORSPACE_RGB32_YV12;
space->destbpp = 12;
return TRUE;
}
- case GST_MAKE_FOURCC ('I','4','2','0'):
+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):
if (from_bpp == 32) {
- space->type = GST_HERMES_COLORSPACE_RGB32_I420;
+ space->type = GST_HERMES_COLORSPACE_RGB32_I420;
space->destbpp = 12;
return TRUE;
}
- case GST_MAKE_FOURCC ('Y','U','Y','2'):
- GST_INFO ( "colorspace: RGB to YUV with bpp %d not implemented!!", from_bpp);
+ case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
+ GST_INFO ("colorspace: RGB to YUV with bpp %d not implemented!!",
+ from_bpp);
return FALSE;
}
break;
}
- case GST_MAKE_FOURCC ('I','4','2','0'):
+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):
switch (to_space) {
- case GST_MAKE_FOURCC ('R','G','B',' '):
- GST_INFO ( "colorspace: YUV to RGB");
+ case GST_MAKE_FOURCC ('R', 'G', 'B', ' '):
+ GST_INFO ("colorspace: YUV to RGB");
gst_structure_get_int (to_struct, "bpp", &space->destbpp);
- space->converter = gst_hermes_colorspace_yuv2rgb_get_converter (from_caps, to_caps);
- space->type = GST_HERMES_COLORSPACE_YUV_RGB;
+ space->converter =
+ gst_hermes_colorspace_yuv2rgb_get_converter (from_caps, to_caps);
+ space->type = GST_HERMES_COLORSPACE_YUV_RGB;
return TRUE;
- case GST_MAKE_FOURCC ('I','4','2','0'):
- space->type = GST_HERMES_COLORSPACE_NONE;
+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):
+ space->type = GST_HERMES_COLORSPACE_NONE;
space->destbpp = 12;
return TRUE;
- case GST_MAKE_FOURCC ('Y','V','1','2'):
- space->type = GST_HERMES_COLORSPACE_420_SWAP;
+ case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
+ space->type = GST_HERMES_COLORSPACE_420_SWAP;
space->destbpp = 12;
return TRUE;
}
break;
- case GST_MAKE_FOURCC ('Y','U','Y','2'):
+ case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
switch (to_space) {
- case GST_MAKE_FOURCC ('I','4','2','0'):
- space->type = GST_HERMES_COLORSPACE_YUY2_I420;
+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):
+ space->type = GST_HERMES_COLORSPACE_YUY2_I420;
space->destbpp = 12;
return TRUE;
- case GST_MAKE_FOURCC ('Y','U','Y','2'):
- space->type = GST_HERMES_COLORSPACE_NONE;
+ case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
+ space->type = GST_HERMES_COLORSPACE_NONE;
space->destbpp = 16;
return TRUE;
- case GST_MAKE_FOURCC ('R','G','B',' '):
- GST_INFO ( "colorspace: YUY2 to RGB not implemented!!");
+ case GST_MAKE_FOURCC ('R', 'G', 'B', ' '):
+ GST_INFO ("colorspace: YUY2 to RGB not implemented!!");
return FALSE;
}
break;
- case GST_MAKE_FOURCC ('Y','V','1','2'):
+ case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
switch (to_space) {
- case GST_MAKE_FOURCC ('R','G','B',' '):
- GST_INFO ( "colorspace: YV12 to RGB");
+ case GST_MAKE_FOURCC ('R', 'G', 'B', ' '):
+ GST_INFO ("colorspace: YV12 to RGB");
gst_structure_get_int (to_struct, "bpp", &space->destbpp);
- space->converter = gst_hermes_colorspace_yuv2rgb_get_converter (from_caps, to_caps);
- space->type = GST_HERMES_COLORSPACE_YUV_RGB;
+ space->converter =
+ gst_hermes_colorspace_yuv2rgb_get_converter (from_caps, to_caps);
+ space->type = GST_HERMES_COLORSPACE_YUV_RGB;
return TRUE;
- case GST_MAKE_FOURCC ('I','4','2','0'):
- space->type = GST_HERMES_COLORSPACE_420_SWAP;
+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):
+ space->type = GST_HERMES_COLORSPACE_420_SWAP;
space->destbpp = 12;
return TRUE;
- case GST_MAKE_FOURCC ('Y','V','1','2'):
- space->type = GST_HERMES_COLORSPACE_NONE;
+ case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
+ space->type = GST_HERMES_COLORSPACE_NONE;
space->destbpp = 12;
return TRUE;
}
@@ -289,13 +301,13 @@ colorspace_setup_converter (GstHermesColorspace *space, GstCaps *from_caps, GstC
#endif
static GstCaps *
-gst_hermes_colorspace_caps_remove_format_info (GstCaps *caps)
+gst_hermes_colorspace_caps_remove_format_info (GstCaps * caps)
{
int i;
GstStructure *structure;
GstCaps *rgbcaps;
- for (i=0; i<gst_caps_get_size (caps); i++) {
+ for (i = 0; i < gst_caps_get_size (caps); i++) {
structure = gst_caps_get_structure (caps, i);
gst_structure_remove_field (structure, "format");
@@ -314,26 +326,26 @@ gst_hermes_colorspace_caps_remove_format_info (GstCaps *caps)
}
static void
-gst_hermes_colorspace_structure_to_hermes_format (HermesFormat *format,
- GstStructure *structure)
+gst_hermes_colorspace_structure_to_hermes_format (HermesFormat * format,
+ GstStructure * structure)
{
- gst_structure_get_int (structure, "red_mask", &format->r);
+ gst_structure_get_int (structure, "red_mask", &format->r);
gst_structure_get_int (structure, "green_mask", &format->g);
- gst_structure_get_int (structure, "blue_mask", &format->b);
+ gst_structure_get_int (structure, "blue_mask", &format->b);
format->a = 0;
- gst_structure_get_int (structure, "bpp", &format->bits);
+ gst_structure_get_int (structure, "bpp", &format->bits);
format->indexed = 0;
format->has_colorkey = 0;
}
-static GstCaps*
-gst_hermes_colorspace_getcaps (GstPad *pad)
+static GstCaps *
+gst_hermes_colorspace_getcaps (GstPad * pad)
{
GstHermesColorspace *space;
GstPad *otherpad;
GstCaps *othercaps;
GstCaps *caps;
-
+
space = GST_HERMES_COLORSPACE (gst_pad_get_parent (pad));
otherpad = (pad == space->srcpad) ? space->sinkpad : space->srcpad;
@@ -349,7 +361,7 @@ gst_hermes_colorspace_getcaps (GstPad *pad)
}
static GstPadLinkReturn
-gst_hermes_colorspace_link (GstPad *pad, const GstCaps *caps)
+gst_hermes_colorspace_link (GstPad * pad, const GstCaps * caps)
{
GstHermesColorspace *space;
GstPad *otherpad;
@@ -370,12 +382,13 @@ gst_hermes_colorspace_link (GstPad *pad, const GstCaps *caps)
structure = gst_caps_get_structure (caps, 0);
- for(i=0; i<G_N_ELEMENTS (gst_hermes_colorspace_formats); i++) {
+ for (i = 0; i < G_N_ELEMENTS (gst_hermes_colorspace_formats); i++) {
GstCaps *icaps;
GstCaps *fcaps;
-
- fcaps = gst_caps_copy (gst_static_caps_get (
- &gst_hermes_colorspace_formats[i].caps));
+
+ fcaps =
+ gst_caps_copy (gst_static_caps_get (&gst_hermes_colorspace_formats[i].
+ caps));
icaps = gst_caps_intersect (caps, fcaps);
if (!gst_caps_is_empty (icaps)) {
@@ -383,7 +396,7 @@ gst_hermes_colorspace_link (GstPad *pad, const GstCaps *caps)
}
gst_caps_free (icaps);
}
- if (i==G_N_ELEMENTS (gst_hermes_colorspace_formats)) {
+ if (i == G_N_ELEMENTS (gst_hermes_colorspace_formats)) {
g_assert_not_reached ();
return GST_PAD_LINK_REFUSED;
}
@@ -392,17 +405,16 @@ gst_hermes_colorspace_link (GstPad *pad, const GstCaps *caps)
gst_structure_get_int (structure, "height", &height);
gst_structure_get_double (structure, "framerate", &fps);
- GST_INFO ( "size: %dx%d", space->width, space->height);
+ GST_INFO ("size: %dx%d", space->width, space->height);
if (gst_pad_is_negotiated (otherpad)) {
GstCaps *othercaps;
-
+
othercaps = gst_caps_copy (gst_pad_get_negotiated_caps (otherpad));
gst_caps_set_simple (othercaps,
- "width", G_TYPE_INT, width,
- "height", G_TYPE_INT, height,
- "framerate", G_TYPE_DOUBLE, fps, NULL);
+ "width", G_TYPE_INT, width,
+ "height", G_TYPE_INT, height, "framerate", G_TYPE_DOUBLE, fps, NULL);
link_ret = gst_pad_try_set_caps (otherpad, othercaps);
if (link_ret != GST_PAD_LINK_OK) {
@@ -412,14 +424,16 @@ gst_hermes_colorspace_link (GstPad *pad, const GstCaps *caps)
if (pad == space->srcpad) {
space->src_format_index = i;
- gst_hermes_colorspace_structure_to_hermes_format (&space->src_format, structure);
+ gst_hermes_colorspace_structure_to_hermes_format (&space->src_format,
+ structure);
} else {
space->sink_format_index = i;
- gst_hermes_colorspace_structure_to_hermes_format (&space->sink_format, structure);
+ gst_hermes_colorspace_structure_to_hermes_format (&space->sink_format,
+ structure);
}
- space->sink_stride = width*(space->sink_format.bits/8);
- space->src_stride = width*(space->src_format.bits/8);
+ space->sink_stride = width * (space->sink_format.bits / 8);
+ space->src_stride = width * (space->src_format.bits / 8);
space->sink_size = space->sink_stride * height;
space->src_size = space->src_stride * height;
space->width = width;
@@ -428,11 +442,11 @@ gst_hermes_colorspace_link (GstPad *pad, const GstCaps *caps)
if (gst_pad_is_negotiated (otherpad)) {
if (!Hermes_ConverterRequest (space->h_handle, &space->sink_format,
- &space->src_format)) {
+ &space->src_format)) {
g_warning ("Hermes: could not get converter\n");
return GST_PAD_LINK_REFUSED;
}
-g_print("inited\n");
+ g_print ("inited\n");
}
return GST_PAD_LINK_OK;
@@ -445,76 +459,72 @@ gst_hermes_colorspace_get_type (void)
if (!colorspace_type) {
static const GTypeInfo colorspace_info = {
- sizeof(GstHermesColorspaceClass),
+ sizeof (GstHermesColorspaceClass),
gst_hermes_colorspace_base_init,
NULL,
- (GClassInitFunc)gst_hermes_colorspace_class_init,
+ (GClassInitFunc) gst_hermes_colorspace_class_init,
NULL,
NULL,
- sizeof(GstHermesColorspace),
+ sizeof (GstHermesColorspace),
0,
- (GInstanceInitFunc)gst_hermes_colorspace_init,
+ (GInstanceInitFunc) gst_hermes_colorspace_init,
};
- colorspace_type = g_type_register_static(GST_TYPE_ELEMENT, "GstHermesColorspace", &colorspace_info, 0);
+ colorspace_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstHermesColorspace",
+ &colorspace_info, 0);
}
return colorspace_type;
}
-static GstStaticPadTemplate gst_hermes_colorspace_src_pad_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
+static GstStaticPadTemplate gst_hermes_colorspace_src_pad_template =
+ GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- GST_VIDEO_CAPS_xRGB "; "
- GST_VIDEO_CAPS_RGBx "; "
- GST_VIDEO_CAPS_BGRx "; "
- GST_VIDEO_CAPS_xBGR "; "
- GST_VIDEO_CAPS_BGR "; "
- GST_VIDEO_CAPS_RGB "; "
- GST_VIDEO_CAPS_RGB_16 "; "
- GST_VIDEO_CAPS_RGB_15)
-);
-
-static GstStaticPadTemplate gst_hermes_colorspace_sink_pad_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_xRGB "; "
+ GST_VIDEO_CAPS_RGBx "; "
+ GST_VIDEO_CAPS_BGRx "; "
+ GST_VIDEO_CAPS_xBGR "; "
+ GST_VIDEO_CAPS_BGR "; "
+ GST_VIDEO_CAPS_RGB "; "
+ GST_VIDEO_CAPS_RGB_16 "; " GST_VIDEO_CAPS_RGB_15)
+ );
+
+static GstStaticPadTemplate gst_hermes_colorspace_sink_pad_template =
+ GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- GST_VIDEO_CAPS_xRGB "; "
- GST_VIDEO_CAPS_RGBx "; "
- GST_VIDEO_CAPS_BGRx "; "
- GST_VIDEO_CAPS_xBGR "; "
- GST_VIDEO_CAPS_BGR "; "
- GST_VIDEO_CAPS_RGB "; "
- GST_VIDEO_CAPS_RGB_16 "; "
- GST_VIDEO_CAPS_RGB_15)
-);
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_xRGB "; "
+ GST_VIDEO_CAPS_RGBx "; "
+ GST_VIDEO_CAPS_BGRx "; "
+ GST_VIDEO_CAPS_xBGR "; "
+ GST_VIDEO_CAPS_BGR "; "
+ GST_VIDEO_CAPS_RGB "; "
+ GST_VIDEO_CAPS_RGB_16 "; " GST_VIDEO_CAPS_RGB_15)
+ );
static void
gst_hermes_colorspace_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_hermes_colorspace_src_pad_template));
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_hermes_colorspace_sink_pad_template));
+ gst_static_pad_template_get (&gst_hermes_colorspace_sink_pad_template));
gst_element_class_set_details (element_class, &colorspace_details);
}
-
+
static void
-gst_hermes_colorspace_class_init (GstHermesColorspaceClass *klass)
+gst_hermes_colorspace_class_init (GstHermesColorspaceClass * 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_hermes_colorspace_set_property;
gobject_class->get_property = gst_hermes_colorspace_get_property;
@@ -523,20 +533,20 @@ gst_hermes_colorspace_class_init (GstHermesColorspaceClass *klass)
}
static void
-gst_hermes_colorspace_init (GstHermesColorspace *space)
+gst_hermes_colorspace_init (GstHermesColorspace * space)
{
- space->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_hermes_colorspace_sink_pad_template),
- "sink");
+ space->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_hermes_colorspace_sink_pad_template), "sink");
gst_pad_set_link_function (space->sinkpad, gst_hermes_colorspace_link);
gst_pad_set_getcaps_function (space->sinkpad, gst_hermes_colorspace_getcaps);
- gst_pad_set_chain_function(space->sinkpad,gst_hermes_colorspace_chain);
- gst_element_add_pad(GST_ELEMENT(space),space->sinkpad);
+ gst_pad_set_chain_function (space->sinkpad, gst_hermes_colorspace_chain);
+ gst_element_add_pad (GST_ELEMENT (space), space->sinkpad);
- space->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_hermes_colorspace_src_pad_template),
- "src");
- gst_element_add_pad(GST_ELEMENT(space),space->srcpad);
+ space->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_hermes_colorspace_src_pad_template), "src");
+ gst_element_add_pad (GST_ELEMENT (space), space->srcpad);
gst_pad_set_link_function (space->srcpad, gst_hermes_colorspace_link);
space->h_handle = Hermes_ConverterInstance (0);
@@ -544,7 +554,7 @@ gst_hermes_colorspace_init (GstHermesColorspace *space)
}
static void
-gst_hermes_colorspace_chain (GstPad *pad,GstData *_data)
+gst_hermes_colorspace_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstHermesColorspace *space;
@@ -555,7 +565,7 @@ gst_hermes_colorspace_chain (GstPad *pad,GstData *_data)
g_return_if_fail (buf != NULL);
space = GST_HERMES_COLORSPACE (gst_pad_get_parent (pad));
-
+
g_return_if_fail (space != NULL);
g_return_if_fail (GST_IS_COLORSPACE (space));
@@ -570,8 +580,8 @@ gst_hermes_colorspace_chain (GstPad *pad,GstData *_data)
outbuf = gst_pad_alloc_buffer (space->srcpad, GST_BUFFER_OFFSET_NONE,
space->src_size);
-
- Hermes_ConverterCopy (space->h_handle,
+
+ Hermes_ConverterCopy (space->h_handle,
GST_BUFFER_DATA (buf), 0, 0, space->width, space->height,
space->sink_stride, GST_BUFFER_DATA (outbuf), 0, 0,
space->width, space->height, space->src_stride);
@@ -584,7 +594,7 @@ gst_hermes_colorspace_chain (GstPad *pad,GstData *_data)
}
static GstElementStateReturn
-gst_hermes_colorspace_change_state (GstElement *element)
+gst_hermes_colorspace_change_state (GstElement * element)
{
GstHermesColorspace *space;
@@ -603,13 +613,14 @@ gst_hermes_colorspace_change_state (GstElement *element)
}
static void
-gst_hermes_colorspace_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_hermes_colorspace_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstHermesColorspace *space;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_COLORSPACE(object));
- space = GST_HERMES_COLORSPACE(object);
+ g_return_if_fail (GST_IS_COLORSPACE (object));
+ space = GST_HERMES_COLORSPACE (object);
switch (prop_id) {
default:
@@ -618,13 +629,14 @@ gst_hermes_colorspace_set_property (GObject *object, guint prop_id, const GValue
}
static void
-gst_hermes_colorspace_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_hermes_colorspace_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
GstHermesColorspace *space;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_COLORSPACE(object));
- space = GST_HERMES_COLORSPACE(object);
+ g_return_if_fail (GST_IS_COLORSPACE (object));
+ space = GST_HERMES_COLORSPACE (object);
switch (prop_id) {
default:
@@ -634,27 +646,22 @@ gst_hermes_colorspace_get_property (GObject *object, guint prop_id, GValue *valu
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
gint hermes_res;
- hermes_res = Hermes_Init();
+ hermes_res = Hermes_Init ();
g_return_val_if_fail (hermes_res != 0, FALSE);
if (!gst_element_register (plugin, "hermescolorspace", GST_RANK_PRIMARY,
- GST_TYPE_COLORSPACE))
+ GST_TYPE_COLORSPACE))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "hermescolorspace",
- "Hermes colorspace converter",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "hermescolorspace",
+ "Hermes colorspace converter",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
diff --git a/ext/ivorbis/vorbis.c b/ext/ivorbis/vorbis.c
index 27087002..774687d6 100644
--- a/ext/ivorbis/vorbis.c
+++ b/ext/ivorbis/vorbis.c
@@ -23,28 +23,24 @@
#include <vorbisenc.h>
-extern GType ivorbisfile_get_type(void);
+extern GType ivorbisfile_get_type (void);
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
if (!gst_library_load ("gstbytestream"))
return FALSE;
- if (!gst_element_register (plugin, "tremor", GST_RANK_PRIMARY, ivorbisfile_get_type ()))
+ if (!gst_element_register (plugin, "tremor", GST_RANK_PRIMARY,
+ ivorbisfile_get_type ()))
return FALSE;
-
+
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "tremor",
- "OGG Vorbis Tremor plugins element",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "tremor",
+ "OGG Vorbis Tremor plugins element",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
diff --git a/ext/ivorbis/vorbisenc.h b/ext/ivorbis/vorbisenc.h
index 60fdf670..e33fb1d9 100644
--- a/ext/ivorbis/vorbisenc.h
+++ b/ext/ivorbis/vorbisenc.h
@@ -27,8 +27,9 @@
#include <tremor/ivorbiscodec.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_VORBISENC \
(vorbisenc_get_type())
@@ -41,60 +42,61 @@ extern "C" {
#define GST_IS_VORBISENC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VORBISENC))
-typedef struct _VorbisEnc VorbisEnc;
-typedef struct _VorbisEncClass VorbisEncClass;
+ typedef struct _VorbisEnc VorbisEnc;
+ typedef struct _VorbisEncClass VorbisEncClass;
-struct _VorbisEnc {
- GstElement element;
+ struct _VorbisEnc
+ {
+ GstElement element;
- GstPad *sinkpad,
- *srcpad;
+ GstPad *sinkpad, *srcpad;
- ogg_stream_state os; /* take physical pages, weld into a logical
- stream of packets */
- ogg_page og; /* one Ogg bitstream page. Vorbis packets are inside */
- ogg_packet op; /* one raw packet of data for decode */
+ ogg_stream_state os; /* take physical pages, weld into a logical
+ stream of packets */
+ ogg_page og; /* one Ogg bitstream page. Vorbis packets are inside */
+ ogg_packet op; /* one raw packet of data for decode */
- vorbis_info vi; /* struct that stores all the static vorbis bitstream
- settings */
- vorbis_comment vc; /* struct that stores all the user comments */
+ vorbis_info vi; /* struct that stores all the static vorbis bitstream
+ settings */
+ vorbis_comment vc; /* struct that stores all the user comments */
- vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
- vorbis_block vb; /* local working space for packet->PCM decode */
+ vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
+ vorbis_block vb; /* local working space for packet->PCM decode */
- gboolean eos;
+ gboolean eos;
- gboolean managed;
- gint bitrate;
- gint min_bitrate;
- gint max_bitrate;
- gfloat quality;
- gboolean quality_set;
- gint serial;
+ gboolean managed;
+ gint bitrate;
+ gint min_bitrate;
+ gint max_bitrate;
+ gfloat quality;
+ gboolean quality_set;
+ gint serial;
- gint channels;
- gint frequency;
+ gint channels;
+ gint frequency;
- guint64 samples_in;
- guint64 bytes_out;
+ guint64 samples_in;
+ guint64 bytes_out;
- GstCaps *metadata;
+ GstCaps *metadata;
- gboolean setup;
- gboolean flush_header;
- gchar *last_message;
-};
+ gboolean setup;
+ gboolean flush_header;
+ gchar *last_message;
+ };
-struct _VorbisEncClass {
- GstElementClass parent_class;
-};
+ struct _VorbisEncClass
+ {
+ GstElementClass parent_class;
+ };
-GType vorbisenc_get_type(void);
+ GType vorbisenc_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __VORBISENC_H__ */
+#endif /* __VORBISENC_H__ */
diff --git a/ext/ivorbis/vorbisfile.c b/ext/ivorbis/vorbisfile.c
index be36e920..2f4f6503 100644
--- a/ext/ivorbis/vorbisfile.c
+++ b/ext/ivorbis/vorbisfile.c
@@ -43,33 +43,34 @@ GST_DEBUG_CATEGORY_STATIC (ivorbisfile_debug);
typedef struct _Ivorbisfile Ivorbisfile;
typedef struct _IvorbisfileClass IvorbisfileClass;
-struct _Ivorbisfile {
- GstElement element;
+struct _Ivorbisfile
+{
+ GstElement element;
- GstPad *sinkpad,
- *srcpad;
+ GstPad *sinkpad, *srcpad;
GstByteStream *bs;
OggVorbis_File vf;
- gint current_link;
-
- gboolean restart;
- gboolean need_discont;
- gboolean eos;
- gboolean seek_pending;
- gint64 seek_value;
- GstFormat seek_format;
- gboolean seek_accurate;
-
- gboolean may_eos;
- guint64 total_bytes;
- guint64 offset;
-
- GstCaps *metadata;
- GstCaps *streaminfo;
+ gint current_link;
+
+ gboolean restart;
+ gboolean need_discont;
+ gboolean eos;
+ gboolean seek_pending;
+ gint64 seek_value;
+ GstFormat seek_format;
+ gboolean seek_accurate;
+
+ gboolean may_eos;
+ guint64 total_bytes;
+ guint64 offset;
+
+ GstCaps *metadata;
+ GstCaps *streaminfo;
};
-struct _IvorbisfileClass {
+struct _IvorbisfileClass
+{
GstElementClass parent_class;
};
@@ -79,14 +80,13 @@ GType ivorbisfile_get_type (void);
static GstPadTemplate *gst_vorbisdec_src_template, *gst_vorbisdec_sink_template;
/* elementfactory information */
-GstElementDetails ivorbisfile_details =
-{
+GstElementDetails ivorbisfile_details = {
"Ogg Vorbis decoder",
"Codec/Audio/Decoder",
"Decodes OGG Vorbis audio using the Tremor vorbisfile API",
- "Monty <monty@xiph.org>\n"
- "Wim Taymans <wim.taymans@chello.be>\n"
- "Amaury Jacquot <sxpert@esitcom.org>",
+ "Monty <monty@xiph.org>\n"
+ "Wim Taymans <wim.taymans@chello.be>\n"
+ "Amaury Jacquot <sxpert@esitcom.org>",
};
/* Ivorbisfile signals and args */
@@ -102,49 +102,36 @@ enum
ARG_STREAMINFO
};
-static void gst_ivorbisfile_base_init (gpointer g_class);
-static void
- gst_ivorbisfile_class_init (IvorbisfileClass *klass);
-static void gst_ivorbisfile_init (Ivorbisfile *ivorbisfile);
+static void gst_ivorbisfile_base_init (gpointer g_class);
+static void gst_ivorbisfile_class_init (IvorbisfileClass * klass);
+static void gst_ivorbisfile_init (Ivorbisfile * ivorbisfile);
static GstElementStateReturn
- gst_ivorbisfile_change_state (GstElement *element);
-
-static const
-GstFormat* gst_ivorbisfile_get_formats (GstPad *pad);
-static gboolean gst_ivorbisfile_src_convert (GstPad *pad,
- GstFormat src_format,
- gint64 src_value,
- GstFormat *dest_format,
- gint64 *dest_value);
-static gboolean gst_ivorbisfile_sink_convert (GstPad *pad,
- GstFormat src_format,
- gint64 src_value,
- GstFormat *dest_format,
- gint64 *dest_value);
-static const GstQueryType*
- gst_ivorbisfile_get_query_types (GstPad *pad);
-
-static gboolean gst_ivorbisfile_src_query (GstPad *pad,
- GstQueryType type,
- GstFormat *format,
- gint64 *value);
-static const
-GstEventMask* gst_ivorbisfile_get_event_masks (GstPad *pad);
-static gboolean gst_ivorbisfile_src_event (GstPad *pad, GstEvent *event);
-
-static void gst_ivorbisfile_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void gst_ivorbisfile_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-
-static void gst_ivorbisfile_loop (GstElement *element);
+gst_ivorbisfile_change_state (GstElement * element);
+
+static const GstFormat *gst_ivorbisfile_get_formats (GstPad * pad);
+static gboolean gst_ivorbisfile_src_convert (GstPad * pad,
+ GstFormat src_format,
+ gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
+static gboolean gst_ivorbisfile_sink_convert (GstPad * pad,
+ GstFormat src_format,
+ gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
+static const GstQueryType *gst_ivorbisfile_get_query_types (GstPad * pad);
+
+static gboolean gst_ivorbisfile_src_query (GstPad * pad,
+ GstQueryType type, GstFormat * format, gint64 * value);
+static const GstEventMask *gst_ivorbisfile_get_event_masks (GstPad * pad);
+static gboolean gst_ivorbisfile_src_event (GstPad * pad, GstEvent * event);
+
+static void gst_ivorbisfile_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
+static void gst_ivorbisfile_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+
+static void gst_ivorbisfile_loop (GstElement * element);
static GstElementClass *parent_class = NULL;
+
//static guint gst_ivorbisfile_signals[LAST_SIGNAL] = { 0 };
static GstFormat logical_stream_format;
@@ -164,53 +151,47 @@ ivorbisfile_get_type (void)
(GInstanceInitFunc) gst_ivorbisfile_init,
};
- ivorbisfile_type = g_type_register_static (GST_TYPE_ELEMENT, "Ivorbisfile",
- &ivorbisfile_info, 0);
+ ivorbisfile_type = g_type_register_static (GST_TYPE_ELEMENT, "Ivorbisfile",
+ &ivorbisfile_info, 0);
+
+ logical_stream_format =
+ gst_format_register ("logical_stream", "The logical stream");
- logical_stream_format = gst_format_register ("logical_stream", "The logical stream");
-
- GST_DEBUG_CATEGORY_INIT (ivorbisfile_debug, "ivorbisfile", 0,
- "vorbis in ogg decoding element (integer arithmetic)");
+ GST_DEBUG_CATEGORY_INIT (ivorbisfile_debug, "ivorbisfile", 0,
+ "vorbis in ogg decoding element (integer arithmetic)");
}
return ivorbisfile_type;
}
-static GstCaps*
+static GstCaps *
vorbis_caps_factory (void)
{
- return
- gst_caps_new_simple (
- "application/ogg",
- NULL);
+ return gst_caps_new_simple ("application/ogg", NULL);
}
-static GstCaps*
+static GstCaps *
raw_caps_factory (void)
{
return
- gst_caps_new_simple (
- "audio/x-raw-int",
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "rate", GST_TYPE_INT_RANGE, 11025, 48000,
- "channels", GST_TYPE_INT_RANGE, 1, 2,
- NULL);
+ gst_caps_new_simple ("audio/x-raw-int",
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "signed", G_TYPE_BOOLEAN, TRUE,
+ "width", G_TYPE_INT, 16,
+ "depth", G_TYPE_INT, 16,
+ "rate", GST_TYPE_INT_RANGE, 11025, 48000,
+ "channels", GST_TYPE_INT_RANGE, 1, 2, NULL);
}
-static GstCaps*
+static GstCaps *
raw_caps2_factory (void)
{
return
- gst_caps_new_simple (
- "audio/x-raw-float",
- "depth", G_TYPE_INT, 32,
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "rate", GST_TYPE_INT_RANGE, 11025, 48000,
- "channels", G_TYPE_INT, 2,
- NULL);
+ gst_caps_new_simple ("audio/x-raw-float",
+ "depth", G_TYPE_INT, 32,
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "rate", GST_TYPE_INT_RANGE, 11025, 48000,
+ "channels", G_TYPE_INT, 2, NULL);
}
@@ -225,16 +206,16 @@ gst_ivorbisfile_base_init (gpointer g_class)
vorbis_caps = vorbis_caps_factory ();
/* register sink pads */
- gst_vorbisdec_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- vorbis_caps);
+ gst_vorbisdec_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS, vorbis_caps);
gst_caps_append (raw_caps2, raw_caps);
/* register src pads */
- gst_vorbisdec_src_template = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS,
- raw_caps2);
- gst_element_class_add_pad_template (element_class, gst_vorbisdec_sink_template);
- gst_element_class_add_pad_template (element_class, gst_vorbisdec_src_template);
+ gst_vorbisdec_src_template = gst_pad_template_new ("src", GST_PAD_SRC,
+ GST_PAD_ALWAYS, raw_caps2);
+ gst_element_class_add_pad_template (element_class,
+ gst_vorbisdec_sink_template);
+ gst_element_class_add_pad_template (element_class,
+ gst_vorbisdec_src_template);
gst_element_class_set_details (element_class, &ivorbisfile_details);
}
@@ -244,17 +225,17 @@ gst_ivorbisfile_class_init (IvorbisfileClass * klass)
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*) klass;
+ gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
g_object_class_install_property (gobject_class, ARG_METADATA,
- g_param_spec_boxed ("metadata", "Metadata", "(logical) Stream metadata",
- GST_TYPE_CAPS, G_PARAM_READABLE));
+ g_param_spec_boxed ("metadata", "Metadata", "(logical) Stream metadata",
+ GST_TYPE_CAPS, G_PARAM_READABLE));
g_object_class_install_property (gobject_class, ARG_STREAMINFO,
- g_param_spec_boxed ("streaminfo", "stream", "(logical) Stream information",
- GST_TYPE_CAPS, G_PARAM_READABLE));
+ g_param_spec_boxed ("streaminfo", "stream",
+ "(logical) Stream information", GST_TYPE_CAPS, G_PARAM_READABLE));
gobject_class->get_property = gst_ivorbisfile_get_property;
gobject_class->set_property = gst_ivorbisfile_set_property;
@@ -266,23 +247,28 @@ static void
gst_ivorbisfile_init (Ivorbisfile * ivorbisfile)
{
ivorbisfile->sinkpad = gst_pad_new_from_template (gst_vorbisdec_sink_template,
- "sink");
+ "sink");
gst_element_add_pad (GST_ELEMENT (ivorbisfile), ivorbisfile->sinkpad);
- gst_pad_set_formats_function (ivorbisfile->sinkpad, gst_ivorbisfile_get_formats);
- gst_pad_set_convert_function (ivorbisfile->sinkpad, gst_ivorbisfile_sink_convert);
-
- gst_element_set_loop_function (GST_ELEMENT (ivorbisfile), gst_ivorbisfile_loop);
- ivorbisfile->srcpad = gst_pad_new_from_template (gst_vorbisdec_src_template,
- "src");
+ gst_pad_set_formats_function (ivorbisfile->sinkpad,
+ gst_ivorbisfile_get_formats);
+ gst_pad_set_convert_function (ivorbisfile->sinkpad,
+ gst_ivorbisfile_sink_convert);
+
+ gst_element_set_loop_function (GST_ELEMENT (ivorbisfile),
+ gst_ivorbisfile_loop);
+ ivorbisfile->srcpad =
+ gst_pad_new_from_template (gst_vorbisdec_src_template, "src");
gst_element_add_pad (GST_ELEMENT (ivorbisfile), ivorbisfile->srcpad);
- gst_pad_set_formats_function (ivorbisfile->srcpad, gst_ivorbisfile_get_formats);
- gst_pad_set_query_type_function (ivorbisfile->srcpad,
- gst_ivorbisfile_get_query_types);
+ gst_pad_set_formats_function (ivorbisfile->srcpad,
+ gst_ivorbisfile_get_formats);
+ gst_pad_set_query_type_function (ivorbisfile->srcpad,
+ gst_ivorbisfile_get_query_types);
gst_pad_set_query_function (ivorbisfile->srcpad, gst_ivorbisfile_src_query);
- gst_pad_set_event_mask_function (ivorbisfile->srcpad,
- gst_ivorbisfile_get_event_masks);
+ gst_pad_set_event_mask_function (ivorbisfile->srcpad,
+ gst_ivorbisfile_get_event_masks);
gst_pad_set_event_function (ivorbisfile->srcpad, gst_ivorbisfile_src_event);
- gst_pad_set_convert_function (ivorbisfile->srcpad, gst_ivorbisfile_src_convert);
+ gst_pad_set_convert_function (ivorbisfile->srcpad,
+ gst_ivorbisfile_src_convert);
ivorbisfile->total_bytes = 0;
ivorbisfile->offset = 0;
@@ -308,41 +294,40 @@ gst_ivorbisfile_read (void *ptr, size_t size, size_t nmemb, void *datasource)
GST_DEBUG ("read %d", read_size);
/* make sure we don't go to EOS */
- if (!ivorbisfile->may_eos && ivorbisfile->total_bytes &&
- ivorbisfile->offset + read_size > ivorbisfile->total_bytes)
- {
+ if (!ivorbisfile->may_eos && ivorbisfile->total_bytes &&
+ ivorbisfile->offset + read_size > ivorbisfile->total_bytes) {
read_size = ivorbisfile->total_bytes - ivorbisfile->offset;
}
if (read_size == 0 || ivorbisfile->eos)
return 0;
-
+
while (got_bytes == 0) {
got_bytes = gst_bytestream_peek_bytes (ivorbisfile->bs, &data, read_size);
if (got_bytes < read_size) {
GstEvent *event;
guint32 avail;
-
- gst_bytestream_get_status (ivorbisfile->bs, &avail, &event);
+
+ gst_bytestream_get_status (ivorbisfile->bs, &avail, &event);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
GST_DEBUG ("eos");
- ivorbisfile->eos = TRUE;
- if (avail == 0) {
- gst_event_unref (event);
- return 0;
+ ivorbisfile->eos = TRUE;
+ if (avail == 0) {
+ gst_event_unref (event);
+ return 0;
}
break;
case GST_EVENT_DISCONTINUOUS:
GST_DEBUG ("discont");
ivorbisfile->need_discont = TRUE;
default:
- break;
+ break;
}
gst_event_unref (event);
- if (avail > 0)
- got_bytes = gst_bytestream_peek_bytes (ivorbisfile->bs, &data, avail);
+ if (avail > 0)
+ got_bytes = gst_bytestream_peek_bytes (ivorbisfile->bs, &data, avail);
else
got_bytes = 0;
}
@@ -368,25 +353,22 @@ gst_ivorbisfile_seek (void *datasource, int64_t offset, int whence)
if (!ivorbisfile->vf.seekable) {
return -1;
}
-
+
GST_DEBUG ("seek %lld %d", offset, whence);
if (whence == SEEK_SET) {
method = GST_SEEK_METHOD_SET;
pending_offset = offset;
- }
- else if (whence == SEEK_CUR) {
+ } else if (whence == SEEK_CUR) {
method = GST_SEEK_METHOD_CUR;
pending_offset += offset;
- }
- else if (whence == SEEK_END) {
+ } else if (whence == SEEK_END) {
method = GST_SEEK_METHOD_END;
need_total = TRUE;
pending_offset = ivorbisfile->total_bytes - offset;
- }
- else
+ } else
return -1;
-
+
if (!gst_bytestream_seek (ivorbisfile->bs, offset, method))
return -1;
@@ -417,8 +399,7 @@ gst_ivorbisfile_tell (void *datasource)
return result;
}
-ov_callbacks ivorbisfile_ov_callbacks =
-{
+ov_callbacks ivorbisfile_ov_callbacks = {
gst_ivorbisfile_read,
gst_ivorbisfile_seek,
gst_ivorbisfile_close,
@@ -430,7 +411,7 @@ ov_callbacks ivorbisfile_ov_callbacks =
* returns TRUE if caps could be set,
* FALSE if they couldn't be read somehow */
static gboolean
-gst_ivorbisfile_update_metadata (Ivorbisfile *ivorbisfile, gint link)
+gst_ivorbisfile_update_metadata (Ivorbisfile * ivorbisfile, gint link)
{
OggVorbis_File *vf = &ivorbisfile->vf;
gchar **ptr;
@@ -453,15 +434,14 @@ gst_ivorbisfile_update_metadata (Ivorbisfile *ivorbisfile, gint link)
while (*ptr) {
value = strstr (*ptr, "=");
if (value) {
- name = g_strndup (*ptr, value-*ptr);
- entry = gst_props_entry_new (name, GST_PROPS_STRING_TYPE, value+1);
+ name = g_strndup (*ptr, value - *ptr);
+ entry = gst_props_entry_new (name, GST_PROPS_STRING_TYPE, value + 1);
gst_props_add_entry (props, (GstPropsEntry *) entry);
}
ptr++;
}
ivorbisfile->metadata = gst_caps_new ("ivorbisfile_metadata",
- "application/x-gst-metadata",
- props);
+ "application/x-gst-metadata", props);
g_object_notify (G_OBJECT (ivorbisfile), "metadata");
@@ -472,7 +452,7 @@ gst_ivorbisfile_update_metadata (Ivorbisfile *ivorbisfile, gint link)
* returns TRUE if caps could be set,
* FALSE if they couldn't be read somehow */
static gboolean
-gst_ivorbisfile_update_streaminfo (Ivorbisfile *ivorbisfile, gint link)
+gst_ivorbisfile_update_streaminfo (Ivorbisfile * ivorbisfile, gint link)
{
OggVorbis_File *vf = &ivorbisfile->vf;
vorbis_info *vi;
@@ -491,25 +471,24 @@ gst_ivorbisfile_update_streaminfo (Ivorbisfile *ivorbisfile, gint link)
vi = ov_info (vf, link);
entry = gst_props_entry_new ("version", GST_PROPS_INT_TYPE, vi->version);
gst_props_add_entry (props, (GstPropsEntry *) entry);
- entry = gst_props_entry_new ("bitrate_upper", GST_PROPS_INT_TYPE,
- vi->bitrate_upper);
+ entry = gst_props_entry_new ("bitrate_upper", GST_PROPS_INT_TYPE,
+ vi->bitrate_upper);
gst_props_add_entry (props, (GstPropsEntry *) entry);
- entry = gst_props_entry_new ("bitrate_nominal", GST_PROPS_INT_TYPE,
- vi->bitrate_nominal);
+ entry = gst_props_entry_new ("bitrate_nominal", GST_PROPS_INT_TYPE,
+ vi->bitrate_nominal);
gst_props_add_entry (props, (GstPropsEntry *) entry);
- entry = gst_props_entry_new ("bitrate_lower", GST_PROPS_INT_TYPE,
- vi->bitrate_lower);
+ entry = gst_props_entry_new ("bitrate_lower", GST_PROPS_INT_TYPE,
+ vi->bitrate_lower);
gst_props_add_entry (props, (GstPropsEntry *) entry);
- entry = gst_props_entry_new ("serial", GST_PROPS_INT_TYPE,
- ov_serialnumber (vf, link));
+ entry = gst_props_entry_new ("serial", GST_PROPS_INT_TYPE,
+ ov_serialnumber (vf, link));
gst_props_add_entry (props, (GstPropsEntry *) entry);
- entry = gst_props_entry_new ("bitrate", GST_PROPS_INT_TYPE,
- ov_bitrate (vf, link));
+ entry = gst_props_entry_new ("bitrate", GST_PROPS_INT_TYPE,
+ ov_bitrate (vf, link));
gst_props_add_entry (props, (GstPropsEntry *) entry);
ivorbisfile->streaminfo = gst_caps_new ("ivorbisfile_streaminfo",
- "application/x-gst-streaminfo",
- props);
+ "application/x-gst-streaminfo", props);
g_object_notify (G_OBJECT (ivorbisfile), "streaminfo");
@@ -518,7 +497,7 @@ gst_ivorbisfile_update_streaminfo (Ivorbisfile *ivorbisfile, gint link)
#endif
static gboolean
-gst_ivorbisfile_new_link (Ivorbisfile *ivorbisfile, gint link)
+gst_ivorbisfile_new_link (Ivorbisfile * ivorbisfile, gint link)
{
vorbis_info *vi = ov_info (&ivorbisfile->vf, link);
GstCaps *caps;
@@ -528,25 +507,23 @@ gst_ivorbisfile_new_link (Ivorbisfile *ivorbisfile, gint link)
ivorbisfile->current_link = link;
caps = gst_caps_new_simple ("audio/x-raw-int",
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "signed", G_TYPE_BOOLEAN, TRUE,
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- "rate", G_TYPE_INT, vi->rate,
- "channels", G_TYPE_INT, vi->channels,
- NULL);
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "signed", G_TYPE_BOOLEAN, TRUE,
+ "width", G_TYPE_INT, 16,
+ "depth", G_TYPE_INT, 16,
+ "rate", G_TYPE_INT, vi->rate, "channels", G_TYPE_INT, vi->channels, NULL);
if (gst_pad_try_set_caps (ivorbisfile->srcpad, caps) <= 0) {
- res = FALSE;
+ res = FALSE;
}
gst_caps_free (caps);
-
+
return TRUE;
}
static void
-gst_ivorbisfile_loop (GstElement *element)
+gst_ivorbisfile_loop (GstElement * element)
{
Ivorbisfile *ivorbisfile = GST_IVORBISFILE (element);
GstBuffer *outbuf;
@@ -562,13 +539,13 @@ gst_ivorbisfile_loop (GstElement *element)
ivorbisfile->total_bytes = 0;
ivorbisfile->may_eos = FALSE;
ivorbisfile->vf.seekable = gst_bytestream_seek (ivorbisfile->bs, 0,
- GST_SEEK_METHOD_SET);
+ GST_SEEK_METHOD_SET);
GST_DEBUG ("ivorbisfile: seekable: %s\n",
- ivorbisfile->vf.seekable ? "yes" : "no");
+ ivorbisfile->vf.seekable ? "yes" : "no");
/* open our custom ivorbisfile data object with the callbacks we provide */
if (ov_open_callbacks (ivorbisfile, &ivorbisfile->vf, NULL, 0,
- ivorbisfile_ov_callbacks) < 0) {
+ ivorbisfile_ov_callbacks) < 0) {
GST_ELEMENT_ERROR (element, STREAM, DECODE, (NULL), (NULL));
return;
}
@@ -583,47 +560,43 @@ gst_ivorbisfile_loop (GstElement *element)
switch (ivorbisfile->seek_format) {
case GST_FORMAT_TIME:
{
- gdouble seek_to = (gdouble) ivorbisfile->seek_value / GST_SECOND;
+ gdouble seek_to = (gdouble) ivorbisfile->seek_value / GST_SECOND;
if (ivorbisfile->seek_accurate) {
- if (ov_time_seek (&ivorbisfile->vf, seek_to) == 0) {
- ivorbisfile->need_discont = TRUE;
- }
- }
- else {
- if (ov_time_seek_page (&ivorbisfile->vf, seek_to) == 0) {
- ivorbisfile->need_discont = TRUE;
- }
+ if (ov_time_seek (&ivorbisfile->vf, seek_to) == 0) {
+ ivorbisfile->need_discont = TRUE;
+ }
+ } else {
+ if (ov_time_seek_page (&ivorbisfile->vf, seek_to) == 0) {
+ ivorbisfile->need_discont = TRUE;
+ }
}
break;
}
case GST_FORMAT_DEFAULT:
if (ivorbisfile->seek_accurate) {
- if (ov_pcm_seek (&ivorbisfile->vf, ivorbisfile->seek_value) == 0) {
- ivorbisfile->need_discont = TRUE;
- }
- }
- else {
- if (ov_pcm_seek_page (&ivorbisfile->vf, ivorbisfile->seek_value) == 0) {
- ivorbisfile->need_discont = TRUE;
- }
+ if (ov_pcm_seek (&ivorbisfile->vf, ivorbisfile->seek_value) == 0) {
+ ivorbisfile->need_discont = TRUE;
+ }
+ } else {
+ if (ov_pcm_seek_page (&ivorbisfile->vf, ivorbisfile->seek_value) == 0) {
+ ivorbisfile->need_discont = TRUE;
+ }
}
break;
default:
if (ivorbisfile->seek_format == logical_stream_format) {
- gint64 seek_to;
-
+ gint64 seek_to;
+
seek_to = ivorbisfile->vf.offsets[ivorbisfile->seek_value];
- if (ov_raw_seek (&ivorbisfile->vf, seek_to) == 0) {
- ivorbisfile->need_discont = TRUE;
- ivorbisfile->current_link = -1;
- }
- else {
+ if (ov_raw_seek (&ivorbisfile->vf, seek_to) == 0) {
+ ivorbisfile->need_discont = TRUE;
+ ivorbisfile->current_link = -1;
+ } else {
g_warning ("raw seek failed");
}
- }
- else
+ } else
g_warning ("unknown seek method, implement me !");
break;
}
@@ -645,30 +618,27 @@ gst_ivorbisfile_loop (GstElement *element)
/* get current time for discont and buffer timestamp */
time = (GstClockTime) (ov_time_tell (&ivorbisfile->vf) * GST_SECOND);
- ret = ov_read (&ivorbisfile->vf,
- GST_BUFFER_DATA (outbuf), GST_BUFFER_SIZE (outbuf),
- &link);
+ ret = ov_read (&ivorbisfile->vf,
+ GST_BUFFER_DATA (outbuf), GST_BUFFER_SIZE (outbuf), &link);
if (ret == 0) {
GST_DEBUG ("eos");
/* send EOS event */
- /*ov_clear (&ivorbisfile->vf);*/
+ /*ov_clear (&ivorbisfile->vf); */
ivorbisfile->restart = TRUE;
gst_buffer_unref (outbuf);
/* if the pad is not usable, don't push it out */
if (GST_PAD_IS_USABLE (ivorbisfile->srcpad)) {
- gst_pad_push (ivorbisfile->srcpad,
- GST_DATA (gst_event_new (GST_EVENT_EOS)));
+ gst_pad_push (ivorbisfile->srcpad,
+ GST_DATA (gst_event_new (GST_EVENT_EOS)));
}
gst_element_set_eos (element);
return;
- }
- else if (ret < 0) {
+ } else if (ret < 0) {
g_warning ("ivorbisfile: decoding error");
gst_buffer_unref (outbuf);
return;
- }
- else {
+ } else {
if (ivorbisfile->need_discont) {
GstEvent *discont;
@@ -676,13 +646,13 @@ gst_ivorbisfile_loop (GstElement *element)
/* if the pad is not usable, don't push it out */
if (GST_PAD_IS_USABLE (ivorbisfile->srcpad)) {
- /* get stream stats */
- samples = (gint64) (ov_pcm_tell (&ivorbisfile->vf));
+ /* get stream stats */
+ samples = (gint64) (ov_pcm_tell (&ivorbisfile->vf));
- discont = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME, time,
- GST_FORMAT_DEFAULT, samples, NULL);
+ discont = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME, time,
+ GST_FORMAT_DEFAULT, samples, NULL);
- gst_pad_push (ivorbisfile->srcpad, GST_DATA (discont));
+ gst_pad_push (ivorbisfile->srcpad, GST_DATA (discont));
}
}
@@ -694,16 +664,16 @@ gst_ivorbisfile_loop (GstElement *element)
if (!ivorbisfile->vf.seekable) {
ivorbisfile->total_bytes += GST_BUFFER_SIZE (outbuf);
}
-
- if (GST_PAD_IS_USABLE (ivorbisfile->srcpad))
+
+ if (GST_PAD_IS_USABLE (ivorbisfile->srcpad))
gst_pad_push (ivorbisfile->srcpad, GST_DATA (outbuf));
else
gst_buffer_unref (outbuf);
}
}
-static const GstFormat*
-gst_ivorbisfile_get_formats (GstPad *pad)
+static const GstFormat *
+gst_ivorbisfile_get_formats (GstPad * pad)
{
static GstFormat src_formats[] = {
GST_FORMAT_TIME,
@@ -721,21 +691,21 @@ gst_ivorbisfile_get_formats (GstPad *pad)
src_formats[3] = logical_stream_format;
sink_formats[2] = logical_stream_format;
-
+
return (GST_PAD_IS_SRC (pad) ? src_formats : sink_formats);
}
static gboolean
-gst_ivorbisfile_src_convert (GstPad *pad,
- GstFormat src_format, gint64 src_value,
- GstFormat *dest_format, gint64 *dest_value)
+gst_ivorbisfile_src_convert (GstPad * pad,
+ GstFormat src_format, gint64 src_value,
+ GstFormat * dest_format, gint64 * dest_value)
{
gboolean res = TRUE;
guint scale = 1;
gint bytes_per_sample;
- Ivorbisfile *ivorbisfile;
+ Ivorbisfile *ivorbisfile;
vorbis_info *vi;
-
+
ivorbisfile = GST_IVORBISFILE (gst_pad_get_parent (pad));
vi = ov_info (&ivorbisfile->vf, -1);
@@ -744,44 +714,44 @@ gst_ivorbisfile_src_convert (GstPad *pad,
switch (src_format) {
case GST_FORMAT_BYTES:
switch (*dest_format) {
- case GST_FORMAT_DEFAULT:
- *dest_value = src_value / (vi->channels * 2);
- break;
- case GST_FORMAT_TIME:
- {
- gint byterate = bytes_per_sample * vi->rate;
-
- if (byterate == 0)
- return FALSE;
- *dest_value = src_value * GST_SECOND / byterate;
- break;
- }
- default:
- res = FALSE;
+ case GST_FORMAT_DEFAULT:
+ *dest_value = src_value / (vi->channels * 2);
+ break;
+ case GST_FORMAT_TIME:
+ {
+ gint byterate = bytes_per_sample * vi->rate;
+
+ if (byterate == 0)
+ return FALSE;
+ *dest_value = src_value * GST_SECOND / byterate;
+ break;
+ }
+ default:
+ res = FALSE;
}
case GST_FORMAT_DEFAULT:
switch (*dest_format) {
- case GST_FORMAT_BYTES:
+ case GST_FORMAT_BYTES:
*dest_value = src_value * bytes_per_sample;
- break;
- case GST_FORMAT_TIME:
+ break;
+ case GST_FORMAT_TIME:
if (vi->rate == 0)
return FALSE;
*dest_value = src_value * GST_SECOND / vi->rate;
- break;
- default:
- res = FALSE;
+ break;
+ default:
+ res = FALSE;
}
break;
case GST_FORMAT_TIME:
switch (*dest_format) {
- case GST_FORMAT_BYTES:
+ case GST_FORMAT_BYTES:
scale = bytes_per_sample;
- case GST_FORMAT_DEFAULT:
+ case GST_FORMAT_DEFAULT:
*dest_value = src_value * scale * vi->rate / GST_SECOND;
- break;
- default:
- res = FALSE;
+ break;
+ default:
+ res = FALSE;
}
break;
default:
@@ -791,11 +761,11 @@ gst_ivorbisfile_src_convert (GstPad *pad,
gint i;
gint64 count = 0;
- switch (*dest_format) {
- case GST_FORMAT_BYTES:
- res = FALSE;
- break;
- case GST_FORMAT_DEFAULT:
+ switch (*dest_format) {
+ case GST_FORMAT_BYTES:
+ res = FALSE;
+ break;
+ case GST_FORMAT_DEFAULT:
if (src_value > ivorbisfile->vf.links) {
src_value = ivorbisfile->vf.links;
}
@@ -805,86 +775,83 @@ gst_ivorbisfile_src_convert (GstPad *pad,
count += ov_pcm_total (&ivorbisfile->vf, i);
}
*dest_value = count;
- break;
- case GST_FORMAT_TIME:
+ break;
+ case GST_FORMAT_TIME:
{
if (src_value > ivorbisfile->vf.links) {
src_value = ivorbisfile->vf.links;
}
for (i = 0; i < src_value; i++) {
vi = ov_info (&ivorbisfile->vf, i);
- if (vi->rate)
- count += ov_pcm_total (&ivorbisfile->vf, i) * GST_SECOND / vi->rate;
+ if (vi->rate)
+ count +=
+ ov_pcm_total (&ivorbisfile->vf, i) * GST_SECOND / vi->rate;
else
- count += ov_time_total (&ivorbisfile->vf, i) * GST_SECOND;
+ count += ov_time_total (&ivorbisfile->vf, i) * GST_SECOND;
}
/* we use the pcm totals to get the total time, it's more accurate */
*dest_value = count;
- break;
+ break;
}
- default:
- res = FALSE;
+ default:
+ res = FALSE;
}
- }
- else
- res = FALSE;
+ } else
+ res = FALSE;
break;
}
return res;
}
static gboolean
-gst_ivorbisfile_sink_convert (GstPad *pad,
- GstFormat src_format, gint64 src_value,
- GstFormat *dest_format, gint64 *dest_value)
+gst_ivorbisfile_sink_convert (GstPad * pad,
+ GstFormat src_format, gint64 src_value,
+ GstFormat * dest_format, gint64 * dest_value)
{
gboolean res = TRUE;
- Ivorbisfile *ivorbisfile;
-
+ Ivorbisfile *ivorbisfile;
+
ivorbisfile = GST_IVORBISFILE (gst_pad_get_parent (pad));
switch (src_format) {
case GST_FORMAT_BYTES:
switch (*dest_format) {
- case GST_FORMAT_TIME:
- break;
- default:
- if (*dest_format == logical_stream_format) {
- }
- else
- res = FALSE;
+ case GST_FORMAT_TIME:
+ break;
+ default:
+ if (*dest_format == logical_stream_format) {
+ } else
+ res = FALSE;
}
case GST_FORMAT_TIME:
switch (*dest_format) {
- case GST_FORMAT_BYTES:
- break;
- default:
- if (*dest_format == logical_stream_format) {
- }
- else
- res = FALSE;
+ case GST_FORMAT_BYTES:
+ break;
+ default:
+ if (*dest_format == logical_stream_format) {
+ } else
+ res = FALSE;
}
default:
if (src_format == logical_stream_format) {
- switch (*dest_format) {
- case GST_FORMAT_TIME:
- break;
- case GST_FORMAT_BYTES:
- break;
- default:
- res = FALSE;
- }
- }
- else
- res = FALSE;
+ switch (*dest_format) {
+ case GST_FORMAT_TIME:
+ break;
+ case GST_FORMAT_BYTES:
+ break;
+ default:
+ res = FALSE;
+ }
+ } else
+ res = FALSE;
break;
}
return res;
}
-static const GstQueryType*
-gst_ivorbisfile_get_query_types (GstPad *pad)
+static const GstQueryType *
+gst_ivorbisfile_get_query_types (GstPad * pad)
{
static const GstQueryType types[] = {
GST_QUERY_TOTAL,
@@ -896,13 +863,13 @@ gst_ivorbisfile_get_query_types (GstPad *pad)
/* handles queries for location in the stream in the requested format */
static gboolean
-gst_ivorbisfile_src_query (GstPad *pad, GstQueryType type,
- GstFormat *format, gint64 *value)
+gst_ivorbisfile_src_query (GstPad * pad, GstQueryType type,
+ GstFormat * format, gint64 * value)
{
gboolean res = TRUE;
- Ivorbisfile *ivorbisfile;
+ Ivorbisfile *ivorbisfile;
vorbis_info *vi;
-
+
ivorbisfile = GST_IVORBISFILE (gst_pad_get_parent (pad));
vi = ov_info (&ivorbisfile->vf, -1);
@@ -911,68 +878,67 @@ gst_ivorbisfile_src_query (GstPad *pad, GstQueryType type,
case GST_QUERY_TOTAL:
{
switch (*format) {
- case GST_FORMAT_DEFAULT:
- if (ivorbisfile->vf.seekable)
+ case GST_FORMAT_DEFAULT:
+ if (ivorbisfile->vf.seekable)
*value = ov_pcm_total (&ivorbisfile->vf, -1);
else
return FALSE;
break;
- case GST_FORMAT_BYTES:
- if (ivorbisfile->vf.seekable)
+ case GST_FORMAT_BYTES:
+ if (ivorbisfile->vf.seekable)
*value = ov_pcm_total (&ivorbisfile->vf, -1) * vi->channels * 2;
else
return FALSE;
break;
- case GST_FORMAT_TIME:
- if (ivorbisfile->vf.seekable)
- *value = (gint64) (ov_time_total (&ivorbisfile->vf, -1) * GST_SECOND);
+ case GST_FORMAT_TIME:
+ if (ivorbisfile->vf.seekable)
+ *value =
+ (gint64) (ov_time_total (&ivorbisfile->vf, -1) * GST_SECOND);
else
return FALSE;
break;
default:
if (*format == logical_stream_format) {
- if (ivorbisfile->vf.seekable)
+ if (ivorbisfile->vf.seekable)
*value = ivorbisfile->vf.links;
else
- return FALSE;
- }
- else
- res = FALSE;
- break;
+ return FALSE;
+ } else
+ res = FALSE;
+ break;
}
break;
}
case GST_QUERY_POSITION:
switch (*format) {
- case GST_FORMAT_TIME:
- if (ivorbisfile->vf.seekable)
+ case GST_FORMAT_TIME:
+ if (ivorbisfile->vf.seekable)
*value = (gint64) (ov_time_tell (&ivorbisfile->vf) * GST_SECOND);
else
- *value = ivorbisfile->total_bytes * GST_SECOND
- / (vi->rate * vi->channels * 2);
+ *value = ivorbisfile->total_bytes * GST_SECOND
+ / (vi->rate * vi->channels * 2);
break;
- case GST_FORMAT_BYTES:
- if (ivorbisfile->vf.seekable)
+ case GST_FORMAT_BYTES:
+ if (ivorbisfile->vf.seekable)
*value = ov_pcm_tell (&ivorbisfile->vf) * vi->channels * 2;
else
- *value = ivorbisfile->total_bytes;
+ *value = ivorbisfile->total_bytes;
break;
- case GST_FORMAT_DEFAULT:
- if (ivorbisfile->vf.seekable)
+ case GST_FORMAT_DEFAULT:
+ if (ivorbisfile->vf.seekable)
*value = ov_pcm_tell (&ivorbisfile->vf);
else
- *value = ivorbisfile->total_bytes / (vi->channels * 2);
+ *value = ivorbisfile->total_bytes / (vi->channels * 2);
break;
- default:
+ default:
if (*format == logical_stream_format) {
- if (ivorbisfile->vf.seekable)
+ if (ivorbisfile->vf.seekable)
*value = ivorbisfile->current_link;
else
- return FALSE;
- }
- else
- res = FALSE;
- break;
+ return FALSE;
+ } else
+ res = FALSE;
+ break;
}
break;
default:
@@ -983,23 +949,23 @@ gst_ivorbisfile_src_query (GstPad *pad, GstQueryType type,
return res;
}
-static const GstEventMask*
-gst_ivorbisfile_get_event_masks (GstPad *pad)
+static const GstEventMask *
+gst_ivorbisfile_get_event_masks (GstPad * pad)
{
static const GstEventMask masks[] = {
- { GST_EVENT_SEEK, GST_SEEK_METHOD_SET | GST_SEEK_FLAG_ACCURATE },
- { 0, }
+ {GST_EVENT_SEEK, GST_SEEK_METHOD_SET | GST_SEEK_FLAG_ACCURATE},
+ {0,}
};
return masks;
}
/* handle events on src pad */
static gboolean
-gst_ivorbisfile_src_event (GstPad *pad, GstEvent *event)
+gst_ivorbisfile_src_event (GstPad * pad, GstEvent * event)
{
gboolean res = TRUE;
- Ivorbisfile *ivorbisfile;
-
+ Ivorbisfile *ivorbisfile;
+
ivorbisfile = GST_IVORBISFILE (gst_pad_get_parent (pad));
switch (GST_EVENT_TYPE (event)) {
@@ -1008,13 +974,13 @@ gst_ivorbisfile_src_event (GstPad *pad, GstEvent *event)
gint64 offset;
vorbis_info *vi;
GstFormat format;
-
+
GST_DEBUG ("ivorbisfile: handling seek event on pad %s:%s",
- GST_DEBUG_PAD_NAME (pad));
+ GST_DEBUG_PAD_NAME (pad));
if (!ivorbisfile->vf.seekable) {
gst_event_unref (event);
GST_DEBUG ("vorbis stream is not seekable");
- return FALSE;
+ return FALSE;
}
offset = GST_EVENT_SEEK_OFFSET (event);
@@ -1025,35 +991,33 @@ gst_ivorbisfile_src_event (GstPad *pad, GstEvent *event)
ivorbisfile->seek_pending = TRUE;
ivorbisfile->seek_value = offset;
ivorbisfile->seek_format = format;
- ivorbisfile->seek_accurate = GST_EVENT_SEEK_FLAGS (event)
- & GST_SEEK_FLAG_ACCURATE;
+ ivorbisfile->seek_accurate = GST_EVENT_SEEK_FLAGS (event)
+ & GST_SEEK_FLAG_ACCURATE;
break;
case GST_FORMAT_BYTES:
- vi = ov_info (&ivorbisfile->vf, -1);
+ vi = ov_info (&ivorbisfile->vf, -1);
if (vi->channels == 0) {
GST_DEBUG ("vorbis stream has 0 channels ?");
res = FALSE;
- goto done;
+ goto done;
}
- offset /= vi->channels * 2;
+ offset /= vi->channels * 2;
/* fallthrough */
case GST_FORMAT_DEFAULT:
ivorbisfile->seek_pending = TRUE;
ivorbisfile->seek_value = offset;
ivorbisfile->seek_format = format;
- ivorbisfile->seek_accurate = GST_EVENT_SEEK_FLAGS (event)
- & GST_SEEK_FLAG_ACCURATE;
+ ivorbisfile->seek_accurate = GST_EVENT_SEEK_FLAGS (event)
+ & GST_SEEK_FLAG_ACCURATE;
break;
default:
if (format == logical_stream_format) {
ivorbisfile->seek_pending = TRUE;
ivorbisfile->seek_value = offset;
ivorbisfile->seek_format = format;
- ivorbisfile->seek_accurate = GST_EVENT_SEEK_FLAGS (event)
- & GST_SEEK_FLAG_ACCURATE;
- }
- else
- {
+ ivorbisfile->seek_accurate = GST_EVENT_SEEK_FLAGS (event)
+ & GST_SEEK_FLAG_ACCURATE;
+ } else {
GST_DEBUG ("unhandled seek format");
res = FALSE;
}
@@ -1072,10 +1036,10 @@ done:
}
static GstElementStateReturn
-gst_ivorbisfile_change_state (GstElement *element)
+gst_ivorbisfile_change_state (GstElement * element)
{
Ivorbisfile *ivorbisfile = GST_IVORBISFILE (element);
-
+
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
case GST_STATE_READY_TO_PAUSED:
@@ -1097,16 +1061,16 @@ gst_ivorbisfile_change_state (GstElement *element)
if (GST_ELEMENT_CLASS (parent_class)->change_state)
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
-
+
return GST_STATE_SUCCESS;
}
static void
-gst_ivorbisfile_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
+gst_ivorbisfile_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
Ivorbisfile *ivorbisfile;
-
+
g_return_if_fail (GST_IS_IVORBISFILE (object));
ivorbisfile = GST_IVORBISFILE (object);
@@ -1117,12 +1081,12 @@ gst_ivorbisfile_set_property (GObject *object, guint prop_id,
}
}
-static void
-gst_ivorbisfile_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+static void
+gst_ivorbisfile_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
Ivorbisfile *ivorbisfile;
-
+
g_return_if_fail (GST_IS_IVORBISFILE (object));
ivorbisfile = GST_IVORBISFILE (object);
diff --git a/ext/jack/gstjack.c b/ext/jack/gstjack.c
index a43c6707..41f078bc 100644
--- a/ext/jack/gstjack.c
+++ b/ext/jack/gstjack.c
@@ -38,118 +38,122 @@
/* elementfactory information */
static GstElementDetails gst_jack_bin_details = {
- "Jack Bin",
- "Generic/Bin",
- "Jack processing bin",
- "Andy Wingo <wingo@pobox.com>",
+ "Jack Bin",
+ "Generic/Bin",
+ "Jack processing bin",
+ "Andy Wingo <wingo@pobox.com>",
};
-static GstElementDetails gst_jack_sink_details = {
- "Jack Sink",
- "Sink/Audio",
- "Output to a Jack processing network",
- "Andy Wingo <wingo@pobox.com>",
+static GstElementDetails gst_jack_sink_details = {
+ "Jack Sink",
+ "Sink/Audio",
+ "Output to a Jack processing network",
+ "Andy Wingo <wingo@pobox.com>",
};
-static GstElementDetails gst_jack_src_details = {
- "Jack Src",
- "Source/Audio",
- "Input from a Jack processing network",
- "Andy Wingo <wingo@pobox.com>",
+static GstElementDetails gst_jack_src_details = {
+ "Jack Src",
+ "Source/Audio",
+ "Input from a Jack processing network",
+ "Andy Wingo <wingo@pobox.com>",
};
static GHashTable *port_name_counts = NULL;
static GstElementClass *parent_class = NULL;
-static void gst_jack_base_init (gpointer g_class);
-static void gst_jack_src_base_init (gpointer g_class);
-static void gst_jack_sink_base_init (gpointer g_class);
-static void gst_jack_init(GstJack *this);
-static void gst_jack_class_init(GstJackClass *klass);
-static void gst_jack_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_jack_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
-
-static GstPadTemplate* gst_jack_src_request_pad_factory();
-static GstPadTemplate* gst_jack_sink_request_pad_factory();
-static GstPad* gst_jack_request_new_pad (GstElement *element, GstPadTemplate *templ,
- const gchar *name);
-static GstElementStateReturn gst_jack_change_state (GstElement *element);
-static GstPadLinkReturn gst_jack_link (GstPad *pad, const GstCaps *caps);
-
-static void gst_jack_loop (GstElement *element);
-
-
-enum {
- ARG_0,
- ARG_PORT_NAME_PREFIX,
+static void gst_jack_base_init (gpointer g_class);
+static void gst_jack_src_base_init (gpointer g_class);
+static void gst_jack_sink_base_init (gpointer g_class);
+static void gst_jack_init (GstJack * this);
+static void gst_jack_class_init (GstJackClass * klass);
+static void gst_jack_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_jack_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
+static GstPadTemplate *gst_jack_src_request_pad_factory ();
+static GstPadTemplate *gst_jack_sink_request_pad_factory ();
+static GstPad *gst_jack_request_new_pad (GstElement * element,
+ GstPadTemplate * templ, const gchar * name);
+static GstElementStateReturn gst_jack_change_state (GstElement * element);
+static GstPadLinkReturn gst_jack_link (GstPad * pad, const GstCaps * caps);
+
+static void gst_jack_loop (GstElement * element);
+
+
+enum
+{
+ ARG_0,
+ ARG_PORT_NAME_PREFIX,
};
GType
-gst_jack_get_type (void)
+gst_jack_get_type (void)
{
static GType jack_type = 0;
if (!jack_type) {
static const GTypeInfo jack_info = {
- sizeof(GstJackClass),
+ sizeof (GstJackClass),
gst_jack_base_init,
NULL,
NULL,
NULL,
NULL,
- sizeof(GstJack),
+ sizeof (GstJack),
0,
NULL,
};
- jack_type = g_type_register_static (GST_TYPE_ELEMENT, "GstJack", &jack_info, 0);
+ jack_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstJack", &jack_info, 0);
}
return jack_type;
}
GType
-gst_jack_sink_get_type (void)
+gst_jack_sink_get_type (void)
{
static GType jack_type = 0;
-
+
if (!jack_type) {
static const GTypeInfo jack_info = {
- sizeof(GstJackClass),
+ sizeof (GstJackClass),
gst_jack_sink_base_init,
NULL,
- (GClassInitFunc)gst_jack_class_init,
+ (GClassInitFunc) gst_jack_class_init,
NULL,
NULL,
- sizeof(GstJack),
+ sizeof (GstJack),
0,
- (GInstanceInitFunc)gst_jack_init,
+ (GInstanceInitFunc) gst_jack_init,
};
- jack_type = g_type_register_static (GST_TYPE_JACK, "GstJackSink", &jack_info, 0);
+ jack_type =
+ g_type_register_static (GST_TYPE_JACK, "GstJackSink", &jack_info, 0);
}
return jack_type;
}
GType
-gst_jack_src_get_type (void)
+gst_jack_src_get_type (void)
{
static GType jack_type = 0;
-
+
if (!jack_type) {
static const GTypeInfo jack_info = {
- sizeof(GstJackClass),
+ sizeof (GstJackClass),
gst_jack_src_base_init,
NULL,
- (GClassInitFunc)gst_jack_class_init,
+ (GClassInitFunc) gst_jack_class_init,
NULL,
NULL,
- sizeof(GstJack),
+ sizeof (GstJack),
0,
- (GInstanceInitFunc)gst_jack_init,
+ (GInstanceInitFunc) gst_jack_init,
};
- jack_type = g_type_register_static (GST_TYPE_JACK, "GstJackSrc", &jack_info, 0);
+ jack_type =
+ g_type_register_static (GST_TYPE_JACK, "GstJackSrc", &jack_info, 0);
}
return jack_type;
}
@@ -167,7 +171,8 @@ gst_jack_src_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_pad_template (element_class, gst_jack_src_request_pad_factory ());
+ gst_element_class_add_pad_template (element_class,
+ gst_jack_src_request_pad_factory ());
gst_element_class_set_details (element_class, &gst_jack_src_details);
}
@@ -176,342 +181,349 @@ gst_jack_sink_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_pad_template (element_class, gst_jack_sink_request_pad_factory ());
+ gst_element_class_add_pad_template (element_class,
+ gst_jack_sink_request_pad_factory ());
gst_element_class_set_details (element_class, &gst_jack_sink_details);
}
static void
-gst_jack_class_init(GstJackClass *klass)
+gst_jack_class_init (GstJackClass * klass)
{
- GObjectClass *object_class;
- GstElementClass *element_class;
- GParamSpec *pspec;
- gchar *prefix;
-
- object_class = (GObjectClass *)klass;
- element_class = (GstElementClass *)klass;
-
- if (parent_class == NULL)
- parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
-
- object_class->get_property = gst_jack_get_property;
- object_class->set_property = gst_jack_set_property;
-
- if (GST_IS_JACK_SINK_CLASS (klass))
- prefix = "gst-out-";
- else
- prefix = "gst-in-";
-
- pspec = g_param_spec_string ("port-name-prefix", "Port name prefix",
- "String to prepend to jack port names",
- prefix, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
- g_object_class_install_property (object_class, ARG_PORT_NAME_PREFIX, pspec);
-
- element_class->change_state = gst_jack_change_state;
-
- element_class->request_new_pad = gst_jack_request_new_pad;
+ GObjectClass *object_class;
+ GstElementClass *element_class;
+ GParamSpec *pspec;
+ gchar *prefix;
+
+ object_class = (GObjectClass *) klass;
+ element_class = (GstElementClass *) klass;
+
+ if (parent_class == NULL)
+ parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
+
+ object_class->get_property = gst_jack_get_property;
+ object_class->set_property = gst_jack_set_property;
+
+ if (GST_IS_JACK_SINK_CLASS (klass))
+ prefix = "gst-out-";
+ else
+ prefix = "gst-in-";
+
+ pspec = g_param_spec_string ("port-name-prefix", "Port name prefix",
+ "String to prepend to jack port names",
+ prefix, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
+ g_object_class_install_property (object_class, ARG_PORT_NAME_PREFIX, pspec);
+
+ element_class->change_state = gst_jack_change_state;
+
+ element_class->request_new_pad = gst_jack_request_new_pad;
}
static void
-gst_jack_init(GstJack *this)
+gst_jack_init (GstJack * this)
{
- if (G_OBJECT_TYPE (this) == GST_TYPE_JACK_SRC)
- this->direction = GST_PAD_SRC;
- else if (G_OBJECT_TYPE (this) == GST_TYPE_JACK_SINK)
- this->direction = GST_PAD_SINK;
- else
- g_assert_not_reached ();
-
- gst_element_set_loop_function (GST_ELEMENT (this), gst_jack_loop);
+ if (G_OBJECT_TYPE (this) == GST_TYPE_JACK_SRC)
+ this->direction = GST_PAD_SRC;
+ else if (G_OBJECT_TYPE (this) == GST_TYPE_JACK_SINK)
+ this->direction = GST_PAD_SINK;
+ else
+ g_assert_not_reached ();
+
+ gst_element_set_loop_function (GST_ELEMENT (this), gst_jack_loop);
}
static void
-gst_jack_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_jack_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
- GstJack *this = (GstJack*)object;
+ GstJack *this = (GstJack *) object;
- switch (prop_id) {
+ switch (prop_id) {
case ARG_PORT_NAME_PREFIX:
- if (this->port_name_prefix)
- g_free (this->port_name_prefix);
- this->port_name_prefix = g_strdup (g_value_get_string (value));
- break;
+ if (this->port_name_prefix)
+ g_free (this->port_name_prefix);
+ this->port_name_prefix = g_strdup (g_value_get_string (value));
+ break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- return;
- }
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ return;
+ }
}
static void
-gst_jack_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_jack_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
- GstJack *this = (GstJack*)object;
+ GstJack *this = (GstJack *) object;
- switch (prop_id) {
+ switch (prop_id) {
case ARG_PORT_NAME_PREFIX:
- g_value_set_string (value, this->port_name_prefix);
- break;
+ g_value_set_string (value, this->port_name_prefix);
+ break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
-static GstPadTemplate*
+static GstPadTemplate *
gst_jack_src_request_pad_factory (void)
{
- static GstPadTemplate *template = NULL;
-
- if (!template) {
- GstCaps *caps;
- caps = gst_caps_from_string (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS);
- template = gst_pad_template_new ("%s", GST_PAD_SRC,
- GST_PAD_REQUEST, caps);
- }
-
- return template;
+ static GstPadTemplate *template = NULL;
+
+ if (!template) {
+ GstCaps *caps;
+
+ caps = gst_caps_from_string (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS);
+ template = gst_pad_template_new ("%s", GST_PAD_SRC, GST_PAD_REQUEST, caps);
+ }
+
+ return template;
}
-static GstPadTemplate*
+static GstPadTemplate *
gst_jack_sink_request_pad_factory (void)
{
- static GstPadTemplate *template = NULL;
-
- if (!template) {
- GstCaps *caps;
- caps = gst_caps_from_string (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS);
- template = gst_pad_template_new ("%s", GST_PAD_SINK,
- GST_PAD_REQUEST, caps);
- }
-
- return template;
+ static GstPadTemplate *template = NULL;
+
+ if (!template) {
+ GstCaps *caps;
+
+ caps = gst_caps_from_string (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS);
+ template = gst_pad_template_new ("%s", GST_PAD_SINK, GST_PAD_REQUEST, caps);
+ }
+
+ return template;
}
-static GstPad*
-gst_jack_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *name)
+static GstPad *
+gst_jack_request_new_pad (GstElement * element, GstPadTemplate * templ,
+ const gchar * name)
{
- GstJack *this;
- gchar *newname;
- GList *l, **pad_list;
- GstJackPad *pad;
- gint count;
-
- g_return_val_if_fail ((this = GST_JACK (element)), NULL);
-
- if (!this->bin)
- pad_list = &this->pads;
- else if (this->direction == GST_PAD_SRC)
- pad_list = &this->bin->src_pads;
- else
- pad_list = &this->bin->sink_pads;
-
- if (name) {
- l = *pad_list;
- while (l) {
- if (strcmp (GST_JACK_PAD(l)->name, name) == 0) {
- g_warning("requested port name %s already in use.", name);
- return NULL;
- }
- l = l->next;
- }
- newname = g_strdup (name);
- } else {
- if (this->direction == GST_PAD_SINK)
- newname = g_strdup ("alsa_pcm:playback_1");
- else
- newname = g_strdup ("alsa_pcm:capture_1");
+ GstJack *this;
+ gchar *newname;
+ GList *l, **pad_list;
+ GstJackPad *pad;
+ gint count;
+
+ g_return_val_if_fail ((this = GST_JACK (element)), NULL);
+
+ if (!this->bin)
+ pad_list = &this->pads;
+ else if (this->direction == GST_PAD_SRC)
+ pad_list = &this->bin->src_pads;
+ else
+ pad_list = &this->bin->sink_pads;
+
+ if (name) {
+ l = *pad_list;
+ while (l) {
+ if (strcmp (GST_JACK_PAD (l)->name, name) == 0) {
+ g_warning ("requested port name %s already in use.", name);
+ return NULL;
+ }
+ l = l->next;
}
-
- pad = g_new0 (GstJackPad, 1);
-
- if (!port_name_counts)
- port_name_counts = g_hash_table_new (g_str_hash, g_str_equal);
-
- count = GPOINTER_TO_INT (g_hash_table_lookup (port_name_counts, this->port_name_prefix));
- g_hash_table_insert (port_name_counts, g_strdup (this->port_name_prefix), GINT_TO_POINTER (count+1));
-
- pad->name = g_strdup_printf ("%s%d", this->port_name_prefix, count);
-
- pad->peer_name = newname;
- pad->pad = gst_pad_new_from_template (templ, newname);
- gst_element_add_pad (GST_ELEMENT (this), pad->pad);
- gst_pad_set_link_function (pad->pad, gst_jack_link);
-
- this->pads = g_list_append (this->pads, pad);
-
- g_print ("returning from request_new_pad, pad %s created, to connect to %s\n", pad->name, pad->peer_name);
- return pad->pad;
+ newname = g_strdup (name);
+ } else {
+ if (this->direction == GST_PAD_SINK)
+ newname = g_strdup ("alsa_pcm:playback_1");
+ else
+ newname = g_strdup ("alsa_pcm:capture_1");
+ }
+
+ pad = g_new0 (GstJackPad, 1);
+
+ if (!port_name_counts)
+ port_name_counts = g_hash_table_new (g_str_hash, g_str_equal);
+
+ count =
+ GPOINTER_TO_INT (g_hash_table_lookup (port_name_counts,
+ this->port_name_prefix));
+ g_hash_table_insert (port_name_counts, g_strdup (this->port_name_prefix),
+ GINT_TO_POINTER (count + 1));
+
+ pad->name = g_strdup_printf ("%s%d", this->port_name_prefix, count);
+
+ pad->peer_name = newname;
+ pad->pad = gst_pad_new_from_template (templ, newname);
+ gst_element_add_pad (GST_ELEMENT (this), pad->pad);
+ gst_pad_set_link_function (pad->pad, gst_jack_link);
+
+ this->pads = g_list_append (this->pads, pad);
+
+ g_print ("returning from request_new_pad, pad %s created, to connect to %s\n",
+ pad->name, pad->peer_name);
+ return pad->pad;
}
static GstElementStateReturn
-gst_jack_change_state (GstElement *element)
+gst_jack_change_state (GstElement * element)
{
- GstJack *this;
- GList *l = NULL, **pads;
- GstJackPad *pad;
- GstCaps *caps;
-
- g_return_val_if_fail (element != NULL, FALSE);
- this = GST_JACK (element);
-
- switch (GST_STATE_PENDING (element)) {
+ GstJack *this;
+ GList *l = NULL, **pads;
+ GstJackPad *pad;
+ GstCaps *caps;
+
+ g_return_val_if_fail (element != NULL, FALSE);
+ this = GST_JACK (element);
+
+ switch (GST_STATE_PENDING (element)) {
case GST_STATE_NULL:
- JACK_DEBUG ("%s: NULL", GST_OBJECT_NAME (GST_OBJECT (this)));
+ JACK_DEBUG ("%s: NULL", GST_OBJECT_NAME (GST_OBJECT (this)));
+
+ break;
- break;
-
case GST_STATE_READY:
- JACK_DEBUG ("%s: READY", GST_OBJECT_NAME (GST_OBJECT (this)));
-
- if (!this->bin) {
- if (!(this->bin = (GstJackBin*)gst_element_get_managing_bin (element))
- || !GST_IS_JACK_BIN (this->bin)) {
- this->bin = NULL;
- g_warning ("jack element %s needs to be contained in a jack bin.",
- GST_OBJECT_NAME (element));
- return GST_STATE_FAILURE;
- }
-
- /* fixme: verify that all names are unique */
- l = this->pads;
- pads = (this->direction == GST_PAD_SRC) ? &this->bin->src_pads : &this->bin->sink_pads;
- while (l) {
- pad = GST_JACK_PAD (l);
- JACK_DEBUG ("%s: appending pad %s:%s to list", GST_OBJECT_NAME (this), pad->name, pad->peer_name);
- *pads = g_list_append (*pads, pad);
- l = g_list_next (l);
- }
- }
- break;
-
+ JACK_DEBUG ("%s: READY", GST_OBJECT_NAME (GST_OBJECT (this)));
+
+ if (!this->bin) {
+ if (!(this->bin = (GstJackBin *) gst_element_get_managing_bin (element))
+ || !GST_IS_JACK_BIN (this->bin)) {
+ this->bin = NULL;
+ g_warning ("jack element %s needs to be contained in a jack bin.",
+ GST_OBJECT_NAME (element));
+ return GST_STATE_FAILURE;
+ }
+
+ /* fixme: verify that all names are unique */
+ l = this->pads;
+ pads =
+ (this->direction ==
+ GST_PAD_SRC) ? &this->bin->src_pads : &this->bin->sink_pads;
+ while (l) {
+ pad = GST_JACK_PAD (l);
+ JACK_DEBUG ("%s: appending pad %s:%s to list", GST_OBJECT_NAME (this),
+ pad->name, pad->peer_name);
+ *pads = g_list_append (*pads, pad);
+ l = g_list_next (l);
+ }
+ }
+ break;
+
case GST_STATE_PAUSED:
- JACK_DEBUG ("%s: PAUSED", GST_OBJECT_NAME (GST_OBJECT (this)));
-
- if (GST_STATE (element) == GST_STATE_READY) {
- /* we're in READY->PAUSED */
- l = this->pads;
- while (l) {
- pad = GST_JACK_PAD (l);
- caps = gst_caps_copy (gst_pad_get_negotiated_caps (pad->pad));
- gst_caps_set_simple (caps,
- "rate", G_TYPE_INT, (int)this->bin->rate,
- "buffer-frames", G_TYPE_INT, (gint)this->bin->nframes,
- NULL);
- if (gst_pad_try_set_caps (pad->pad, caps) <= 0)
- return GST_STATE_FAILURE;
- l = g_list_next (l);
- }
- }
- break;
+ JACK_DEBUG ("%s: PAUSED", GST_OBJECT_NAME (GST_OBJECT (this)));
+
+ if (GST_STATE (element) == GST_STATE_READY) {
+ /* we're in READY->PAUSED */
+ l = this->pads;
+ while (l) {
+ pad = GST_JACK_PAD (l);
+ caps = gst_caps_copy (gst_pad_get_negotiated_caps (pad->pad));
+ gst_caps_set_simple (caps,
+ "rate", G_TYPE_INT, (int) this->bin->rate,
+ "buffer-frames", G_TYPE_INT, (gint) this->bin->nframes, NULL);
+ if (gst_pad_try_set_caps (pad->pad, caps) <= 0)
+ return GST_STATE_FAILURE;
+ l = g_list_next (l);
+ }
+ }
+ break;
case GST_STATE_PLAYING:
- JACK_DEBUG ("%s: PLAYING", GST_OBJECT_NAME (GST_OBJECT (this)));
- break;
- }
-
- JACK_DEBUG ("%s: state change finished", GST_OBJECT_NAME (this));
-
- if (GST_ELEMENT_CLASS (parent_class)->change_state)
- return GST_ELEMENT_CLASS (parent_class)->change_state (element);
+ JACK_DEBUG ("%s: PLAYING", GST_OBJECT_NAME (GST_OBJECT (this)));
+ break;
+ }
+
+ JACK_DEBUG ("%s: state change finished", GST_OBJECT_NAME (this));
- return GST_STATE_SUCCESS;
+ if (GST_ELEMENT_CLASS (parent_class)->change_state)
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element);
+
+ return GST_STATE_SUCCESS;
}
static GstPadLinkReturn
-gst_jack_link (GstPad *pad, const GstCaps *caps)
+gst_jack_link (GstPad * pad, const GstCaps * caps)
{
GstJack *this;
gint rate, buffer_frames;
GstStructure *structure;
-
+
this = GST_JACK (GST_OBJECT_PARENT (pad));
-
+
structure = gst_caps_get_structure (caps, 0);
- gst_structure_get_int (structure, "rate", &rate);
- gst_structure_get_int (structure, "buffer-frames", &buffer_frames);
+ gst_structure_get_int (structure, "rate", &rate);
+ gst_structure_get_int (structure, "buffer-frames", &buffer_frames);
if (this->bin && (rate != this->bin->rate ||
- buffer_frames != this->bin->nframes))
- return GST_PAD_LINK_REFUSED;
-
+ buffer_frames != this->bin->nframes))
+ return GST_PAD_LINK_REFUSED;
+
return GST_PAD_LINK_OK;
}
static void
-gst_jack_loop (GstElement *element)
+gst_jack_loop (GstElement * element)
{
- GstJack *this;
- GList *pads;
- gint len;
- GstJackPad *pad;
- GstBuffer *buffer;
-
- this = GST_JACK (element);
-
- len = this->bin->nframes * sizeof (sample_t);
-
- pads = this->pads;
- while (pads) {
- pad = GST_JACK_PAD (pads);
-
- if (this->direction == GST_PAD_SINK) {
- buffer = GST_BUFFER (gst_pad_pull (pad->pad));
-
- if (GST_IS_EVENT (buffer)) {
- GstEvent *event = GST_EVENT (buffer);
- switch (GST_EVENT_TYPE (buffer)) {
- case GST_EVENT_EOS:
- gst_element_set_eos (element);
- gst_event_unref (event);
- return;
- default:
- gst_pad_event_default (pad->pad, event);
- return;
- }
- }
-
- /* if the other plugins only give out buffer-frames or less (as
- they should), if the length of the GstBuffer is different
- from nframes then the buffer is short and we will get EOS
- next */
- memcpy (pad->data, GST_BUFFER_DATA (buffer),
- GST_BUFFER_SIZE (buffer));
- if (len != GST_BUFFER_SIZE (buffer))
- memset (pad->data + GST_BUFFER_SIZE (buffer), 0,
- len - GST_BUFFER_SIZE (buffer));
-
- gst_buffer_unref (buffer);
- } else {
- buffer = gst_buffer_new ();
- gst_buffer_set_data (buffer, pad->data, len);
- GST_BUFFER_FLAG_SET(buffer, GST_BUFFER_DONTFREE);
-
- gst_pad_push (pad->pad, GST_DATA (buffer));
- }
- pads = g_list_next (pads);
+ GstJack *this;
+ GList *pads;
+ gint len;
+ GstJackPad *pad;
+ GstBuffer *buffer;
+
+ this = GST_JACK (element);
+
+ len = this->bin->nframes * sizeof (sample_t);
+
+ pads = this->pads;
+ while (pads) {
+ pad = GST_JACK_PAD (pads);
+
+ if (this->direction == GST_PAD_SINK) {
+ buffer = GST_BUFFER (gst_pad_pull (pad->pad));
+
+ if (GST_IS_EVENT (buffer)) {
+ GstEvent *event = GST_EVENT (buffer);
+
+ switch (GST_EVENT_TYPE (buffer)) {
+ case GST_EVENT_EOS:
+ gst_element_set_eos (element);
+ gst_event_unref (event);
+ return;
+ default:
+ gst_pad_event_default (pad->pad, event);
+ return;
+ }
+ }
+
+ /* if the other plugins only give out buffer-frames or less (as
+ they should), if the length of the GstBuffer is different
+ from nframes then the buffer is short and we will get EOS
+ next */
+ memcpy (pad->data, GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer));
+ if (len != GST_BUFFER_SIZE (buffer))
+ memset (pad->data + GST_BUFFER_SIZE (buffer), 0,
+ len - GST_BUFFER_SIZE (buffer));
+
+ gst_buffer_unref (buffer);
+ } else {
+ buffer = gst_buffer_new ();
+ gst_buffer_set_data (buffer, pad->data, len);
+ GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_DONTFREE);
+
+ gst_pad_push (pad->pad, GST_DATA (buffer));
}
+ pads = g_list_next (pads);
+ }
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- if (!gst_element_register (plugin, "jackbin", GST_RANK_NONE, GST_TYPE_JACK_BIN))
+ if (!gst_element_register (plugin, "jackbin", GST_RANK_NONE,
+ GST_TYPE_JACK_BIN))
return FALSE;
- if (!gst_element_register (plugin, "jacksrc", GST_RANK_NONE, GST_TYPE_JACK_SRC))
+ if (!gst_element_register (plugin, "jacksrc", GST_RANK_NONE,
+ GST_TYPE_JACK_SRC))
return FALSE;
- if (!gst_element_register (plugin, "jacksink", GST_RANK_NONE, GST_TYPE_JACK_SINK))
+ if (!gst_element_register (plugin, "jacksink", GST_RANK_NONE,
+ GST_TYPE_JACK_SINK))
return FALSE;
-
+
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "jack",
- "Jack Plugin Library",
- plugin_init,
- VERSION,
- "GPL",
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "jack",
+ "Jack Plugin Library", plugin_init, VERSION, "GPL", GST_PACKAGE, GST_ORIGIN)
diff --git a/ext/jack/gstjack.h b/ext/jack/gstjack.h
index 87d7d611..f5a5416f 100644
--- a/ext/jack/gstjack.h
+++ b/ext/jack/gstjack.h
@@ -51,7 +51,7 @@
#define GST_IS_JACK_BIN_CLASS(klass) G_TYPE_CHECK_CLASS_TYPE(klass, GST_TYPE_JACK_BIN)
#define GST_TYPE_JACK_BIN gst_jack_bin_get_type()
-#define GST_JACK_PAD(l) ((GstJackPad*)l->data) /* l is a GList */
+#define GST_JACK_PAD(l) ((GstJackPad*)l->data) /* l is a GList */
typedef struct _GstJack GstJack;
@@ -64,59 +64,65 @@ typedef GstJack GstJackSrc;
typedef GstJackClass GstJackSrcClass;
-enum {
- GST_JACK_OPEN = GST_BIN_FLAG_LAST,
- GST_JACK_ACTIVE,
- GST_JACK_FLAG_LAST = GST_BIN_FLAG_LAST + 3,
+enum
+{
+ GST_JACK_OPEN = GST_BIN_FLAG_LAST,
+ GST_JACK_ACTIVE,
+ GST_JACK_FLAG_LAST = GST_BIN_FLAG_LAST + 3,
};
typedef jack_default_audio_sample_t sample_t;
-typedef struct {
- GstPad *pad;
- void *data;
- const gchar *name;
- const gchar *peer_name;
- jack_port_t *port;
+typedef struct
+{
+ GstPad *pad;
+ void *data;
+ const gchar *name;
+ const gchar *peer_name;
+ jack_port_t *port;
} GstJackPad;
-struct _GstJack {
- GstElement element;
+struct _GstJack
+{
+ GstElement element;
- /* list of GstJackPads */
- GList *pads;
+ /* list of GstJackPads */
+ GList *pads;
- /* for convenience */
- GstPadDirection direction;
+ /* for convenience */
+ GstPadDirection direction;
- gchar *port_name_prefix;
+ gchar *port_name_prefix;
- GstJackBin *bin;
+ GstJackBin *bin;
};
-struct _GstJackClass {
- GstElementClass parent_class;
+struct _GstJackClass
+{
+ GstElementClass parent_class;
};
-struct _GstJackBin {
- GstBin bin;
+struct _GstJackBin
+{
+ GstBin bin;
- jack_client_t *client;
- gint default_new_port_number;
+ jack_client_t *client;
+ gint default_new_port_number;
- /* lists of GstJackPads */
- GList *sink_pads;
- GList *src_pads;
+ /* lists of GstJackPads */
+ GList *sink_pads;
+ GList *src_pads;
- gchar *client_name;
+ gchar *client_name;
- guint rate;
- jack_nframes_t nframes;
+ guint rate;
+ jack_nframes_t nframes;
};
-struct _GstJackBinClass {
- GstBinClass parent_class;
+struct _GstJackBinClass
+{
+ GstBinClass parent_class;
};
diff --git a/ext/jack/gstjackbin.c b/ext/jack/gstjackbin.c
index b0cea9bc..9be6e915 100644
--- a/ext/jack/gstjackbin.c
+++ b/ext/jack/gstjackbin.c
@@ -29,10 +29,10 @@
static GstBinClass *parent_class = NULL;
-static void gst_jack_bin_init(GstJackBin *this);
-static void gst_jack_bin_class_init(GstJackBinClass *klass);
+static void gst_jack_bin_init (GstJackBin * this);
+static void gst_jack_bin_class_init (GstJackBinClass * klass);
-static GstElementStateReturn gst_jack_bin_change_state(GstElement *element);
+static GstElementStateReturn gst_jack_bin_change_state (GstElement * element);
/* jack callbacks */
static int process (jack_nframes_t nframes, void *arg);
@@ -48,196 +48,213 @@ static gboolean watchdog_please_set_the_jackbin_to_ready = FALSE;
* so set the state of the bin to READY. */
GType
-gst_jack_bin_get_type (void)
+gst_jack_bin_get_type (void)
{
- static GType jack_bin_type = 0;
-if (!jack_bin_type) {
- static const GTypeInfo jack_bin_info = {
- sizeof(GstJackBinClass),
- NULL,
- NULL,
- (GClassInitFunc)gst_jack_bin_class_init,
- NULL,
- NULL,
- sizeof(GstJackBin),
- 0,
- (GInstanceInitFunc)gst_jack_bin_init,
- };
- jack_bin_type = g_type_register_static (GST_TYPE_BIN, "GstJackBin", &jack_bin_info, 0);
- }
- return jack_bin_type;
+ static GType jack_bin_type = 0;
+
+ if (!jack_bin_type) {
+ static const GTypeInfo jack_bin_info = {
+ sizeof (GstJackBinClass),
+ NULL,
+ NULL,
+ (GClassInitFunc) gst_jack_bin_class_init,
+ NULL,
+ NULL,
+ sizeof (GstJackBin),
+ 0,
+ (GInstanceInitFunc) gst_jack_bin_init,
+ };
+ jack_bin_type =
+ g_type_register_static (GST_TYPE_BIN, "GstJackBin", &jack_bin_info, 0);
+ }
+ return jack_bin_type;
}
static void
-gst_jack_bin_class_init(GstJackBinClass *klass)
+gst_jack_bin_class_init (GstJackBinClass * klass)
{
- GObjectClass *object_class;
- GstElementClass *element_class;
-
- object_class = (GObjectClass *)klass;
- element_class = (GstElementClass *)klass;
-
- parent_class = g_type_class_ref(GST_TYPE_BIN);
-
- element_class->change_state = gst_jack_bin_change_state;
+ GObjectClass *object_class;
+ GstElementClass *element_class;
+
+ object_class = (GObjectClass *) klass;
+ element_class = (GstElementClass *) klass;
+
+ parent_class = g_type_class_ref (GST_TYPE_BIN);
+
+ element_class->change_state = gst_jack_bin_change_state;
}
static void
-gst_jack_bin_init(GstJackBin *this)
+gst_jack_bin_init (GstJackBin * this)
{
- GST_DEBUG ("initializing jack bin");
-
- /* jack bins are managing bins and iterate themselves */
- GST_FLAG_SET (this, GST_BIN_FLAG_MANAGER);
- GST_FLAG_SET (this, GST_BIN_SELF_SCHEDULABLE);
-
- /* make a new scheduler and associate it with the bin */
- gst_scheduler_factory_make (NULL, GST_ELEMENT (this));
+ GST_DEBUG ("initializing jack bin");
+
+ /* jack bins are managing bins and iterate themselves */
+ GST_FLAG_SET (this, GST_BIN_FLAG_MANAGER);
+ GST_FLAG_SET (this, GST_BIN_SELF_SCHEDULABLE);
+
+ /* make a new scheduler and associate it with the bin */
+ gst_scheduler_factory_make (NULL, GST_ELEMENT (this));
}
static GstElementStateReturn
-gst_jack_bin_change_state (GstElement *element)
+gst_jack_bin_change_state (GstElement * element)
{
- GstJackBin *this;
- GList *l = NULL;
- GstJackPad *pad;
-
- g_return_val_if_fail (element != NULL, FALSE);
- this = GST_JACK_BIN (element);
-
- switch (GST_STATE_PENDING (element)) {
+ GstJackBin *this;
+ GList *l = NULL;
+ GstJackPad *pad;
+
+ g_return_val_if_fail (element != NULL, FALSE);
+ this = GST_JACK_BIN (element);
+
+ switch (GST_STATE_PENDING (element)) {
case GST_STATE_NULL:
- JACK_DEBUG ("jackbin: NULL state");
- if (this->client) {
- JACK_DEBUG ("jackbin: closing client");
- jack_client_close (this->client);
- this->client = NULL;
- }
-
- if (_jackbin)
- signal (SIGHUP, SIG_DFL);
- _jackbin = NULL;
-
- if (GST_ELEMENT_CLASS (parent_class)->change_state)
- return GST_ELEMENT_CLASS (parent_class)->change_state (element);
- break;
-
+ JACK_DEBUG ("jackbin: NULL state");
+ if (this->client) {
+ JACK_DEBUG ("jackbin: closing client");
+ jack_client_close (this->client);
+ this->client = NULL;
+ }
+
+ if (_jackbin)
+ signal (SIGHUP, SIG_DFL);
+ _jackbin = NULL;
+
+ if (GST_ELEMENT_CLASS (parent_class)->change_state)
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element);
+ break;
+
case GST_STATE_READY:
- JACK_DEBUG ("jackbin: READY");
-
- _jackbin = this;
- signal (SIGHUP, sighup_handler);
-
- if (!this->client) {
- if (!(this->client = jack_client_new ("gst-jack"))) {
- g_warning ("jack server not running?");
- return GST_STATE_FAILURE;
- }
-
- gst_scheduler_setup (GST_ELEMENT_SCHED (this));
-
- jack_set_process_callback (this->client, process, this);
- jack_set_sample_rate_callback (this->client, sample_rate, this);
- jack_set_buffer_size_callback (this->client, buffer_size, this);
- this->nframes = jack_get_buffer_size (this->client);
- jack_on_shutdown (this->client, shutdown, this);
- }
-
- if (GST_FLAG_IS_SET (GST_OBJECT (this), GST_JACK_OPEN)) {
- l = this->src_pads;
- while (l) {
- JACK_DEBUG ("jackbin: unregistering pad %s:%s", GST_JACK_PAD (l)->name, GST_JACK_PAD (l)->peer_name);
- jack_port_unregister (this->client, GST_JACK_PAD (l)->port);
- l = g_list_next (l);
- }
- l = this->sink_pads;
- while (l) {
- JACK_DEBUG ("jackbin: unregistering pad %s:%s", GST_JACK_PAD (l)->name, GST_JACK_PAD (l)->peer_name);
- jack_port_unregister (this->client, GST_JACK_PAD (l)->port);
- l = g_list_next (l);
- }
- GST_FLAG_UNSET (GST_OBJECT (this), GST_JACK_OPEN);
-
- if (GST_FLAG_IS_SET (GST_OBJECT (this), GST_JACK_ACTIVE)) {
- JACK_DEBUG ("jackbin: deactivating client");
- jack_deactivate (this->client);
- GST_FLAG_UNSET (GST_OBJECT (this), GST_JACK_ACTIVE);
- }
- }
-
- if (GST_ELEMENT_CLASS (parent_class)->change_state)
- return GST_ELEMENT_CLASS (parent_class)->change_state (element);
- break;
-
+ JACK_DEBUG ("jackbin: READY");
+
+ _jackbin = this;
+ signal (SIGHUP, sighup_handler);
+
+ if (!this->client) {
+ if (!(this->client = jack_client_new ("gst-jack"))) {
+ g_warning ("jack server not running?");
+ return GST_STATE_FAILURE;
+ }
+
+ gst_scheduler_setup (GST_ELEMENT_SCHED (this));
+
+ jack_set_process_callback (this->client, process, this);
+ jack_set_sample_rate_callback (this->client, sample_rate, this);
+ jack_set_buffer_size_callback (this->client, buffer_size, this);
+ this->nframes = jack_get_buffer_size (this->client);
+ jack_on_shutdown (this->client, shutdown, this);
+ }
+
+ if (GST_FLAG_IS_SET (GST_OBJECT (this), GST_JACK_OPEN)) {
+ l = this->src_pads;
+ while (l) {
+ JACK_DEBUG ("jackbin: unregistering pad %s:%s",
+ GST_JACK_PAD (l)->name, GST_JACK_PAD (l)->peer_name);
+ jack_port_unregister (this->client, GST_JACK_PAD (l)->port);
+ l = g_list_next (l);
+ }
+ l = this->sink_pads;
+ while (l) {
+ JACK_DEBUG ("jackbin: unregistering pad %s:%s",
+ GST_JACK_PAD (l)->name, GST_JACK_PAD (l)->peer_name);
+ jack_port_unregister (this->client, GST_JACK_PAD (l)->port);
+ l = g_list_next (l);
+ }
+ GST_FLAG_UNSET (GST_OBJECT (this), GST_JACK_OPEN);
+
+ if (GST_FLAG_IS_SET (GST_OBJECT (this), GST_JACK_ACTIVE)) {
+ JACK_DEBUG ("jackbin: deactivating client");
+ jack_deactivate (this->client);
+ GST_FLAG_UNSET (GST_OBJECT (this), GST_JACK_ACTIVE);
+ }
+ }
+
+ if (GST_ELEMENT_CLASS (parent_class)->change_state)
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element);
+ break;
+
case GST_STATE_PAUSED:
- JACK_DEBUG ("jackbin: PAUSED");
-
- if (!GST_FLAG_IS_SET (GST_OBJECT (this), GST_JACK_OPEN)) {
- l = this->src_pads;
- while (l) {
- pad = GST_JACK_PAD (l);
- JACK_DEBUG ("jackbin: registering input port %s (peer %s)", pad->name, pad->peer_name);
- pad->port = jack_port_register (this->client, pad->name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput|JackPortIsTerminal, 0);
- l = g_list_next (l);
- }
- l = this->sink_pads;
- while (l) {
- pad = GST_JACK_PAD (l);
- JACK_DEBUG ("jackbin: registering output port %s (peer %s)", pad->name, pad->peer_name);
- pad->port = jack_port_register (this->client, pad->name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput|JackPortIsTerminal, 0);
- l = g_list_next (l);
- }
-
- /* must activate before connecting */
- if (!GST_FLAG_IS_SET (GST_OBJECT (this), GST_JACK_ACTIVE)) {
- JACK_DEBUG ("jackbin: activating client");
- jack_activate (this->client);
- GST_FLAG_SET (GST_OBJECT (this), GST_JACK_ACTIVE);
- }
-
- l = this->src_pads;
- while (l) {
- pad = GST_JACK_PAD (l);
- JACK_DEBUG ("connecting jack port %s to gst jack port %s", pad->peer_name, jack_port_name (pad->port));
- if (jack_connect (this->client, pad->peer_name, jack_port_name (pad->port))) {
- g_warning ("jackbin: could not connect %s and %s", pad->peer_name, jack_port_name (pad->port));
- return GST_STATE_FAILURE;
- }
- l = g_list_next (l);
- }
- l = this->sink_pads;
- while (l) {
- pad = GST_JACK_PAD (l);
- JACK_DEBUG ("connecting gst jack port %s to jack port %s", jack_port_name (pad->port), pad->peer_name);
- if (jack_connect (this->client, jack_port_name (pad->port), pad->peer_name)) {
- g_warning ("jackbin: could not connect %s and %s", pad->peer_name, jack_port_name (pad->port));
- return GST_STATE_FAILURE;
- }
- l = g_list_next (l);
- }
-
- JACK_DEBUG ("jackbin: setting OPEN flag");
- GST_FLAG_SET (GST_OBJECT (this), GST_JACK_OPEN);
-
- if (GST_ELEMENT_CLASS (parent_class)->change_state)
- return GST_ELEMENT_CLASS (parent_class)->change_state (element);
- } else {
- if (GST_ELEMENT_CLASS (parent_class)->change_state)
- return GST_ELEMENT_CLASS (parent_class)->change_state (element);
- }
-
- break;
+ JACK_DEBUG ("jackbin: PAUSED");
+
+ if (!GST_FLAG_IS_SET (GST_OBJECT (this), GST_JACK_OPEN)) {
+ l = this->src_pads;
+ while (l) {
+ pad = GST_JACK_PAD (l);
+ JACK_DEBUG ("jackbin: registering input port %s (peer %s)", pad->name,
+ pad->peer_name);
+ pad->port =
+ jack_port_register (this->client, pad->name,
+ JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput | JackPortIsTerminal, 0);
+ l = g_list_next (l);
+ }
+ l = this->sink_pads;
+ while (l) {
+ pad = GST_JACK_PAD (l);
+ JACK_DEBUG ("jackbin: registering output port %s (peer %s)",
+ pad->name, pad->peer_name);
+ pad->port =
+ jack_port_register (this->client, pad->name,
+ JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput | JackPortIsTerminal,
+ 0);
+ l = g_list_next (l);
+ }
+
+ /* must activate before connecting */
+ if (!GST_FLAG_IS_SET (GST_OBJECT (this), GST_JACK_ACTIVE)) {
+ JACK_DEBUG ("jackbin: activating client");
+ jack_activate (this->client);
+ GST_FLAG_SET (GST_OBJECT (this), GST_JACK_ACTIVE);
+ }
+
+ l = this->src_pads;
+ while (l) {
+ pad = GST_JACK_PAD (l);
+ JACK_DEBUG ("connecting jack port %s to gst jack port %s",
+ pad->peer_name, jack_port_name (pad->port));
+ if (jack_connect (this->client, pad->peer_name,
+ jack_port_name (pad->port))) {
+ g_warning ("jackbin: could not connect %s and %s", pad->peer_name,
+ jack_port_name (pad->port));
+ return GST_STATE_FAILURE;
+ }
+ l = g_list_next (l);
+ }
+ l = this->sink_pads;
+ while (l) {
+ pad = GST_JACK_PAD (l);
+ JACK_DEBUG ("connecting gst jack port %s to jack port %s",
+ jack_port_name (pad->port), pad->peer_name);
+ if (jack_connect (this->client, jack_port_name (pad->port),
+ pad->peer_name)) {
+ g_warning ("jackbin: could not connect %s and %s", pad->peer_name,
+ jack_port_name (pad->port));
+ return GST_STATE_FAILURE;
+ }
+ l = g_list_next (l);
+ }
+
+ JACK_DEBUG ("jackbin: setting OPEN flag");
+ GST_FLAG_SET (GST_OBJECT (this), GST_JACK_OPEN);
+
+ if (GST_ELEMENT_CLASS (parent_class)->change_state)
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element);
+ } else {
+ if (GST_ELEMENT_CLASS (parent_class)->change_state)
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element);
+ }
+
+ break;
case GST_STATE_PLAYING:
- JACK_DEBUG ("jackbin: PLAYING");
-
- if (GST_ELEMENT_CLASS (parent_class)->change_state)
- return GST_ELEMENT_CLASS (parent_class)->change_state (element);
- break;
- }
-
- JACK_DEBUG ("jackbin: state change finished");
-
- return GST_STATE_SUCCESS;
+ JACK_DEBUG ("jackbin: PLAYING");
+
+ if (GST_ELEMENT_CLASS (parent_class)->change_state)
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element);
+ break;
+ }
+
+ JACK_DEBUG ("jackbin: state change finished");
+
+ return GST_STATE_SUCCESS;
}
/* jack callbacks */
@@ -247,76 +264,79 @@ gst_jack_bin_change_state (GstElement *element)
static int
process (jack_nframes_t nframes, void *arg)
{
- GstJackBin *bin = (GstJackBin*) arg;
- GstJackPad *pad;
- GList *l;
-
- g_assert (bin);
-
- JACK_DEBUG ("jackbin: process()");
-
- if (GST_STATE (bin) != GST_STATE_PLAYING) {
- JACK_DEBUG ("jackbin: bin is not PLAYING yet, returning");
- return 0;
- } else {
- JACK_DEBUG ("jackbin: we are PLAYING, let's process()");
- }
-
- l = bin->src_pads;
- while (l) {
- pad = GST_JACK_PAD (l);
- pad->data = jack_port_get_buffer (pad->port, nframes);
- l = g_list_next (l);
- }
-
- l = bin->sink_pads;
- while (l) {
- pad = GST_JACK_PAD (l);
- pad->data = jack_port_get_buffer (pad->port, nframes);
- l = g_list_next (l);
- }
-
- bin->nframes = nframes;
-
- JACK_DEBUG ("jackbin: iterating to process %ld frames of audio...", nframes);
- if (!gst_bin_iterate (GST_BIN (bin))) {
- g_warning ("bin failed to iterate");
- return -1;
- }
-
- /* that's all folks */
-
- return 0;
+ GstJackBin *bin = (GstJackBin *) arg;
+ GstJackPad *pad;
+ GList *l;
+
+ g_assert (bin);
+
+ JACK_DEBUG ("jackbin: process()");
+
+ if (GST_STATE (bin) != GST_STATE_PLAYING) {
+ JACK_DEBUG ("jackbin: bin is not PLAYING yet, returning");
+ return 0;
+ } else {
+ JACK_DEBUG ("jackbin: we are PLAYING, let's process()");
+ }
+
+ l = bin->src_pads;
+ while (l) {
+ pad = GST_JACK_PAD (l);
+ pad->data = jack_port_get_buffer (pad->port, nframes);
+ l = g_list_next (l);
+ }
+
+ l = bin->sink_pads;
+ while (l) {
+ pad = GST_JACK_PAD (l);
+ pad->data = jack_port_get_buffer (pad->port, nframes);
+ l = g_list_next (l);
+ }
+
+ bin->nframes = nframes;
+
+ JACK_DEBUG ("jackbin: iterating to process %ld frames of audio...", nframes);
+ if (!gst_bin_iterate (GST_BIN (bin))) {
+ g_warning ("bin failed to iterate");
+ return -1;
+ }
+
+ /* that's all folks */
+
+ return 0;
}
static int
sample_rate (jack_nframes_t nframes, void *arg)
{
- GstJackBin *bin = (GstJackBin*) arg;
- JACK_DEBUG ("the sample rate is now %lu/sec\n", nframes);
- bin->rate = nframes;
- return 0;
+ GstJackBin *bin = (GstJackBin *) arg;
+
+ JACK_DEBUG ("the sample rate is now %lu/sec\n", nframes);
+ bin->rate = nframes;
+ return 0;
}
static int
buffer_size (jack_nframes_t nframes, void *arg)
{
- GstJackBin *bin = (GstJackBin*) arg;
- JACK_DEBUG ("the buffer size is now %lu\n", nframes);
- bin->nframes = nframes;
- return 0;
+ GstJackBin *bin = (GstJackBin *) arg;
+
+ JACK_DEBUG ("the buffer size is now %lu\n", nframes);
+ bin->nframes = nframes;
+ return 0;
}
static void
shutdown (void *arg)
{
/* GstJackClient *client = (GstJackClient*) arg; */
- printf ("shutdown %p\n", arg);
+ printf ("shutdown %p\n", arg);
/* gst_element_set_state (GST_ELEMENT (client->manager), GST_STATE_READY); */
}
-static void sighup_handler (int sig)
+static void
+sighup_handler (int sig)
{
- g_message ("got sighup, setting state to READY");
- watchdog_please_set_the_jackbin_to_ready = TRUE;
+ g_message ("got sighup, setting state to READY");
+ watchdog_please_set_the_jackbin_to_ready = TRUE;
}
diff --git a/ext/ladspa/gstladspa.c b/ext/ladspa/gstladspa.c
index 020767fa..4f6c1f0c 100644
--- a/ext/ladspa/gstladspa.c
+++ b/ext/ladspa/gstladspa.c
@@ -28,8 +28,8 @@
#include <gst/audio/audio.h>
#include "gstladspa.h"
-#include <ladspa.h> /* main ladspa sdk include file */
-#include "utils.h" /* ladspa sdk utility functions */
+#include <ladspa.h> /* main ladspa sdk include file */
+#include "utils.h" /* ladspa sdk utility functions */
/* 1.0 and the 1.1 preliminary headers don't define a version, but 1.1 final
does */
@@ -40,31 +40,34 @@
static GstStaticCaps ladspa_pad_caps =
GST_STATIC_CAPS (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS);
-static void gst_ladspa_class_init (GstLADSPAClass *klass);
-static void gst_ladspa_base_init (GstLADSPAClass *klass);
-static void gst_ladspa_init (GstLADSPA *ladspa);
+static void gst_ladspa_class_init (GstLADSPAClass * klass);
+static void gst_ladspa_base_init (GstLADSPAClass * klass);
+static void gst_ladspa_init (GstLADSPA * ladspa);
-static void gst_ladspa_update_int (const GValue *value, gpointer data);
-static GstPadLinkReturn gst_ladspa_link (GstPad *pad, const GstCaps *caps);
+static void gst_ladspa_update_int (const GValue * value, gpointer data);
+static GstPadLinkReturn gst_ladspa_link (GstPad * pad, const GstCaps * caps);
-static void gst_ladspa_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_ladspa_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void gst_ladspa_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_ladspa_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static gboolean gst_ladspa_instantiate (GstLADSPA *ladspa);
-static void gst_ladspa_activate (GstLADSPA *ladspa);
-static void gst_ladspa_deactivate (GstLADSPA *ladspa);
+static gboolean gst_ladspa_instantiate (GstLADSPA * ladspa);
+static void gst_ladspa_activate (GstLADSPA * ladspa);
+static void gst_ladspa_deactivate (GstLADSPA * ladspa);
-static GstElementStateReturn gst_ladspa_change_state (GstElement *element);
-static void gst_ladspa_loop (GstElement *element);
-static void gst_ladspa_chain (GstPad *pad,GstData *_data);
-static GstData * gst_ladspa_get (GstPad *pad);
+static GstElementStateReturn gst_ladspa_change_state (GstElement * element);
+static void gst_ladspa_loop (GstElement * element);
+static void gst_ladspa_chain (GstPad * pad, GstData * _data);
+static GstData *gst_ladspa_get (GstPad * pad);
static GstElementClass *parent_class = NULL;
static GstPlugin *ladspa_plugin;
static GHashTable *ladspa_descriptors;
-enum {
+enum
+{
ARG_0,
ARG_SAMPLERATE,
ARG_BUFFERSIZE,
@@ -78,38 +81,39 @@ GST_DEBUG_CATEGORY_STATIC (ladspa_debug);
GST_CAT_LEVEL_LOG (ladspa_debug, GST_LEVEL_DEBUG, obj, __VA_ARGS__)
static void
-gst_ladspa_base_init (GstLADSPAClass *klass)
+gst_ladspa_base_init (GstLADSPAClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
GstPadTemplate *templ;
GstElementDetails *details;
LADSPA_Descriptor *desc;
- gint j, sinkcount,srccount;
+ gint j, sinkcount, srccount;
- desc = g_hash_table_lookup(ladspa_descriptors,
- GINT_TO_POINTER(G_TYPE_FROM_CLASS(klass)));
+ desc = g_hash_table_lookup (ladspa_descriptors,
+ GINT_TO_POINTER (G_TYPE_FROM_CLASS (klass)));
if (!desc)
- desc = g_hash_table_lookup(ladspa_descriptors, GINT_TO_POINTER(0));
+ desc = g_hash_table_lookup (ladspa_descriptors, GINT_TO_POINTER (0));
g_assert (desc);
/* pad templates */
klass->numports = desc->PortCount;
klass->numsinkpads = 0;
klass->numsrcpads = 0;
- for (j=0;j<desc->PortCount;j++) {
- if (LADSPA_IS_PORT_AUDIO(desc->PortDescriptors[j])) {
- gchar *name = g_strdup((gchar *)desc->PortNames[j]);
+ for (j = 0; j < desc->PortCount; j++) {
+ if (LADSPA_IS_PORT_AUDIO (desc->PortDescriptors[j])) {
+ gchar *name = g_strdup ((gchar *) desc->PortNames[j]);
+
g_strcanon (name, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-", '-');
/* the factories take ownership of the name */
- if (LADSPA_IS_PORT_INPUT(desc->PortDescriptors[j])) {
- templ = gst_pad_template_new (name, GST_PAD_SINK, GST_PAD_ALWAYS,
- gst_caps_copy (gst_static_caps_get (&ladspa_pad_caps)));
- klass->numsinkpads++;
+ if (LADSPA_IS_PORT_INPUT (desc->PortDescriptors[j])) {
+ templ = gst_pad_template_new (name, GST_PAD_SINK, GST_PAD_ALWAYS,
+ gst_caps_copy (gst_static_caps_get (&ladspa_pad_caps)));
+ klass->numsinkpads++;
} else {
- templ = gst_pad_template_new (name, GST_PAD_SRC, GST_PAD_ALWAYS,
- gst_caps_copy (gst_static_caps_get (&ladspa_pad_caps)));
- klass->numsrcpads++;
+ templ = gst_pad_template_new (name, GST_PAD_SRC, GST_PAD_ALWAYS,
+ gst_caps_copy (gst_static_caps_get (&ladspa_pad_caps)));
+ klass->numsrcpads++;
}
gst_element_class_add_pad_template (element_class, templ);
@@ -117,28 +121,32 @@ gst_ladspa_base_init (GstLADSPAClass *klass)
}
/* construct the element details struct */
- details = g_new0(GstElementDetails,1);
- details->longname = g_strdup(desc->Name);
+ details = g_new0 (GstElementDetails, 1);
+ details->longname = g_strdup (desc->Name);
details->description = details->longname;
- details->author = g_strdup(desc->Maker);
- if ((klass->numsinkpads >0) && (klass->numsrcpads >0)) details->klass = "Filter/Effect/Audio/LADSPA";
- else if((klass->numsinkpads==0) && (klass->numsrcpads >0)) details->klass = "Source/Audio/LADSPA";
- else if((klass->numsinkpads >0) && (klass->numsrcpads==0)) details->klass = "Sink/Audio/LADSPA";
- else details->klass = "Filter/Effect/Audio/LADSPA"; /* whatever this is */
+ details->author = g_strdup (desc->Maker);
+ if ((klass->numsinkpads > 0) && (klass->numsrcpads > 0))
+ details->klass = "Filter/Effect/Audio/LADSPA";
+ else if ((klass->numsinkpads == 0) && (klass->numsrcpads > 0))
+ details->klass = "Source/Audio/LADSPA";
+ else if ((klass->numsinkpads > 0) && (klass->numsrcpads == 0))
+ details->klass = "Sink/Audio/LADSPA";
+ else
+ details->klass = "Filter/Effect/Audio/LADSPA"; /* whatever this is */
gst_element_class_set_details (element_class, details);
- klass->srcpad_portnums = g_new0(gint,klass->numsrcpads);
- klass->sinkpad_portnums = g_new0(gint,klass->numsinkpads);
+ klass->srcpad_portnums = g_new0 (gint, klass->numsrcpads);
+ klass->sinkpad_portnums = g_new0 (gint, klass->numsinkpads);
sinkcount = 0;
srccount = 0;
/* walk through the ports, note the portnums for srcpads, sinkpads */
- for (j=0; j<desc->PortCount; j++) {
- if (LADSPA_IS_PORT_AUDIO(desc->PortDescriptors[j])) {
- if (LADSPA_IS_PORT_INPUT(desc->PortDescriptors[j]))
- klass->sinkpad_portnums[sinkcount++] = j;
+ for (j = 0; j < desc->PortCount; j++) {
+ if (LADSPA_IS_PORT_AUDIO (desc->PortDescriptors[j])) {
+ if (LADSPA_IS_PORT_INPUT (desc->PortDescriptors[j]))
+ klass->sinkpad_portnums[sinkcount++] = j;
else
- klass->srcpad_portnums[srccount++] = j;
+ klass->srcpad_portnums[srccount++] = j;
}
}
@@ -146,19 +154,19 @@ gst_ladspa_base_init (GstLADSPAClass *klass)
}
static void
-gst_ladspa_class_init (GstLADSPAClass *klass)
+gst_ladspa_class_init (GstLADSPAClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
LADSPA_Descriptor *desc;
- gint i,current_portnum,controlcount;
+ gint i, current_portnum, controlcount;
gint hintdesc;
- gint argtype,argperms;
+ gint argtype, argperms;
GParamSpec *paramspec = NULL;
gchar *argname, *tempstr, *paren;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
gobject_class->set_property = gst_ladspa_set_property;
gobject_class->get_property = gst_ladspa_get_property;
@@ -166,78 +174,85 @@ gst_ladspa_class_init (GstLADSPAClass *klass)
gstelement_class->change_state = gst_ladspa_change_state;
/* look up and store the ladspa descriptor */
- desc = g_hash_table_lookup(ladspa_descriptors,
- GINT_TO_POINTER(G_TYPE_FROM_CLASS(klass)));
+ desc = g_hash_table_lookup (ladspa_descriptors,
+ GINT_TO_POINTER (G_TYPE_FROM_CLASS (klass)));
if (!desc)
- desc = g_hash_table_lookup(ladspa_descriptors, GINT_TO_POINTER(0));
+ desc = g_hash_table_lookup (ladspa_descriptors, GINT_TO_POINTER (0));
g_assert (desc);
klass->numcontrols = 0;
/* walk through the ports, count the input, output and control ports */
- for (i=0; i<desc->PortCount; i++) {
- if (!LADSPA_IS_PORT_AUDIO(desc->PortDescriptors[i]) &&
- LADSPA_IS_PORT_INPUT(desc->PortDescriptors[i]))
+ for (i = 0; i < desc->PortCount; i++) {
+ if (!LADSPA_IS_PORT_AUDIO (desc->PortDescriptors[i]) &&
+ LADSPA_IS_PORT_INPUT (desc->PortDescriptors[i]))
klass->numcontrols++;
}
DEBUG ("ladspa element class: init %s with %d sink, %d src, %d control\n",
- g_type_name (G_TYPE_FROM_CLASS (klass)),
- klass->numsinkpads, klass->numsrcpads, klass->numcontrols);
+ g_type_name (G_TYPE_FROM_CLASS (klass)),
+ klass->numsinkpads, klass->numsrcpads, klass->numcontrols);
- klass->control_portnums = g_new0(gint,klass->numcontrols);
+ klass->control_portnums = g_new0 (gint, klass->numcontrols);
controlcount = 0;
/* walk through the ports, note the portnums for control params */
- for (i=0; i<desc->PortCount; i++) {
- if (!LADSPA_IS_PORT_AUDIO(desc->PortDescriptors[i]) &&
- LADSPA_IS_PORT_INPUT(desc->PortDescriptors[i]))
+ for (i = 0; i < desc->PortCount; i++) {
+ if (!LADSPA_IS_PORT_AUDIO (desc->PortDescriptors[i]) &&
+ LADSPA_IS_PORT_INPUT (desc->PortDescriptors[i]))
klass->control_portnums[controlcount++] = i;
}
/* now build the control info from the control ports */
- klass->control_info = g_new0(ladspa_control_info,klass->numcontrols);
-
- for (i=0;i<klass->numcontrols;i++) {
+ klass->control_info = g_new0 (ladspa_control_info, klass->numcontrols);
+
+ for (i = 0; i < klass->numcontrols; i++) {
current_portnum = klass->control_portnums[i];
-
+
/* short name for hint descriptor */
hintdesc = desc->PortRangeHints[current_portnum].HintDescriptor;
/* get the various bits */
- if (LADSPA_IS_HINT_TOGGLED(hintdesc))
+ if (LADSPA_IS_HINT_TOGGLED (hintdesc))
klass->control_info[i].toggled = TRUE;
- if (LADSPA_IS_HINT_LOGARITHMIC(hintdesc))
+ if (LADSPA_IS_HINT_LOGARITHMIC (hintdesc))
klass->control_info[i].logarithmic = TRUE;
- if (LADSPA_IS_HINT_INTEGER(hintdesc))
+ if (LADSPA_IS_HINT_INTEGER (hintdesc))
klass->control_info[i].integer = TRUE;
/* figure out the argument details */
- if (klass->control_info[i].toggled) argtype = G_TYPE_BOOLEAN;
- else if (klass->control_info[i].integer) argtype = G_TYPE_INT;
- else argtype = G_TYPE_FLOAT;
+ if (klass->control_info[i].toggled)
+ argtype = G_TYPE_BOOLEAN;
+ else if (klass->control_info[i].integer)
+ argtype = G_TYPE_INT;
+ else
+ argtype = G_TYPE_FLOAT;
/* grab the bounds */
- if (LADSPA_IS_HINT_BOUNDED_BELOW(hintdesc)) {
+ if (LADSPA_IS_HINT_BOUNDED_BELOW (hintdesc)) {
klass->control_info[i].lower = TRUE;
klass->control_info[i].lowerbound =
- desc->PortRangeHints[current_portnum].LowerBound;
+ desc->PortRangeHints[current_portnum].LowerBound;
} else {
- if (argtype==G_TYPE_INT) klass->control_info[i].lowerbound = (gfloat)G_MININT;
- if (argtype==G_TYPE_FLOAT) klass->control_info[i].lowerbound = -G_MAXFLOAT;
+ if (argtype == G_TYPE_INT)
+ klass->control_info[i].lowerbound = (gfloat) G_MININT;
+ if (argtype == G_TYPE_FLOAT)
+ klass->control_info[i].lowerbound = -G_MAXFLOAT;
}
-
- if (LADSPA_IS_HINT_BOUNDED_ABOVE(hintdesc)) {
+
+ if (LADSPA_IS_HINT_BOUNDED_ABOVE (hintdesc)) {
klass->control_info[i].upper = TRUE;
klass->control_info[i].upperbound =
- desc->PortRangeHints[current_portnum].UpperBound;
- if (LADSPA_IS_HINT_SAMPLE_RATE(hintdesc)) {
- klass->control_info[i].samplerate = TRUE;
- klass->control_info[i].upperbound *= 44100; /* FIXME? */
+ desc->PortRangeHints[current_portnum].UpperBound;
+ if (LADSPA_IS_HINT_SAMPLE_RATE (hintdesc)) {
+ klass->control_info[i].samplerate = TRUE;
+ klass->control_info[i].upperbound *= 44100; /* FIXME? */
}
} else {
- if (argtype==G_TYPE_INT) klass->control_info[i].upperbound = (gfloat)G_MAXINT;
- if (argtype==G_TYPE_FLOAT) klass->control_info[i].upperbound = G_MAXFLOAT;
+ if (argtype == G_TYPE_INT)
+ klass->control_info[i].upperbound = (gfloat) G_MAXINT;
+ if (argtype == G_TYPE_FLOAT)
+ klass->control_info[i].upperbound = G_MAXFLOAT;
}
/* use the lowerbound as the default value */
@@ -247,46 +262,51 @@ gst_ladspa_class_init (GstLADSPAClass *klass)
/* figure out the defaults */
if (LADSPA_IS_HINT_HAS_DEFAULT (hintdesc)) {
if (LADSPA_IS_HINT_DEFAULT_MINIMUM (hintdesc))
- klass->control_info[i].def = klass->control_info[i].lowerbound;
+ klass->control_info[i].def = klass->control_info[i].lowerbound;
else if (LADSPA_IS_HINT_DEFAULT_LOW (hintdesc))
- if (LADSPA_IS_HINT_LOGARITHMIC (hintdesc))
- klass->control_info[i].def = exp (0.75*log(klass->control_info[i].lowerbound) +
- 0.25*log(klass->control_info[i].upperbound));
- else
- klass->control_info[i].def = (0.75*klass->control_info[i].lowerbound +
- 0.25*klass->control_info[i].upperbound);
+ if (LADSPA_IS_HINT_LOGARITHMIC (hintdesc))
+ klass->control_info[i].def =
+ exp (0.75 * log (klass->control_info[i].lowerbound) +
+ 0.25 * log (klass->control_info[i].upperbound));
+ else
+ klass->control_info[i].def =
+ (0.75 * klass->control_info[i].lowerbound +
+ 0.25 * klass->control_info[i].upperbound);
else if (LADSPA_IS_HINT_DEFAULT_MIDDLE (hintdesc))
- if (LADSPA_IS_HINT_LOGARITHMIC (hintdesc))
- klass->control_info[i].def = exp (0.5*log(klass->control_info[i].lowerbound) +
- 0.5*log(klass->control_info[i].upperbound));
- else
- klass->control_info[i].def = (0.5*klass->control_info[i].lowerbound +
- 0.5*klass->control_info[i].upperbound);
+ if (LADSPA_IS_HINT_LOGARITHMIC (hintdesc))
+ klass->control_info[i].def =
+ exp (0.5 * log (klass->control_info[i].lowerbound) +
+ 0.5 * log (klass->control_info[i].upperbound));
+ else
+ klass->control_info[i].def =
+ (0.5 * klass->control_info[i].lowerbound +
+ 0.5 * klass->control_info[i].upperbound);
else if (LADSPA_IS_HINT_DEFAULT_HIGH (hintdesc))
- if (LADSPA_IS_HINT_LOGARITHMIC (hintdesc))
- klass->control_info[i].def = exp (0.25*log(klass->control_info[i].lowerbound) +
- 0.75*log(klass->control_info[i].upperbound));
- else
- klass->control_info[i].def = (0.25*klass->control_info[i].lowerbound +
- 0.75*klass->control_info[i].upperbound);
+ if (LADSPA_IS_HINT_LOGARITHMIC (hintdesc))
+ klass->control_info[i].def =
+ exp (0.25 * log (klass->control_info[i].lowerbound) +
+ 0.75 * log (klass->control_info[i].upperbound));
+ else
+ klass->control_info[i].def =
+ (0.25 * klass->control_info[i].lowerbound +
+ 0.75 * klass->control_info[i].upperbound);
else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM (hintdesc))
- klass->control_info[i].def = klass->control_info[i].upperbound;
+ klass->control_info[i].def = klass->control_info[i].upperbound;
else if (LADSPA_IS_HINT_DEFAULT_0 (hintdesc))
- klass->control_info[i].def = 0.0;
+ klass->control_info[i].def = 0.0;
else if (LADSPA_IS_HINT_DEFAULT_1 (hintdesc))
- klass->control_info[i].def = 1.0;
+ klass->control_info[i].def = 1.0;
else if (LADSPA_IS_HINT_DEFAULT_100 (hintdesc))
- klass->control_info[i].def = 100.0;
+ klass->control_info[i].def = 100.0;
else if (LADSPA_IS_HINT_DEFAULT_440 (hintdesc))
- klass->control_info[i].def = 440.0;
+ klass->control_info[i].def = 440.0;
}
#endif /* LADSPA_IS_HINT_HAS_DEFAULT */
- klass->control_info[i].def = CLAMP(klass->control_info[i].def,
- klass->control_info[i].lowerbound,
- klass->control_info[i].upperbound);
-
- if (LADSPA_IS_PORT_INPUT(desc->PortDescriptors[current_portnum])) {
+ klass->control_info[i].def = CLAMP (klass->control_info[i].def,
+ klass->control_info[i].lowerbound, klass->control_info[i].upperbound);
+
+ if (LADSPA_IS_PORT_INPUT (desc->PortDescriptors[current_portnum])) {
argperms = G_PARAM_READWRITE;
klass->control_info[i].writable = TRUE;
} else {
@@ -294,8 +314,8 @@ gst_ladspa_class_init (GstLADSPAClass *klass)
klass->control_info[i].writable = FALSE;
}
- klass->control_info[i].name = g_strdup(desc->PortNames[current_portnum]);
- argname = g_strdup(klass->control_info[i].name);
+ klass->control_info[i].name = g_strdup (desc->PortNames[current_portnum]);
+ argname = g_strdup (klass->control_info[i].name);
/* find out if there is a (unitname) at the end of the argname and get rid
of it */
paren = g_strrstr (argname, " (");
@@ -305,123 +325,120 @@ gst_ladspa_class_init (GstLADSPAClass *klass)
/* this is the same thing that param_spec_* will do */
g_strcanon (argname, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-", '-');
/* satisfy glib2 (argname[0] must be [A-Za-z]) */
- if (!((argname[0] >= 'a' && argname[0] <= 'z') || (argname[0] >= 'A' && argname[0] <= 'Z'))) {
+ if (!((argname[0] >= 'a' && argname[0] <= 'z') || (argname[0] >= 'A'
+ && argname[0] <= 'Z'))) {
tempstr = argname;
- argname = g_strconcat("param-", argname, NULL);
+ argname = g_strconcat ("param-", argname, NULL);
g_free (tempstr);
}
-
+
/* check for duplicate property names */
- if (g_object_class_find_property(G_OBJECT_CLASS(klass), argname) != NULL){
- gint numarg=1;
- gchar *numargname = g_strdup_printf("%s_%d",argname,numarg++);
- while (g_object_class_find_property(G_OBJECT_CLASS(klass), numargname) != NULL){
- g_free(numargname);
- numargname = g_strdup_printf("%s_%d",argname,numarg++);
+ if (g_object_class_find_property (G_OBJECT_CLASS (klass), argname) != NULL) {
+ gint numarg = 1;
+ gchar *numargname = g_strdup_printf ("%s_%d", argname, numarg++);
+
+ while (g_object_class_find_property (G_OBJECT_CLASS (klass),
+ numargname) != NULL) {
+ g_free (numargname);
+ numargname = g_strdup_printf ("%s_%d", argname, numarg++);
}
argname = numargname;
}
-
+
klass->control_info[i].param_name = argname;
-
+
DEBUG ("adding arg %s from %s", argname, klass->control_info[i].name);
-
- if (argtype==G_TYPE_BOOLEAN){
- paramspec = g_param_spec_boolean(argname,argname,argname, FALSE, argperms);
- } else if (argtype==G_TYPE_INT){
- paramspec = g_param_spec_int(argname,argname,argname,
- (gint)klass->control_info[i].lowerbound,
- (gint)klass->control_info[i].upperbound,
- (gint)klass->control_info[i].def, argperms);
- } else if (klass->control_info[i].samplerate){
- paramspec = g_param_spec_float(argname,argname,argname,
- 0.0, G_MAXFLOAT,
- 0.0, argperms);
+
+ if (argtype == G_TYPE_BOOLEAN) {
+ paramspec =
+ g_param_spec_boolean (argname, argname, argname, FALSE, argperms);
+ } else if (argtype == G_TYPE_INT) {
+ paramspec = g_param_spec_int (argname, argname, argname,
+ (gint) klass->control_info[i].lowerbound,
+ (gint) klass->control_info[i].upperbound,
+ (gint) klass->control_info[i].def, argperms);
+ } else if (klass->control_info[i].samplerate) {
+ paramspec = g_param_spec_float (argname, argname, argname,
+ 0.0, G_MAXFLOAT, 0.0, argperms);
} else {
- paramspec = g_param_spec_float(argname,argname,argname,
- klass->control_info[i].lowerbound, klass->control_info[i].upperbound,
- klass->control_info[i].def, argperms);
+ paramspec = g_param_spec_float (argname, argname, argname,
+ klass->control_info[i].lowerbound, klass->control_info[i].upperbound,
+ klass->control_info[i].def, argperms);
}
-
+
/* properties have an offset of 1 */
- g_object_class_install_property(G_OBJECT_CLASS(klass), i+1, paramspec);
+ g_object_class_install_property (G_OBJECT_CLASS (klass), i + 1, paramspec);
}
}
static void
-gst_ladspa_init (GstLADSPA *ladspa)
+gst_ladspa_init (GstLADSPA * ladspa)
{
GstLADSPAClass *oclass;
ladspa_control_info cinfo;
GList *l;
LADSPA_Descriptor *desc;
- gint i,sinkcount,srccount;
+ gint i, sinkcount, srccount;
- oclass = (GstLADSPAClass*)G_OBJECT_GET_CLASS (ladspa);
+ oclass = (GstLADSPAClass *) G_OBJECT_GET_CLASS (ladspa);
desc = oclass->descriptor;
ladspa->descriptor = oclass->descriptor;
-
+
/* allocate the various arrays */
- ladspa->srcpads = g_new0(GstPad*,oclass->numsrcpads);
- ladspa->sinkpads = g_new0(GstPad*,oclass->numsinkpads);
- ladspa->controls = g_new(gfloat,oclass->numcontrols);
- ladspa->dpman = gst_dpman_new ("ladspa_dpman", GST_ELEMENT(ladspa));
-
+ ladspa->srcpads = g_new0 (GstPad *, oclass->numsrcpads);
+ ladspa->sinkpads = g_new0 (GstPad *, oclass->numsinkpads);
+ ladspa->controls = g_new (gfloat, oclass->numcontrols);
+ ladspa->dpman = gst_dpman_new ("ladspa_dpman", GST_ELEMENT (ladspa));
+
/* set up pads */
sinkcount = 0;
srccount = 0;
- for (l=GST_ELEMENT_CLASS (oclass)->padtemplates; l; l=l->next) {
+ for (l = GST_ELEMENT_CLASS (oclass)->padtemplates; l; l = l->next) {
GstPad *pad = gst_pad_new_from_template (GST_PAD_TEMPLATE (l->data),
- GST_PAD_TEMPLATE_NAME_TEMPLATE (l->data));
+ GST_PAD_TEMPLATE_NAME_TEMPLATE (l->data));
+
gst_pad_set_link_function (pad, gst_ladspa_link);
- gst_element_add_pad ((GstElement*)ladspa, pad);
+ gst_element_add_pad ((GstElement *) ladspa, pad);
if (GST_PAD_DIRECTION (pad) == GST_PAD_SINK)
ladspa->sinkpads[sinkcount++] = pad;
else
ladspa->srcpads[srccount++] = pad;
}
-
+
/* set up dparams */
- for (i=0; i<oclass->numcontrols; i++) {
- if (LADSPA_IS_PORT_INPUT(desc->PortDescriptors[i])) {
+ for (i = 0; i < oclass->numcontrols; i++) {
+ if (LADSPA_IS_PORT_INPUT (desc->PortDescriptors[i])) {
cinfo = oclass->control_info[i];
- ladspa->controls[i]=cinfo.def;
-
- if (cinfo.toggled){
- gst_dpman_add_required_dparam_callback (
- ladspa->dpman,
- g_param_spec_int(cinfo.param_name, cinfo.name, cinfo.name,
- 0, 1, (gint)(ladspa->controls[i]), G_PARAM_READWRITE),
- "int", gst_ladspa_update_int, &(ladspa->controls[i])
- );
- }
- else if (cinfo.integer){
- gst_dpman_add_required_dparam_callback (
- ladspa->dpman,
- g_param_spec_int(cinfo.param_name, cinfo.name, cinfo.name,
- (gint)cinfo.lowerbound, (gint)cinfo.upperbound,
- (gint)ladspa->controls[i], G_PARAM_READWRITE),
- "int", gst_ladspa_update_int, &(ladspa->controls[i])
- );
- }
- else if (cinfo.samplerate){
- gst_dpman_add_required_dparam_direct (
- ladspa->dpman,
- g_param_spec_float(cinfo.param_name, cinfo.name, cinfo.name,
- cinfo.lowerbound, cinfo.upperbound,
- ladspa->controls[i], G_PARAM_READWRITE),
- "hertz-rate-bound", &(ladspa->controls[i])
- );
- }
- else {
- gst_dpman_add_required_dparam_direct (
- ladspa->dpman,
- g_param_spec_float(cinfo.param_name, cinfo.name, cinfo.name,
- cinfo.lowerbound, cinfo.upperbound,
- ladspa->controls[i], G_PARAM_READWRITE),
- "float", &(ladspa->controls[i])
- );
+ ladspa->controls[i] = cinfo.def;
+
+ if (cinfo.toggled) {
+ gst_dpman_add_required_dparam_callback (ladspa->dpman,
+ g_param_spec_int (cinfo.param_name, cinfo.name, cinfo.name,
+ 0, 1, (gint) (ladspa->controls[i]), G_PARAM_READWRITE),
+ "int", gst_ladspa_update_int, &(ladspa->controls[i])
+ );
+ } else if (cinfo.integer) {
+ gst_dpman_add_required_dparam_callback (ladspa->dpman,
+ g_param_spec_int (cinfo.param_name, cinfo.name, cinfo.name,
+ (gint) cinfo.lowerbound, (gint) cinfo.upperbound,
+ (gint) ladspa->controls[i], G_PARAM_READWRITE),
+ "int", gst_ladspa_update_int, &(ladspa->controls[i])
+ );
+ } else if (cinfo.samplerate) {
+ gst_dpman_add_required_dparam_direct (ladspa->dpman,
+ g_param_spec_float (cinfo.param_name, cinfo.name, cinfo.name,
+ cinfo.lowerbound, cinfo.upperbound,
+ ladspa->controls[i], G_PARAM_READWRITE),
+ "hertz-rate-bound", &(ladspa->controls[i])
+ );
+ } else {
+ gst_dpman_add_required_dparam_direct (ladspa->dpman,
+ g_param_spec_float (cinfo.param_name, cinfo.name, cinfo.name,
+ cinfo.lowerbound, cinfo.upperbound,
+ ladspa->controls[i], G_PARAM_READWRITE),
+ "float", &(ladspa->controls[i])
+ );
}
}
}
@@ -429,58 +446,62 @@ gst_ladspa_init (GstLADSPA *ladspa)
/* nonzero default needed to instantiate() some plugins */
ladspa->samplerate = 44100;
- ladspa->buffer_frames = 0; /* should be set with caps */
+ ladspa->buffer_frames = 0; /* should be set with caps */
ladspa->activated = FALSE;
- ladspa->inplace_broken = LADSPA_IS_INPLACE_BROKEN(ladspa->descriptor->Properties);
+ ladspa->inplace_broken =
+ LADSPA_IS_INPLACE_BROKEN (ladspa->descriptor->Properties);
- if (sinkcount==0 && srccount == 1) {
+ if (sinkcount == 0 && srccount == 1) {
/* get mode (no sink pads) */
DEBUG_OBJ (ladspa, "mono get mode with 1 src pad");
gst_pad_set_get_function (ladspa->srcpads[0], gst_ladspa_get);
- } else if (sinkcount==1){
+ } else if (sinkcount == 1) {
/* with one sink we can use the chain function */
DEBUG_OBJ (ladspa, "chain mode");
gst_pad_set_chain_function (ladspa->sinkpads[0], gst_ladspa_chain);
- } else if (sinkcount > 1){
+ } else if (sinkcount > 1) {
/* more than one sink pad needs loop mode */
- DEBUG_OBJ (ladspa, "loop mode with %d sink pads and %d src pads", sinkcount, srccount);
+ DEBUG_OBJ (ladspa, "loop mode with %d sink pads and %d src pads", sinkcount,
+ srccount);
gst_element_set_loop_function (GST_ELEMENT (ladspa), gst_ladspa_loop);
- } else if (sinkcount==0 && srccount == 0) {
+ } else if (sinkcount == 0 && srccount == 0) {
/* for example, a plugin with only control inputs and output -- just ignore
* it for now */
} else {
- g_warning ("%d sink pads, %d src pads not yet supported", sinkcount, srccount);
+ g_warning ("%d sink pads, %d src pads not yet supported", sinkcount,
+ srccount);
}
gst_ladspa_instantiate (ladspa);
}
static void
-gst_ladspa_update_int(const GValue *value, gpointer data)
+gst_ladspa_update_int (const GValue * value, gpointer data)
{
- gfloat *target = (gfloat*) data;
- *target = (gfloat)g_value_get_int(value);
+ gfloat *target = (gfloat *) data;
+
+ *target = (gfloat) g_value_get_int (value);
}
static GstPadLinkReturn
-gst_ladspa_link (GstPad *pad, const GstCaps *caps)
+gst_ladspa_link (GstPad * pad, const GstCaps * caps)
{
- GstElement *element = (GstElement*)GST_PAD_PARENT (pad);
- GstLADSPA *ladspa = (GstLADSPA*)element;
+ GstElement *element = (GstElement *) GST_PAD_PARENT (pad);
+ GstLADSPA *ladspa = (GstLADSPA *) element;
const GList *l = NULL;
gint rate;
GstStructure *structure;
/* if this fails in some other plugin, the graph is left in an inconsistent
state */
- for (l=gst_element_get_pad_list (element); l; l=l->next)
- if (pad != (GstPad*)l->data)
- if (gst_pad_try_set_caps ((GstPad*)l->data, caps) <= 0)
- return GST_PAD_LINK_REFUSED;
-
+ for (l = gst_element_get_pad_list (element); l; l = l->next)
+ if (pad != (GstPad *) l->data)
+ if (gst_pad_try_set_caps ((GstPad *) l->data, caps) <= 0)
+ return GST_PAD_LINK_REFUSED;
+
/* we assume that the ladspa plugin can handle any sample rate, so this
check gets put last */
structure = gst_caps_get_structure (caps, 0);
@@ -488,48 +509,46 @@ gst_ladspa_link (GstPad *pad, const GstCaps *caps)
/* have to instantiate ladspa plugin when samplerate changes (groan) */
if (ladspa->samplerate != rate) {
ladspa->samplerate = rate;
- if (! gst_ladspa_instantiate(ladspa))
+ if (!gst_ladspa_instantiate (ladspa))
return GST_PAD_LINK_REFUSED;
}
-
- gst_structure_get_int (structure, "buffer-frames", &ladspa->buffer_frames);
-
+
+ gst_structure_get_int (structure, "buffer-frames", &ladspa->buffer_frames);
+
return GST_PAD_LINK_OK;
}
#if 0
static void
-gst_ladspa_force_src_caps(GstLADSPA *ladspa, GstPad *pad)
+gst_ladspa_force_src_caps (GstLADSPA * ladspa, GstPad * pad)
{
if (!ladspa->buffer_frames) {
- ladspa->buffer_frames = 256; /* 5 ms at 44100 kHz (just a default...) */
+ ladspa->buffer_frames = 256; /* 5 ms at 44100 kHz (just a default...) */
}
DEBUG_OBJ (ladspa, "forcing caps with rate=%d, buffer-frames=%d",
- ladspa->samplerate, ladspa->buffer_frames);
+ ladspa->samplerate, ladspa->buffer_frames);
gst_pad_try_set_caps (pad,
- gst_caps_new (
- "ladspa_src_caps",
- "audio/x-raw-float",
- gst_props_new (
- "width", G_TYPE_INT (32),
- "endianness", G_TYPE_INT (G_BYTE_ORDER),
- "rate", G_TYPE_INT (ladspa->samplerate),
- "buffer-frames", G_TYPE_INT (ladspa->buffer_frames),
- "channels", G_TYPE_INT (1),
- NULL)));
+ gst_caps_new ("ladspa_src_caps",
+ "audio/x-raw-float",
+ gst_props_new ("width", G_TYPE_INT (32),
+ "endianness", G_TYPE_INT (G_BYTE_ORDER),
+ "rate", G_TYPE_INT (ladspa->samplerate),
+ "buffer-frames", G_TYPE_INT (ladspa->buffer_frames),
+ "channels", G_TYPE_INT (1), NULL)));
}
#endif
static void
-gst_ladspa_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_ladspa_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
- GstLADSPA *ladspa = (GstLADSPA*)object;
+ GstLADSPA *ladspa = (GstLADSPA *) object;
GstLADSPAClass *oclass;
ladspa_control_info *control_info;
- oclass = (GstLADSPAClass*)(G_OBJECT_GET_CLASS (object));
+ oclass = (GstLADSPAClass *) (G_OBJECT_GET_CLASS (object));
/* remember, properties have an offset of 1 */
prop_id--;
@@ -551,14 +570,16 @@ gst_ladspa_set_property (GObject *object, guint prop_id, const GValue *value, GP
else
ladspa->controls[prop_id] = g_value_get_float (value);
- DEBUG_OBJ (object, "set arg %s to %f", control_info->name, ladspa->controls[prop_id]);
+ DEBUG_OBJ (object, "set arg %s to %f", control_info->name,
+ ladspa->controls[prop_id]);
}
static void
-gst_ladspa_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_ladspa_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
- GstLADSPA *ladspa = (GstLADSPA*)object;
- GstLADSPAClass *oclass = (GstLADSPAClass*)(G_OBJECT_GET_CLASS (object));
+ GstLADSPA *ladspa = (GstLADSPA *) object;
+ GstLADSPAClass *oclass = (GstLADSPAClass *) (G_OBJECT_GET_CLASS (object));
ladspa_control_info *control_info;
/* remember, properties have an offset of 1 */
@@ -574,62 +595,63 @@ gst_ladspa_get_property (GObject *object, guint prop_id, GValue *value, GParamSp
if (control_info->toggled)
g_value_set_boolean (value, ladspa->controls[prop_id] == 1.0);
else if (control_info->integer)
- g_value_set_int (value, (gint)ladspa->controls[prop_id]);
+ g_value_set_int (value, (gint) ladspa->controls[prop_id]);
else
g_value_set_float (value, ladspa->controls[prop_id]);
- DEBUG_OBJ (object, "got arg %s as %f", control_info->name, ladspa->controls[prop_id]);
+ DEBUG_OBJ (object, "got arg %s as %f", control_info->name,
+ ladspa->controls[prop_id]);
}
static gboolean
-gst_ladspa_instantiate (GstLADSPA *ladspa)
+gst_ladspa_instantiate (GstLADSPA * ladspa)
{
LADSPA_Descriptor *desc;
int i;
- GstLADSPAClass *oclass = (GstLADSPAClass*)(G_OBJECT_GET_CLASS (ladspa));
+ GstLADSPAClass *oclass = (GstLADSPAClass *) (G_OBJECT_GET_CLASS (ladspa));
gboolean was_activated;
-
+
desc = ladspa->descriptor;
-
+
/* check for old handle */
was_activated = ladspa->activated;
- if (ladspa->handle != NULL){
- gst_ladspa_deactivate(ladspa);
- desc->cleanup(ladspa->handle);
+ if (ladspa->handle != NULL) {
+ gst_ladspa_deactivate (ladspa);
+ desc->cleanup (ladspa->handle);
}
-
- /* instantiate the plugin */
+
+ /* instantiate the plugin */
DEBUG_OBJ (ladspa, "instantiating the plugin at %d Hz", ladspa->samplerate);
-
- ladspa->handle = desc->instantiate(desc,ladspa->samplerate);
+
+ ladspa->handle = desc->instantiate (desc, ladspa->samplerate);
g_return_val_if_fail (ladspa->handle != NULL, FALSE);
/* connect the control ports */
- for (i=0;i<oclass->numcontrols;i++)
- desc->connect_port(ladspa->handle,
- oclass->control_portnums[i],
- &(ladspa->controls[i]));
+ for (i = 0; i < oclass->numcontrols; i++)
+ desc->connect_port (ladspa->handle,
+ oclass->control_portnums[i], &(ladspa->controls[i]));
/* reactivate if it was activated before the reinstantiation */
if (was_activated)
- gst_ladspa_activate(ladspa);
+ gst_ladspa_activate (ladspa);
return TRUE;
}
static GstElementStateReturn
-gst_ladspa_change_state (GstElement *element)
+gst_ladspa_change_state (GstElement * element)
{
LADSPA_Descriptor *desc;
- GstLADSPA *ladspa = (GstLADSPA*)element;
+ GstLADSPA *ladspa = (GstLADSPA *) element;
+
desc = ladspa->descriptor;
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
- gst_ladspa_activate(ladspa);
+ gst_ladspa_activate (ladspa);
break;
case GST_STATE_READY_TO_NULL:
- gst_ladspa_deactivate(ladspa);
+ gst_ladspa_deactivate (ladspa);
break;
default:
break;
@@ -642,104 +664,109 @@ gst_ladspa_change_state (GstElement *element)
}
static void
-gst_ladspa_activate (GstLADSPA *ladspa)
+gst_ladspa_activate (GstLADSPA * ladspa)
{
LADSPA_Descriptor *desc;
+
desc = ladspa->descriptor;
-
+
if (ladspa->activated)
- gst_ladspa_deactivate(ladspa);
-
+ gst_ladspa_deactivate (ladspa);
+
DEBUG_OBJ (ladspa, "activating");
/* activate the plugin (function might be null) */
if (desc->activate != NULL)
- desc->activate(ladspa->handle);
+ desc->activate (ladspa->handle);
ladspa->activated = TRUE;
}
static void
-gst_ladspa_deactivate (GstLADSPA *ladspa)
+gst_ladspa_deactivate (GstLADSPA * ladspa)
{
LADSPA_Descriptor *desc;
+
desc = ladspa->descriptor;
DEBUG_OBJ (ladspa, "deactivating");
/* deactivate the plugin (function might be null) */
if (ladspa->activated && (desc->deactivate != NULL))
- desc->deactivate(ladspa->handle);
+ desc->deactivate (ladspa->handle);
ladspa->activated = FALSE;
}
static void
-gst_ladspa_loop (GstElement *element)
+gst_ladspa_loop (GstElement * element)
{
- guint i, j, numsrcpads, numsinkpads;
- guint num_processed, num_to_process;
- gint largest_buffer;
- LADSPA_Data **data_in, **data_out;
- GstBuffer **buffers_in, **buffers_out;
-
- GstLADSPA *ladspa = (GstLADSPA *)element;
- GstLADSPAClass *oclass = (GstLADSPAClass*)(G_OBJECT_GET_CLASS (ladspa));
+ guint i, j, numsrcpads, numsinkpads;
+ guint num_processed, num_to_process;
+ gint largest_buffer;
+ LADSPA_Data **data_in, **data_out;
+ GstBuffer **buffers_in, **buffers_out;
+
+ GstLADSPA *ladspa = (GstLADSPA *) element;
+ GstLADSPAClass *oclass = (GstLADSPAClass *) (G_OBJECT_GET_CLASS (ladspa));
LADSPA_Descriptor *desc = ladspa->descriptor;
numsinkpads = oclass->numsinkpads;
numsrcpads = oclass->numsrcpads;
-
+
/* fixme: these mallocs need to die */
- data_in = g_new0(LADSPA_Data*, numsinkpads);
- data_out = g_new0(LADSPA_Data*, numsrcpads);
- buffers_in = g_new0(GstBuffer*, numsinkpads);
- buffers_out = g_new0(GstBuffer*, numsrcpads);
-
+ data_in = g_new0 (LADSPA_Data *, numsinkpads);
+ data_out = g_new0 (LADSPA_Data *, numsrcpads);
+ buffers_in = g_new0 (GstBuffer *, numsinkpads);
+ buffers_out = g_new0 (GstBuffer *, numsrcpads);
+
largest_buffer = -1;
/* first get all the necessary data from the input ports */
- for (i=0 ; i<numsinkpads ; i++){
+ for (i = 0; i < numsinkpads; i++) {
get_buffer:
buffers_in[i] = GST_BUFFER (gst_pad_pull (ladspa->sinkpads[i]));
-
+
if (GST_IS_EVENT (buffers_in[i])) {
/* push it out on all pads */
- gst_data_ref_by_count ((GstData*)buffers_in[i], numsrcpads);
- for (j=0; j<numsrcpads; j++)
- gst_pad_push (ladspa->srcpads[j], GST_DATA (buffers_in[i]));
+ gst_data_ref_by_count ((GstData *) buffers_in[i], numsrcpads);
+ for (j = 0; j < numsrcpads; j++)
+ gst_pad_push (ladspa->srcpads[j], GST_DATA (buffers_in[i]));
if (GST_EVENT_TYPE (buffers_in[i]) == GST_EVENT_EOS) {
- /* shut down */
- gst_element_set_eos (element);
- return;
+ /* shut down */
+ gst_element_set_eos (element);
+ return;
} else {
- goto get_buffer;
+ goto get_buffer;
}
}
if (largest_buffer < 0)
- largest_buffer = GST_BUFFER_SIZE (buffers_in[i])/sizeof(gfloat);
+ largest_buffer = GST_BUFFER_SIZE (buffers_in[i]) / sizeof (gfloat);
else
- largest_buffer = MIN (GST_BUFFER_SIZE (buffers_in[i])/sizeof(gfloat), largest_buffer);
- data_in[i] = (LADSPA_Data *) GST_BUFFER_DATA(buffers_in[i]);
- GST_BUFFER_TIMESTAMP(buffers_in[i]) = ladspa->timestamp;
+ largest_buffer =
+ MIN (GST_BUFFER_SIZE (buffers_in[i]) / sizeof (gfloat),
+ largest_buffer);
+ data_in[i] = (LADSPA_Data *) GST_BUFFER_DATA (buffers_in[i]);
+ GST_BUFFER_TIMESTAMP (buffers_in[i]) = ladspa->timestamp;
}
- i=0;
+ i = 0;
if (!ladspa->inplace_broken) {
- for (; i<numsrcpads && i<numsinkpads; i++) {
+ for (; i < numsrcpads && i < numsinkpads; i++) {
/* reuse input buffers */
buffers_out[i] = buffers_in[i];
data_out[i] = data_in[i];
}
}
- for (; i<numsrcpads; i++) {
- buffers_out[i] = gst_buffer_new_and_alloc (ladspa->buffer_frames * sizeof(gfloat));
+ for (; i < numsrcpads; i++) {
+ buffers_out[i] =
+ gst_buffer_new_and_alloc (ladspa->buffer_frames * sizeof (gfloat));
GST_BUFFER_TIMESTAMP (buffers_out[i]) = ladspa->timestamp;
- data_out[i] = (LADSPA_Data*)GST_BUFFER_DATA (buffers_out[i]);
+ data_out[i] = (LADSPA_Data *) GST_BUFFER_DATA (buffers_out[i]);
}
-
- GST_DPMAN_PREPROCESS(ladspa->dpman, largest_buffer, ladspa->timestamp);
+
+ GST_DPMAN_PREPROCESS (ladspa->dpman, largest_buffer, ladspa->timestamp);
num_processed = 0;
/* split up processing of the buffer into chunks so that dparams can
@@ -747,37 +774,39 @@ gst_ladspa_loop (GstElement *element)
* In many cases the buffer will be processed in one chunk anyway.
*/
while (GST_DPMAN_PROCESS (ladspa->dpman, num_processed)) {
- num_to_process = GST_DPMAN_FRAMES_TO_PROCESS(ladspa->dpman);
+ num_to_process = GST_DPMAN_FRAMES_TO_PROCESS (ladspa->dpman);
- for (i=0 ; i<numsinkpads ; i++)
- desc->connect_port (ladspa->handle, oclass->sinkpad_portnums[i], data_in[i]);
- for (i=0 ; i<numsrcpads ; i++)
- desc->connect_port (ladspa->handle, oclass->srcpad_portnums[i], data_out[i]);
+ for (i = 0; i < numsinkpads; i++)
+ desc->connect_port (ladspa->handle, oclass->sinkpad_portnums[i],
+ data_in[i]);
+ for (i = 0; i < numsrcpads; i++)
+ desc->connect_port (ladspa->handle, oclass->srcpad_portnums[i],
+ data_out[i]);
- desc->run(ladspa->handle, num_to_process);
+ desc->run (ladspa->handle, num_to_process);
- for (i=0 ; i<numsinkpads ; i++)
+ for (i = 0; i < numsinkpads; i++)
data_in[i] += num_to_process;
- for (i=0 ; i<numsrcpads ; i++)
+ for (i = 0; i < numsrcpads; i++)
data_out[i] += num_to_process;
-
+
num_processed += num_to_process;
}
-
- for (i=0 ; i<numsinkpads ; i++) {
+
+ for (i = 0; i < numsinkpads; i++) {
if (i >= numsrcpads || buffers_out[i] != buffers_in[i])
- gst_buffer_unref(buffers_in[i]);
+ gst_buffer_unref (buffers_in[i]);
data_in[i] = NULL;
buffers_in[i] = NULL;
- }
- for (i=0 ; i<numsrcpads ; i++) {
+ }
+ for (i = 0; i < numsrcpads; i++) {
DEBUG_OBJ (ladspa, "pushing buffer (%p) on src pad %d", buffers_out[i], i);
gst_pad_push (ladspa->srcpads[i], GST_DATA (buffers_out[i]));
-
+
data_out[i] = NULL;
buffers_out[i] = NULL;
}
-
+
ladspa->timestamp += ladspa->buffer_frames * GST_SECOND / ladspa->samplerate;
/* FIXME: move these mallocs and frees to the state-change handler */
@@ -789,7 +818,7 @@ gst_ladspa_loop (GstElement *element)
}
static void
-gst_ladspa_chain (GstPad *pad, GstData *_data)
+gst_ladspa_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buffer_in = GST_BUFFER (_data);
LADSPA_Descriptor *desc;
@@ -800,23 +829,23 @@ gst_ladspa_chain (GstPad *pad, GstData *_data)
GstLADSPA *ladspa;
GstLADSPAClass *oclass;
- ladspa = (GstLADSPA*)GST_OBJECT_PARENT (pad);
+ ladspa = (GstLADSPA *) GST_OBJECT_PARENT (pad);
oclass = (GstLADSPAClass *) (G_OBJECT_GET_CLASS (ladspa));
- data_in = (LADSPA_Data *) GST_BUFFER_DATA(buffer_in);
- num_samples = GST_BUFFER_SIZE(buffer_in) / sizeof(gfloat);
+ data_in = (LADSPA_Data *) GST_BUFFER_DATA (buffer_in);
+ num_samples = GST_BUFFER_SIZE (buffer_in) / sizeof (gfloat);
numsrcpads = oclass->numsrcpads;
desc = ladspa->descriptor;
/* we shouldn't get events here... */
g_return_if_fail (GST_IS_BUFFER (buffer_in));
-
+
/* FIXME: this function shouldn't need to malloc() anything */
if (numsrcpads > 0) {
- buffers_out = g_new(GstBuffer*, numsrcpads);
- data_out = g_new(LADSPA_Data*, numsrcpads);
+ buffers_out = g_new (GstBuffer *, numsrcpads);
+ data_out = g_new (LADSPA_Data *, numsrcpads);
}
- i=0;
+ i = 0;
if (!ladspa->inplace_broken && numsrcpads) {
/* reuse the first (chained) buffer */
buffers_out[i] = buffer_in;
@@ -824,54 +853,56 @@ gst_ladspa_chain (GstPad *pad, GstData *_data)
data_out[i] = data_in;
i++;
}
- for (; i<numsrcpads; i++) {
- buffers_out[i] = gst_buffer_new_and_alloc (GST_BUFFER_SIZE(buffer_in));
+ for (; i < numsrcpads; i++) {
+ buffers_out[i] = gst_buffer_new_and_alloc (GST_BUFFER_SIZE (buffer_in));
DEBUG ("new %d", GST_BUFFER_SIZE (buffer_in));
GST_BUFFER_TIMESTAMP (buffers_out[i]) = ladspa->timestamp;
- data_out[i] = (LADSPA_Data*)GST_BUFFER_DATA (buffers_out[i]);
+ data_out[i] = (LADSPA_Data *) GST_BUFFER_DATA (buffers_out[i]);
}
- GST_DPMAN_PREPROCESS(ladspa->dpman, num_samples, GST_BUFFER_TIMESTAMP(buffer_in));
+ GST_DPMAN_PREPROCESS (ladspa->dpman, num_samples,
+ GST_BUFFER_TIMESTAMP (buffer_in));
num_processed = 0;
/* split up processing of the buffer into chunks so that dparams can
* be updated when required.
* In many cases the buffer will be processed in one chunk anyway.
*/
- while(GST_DPMAN_PROCESS(ladspa->dpman, num_processed)) {
- num_to_process = GST_DPMAN_FRAMES_TO_PROCESS(ladspa->dpman);
+ while (GST_DPMAN_PROCESS (ladspa->dpman, num_processed)) {
+ num_to_process = GST_DPMAN_FRAMES_TO_PROCESS (ladspa->dpman);
+
+ desc->connect_port (ladspa->handle, oclass->sinkpad_portnums[0], data_in);
+ for (i = 0; i < numsrcpads; i++)
+ desc->connect_port (ladspa->handle, oclass->srcpad_portnums[i],
+ data_out[i]);
- desc->connect_port(ladspa->handle,oclass->sinkpad_portnums[0],data_in);
- for (i=0 ; i<numsrcpads ; i++)
- desc->connect_port(ladspa->handle,oclass->srcpad_portnums[i],data_out[i]);
+ desc->run (ladspa->handle, num_to_process);
- desc->run(ladspa->handle, num_to_process);
-
data_in += num_to_process;
- for (i=0 ; i<numsrcpads ; i++)
+ for (i = 0; i < numsrcpads; i++)
data_out[i] += num_to_process;
num_processed += num_to_process;
}
if (!numsrcpads || buffers_out[0] != buffer_in)
- gst_buffer_unref(buffer_in);
+ gst_buffer_unref (buffer_in);
if (numsrcpads) {
- for (i=0; i<numsrcpads; i++) {
+ for (i = 0; i < numsrcpads; i++) {
DEBUG_OBJ (ladspa, "pushing buffer (%p, length %u bytes) on src pad %d",
- buffers_out[i], GST_BUFFER_SIZE (buffers_out[i]), i);
+ buffers_out[i], GST_BUFFER_SIZE (buffers_out[i]), i);
gst_pad_push (ladspa->srcpads[i], GST_DATA (buffers_out[i]));
}
- g_free(buffers_out);
- g_free(data_out);
+ g_free (buffers_out);
+ g_free (data_out);
}
}
static GstData *
-gst_ladspa_get(GstPad *pad)
-{
+gst_ladspa_get (GstPad * pad)
+{
GstLADSPA *ladspa;
GstLADSPAClass *oclass;
GstBuffer *buf;
@@ -879,120 +910,111 @@ gst_ladspa_get(GstPad *pad)
LADSPA_Descriptor *desc;
guint num_to_process, num_processed;
- ladspa = (GstLADSPA *)gst_pad_get_parent (pad);
- oclass = (GstLADSPAClass*)(G_OBJECT_GET_CLASS(ladspa));
+ ladspa = (GstLADSPA *) gst_pad_get_parent (pad);
+ oclass = (GstLADSPAClass *) (G_OBJECT_GET_CLASS (ladspa));
desc = ladspa->descriptor;
/* 4096 is arbitrary */
buf = gst_buffer_new_and_alloc (4096);
- GST_BUFFER_TIMESTAMP(buf) = ladspa->timestamp;
- data = (LADSPA_Data *) GST_BUFFER_DATA(buf);
+ GST_BUFFER_TIMESTAMP (buf) = ladspa->timestamp;
+ data = (LADSPA_Data *) GST_BUFFER_DATA (buf);
- GST_DPMAN_PREPROCESS(ladspa->dpman, ladspa->buffer_frames, ladspa->timestamp);
+ GST_DPMAN_PREPROCESS (ladspa->dpman, ladspa->buffer_frames,
+ ladspa->timestamp);
num_processed = 0;
/* split up processing of the buffer into chunks so that dparams can
* be updated when required.
* In many cases the buffer will be processed in one chunk anyway.
*/
- while(GST_DPMAN_PROCESS(ladspa->dpman, num_processed)) {
- num_to_process = GST_DPMAN_FRAMES_TO_PROCESS(ladspa->dpman);
+ while (GST_DPMAN_PROCESS (ladspa->dpman, num_processed)) {
+ num_to_process = GST_DPMAN_FRAMES_TO_PROCESS (ladspa->dpman);
- /* update timestamp */
+ /* update timestamp */
ladspa->timestamp += num_to_process * GST_SECOND / ladspa->samplerate;
- desc->connect_port(ladspa->handle,oclass->srcpad_portnums[0],data);
+ desc->connect_port (ladspa->handle, oclass->srcpad_portnums[0], data);
+
+ desc->run (ladspa->handle, num_to_process);
- desc->run(ladspa->handle, num_to_process);
-
data += num_to_process;
num_processed = num_to_process;
}
-
+
return GST_DATA (buf);
}
static void
-ladspa_describe_plugin(const char *pcFullFilename,
- void *pvPluginHandle,
- LADSPA_Descriptor_Function pfDescriptorFunction)
+ladspa_describe_plugin (const char *pcFullFilename,
+ void *pvPluginHandle, LADSPA_Descriptor_Function pfDescriptorFunction)
{
const LADSPA_Descriptor *desc;
gint i;
GTypeInfo typeinfo = {
- sizeof(GstLADSPAClass),
- (GBaseInitFunc)gst_ladspa_base_init,
- NULL,
- (GClassInitFunc)gst_ladspa_class_init,
- NULL,
- NULL,
- sizeof(GstLADSPA),
- 0,
- (GInstanceInitFunc)gst_ladspa_init,
+ sizeof (GstLADSPAClass),
+ (GBaseInitFunc) gst_ladspa_base_init,
+ NULL,
+ (GClassInitFunc) gst_ladspa_class_init,
+ NULL,
+ NULL,
+ sizeof (GstLADSPA),
+ 0,
+ (GInstanceInitFunc) gst_ladspa_init,
};
GType type;
/* walk through all the plugins in this pluginlibrary */
i = 0;
- while ((desc = pfDescriptorFunction(i++))) {
+ while ((desc = pfDescriptorFunction (i++))) {
gchar *type_name;
/* construct the type */
- type_name = g_strdup_printf("ladspa-%s",desc->Label);
+ type_name = g_strdup_printf ("ladspa-%s", desc->Label);
g_strcanon (type_name, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-+", '-');
/* if it's already registered, drop it */
- if (g_type_from_name(type_name)) {
- g_free(type_name);
+ if (g_type_from_name (type_name)) {
+ g_free (type_name);
continue;
}
/* base-init temp alloc */
- g_hash_table_insert(ladspa_descriptors,
- GINT_TO_POINTER(0),
- (gpointer)desc);
+ g_hash_table_insert (ladspa_descriptors,
+ GINT_TO_POINTER (0), (gpointer) desc);
/* create the type now */
- type = g_type_register_static(GST_TYPE_ELEMENT, type_name, &typeinfo, 0);
+ type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0);
if (!gst_element_register (ladspa_plugin, type_name, GST_RANK_NONE, type))
continue;
/* add this plugin to the hash */
- g_hash_table_insert(ladspa_descriptors,
- GINT_TO_POINTER(type),
- (gpointer)desc);
+ g_hash_table_insert (ladspa_descriptors,
+ GINT_TO_POINTER (type), (gpointer) desc);
}
g_hash_table_remove (ladspa_descriptors, GINT_TO_POINTER (0));
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
GST_DEBUG_CATEGORY_INIT (ladspa_debug, "ladspa",
- GST_DEBUG_FG_GREEN | GST_DEBUG_BG_BLACK | GST_DEBUG_BOLD,
- "LADSPA");
+ GST_DEBUG_FG_GREEN | GST_DEBUG_BG_BLACK | GST_DEBUG_BOLD, "LADSPA");
- ladspa_descriptors = g_hash_table_new(NULL,NULL);
- parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
+ ladspa_descriptors = g_hash_table_new (NULL, NULL);
+ parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
ladspa_plugin = plugin;
- LADSPAPluginSearch(ladspa_describe_plugin);
+ LADSPAPluginSearch (ladspa_describe_plugin);
/* initialize dparam support library */
- gst_control_init(NULL,NULL);
-
+ gst_control_init (NULL, NULL);
+
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "ladspa",
- "All LADSPA plugins",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "ladspa",
+ "All LADSPA plugins",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
diff --git a/ext/ladspa/gstladspa.h b/ext/ladspa/gstladspa.h
index f3556f74..b40cd145 100644
--- a/ext/ladspa/gstladspa.h
+++ b/ext/ladspa/gstladspa.h
@@ -31,62 +31,60 @@
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
-typedef struct _ladspa_control_info {
- gchar *name;
- gchar *param_name;
- gfloat lowerbound, upperbound;
- gfloat def;
- gboolean lower,upper,samplerate;
- gboolean toggled, logarithmic, integer, writable;
-} ladspa_control_info;
+ typedef struct _ladspa_control_info
+ {
+ gchar *name;
+ gchar *param_name;
+ gfloat lowerbound, upperbound;
+ gfloat def;
+ gboolean lower, upper, samplerate;
+ gboolean toggled, logarithmic, integer, writable;
+ } ladspa_control_info;
-typedef struct _GstLADSPA GstLADSPA;
-typedef struct _GstLADSPAClass GstLADSPAClass;
+ typedef struct _GstLADSPA GstLADSPA;
+ typedef struct _GstLADSPAClass GstLADSPAClass;
-struct _GstLADSPA {
- GstElement element;
+ struct _GstLADSPA
+ {
+ GstElement element;
- LADSPA_Descriptor *descriptor;
- LADSPA_Handle *handle;
+ LADSPA_Descriptor *descriptor;
+ LADSPA_Handle *handle;
- GstDParamManager *dpman;
+ GstDParamManager *dpman;
- gfloat *controls;
-
- GstPad **sinkpads,
- **srcpads;
+ gfloat *controls;
- gboolean activated;
+ GstPad **sinkpads, **srcpads;
- gint samplerate, buffer_frames;
- gint64 timestamp;
- gboolean inplace_broken;
-};
+ gboolean activated;
-struct _GstLADSPAClass {
- GstElementClass parent_class;
+ gint samplerate, buffer_frames;
+ gint64 timestamp;
+ gboolean inplace_broken;
+ };
- LADSPA_Descriptor *descriptor;
+ struct _GstLADSPAClass
+ {
+ GstElementClass parent_class;
- gint numports,
- numsinkpads,
- numsrcpads,
- numcontrols;
+ LADSPA_Descriptor *descriptor;
- gint *sinkpad_portnums,
- *srcpad_portnums,
- *control_portnums;
+ gint numports, numsinkpads, numsrcpads, numcontrols;
- ladspa_control_info *control_info;
-};
+ gint *sinkpad_portnums, *srcpad_portnums, *control_portnums;
+
+ ladspa_control_info *control_info;
+ };
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_LADSPA_H__ */
+#endif /* __GST_LADSPA_H__ */
diff --git a/ext/ladspa/load.c b/ext/ladspa/load.c
index bf52eb1f..98337f58 100644
--- a/ext/ladspa/load.c
+++ b/ext/ladspa/load.c
@@ -26,18 +26,19 @@
not an absolute path (i.e. does not begin with / character), this
routine will search the LADSPA_PATH for the file. */
static void *
-dlopenLADSPA(const char * pcFilename, int iFlag) {
+dlopenLADSPA (const char *pcFilename, int iFlag)
+{
- char * pcBuffer;
- const char * pcEnd;
- const char * pcLADSPAPath;
- const char * pcStart;
+ char *pcBuffer;
+ const char *pcEnd;
+ const char *pcLADSPAPath;
+ const char *pcStart;
int iEndsInSO;
int iNeedSlash;
size_t iFilenameLength;
- void * pvResult;
+ void *pvResult;
- iFilenameLength = strlen(pcFilename);
+ iFilenameLength = strlen (pcFilename);
pvResult = NULL;
if (pcFilename[0] == '/') {
@@ -45,12 +46,11 @@ dlopenLADSPA(const char * pcFilename, int iFlag) {
/* The filename is absolute. Assume the user knows what he/she is
doing and simply dlopen() it. */
- pvResult = dlopen(pcFilename, iFlag);
+ pvResult = dlopen (pcFilename, iFlag);
if (pvResult != NULL)
return pvResult;
- }
- else {
+ } else {
/* If the filename is not absolute then we wish to check along the
LADSPA_PATH path to see if we can find the file there. We do
@@ -63,8 +63,8 @@ dlopenLADSPA(const char * pcFilename, int iFlag) {
*/
pcLADSPAPath = g_strdup_printf ("%s:/usr/lib/ladspa:/usr/local/lib/ladspa",
- getenv("LADSPA_PATH"));
-
+ getenv ("LADSPA_PATH"));
+
if (pcLADSPAPath) {
pcStart = pcLADSPAPath;
@@ -72,24 +72,24 @@ dlopenLADSPA(const char * pcFilename, int iFlag) {
pcEnd = pcStart;
while (*pcEnd != ':' && *pcEnd != '\0')
pcEnd++;
-
- pcBuffer = malloc(iFilenameLength + 2 + (pcEnd - pcStart));
+
+ pcBuffer = malloc (iFilenameLength + 2 + (pcEnd - pcStart));
if (pcEnd > pcStart)
- strncpy(pcBuffer, pcStart, pcEnd - pcStart);
+ strncpy (pcBuffer, pcStart, pcEnd - pcStart);
iNeedSlash = 0;
if (pcEnd > pcStart)
if (*(pcEnd - 1) != '/') {
iNeedSlash = 1;
pcBuffer[pcEnd - pcStart] = '/';
}
- strcpy(pcBuffer + iNeedSlash + (pcEnd - pcStart), pcFilename);
-
- pvResult = dlopen(pcBuffer, iFlag);
-
+ strcpy (pcBuffer + iNeedSlash + (pcEnd - pcStart), pcFilename);
+
+ pvResult = dlopen (pcBuffer, iFlag);
+
free (pcBuffer);
if (pvResult != NULL)
return pvResult;
-
+
pcStart = pcEnd;
if (*pcStart == ':')
pcStart++;
@@ -101,13 +101,13 @@ dlopenLADSPA(const char * pcFilename, int iFlag) {
".so". In this case, add this suffix and recurse. */
iEndsInSO = 0;
if (iFilenameLength > 3)
- iEndsInSO = (strcmp(pcFilename + iFilenameLength - 3, ".so") == 0);
+ iEndsInSO = (strcmp (pcFilename + iFilenameLength - 3, ".so") == 0);
if (!iEndsInSO) {
- pcBuffer = malloc(iFilenameLength + 4);
- strcpy(pcBuffer, pcFilename);
- strcat(pcBuffer, ".so");
- pvResult = dlopenLADSPA(pcBuffer, iFlag);
- free(pcBuffer);
+ pcBuffer = malloc (iFilenameLength + 4);
+ strcpy (pcBuffer, pcFilename);
+ strcat (pcBuffer, ".so");
+ pvResult = dlopenLADSPA (pcBuffer, iFlag);
+ free (pcBuffer);
}
if (pvResult != NULL)
@@ -120,23 +120,22 @@ dlopenLADSPA(const char * pcFilename, int iFlag) {
will be kept when multiple calls are made to dlopen(). We've
covered the former case - now we can handle the latter by calling
dlopen() again here. */
- return dlopen(pcFilename, iFlag);
+ return dlopen (pcFilename, iFlag);
}
/*****************************************************************************/
void *
-loadLADSPAPluginLibrary(const char * pcPluginFilename) {
+loadLADSPAPluginLibrary (const char *pcPluginFilename)
+{
- void * pvPluginHandle;
+ void *pvPluginHandle;
- pvPluginHandle = dlopenLADSPA(pcPluginFilename, RTLD_NOW);
+ pvPluginHandle = dlopenLADSPA (pcPluginFilename, RTLD_NOW);
if (!pvPluginHandle) {
- fprintf(stderr,
- "Failed to load plugin \"%s\": %s\n",
- pcPluginFilename,
- dlerror());
- exit(1);
+ fprintf (stderr,
+ "Failed to load plugin \"%s\": %s\n", pcPluginFilename, dlerror ());
+ exit (1);
}
return pvPluginHandle;
@@ -144,49 +143,49 @@ loadLADSPAPluginLibrary(const char * pcPluginFilename) {
/*****************************************************************************/
-void
-unloadLADSPAPluginLibrary(void * pvLADSPAPluginLibrary) {
- dlclose(pvLADSPAPluginLibrary);
+void
+unloadLADSPAPluginLibrary (void *pvLADSPAPluginLibrary)
+{
+ dlclose (pvLADSPAPluginLibrary);
}
/*****************************************************************************/
const LADSPA_Descriptor *
-findLADSPAPluginDescriptor(void * pvLADSPAPluginLibrary,
- const char * pcPluginLibraryFilename,
- const char * pcPluginLabel) {
+findLADSPAPluginDescriptor (void *pvLADSPAPluginLibrary,
+ const char *pcPluginLibraryFilename, const char *pcPluginLabel)
+{
- const LADSPA_Descriptor * psDescriptor;
+ const LADSPA_Descriptor *psDescriptor;
LADSPA_Descriptor_Function pfDescriptorFunction;
unsigned long lPluginIndex;
- dlerror();
- pfDescriptorFunction
- = (LADSPA_Descriptor_Function)dlsym(pvLADSPAPluginLibrary,
- "ladspa_descriptor");
+ dlerror ();
+ pfDescriptorFunction
+ = (LADSPA_Descriptor_Function) dlsym (pvLADSPAPluginLibrary,
+ "ladspa_descriptor");
if (!pfDescriptorFunction) {
- const char * pcError = dlerror();
+ const char *pcError = dlerror ();
+
if (pcError) {
- fprintf(stderr,
- "Unable to find ladspa_descriptor() function in plugin "
- "library file \"%s\": %s.\n"
- "Are you sure this is a LADSPA plugin file?\n",
- pcPluginLibraryFilename,
- pcError);
- exit(1);
+ fprintf (stderr,
+ "Unable to find ladspa_descriptor() function in plugin "
+ "library file \"%s\": %s.\n"
+ "Are you sure this is a LADSPA plugin file?\n",
+ pcPluginLibraryFilename, pcError);
+ exit (1);
}
}
for (lPluginIndex = 0;; lPluginIndex++) {
- psDescriptor = pfDescriptorFunction(lPluginIndex);
+ psDescriptor = pfDescriptorFunction (lPluginIndex);
if (psDescriptor == NULL) {
- fprintf(stderr,
- "Unable to find label \"%s\" in plugin library file \"%s\".\n",
- pcPluginLabel,
- pcPluginLibraryFilename);
- exit(1);
+ fprintf (stderr,
+ "Unable to find label \"%s\" in plugin library file \"%s\".\n",
+ pcPluginLabel, pcPluginLibraryFilename);
+ exit (1);
}
- if (strcmp(psDescriptor->Label, pcPluginLabel) == 0)
+ if (strcmp (psDescriptor->Label, pcPluginLabel) == 0)
return psDescriptor;
}
}
diff --git a/ext/ladspa/search.c b/ext/ladspa/search.c
index 08b28d12..0f690275 100644
--- a/ext/ladspa/search.c
+++ b/ext/ladspa/search.c
@@ -27,19 +27,20 @@
/* Search just the one directory. */
static void
-LADSPADirectoryPluginSearch
-(const char * pcDirectory,
- LADSPAPluginSearchCallbackFunction fCallbackFunction) {
+ LADSPADirectoryPluginSearch
+ (const char *pcDirectory,
+ LADSPAPluginSearchCallbackFunction fCallbackFunction)
+{
- char * pcFilename;
- DIR * psDirectory;
+ char *pcFilename;
+ DIR *psDirectory;
LADSPA_Descriptor_Function fDescriptorFunction;
long lDirLength;
long iNeedSlash;
- struct dirent * psDirectoryEntry;
- void * pvPluginHandle;
+ struct dirent *psDirectoryEntry;
+ void *pvPluginHandle;
- lDirLength = strlen(pcDirectory);
+ lDirLength = strlen (pcDirectory);
if (!lDirLength)
return;
if (pcDirectory[lDirLength - 1] == '/')
@@ -47,66 +48,63 @@ LADSPADirectoryPluginSearch
else
iNeedSlash = 1;
- psDirectory = opendir(pcDirectory);
+ psDirectory = opendir (pcDirectory);
if (!psDirectory)
return;
while (1) {
- psDirectoryEntry = readdir(psDirectory);
+ psDirectoryEntry = readdir (psDirectory);
if (!psDirectoryEntry) {
- closedir(psDirectory);
+ closedir (psDirectory);
return;
}
- pcFilename = malloc(lDirLength
- + strlen(psDirectoryEntry->d_name)
- + 1 + iNeedSlash);
- strcpy(pcFilename, pcDirectory);
+ pcFilename = malloc (lDirLength + strlen (psDirectoryEntry->d_name)
+ + 1 + iNeedSlash);
+ strcpy (pcFilename, pcDirectory);
if (iNeedSlash)
- strcat(pcFilename, "/");
- strcat(pcFilename, psDirectoryEntry->d_name);
-
- pvPluginHandle = dlopen(pcFilename, RTLD_LAZY);
+ strcat (pcFilename, "/");
+ strcat (pcFilename, psDirectoryEntry->d_name);
+
+ pvPluginHandle = dlopen (pcFilename, RTLD_LAZY);
if (pvPluginHandle) {
/* This is a file and the file is a shared library! */
- dlerror();
+ dlerror ();
fDescriptorFunction
- = (LADSPA_Descriptor_Function)dlsym(pvPluginHandle,
- "ladspa_descriptor");
- if (dlerror() == NULL && fDescriptorFunction) {
+ = (LADSPA_Descriptor_Function) dlsym (pvPluginHandle,
+ "ladspa_descriptor");
+ if (dlerror () == NULL && fDescriptorFunction) {
/* We've successfully found a ladspa_descriptor function. Pass
- it to the callback function. */
- fCallbackFunction(pcFilename,
- pvPluginHandle,
- fDescriptorFunction);
- }
- else {
+ it to the callback function. */
+ fCallbackFunction (pcFilename, pvPluginHandle, fDescriptorFunction);
+ } else {
/* It was a library, but not a LADSPA one. Unload it. */
- dlclose(pcFilename);
+ dlclose (pcFilename);
}
}
- free(pcFilename);
+ free (pcFilename);
}
}
/*****************************************************************************/
-void
-LADSPAPluginSearch(LADSPAPluginSearchCallbackFunction fCallbackFunction) {
+void
+LADSPAPluginSearch (LADSPAPluginSearchCallbackFunction fCallbackFunction)
+{
- char * pcBuffer;
- const char * pcEnd;
- const char * pcLADSPAPath;
- const char * pcStart;
+ char *pcBuffer;
+ const char *pcEnd;
+ const char *pcLADSPAPath;
+ const char *pcStart;
/* thomasvs: I'm sorry, but I'm going to add glib stuff here.
- * I'm appending logical values for LADSPA_PATH here
- */
+ * I'm appending logical values for LADSPA_PATH here
+ */
pcLADSPAPath = g_strdup_printf ("%s:/usr/lib/ladspa:/usr/local/lib/ladspa",
- getenv("LADSPA_PATH"));
+ getenv ("LADSPA_PATH"));
if (!pcLADSPAPath) {
/* fprintf(stderr, */
@@ -114,20 +112,20 @@ LADSPAPluginSearch(LADSPAPluginSearchCallbackFunction fCallbackFunction) {
/* "environment variable set.\n"); */
return;
}
-
+
pcStart = pcLADSPAPath;
while (*pcStart != '\0') {
pcEnd = pcStart;
while (*pcEnd != ':' && *pcEnd != '\0')
pcEnd++;
-
- pcBuffer = malloc(1 + pcEnd - pcStart);
+
+ pcBuffer = malloc (1 + pcEnd - pcStart);
if (pcEnd > pcStart)
- strncpy(pcBuffer, pcStart, pcEnd - pcStart);
+ strncpy (pcBuffer, pcStart, pcEnd - pcStart);
pcBuffer[pcEnd - pcStart] = '\0';
-
- LADSPADirectoryPluginSearch(pcBuffer, fCallbackFunction);
- free(pcBuffer);
+
+ LADSPADirectoryPluginSearch (pcBuffer, fCallbackFunction);
+ free (pcBuffer);
pcStart = pcEnd;
if (*pcStart == ':')
diff --git a/ext/ladspa/utils.h b/ext/ladspa/utils.h
index d470eb0d..7a22b50b 100644
--- a/ext/ladspa/utils.h
+++ b/ext/ladspa/utils.h
@@ -20,20 +20,19 @@
unloadLADSPAPluginLibrary(). Errors are handled by writing a
message to stderr and calling exit(1). It is alright (although
inefficient) to call this more than once for the same file. */
-void * loadLADSPAPluginLibrary(const char * pcPluginFilename);
+void *loadLADSPAPluginLibrary (const char *pcPluginFilename);
/* This function unloads a LADSPA plugin library. */
-void unloadLADSPAPluginLibrary(void * pvLADSPAPluginLibrary);
+void unloadLADSPAPluginLibrary (void *pvLADSPAPluginLibrary);
/* This function locates a LADSPA plugin within a plugin library
loaded with loadLADSPAPluginLibrary(). Errors are handled by
writing a message to stderr and calling exit(1). Note that the
plugin library filename is only included to help provide
informative error messages. */
-const LADSPA_Descriptor *
-findLADSPAPluginDescriptor(void * pvLADSPAPluginLibrary,
- const char * pcPluginLibraryFilename,
- const char * pcPluginLabel);
+const LADSPA_Descriptor *findLADSPAPluginDescriptor (void
+ *pvLADSPAPluginLibrary, const char *pcPluginLibraryFilename,
+ const char *pcPluginLabel);
/*****************************************************************************/
@@ -44,16 +43,15 @@ findLADSPAPluginDescriptor(void * pvLADSPAPluginLibrary,
style) and a LADSPA_DescriptorFunction (from which
LADSPA_Descriptors can be acquired). */
typedef void LADSPAPluginSearchCallbackFunction
-(const char * pcFullFilename,
- void * pvPluginHandle,
- LADSPA_Descriptor_Function fDescriptorFunction);
+ (const char *pcFullFilename,
+ void *pvPluginHandle, LADSPA_Descriptor_Function fDescriptorFunction);
/* Search through the $(LADSPA_PATH) (or a default path) for any
LADSPA plugin libraries. Each plugin library is tested using
dlopen() and dlsym(,"ladspa_descriptor"). After loading each
library, the callback function is called to process it. This
function leaves items passed to the callback function open. */
-void LADSPAPluginSearch(LADSPAPluginSearchCallbackFunction fCallbackFunction);
+void LADSPAPluginSearch (LADSPAPluginSearchCallbackFunction fCallbackFunction);
/*****************************************************************************/
diff --git a/ext/lcs/gstcolorspace.c b/ext/lcs/gstcolorspace.c
index 128e017e..064e52ca 100644
--- a/ext/lcs/gstcolorspace.c
+++ b/ext/lcs/gstcolorspace.c
@@ -39,20 +39,22 @@
typedef struct _GstColorspace GstColorspace;
typedef struct _GstColorspaceClass GstColorspaceClass;
-struct _GstColorspace {
- GstElement element;
+struct _GstColorspace
+{
+ GstElement element;
+
+ GstPad *sinkpad, *srcpad;
- GstPad *sinkpad, *srcpad;
+ LCSConverter *converter;
- LCSConverter *converter;
-
- gboolean passthrough;
- gint width, height;
- double framerate;
- gboolean disabled;
+ gboolean passthrough;
+ gint width, height;
+ double framerate;
+ gboolean disabled;
};
-struct _GstColorspaceClass {
+struct _GstColorspaceClass
+{
GstElementClass parent_class;
};
@@ -66,77 +68,75 @@ static GstElementDetails colorspace_details = {
/* Stereo signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_SOURCE,
ARG_DEST,
};
-static GType gst_colorspace_get_type (void);
+static GType gst_colorspace_get_type (void);
-static void gst_colorspace_class_init (GstColorspaceClass *klass);
-static void gst_colorspace_base_init (GstColorspaceClass *klass);
-static void gst_colorspace_init (GstColorspace *space);
+static void gst_colorspace_class_init (GstColorspaceClass * klass);
+static void gst_colorspace_base_init (GstColorspaceClass * klass);
+static void gst_colorspace_init (GstColorspace * space);
-static void gst_colorspace_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_colorspace_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_colorspace_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_colorspace_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
static GstPadLinkReturn
- gst_colorspace_link (GstPad *pad, const GstCaps *caps);
-static void gst_colorspace_chain (GstPad *pad, GstData *_data);
-static GstElementStateReturn
- gst_colorspace_change_state (GstElement *element);
+gst_colorspace_link (GstPad * pad, const GstCaps * caps);
+static void gst_colorspace_chain (GstPad * pad, GstData * _data);
+static GstElementStateReturn gst_colorspace_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_colorspace_signals[LAST_SIGNAL] = { 0 }; */
static GstStaticPadTemplate gst_colorspace_src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
+ GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- GST_VIDEO_CAPS_RGB "; "
- GST_VIDEO_CAPS_BGR "; "
- GST_VIDEO_CAPS_RGBx "; "
- GST_VIDEO_CAPS_xRGB "; "
- GST_VIDEO_CAPS_BGRx "; "
- GST_VIDEO_CAPS_xBGR "; "
- GST_VIDEO_CAPS_RGB_16 "; "
- GST_VIDEO_CAPS_RGB_15 "; "
- GST_VIDEO_CAPS_YUV("{ I420, YV12, YUY2, YVYU, UYVY, YUV9, YVU9, "
- "Y800, Y41P, Y41B, Y42B, IUY2 }")
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB "; "
+ GST_VIDEO_CAPS_BGR "; "
+ GST_VIDEO_CAPS_RGBx "; "
+ GST_VIDEO_CAPS_xRGB "; "
+ GST_VIDEO_CAPS_BGRx "; "
+ GST_VIDEO_CAPS_xBGR "; "
+ GST_VIDEO_CAPS_RGB_16 "; "
+ GST_VIDEO_CAPS_RGB_15 "; "
+ GST_VIDEO_CAPS_YUV ("{ I420, YV12, YUY2, YVYU, UYVY, YUV9, YVU9, "
+ "Y800, Y41P, Y41B, Y42B, IUY2 }")
)
-);
+ );
static GstStaticPadTemplate gst_colorspace_sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
+ GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- GST_VIDEO_CAPS_RGB "; "
- GST_VIDEO_CAPS_BGR "; "
- GST_VIDEO_CAPS_RGBx "; "
- GST_VIDEO_CAPS_xRGB "; "
- GST_VIDEO_CAPS_BGRx "; "
- GST_VIDEO_CAPS_xBGR "; "
- GST_VIDEO_CAPS_RGB_16 "; "
- GST_VIDEO_CAPS_RGB_15 "; "
- GST_VIDEO_CAPS_YUV("{ I420, YV12, YUY2, YVYU, UYVY, YUV9, YVU9, "
- "Y800, Y41P, Y41B, Y42B, IUY2 }")
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB "; "
+ GST_VIDEO_CAPS_BGR "; "
+ GST_VIDEO_CAPS_RGBx "; "
+ GST_VIDEO_CAPS_xRGB "; "
+ GST_VIDEO_CAPS_BGRx "; "
+ GST_VIDEO_CAPS_xBGR "; "
+ GST_VIDEO_CAPS_RGB_16 "; "
+ GST_VIDEO_CAPS_RGB_15 "; "
+ GST_VIDEO_CAPS_YUV ("{ I420, YV12, YUY2, YVYU, UYVY, YUV9, YVU9, "
+ "Y800, Y41P, Y41B, Y42B, IUY2 }")
)
-);
+ );
-static const LCSFormat*
-colorspace_find_lcs_format (const GstCaps *caps)
+static const LCSFormat *
+colorspace_find_lcs_format (const GstCaps * caps)
{
const LCSFormat *format = NULL;
const char *name;
@@ -154,16 +154,16 @@ colorspace_find_lcs_format (const GstCaps *caps)
((LCSFormat *) rgb_fmt)->type = LCS_FORMAT_RGB_PACKED;
gst_structure_get_int (structure, "bpp",
- &((LCSFormat *) rgb_fmt)->bits_per_pixel);
+ &((LCSFormat *) rgb_fmt)->bits_per_pixel);
gst_structure_get_int (structure, "red_mask", &mask);
lcs_utils_mask_to_shift (mask, &rgb_fmt->bits_per_component[LCS_R],
- &rgb_fmt->component_bit_offset[LCS_R]);
+ &rgb_fmt->component_bit_offset[LCS_R]);
gst_structure_get_int (structure, "green_mask", &mask);
lcs_utils_mask_to_shift (mask, &rgb_fmt->bits_per_component[LCS_G],
- &rgb_fmt->component_bit_offset[LCS_G]);
+ &rgb_fmt->component_bit_offset[LCS_G]);
gst_structure_get_int (structure, "blue_mask", &mask);
lcs_utils_mask_to_shift (mask, &rgb_fmt->bits_per_component[LCS_B],
- &rgb_fmt->component_bit_offset[LCS_B]);
+ &rgb_fmt->component_bit_offset[LCS_B]);
rgb_fmt->bits_per_component[LCS_A] = 0;
rgb_fmt->component_bit_offset[LCS_A] = 0;
gst_structure_get_int (structure, "endianness", &endianness);
@@ -171,8 +171,7 @@ colorspace_find_lcs_format (const GstCaps *caps)
format_name = g_strdup_printf ("GST_RGB_%d", format->bits_per_pixel);
lcs_register_format (format_name, (LCSFormat *) rgb_fmt, 1);
- }
- else if (strcmp (name, "video/x-raw-yuv") == 0) {
+ } else if (strcmp (name, "video/x-raw-yuv") == 0) {
guint32 space;
gchar fourcc[5];
@@ -181,30 +180,30 @@ colorspace_find_lcs_format (const GstCaps *caps)
fourcc[4] = '\0';
format = lcs_find_format (fourcc);
} else {
- g_assert_not_reached();
+ g_assert_not_reached ();
}
return format;
}
static guint32
-gst_colorspace_caps_get_fourcc (const GstCaps *caps)
+gst_colorspace_caps_get_fourcc (const GstCaps * caps)
{
guint32 format;
GstStructure *structure;
structure = gst_caps_get_structure (caps, 0);
if (strcmp (gst_structure_get_name (structure), "video/x-raw-rgb") == 0) {
- format = GST_MAKE_FOURCC ('R','G','B',' ');
+ format = GST_MAKE_FOURCC ('R', 'G', 'B', ' ');
} else {
gst_structure_get_fourcc (structure, "format", &format);
}
return format;
}
-static gboolean
-colorspace_setup_converter (GstColorspace *space, const GstCaps *from_caps,
- const GstCaps *to_caps)
+static gboolean
+colorspace_setup_converter (GstColorspace * space, const GstCaps * from_caps,
+ const GstCaps * to_caps)
{
const LCSFormat *from_format = NULL;
const LCSFormat *to_format = NULL;
@@ -216,18 +215,16 @@ colorspace_setup_converter (GstColorspace *space, const GstCaps *from_caps,
from_space = gst_colorspace_caps_get_fourcc (from_caps);
to_space = gst_colorspace_caps_get_fourcc (to_caps);
- from_format = colorspace_find_lcs_format (from_caps);
- to_format = colorspace_find_lcs_format (to_caps);
-
+ from_format = colorspace_find_lcs_format (from_caps);
+ to_format = colorspace_find_lcs_format (to_caps);
+
GST_DEBUG ("trying from " GST_FOURCC_FORMAT " to " GST_FOURCC_FORMAT,
- GST_FOURCC_ARGS (from_space),
- GST_FOURCC_ARGS (to_space));
+ GST_FOURCC_ARGS (from_space), GST_FOURCC_ARGS (to_space));
space->converter = lcs_find_converter (from_format, to_format, LCS_FLAG_FAST);
if (space->converter) {
GST_DEBUG ("trying from " GST_FOURCC_FORMAT " to " GST_FOURCC_FORMAT,
- GST_FOURCC_ARGS (from_space),
- GST_FOURCC_ARGS (to_space));
+ GST_FOURCC_ARGS (from_space), GST_FOURCC_ARGS (to_space));
space->disabled = FALSE;
return TRUE;
}
@@ -235,15 +232,15 @@ colorspace_setup_converter (GstColorspace *space, const GstCaps *from_caps,
return FALSE;
}
-static GstCaps*
-gst_colorspace_getcaps (GstPad *pad)
+static GstCaps *
+gst_colorspace_getcaps (GstPad * pad)
{
#if unused
GstColorspace *space;
GstCaps *result;
GstCaps *peercaps;
GstCaps *ourcaps;
-
+
space = GST_COLORSPACE (gst_pad_get_parent (pad));
/* we can do everything our peer can... */
@@ -260,7 +257,7 @@ gst_colorspace_getcaps (GstPad *pad)
}
static GstPadLinkReturn
-gst_colorspace_link (GstPad *pad, const GstCaps *caps)
+gst_colorspace_link (GstPad * pad, const GstCaps * caps)
{
GstStructure *structure;
GstPad *otherpad;
@@ -293,10 +290,9 @@ gst_colorspace_link (GstPad *pad, const GstCaps *caps)
othercaps = gst_caps_copy (gst_pad_get_negotiated_caps (otherpad));
gst_caps_set_simple (othercaps,
- "width", G_TYPE_INT, width,
- "height", G_TYPE_INT, height,
- "framerate", G_TYPE_DOUBLE, framerate,
- NULL);
+ "width", G_TYPE_INT, width,
+ "height", G_TYPE_INT, height,
+ "framerate", G_TYPE_DOUBLE, framerate, NULL);
ret = gst_pad_try_set_caps (otherpad, othercaps);
if (!GST_PAD_LINK_SUCCESSFUL (ret)) {
@@ -312,7 +308,7 @@ gst_colorspace_link (GstPad *pad, const GstCaps *caps)
return GST_PAD_LINK_REFUSED;
}
}
-
+
return GST_PAD_LINK_OK;
}
@@ -323,23 +319,25 @@ gst_colorspace_get_type (void)
if (!colorspace_type) {
static const GTypeInfo colorspace_info = {
- sizeof(GstColorspaceClass),
- (GBaseInitFunc)gst_colorspace_base_init,
+ sizeof (GstColorspaceClass),
+ (GBaseInitFunc) gst_colorspace_base_init,
NULL,
- (GClassInitFunc)gst_colorspace_class_init,
+ (GClassInitFunc) gst_colorspace_class_init,
NULL,
NULL,
- sizeof(GstColorspace),
+ sizeof (GstColorspace),
0,
- (GInstanceInitFunc)gst_colorspace_init,
+ (GInstanceInitFunc) gst_colorspace_init,
};
- colorspace_type = g_type_register_static(GST_TYPE_ELEMENT, "GstColorspaceLCS", &colorspace_info, 0);
+ colorspace_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstColorspaceLCS",
+ &colorspace_info, 0);
}
return colorspace_type;
}
static void
-gst_colorspace_base_init (GstColorspaceClass *klass)
+gst_colorspace_base_init (GstColorspaceClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
@@ -351,15 +349,15 @@ gst_colorspace_base_init (GstColorspaceClass *klass)
}
static void
-gst_colorspace_class_init (GstColorspaceClass *klass)
+gst_colorspace_class_init (GstColorspaceClass * 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_colorspace_set_property;
gobject_class->get_property = gst_colorspace_get_property;
@@ -368,25 +366,27 @@ gst_colorspace_class_init (GstColorspaceClass *klass)
}
static void
-gst_colorspace_init (GstColorspace *space)
+gst_colorspace_init (GstColorspace * space)
{
- space->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get(&gst_colorspace_sink_template), "sink");
+ space->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_colorspace_sink_template), "sink");
gst_pad_set_link_function (space->sinkpad, gst_colorspace_link);
gst_pad_set_getcaps_function (space->sinkpad, gst_colorspace_getcaps);
- gst_pad_set_chain_function(space->sinkpad,gst_colorspace_chain);
- gst_element_add_pad(GST_ELEMENT(space),space->sinkpad);
+ gst_pad_set_chain_function (space->sinkpad, gst_colorspace_chain);
+ gst_element_add_pad (GST_ELEMENT (space), space->sinkpad);
- space->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get(&gst_colorspace_src_template), "src");
- gst_element_add_pad(GST_ELEMENT(space),space->srcpad);
+ space->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_colorspace_src_template), "src");
+ gst_element_add_pad (GST_ELEMENT (space), space->srcpad);
gst_pad_set_link_function (space->srcpad, gst_colorspace_link);
space->disabled = TRUE;
}
static void
-gst_colorspace_chain (GstPad *pad,GstData *_data)
+gst_colorspace_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstColorspace *space;
@@ -397,26 +397,23 @@ gst_colorspace_chain (GstPad *pad,GstData *_data)
g_return_if_fail (buf != NULL);
space = GST_COLORSPACE (gst_pad_get_parent (pad));
-
+
g_return_if_fail (space != NULL);
g_return_if_fail (GST_IS_COLORSPACE (space));
if (space->passthrough) {
outbuf = buf;
- }
- else {
+ } else {
unsigned long size;
- lcs_format_buffer_size (
- lcs_converter_get_dest_format (space->converter),
- space->width, space->height, &size);
+ lcs_format_buffer_size (lcs_converter_get_dest_format (space->converter),
+ space->width, space->height, &size);
outbuf = gst_pad_alloc_buffer (space->srcpad, GST_BUFFER_OFFSET_NONE, size);
- lcs_convert_auto (space->converter,
- GST_BUFFER_DATA (buf),
- GST_BUFFER_DATA (outbuf),
- space->width, space->height);
+ lcs_convert_auto (space->converter,
+ GST_BUFFER_DATA (buf),
+ GST_BUFFER_DATA (outbuf), space->width, space->height);
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buf);
@@ -427,7 +424,7 @@ gst_colorspace_chain (GstPad *pad,GstData *_data)
}
static GstElementStateReturn
-gst_colorspace_change_state (GstElement *element)
+gst_colorspace_change_state (GstElement * element)
{
GstColorspace *space;
@@ -444,13 +441,14 @@ gst_colorspace_change_state (GstElement *element)
}
static void
-gst_colorspace_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_colorspace_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstColorspace *space;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_COLORSPACE(object));
- space = GST_COLORSPACE(object);
+ g_return_if_fail (GST_IS_COLORSPACE (object));
+ space = GST_COLORSPACE (object);
switch (prop_id) {
default:
@@ -459,13 +457,14 @@ gst_colorspace_set_property (GObject *object, guint prop_id, const GValue *value
}
static void
-gst_colorspace_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_colorspace_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstColorspace *space;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_COLORSPACE(object));
- space = GST_COLORSPACE(object);
+ g_return_if_fail (GST_IS_COLORSPACE (object));
+ space = GST_COLORSPACE (object);
switch (prop_id) {
default:
@@ -475,7 +474,7 @@ gst_colorspace_get_property (GObject *object, guint prop_id, GValue *value, GPar
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
lcs_init (NULL, NULL);
@@ -484,14 +483,8 @@ plugin_init (GstPlugin *plugin)
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "colorspacelcs",
- "LCS colorspace convertor",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "colorspacelcs",
+ "LCS colorspace convertor",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
diff --git a/ext/libfame/gstlibfame.c b/ext/libfame/gstlibfame.c
index c68ff36b..43e0e487 100644
--- a/ext/libfame/gstlibfame.c
+++ b/ext/libfame/gstlibfame.c
@@ -27,7 +27,7 @@
#include "gstlibfame.h"
#include <gst/video/video.h>
-#define FAMEENC_BUFFER_SIZE (300 * 1024)
+#define FAMEENC_BUFFER_SIZE (300 * 1024)
/* elementfactory information */
static GstElementDetails gst_fameenc_details = {
@@ -41,12 +41,14 @@ static GQuark fame_object_name;
/* FameEnc signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_VERSION,
ARG_BITRATE,
@@ -57,39 +59,31 @@ enum {
ARG_FRAMES_PER_SEQUENCE,
/* dynamically generated properties start here */
ARG_FAME_PROPS_START
- /* FILL ME */
+ /* FILL ME */
};
-static GstStaticPadTemplate sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "video/x-raw-yuv, "
- "format = (fourcc) I420, "
- "width = (int) [ 16, 4096 ], "
- "height = (int) [ 16, 4096 ], "
- "framerate = (double) { 23.976024, 24.0, 25.0, 29.970030, 30.0, "
- " 50.0, 59.940060, 60.0 }"
- )
-);
-
-static GstStaticPadTemplate src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "video/mpeg, "
- "mpegversion = (int) { 1, 4 }, "
- "systemstream = (boolean) FALSE, "
- "width = (int) [ 16, 4096 ], "
- "height = (int) [ 16, 4096 ], "
- "framerate = (double) { 23.976024, 24.0, 25.0, 29.970030, 30.0, "
- " 50.0, 59.940060, 60.0 }"
- )
-);
+static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-raw-yuv, "
+ "format = (fourcc) I420, "
+ "width = (int) [ 16, 4096 ], "
+ "height = (int) [ 16, 4096 ], "
+ "framerate = (double) { 23.976024, 24.0, 25.0, 29.970030, 30.0, "
+ " 50.0, 59.940060, 60.0 }")
+ );
+
+static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/mpeg, "
+ "mpegversion = (int) { 1, 4 }, "
+ "systemstream = (boolean) FALSE, "
+ "width = (int) [ 16, 4096 ], "
+ "height = (int) [ 16, 4096 ], "
+ "framerate = (double) { 23.976024, 24.0, 25.0, 29.970030, 30.0, "
+ " 50.0, 59.940060, 60.0 }")
+ );
#define MAX_FRAME_RATES 9
typedef struct
@@ -98,17 +92,16 @@ typedef struct
gint den;
} frame_rate_entry;
-static const frame_rate_entry frame_rates[] =
-{
- { 0, 0 },
- { 24000, 1001 },
- { 24, 1 },
- { 25, 1 },
- { 30000, 1001 },
- { 30, 1 },
- { 50, 1 },
- { 60000, 1001 },
- { 60, 1 },
+static const frame_rate_entry frame_rates[] = {
+ {0, 0},
+ {24000, 1001},
+ {24, 1},
+ {25, 1},
+ {30000, 1001},
+ {30, 1},
+ {50, 1},
+ {60000, 1001},
+ {60, 1},
};
static gint
@@ -116,18 +109,18 @@ framerate_to_index (gfloat fps)
{
gint i;
gint idx = -1;
-
+
for (i = 1; i < MAX_FRAME_RATES; i++) {
if (idx == -1) {
idx = i;
} else {
- gfloat old_diff = fabs((1. * frame_rates[idx].num /
- frame_rates[idx].den) - fps),
- new_diff = fabs((1. * frame_rates[i].num /
- frame_rates[i].den) - fps);
+ gfloat old_diff = fabs ((1. * frame_rates[idx].num /
+ frame_rates[idx].den) - fps),
+ new_diff = fabs ((1. * frame_rates[i].num /
+ frame_rates[i].den) - fps);
if (new_diff < old_diff) {
- idx = i;
+ idx = i;
}
}
}
@@ -135,19 +128,20 @@ framerate_to_index (gfloat fps)
return idx;
}
-static void gst_fameenc_class_init (GstFameEncClass *klass);
-static void gst_fameenc_base_init (GstFameEncClass *klass);
-static void gst_fameenc_init (GstFameEnc *fameenc);
-static void gst_fameenc_dispose (GObject *object);
+static void gst_fameenc_class_init (GstFameEncClass * klass);
+static void gst_fameenc_base_init (GstFameEncClass * klass);
+static void gst_fameenc_init (GstFameEnc * fameenc);
+static void gst_fameenc_dispose (GObject * object);
-static void gst_fameenc_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_fameenc_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_fameenc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_fameenc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_fameenc_chain (GstPad *pad, GstData *_data);
+static void gst_fameenc_chain (GstPad * pad, GstData * _data);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_fameenc_signals[LAST_SIGNAL] = { 0 };*/
GType
@@ -157,7 +151,7 @@ gst_fameenc_get_type (void)
if (!fameenc_type) {
static const GTypeInfo fameenc_info = {
- sizeof (GstFameEncClass),
+ sizeof (GstFameEncClass),
(GBaseInitFunc) gst_fameenc_base_init,
NULL,
(GClassInitFunc) gst_fameenc_class_init,
@@ -167,33 +161,33 @@ gst_fameenc_get_type (void)
0,
(GInstanceInitFunc) gst_fameenc_init,
};
- fameenc_type = g_type_register_static (GST_TYPE_ELEMENT,
- "GstFameEnc", &fameenc_info, 0);
+ fameenc_type = g_type_register_static (GST_TYPE_ELEMENT,
+ "GstFameEnc", &fameenc_info, 0);
}
return fameenc_type;
}
static int
-gst_fameenc_item_compare (fame_list_t *item1, fame_list_t *item2)
+gst_fameenc_item_compare (fame_list_t * item1, fame_list_t * item2)
{
return strcmp (item1->type, item2->type);
}
static void
-gst_fameenc_base_init (GstFameEncClass *klass)
+gst_fameenc_base_init (GstFameEncClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&sink_template));
+ gst_static_pad_template_get (&sink_template));
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&src_template));
+ gst_static_pad_template_get (&src_template));
gst_element_class_set_details (element_class, &gst_fameenc_details);
}
static void
-gst_fameenc_class_init (GstFameEncClass *klass)
+gst_fameenc_class_init (GstFameEncClass * klass)
{
GObjectClass *gobject_class = NULL;
GstElementClass *gstelement_class = NULL;
@@ -202,8 +196,8 @@ gst_fameenc_class_init (GstFameEncClass *klass)
GList *props = NULL, *props_walk;
gint current_prop = ARG_FAME_PROPS_START;
- 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);
@@ -219,7 +213,9 @@ gst_fameenc_class_init (GstFameEncClass *klass)
/* first sort the list */
walk = context->type_list;
while (walk) {
- props = g_list_insert_sorted (props, walk, (GCompareFunc)gst_fameenc_item_compare);
+ props =
+ g_list_insert_sorted (props, walk,
+ (GCompareFunc) gst_fameenc_item_compare);
walk = walk->next;
}
@@ -232,7 +228,7 @@ gst_fameenc_class_init (GstFameEncClass *klass)
fame_object_t *current_default;
gint default_index;
- walk = (fame_list_t *)props_walk->data;
+ walk = (fame_list_t *) props_walk->data;
array = g_array_new (TRUE, FALSE, sizeof (GEnumValue));
current_type = walk->type;
@@ -245,60 +241,68 @@ gst_fameenc_class_init (GstFameEncClass *klass)
if (strstr (walk->type, "/")) {
GEnumValue value;
- if (current_default == walk->item)
- default_index = current_value;
+ if (current_default == walk->item)
+ default_index = current_value;
value.value = current_value++;
value.value_name = g_strdup (walk->type);
value.value_nick = g_strdup (walk->item->name);
-
+
g_array_append_val (array, value);
}
props_walk = g_list_next (props_walk);
if (props_walk)
- walk = (fame_list_t *)props_walk->data;
+ walk = (fame_list_t *) props_walk->data;
} while (props_walk && !strncmp (walk->type, current_type, current_len));
if (array->len > 0) {
GType type;
GParamSpec *pspec;
-
- type = g_enum_register_static (g_strdup_printf ("GstFameEnc_%s", current_type), (GEnumValue *)array->data);
- pspec = g_param_spec_enum (current_type, current_type, g_strdup_printf ("The FAME \"%s\" object", current_type),
- type, default_index, G_PARAM_READWRITE);
+ type =
+ g_enum_register_static (g_strdup_printf ("GstFameEnc_%s",
+ current_type), (GEnumValue *) array->data);
+
+ pspec =
+ g_param_spec_enum (current_type, current_type,
+ g_strdup_printf ("The FAME \"%s\" object", current_type), type,
+ default_index, G_PARAM_READWRITE);
g_param_spec_set_qdata (pspec, fame_object_name, (gpointer) current_type);
-
- g_object_class_install_property (G_OBJECT_CLASS (klass), current_prop++, pspec);
+
+ g_object_class_install_property (G_OBJECT_CLASS (klass), current_prop++,
+ pspec);
}
}
g_object_class_install_property (gobject_class, ARG_BITRATE,
- g_param_spec_int ("bitrate", "Bitrate", "Target bitrate (0 = VBR)",
- 0, 5000000, 0, G_PARAM_READWRITE));
+ g_param_spec_int ("bitrate", "Bitrate", "Target bitrate (0 = VBR)",
+ 0, 5000000, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_QUALITY,
- g_param_spec_int ("quality", "Quality", "Percentage of quality of compression (versus size)",
- 0, 100, 75, G_PARAM_READWRITE));
+ g_param_spec_int ("quality", "Quality",
+ "Percentage of quality of compression (versus size)", 0, 100, 75,
+ G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_PATTERN,
- g_param_spec_string ("pattern", "Pattern", "Encoding pattern of I, P, and B frames",
- "IPPPPPPPPPPP", G_PARAM_READWRITE));
+ g_param_spec_string ("pattern", "Pattern",
+ "Encoding pattern of I, P, and B frames", "IPPPPPPPPPPP",
+ G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_FRAMES_PER_SEQUENCE,
- g_param_spec_int ("frames_per_sequence", "Frames Per Sequence",
- "The number of frames in one sequence",
- 1, G_MAXINT, 12, G_PARAM_READWRITE));
+ g_param_spec_int ("frames_per_sequence", "Frames Per Sequence",
+ "The number of frames in one sequence", 1, G_MAXINT, 12,
+ G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_FAME_VERBOSE,
- g_param_spec_boolean ("fame_verbose", "Fame Verbose", "Make FAME produce verbose output",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("fame_verbose", "Fame Verbose",
+ "Make FAME produce verbose output", FALSE, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_BUFFER_SIZE,
- g_param_spec_int ("buffer_size", "Buffer Size", "Set the decoding output buffer size",
- 0, 1024*1024, FAMEENC_BUFFER_SIZE, G_PARAM_READWRITE));
+ g_param_spec_int ("buffer_size", "Buffer Size",
+ "Set the decoding output buffer size", 0, 1024 * 1024,
+ FAMEENC_BUFFER_SIZE, G_PARAM_READWRITE));
}
static GstPadLinkReturn
-gst_fameenc_sink_link (GstPad *pad, const GstCaps *caps)
+gst_fameenc_sink_link (GstPad * pad, const GstCaps * caps)
{
gint width, height, fps_idx;
gdouble fps;
@@ -316,7 +320,7 @@ gst_fameenc_sink_link (GstPad *pad, const GstCaps *caps)
gst_structure_get_int (structure, "width", &width);
gst_structure_get_int (structure, "height", &height);
gst_structure_get_double (structure, "framerate", &fps);
-
+
/* fameenc requires width and height to be multiples of 16 */
if (width % 16 != 0 || height % 16 != 0)
return GST_PAD_LINK_REFUSED;
@@ -343,12 +347,12 @@ gst_fameenc_sink_link (GstPad *pad, const GstCaps *caps)
fameenc->initialized = TRUE;
fameenc->time_interval = 0;
-
+
return GST_PAD_LINK_OK;
}
static void
-gst_fameenc_init (GstFameEnc *fameenc)
+gst_fameenc_init (GstFameEnc * fameenc)
{
g_assert (fameenc != NULL);
g_assert (GST_IS_FAMEENC (fameenc));
@@ -358,14 +362,16 @@ gst_fameenc_init (GstFameEnc *fameenc)
g_assert (fameenc->fc != NULL);
/* create the sink and src pads */
- fameenc->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&sink_template), "sink");
+ fameenc->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&sink_template),
+ "sink");
gst_element_add_pad (GST_ELEMENT (fameenc), fameenc->sinkpad);
gst_pad_set_chain_function (fameenc->sinkpad, gst_fameenc_chain);
gst_pad_set_link_function (fameenc->sinkpad, gst_fameenc_sink_link);
- fameenc->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&src_template), "src");
+ fameenc->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&src_template),
+ "src");
gst_element_add_pad (GST_ELEMENT (fameenc), fameenc->srcpad);
/* FIXME: set some more handler functions here */
@@ -380,21 +386,21 @@ gst_fameenc_init (GstFameEnc *fameenc)
fameenc->fp.bitrate = 0;
fameenc->fp.quality = 75;
fameenc->fp.frame_rate_num = 25;
- fameenc->fp.frame_rate_den = 1; /* avoid floating point exceptions */
- fameenc->fp.frames_per_sequence = 12;
+ fameenc->fp.frame_rate_den = 1; /* avoid floating point exceptions */
+ fameenc->fp.frames_per_sequence = 12;
fameenc->pattern = g_strdup ("IPPPPPPPPPP");
/* allocate space for the buffer */
- fameenc->buffer_size = FAMEENC_BUFFER_SIZE; /* FIXME */
+ fameenc->buffer_size = FAMEENC_BUFFER_SIZE; /* FIXME */
fameenc->buffer = (unsigned char *) g_malloc (fameenc->buffer_size);
-
- fameenc->next_time = 0;
+
+ fameenc->next_time = 0;
fameenc->time_interval = 0;
}
static void
-gst_fameenc_dispose (GObject *object)
+gst_fameenc_dispose (GObject * object)
{
GstFameEnc *fameenc = GST_FAMEENC (object);
@@ -404,7 +410,7 @@ gst_fameenc_dispose (GObject *object)
}
static void
-gst_fameenc_chain (GstPad *pad, GstData *_data)
+gst_fameenc_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstFameEnc *fameenc;
@@ -423,8 +429,8 @@ gst_fameenc_chain (GstPad *pad, GstData *_data)
data = (guchar *) GST_BUFFER_DATA (buf);
size = GST_BUFFER_SIZE (buf);
- GST_DEBUG ("gst_fameenc_chain: got buffer of %ld bytes in '%s'",
- size, GST_OBJECT_NAME (fameenc));
+ GST_DEBUG ("gst_fameenc_chain: got buffer of %ld bytes in '%s'",
+ size, GST_OBJECT_NAME (fameenc));
/* the data contains the three planes side by side, with size w * h, w * h /4,
* w * h / 4 */
@@ -433,7 +439,7 @@ gst_fameenc_chain (GstPad *pad, GstData *_data)
frame_size = fameenc->fp.width * fameenc->fp.height;
- fameenc->fy.p = 0;
+ fameenc->fy.p = 0;
fameenc->fy.y = data;
fameenc->fy.u = data + frame_size;
fameenc->fy.v = fameenc->fy.u + (frame_size >> 2);
@@ -447,10 +453,13 @@ gst_fameenc_chain (GstPad *pad, GstData *_data)
/* FIXME: safeguard, remove me when a better way is found */
if (length > FAMEENC_BUFFER_SIZE)
- g_warning ("FAMEENC_BUFFER_SIZE is defined too low, encoded slice has size %d !\n", length);
+ g_warning
+ ("FAMEENC_BUFFER_SIZE is defined too low, encoded slice has size %d !\n",
+ length);
if (!fameenc->time_interval) {
- fameenc->time_interval = GST_SECOND * fameenc->fp.frame_rate_den / fameenc->fp.frame_rate_num;
+ fameenc->time_interval =
+ GST_SECOND * fameenc->fp.frame_rate_den / fameenc->fp.frame_rate_num;
}
fameenc->next_time += fameenc->time_interval;
@@ -458,23 +467,23 @@ gst_fameenc_chain (GstPad *pad, GstData *_data)
GST_BUFFER_SIZE (outbuf) = length;
GST_BUFFER_TIMESTAMP (outbuf) = fameenc->next_time;
GST_BUFFER_DATA (outbuf) = g_malloc (length);
- memcpy (GST_BUFFER_DATA(outbuf), fameenc->buffer, length);
+ memcpy (GST_BUFFER_DATA (outbuf), fameenc->buffer, length);
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
GST_DEBUG ("gst_fameenc_chain: pushing buffer of size %d",
- GST_BUFFER_SIZE(outbuf));
+ GST_BUFFER_SIZE (outbuf));
gst_pad_push (fameenc->srcpad, GST_DATA (outbuf));
}
- fame_end_frame (fameenc->fc, NULL);
+ fame_end_frame (fameenc->fc, NULL);
- gst_buffer_unref(buf);
+ gst_buffer_unref (buf);
}
static void
-gst_fameenc_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
+gst_fameenc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstFameEnc *fameenc;
@@ -482,7 +491,8 @@ gst_fameenc_set_property (GObject *object, guint prop_id,
fameenc = GST_FAMEENC (object);
if (fameenc->initialized) {
- GST_DEBUG ("error: fameenc encoder already initialized, cannot set properties !");
+ GST_DEBUG
+ ("error: fameenc encoder already initialized, cannot set properties !");
return;
}
@@ -514,18 +524,18 @@ gst_fameenc_set_property (GObject *object, guint prop_id,
values = G_ENUM_CLASS (g_type_class_ref (pspec->value_type))->values;
name = (gchar *) g_param_spec_get_qdata (pspec, fame_object_name);
-
- fame_register (fameenc->fc, name, fame_get_object (fameenc->fc, values[index].value_name));
- }
- else
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+
+ fame_register (fameenc->fc, name, fame_get_object (fameenc->fc,
+ values[index].value_name));
+ } else
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
-gst_fameenc_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+gst_fameenc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
GstFameEnc *fameenc;
@@ -560,12 +570,12 @@ gst_fameenc_get_property (GObject *object, guint prop_id,
values = G_ENUM_CLASS (g_type_class_ref (pspec->value_type))->values;
name = (gchar *) g_param_spec_get_qdata (pspec, fame_object_name);
-
+
f_object = fame_get_object (fameenc->fc, name);
while (values[index].value_name) {
if (!strcmp (values[index].value_nick, f_object->name)) {
- g_value_set_enum (value, index);
+ g_value_set_enum (value, index);
return;
}
index++;
@@ -577,20 +587,15 @@ gst_fameenc_get_property (GObject *object, guint prop_id,
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return gst_element_register (plugin, "fameenc",
- GST_RANK_NONE, GST_TYPE_FAMEENC);
+ GST_RANK_NONE, GST_TYPE_FAMEENC);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "fameenc",
- "Fast Assembly MPEG Encoder",
- plugin_init,
- LIBFAME_VERSION,
- "LGPL",
- "libfame",
- "http://fame.sourceforge.net/"
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "fameenc",
+ "Fast Assembly MPEG Encoder",
+ plugin_init,
+ LIBFAME_VERSION, "LGPL", "libfame", "http://fame.sourceforge.net/")
diff --git a/ext/libfame/gstlibfame.h b/ext/libfame/gstlibfame.h
index 15affdaf..74726bb6 100644
--- a/ext/libfame/gstlibfame.h
+++ b/ext/libfame/gstlibfame.h
@@ -25,8 +25,9 @@
#include <fame.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_FAMEENC \
@@ -40,48 +41,50 @@ extern "C" {
#define GST_IS_FAMEENC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FAMEENC))
-typedef struct _GstFameEnc GstFameEnc;
-typedef struct _GstFameEncClass GstFameEncClass;
+ typedef struct _GstFameEnc GstFameEnc;
+ typedef struct _GstFameEncClass GstFameEncClass;
-struct _GstFameEnc {
- GstElement element;
+ struct _GstFameEnc
+ {
+ GstElement element;
- /* pads */
- GstPad *sinkpad, *srcpad;
+ /* pads */
+ GstPad *sinkpad, *srcpad;
- /* the timestamp of the next frame */
- guint64 next_time;
- /* the interval between frames */
- guint64 time_interval;
+ /* the timestamp of the next frame */
+ guint64 next_time;
+ /* the interval between frames */
+ guint64 time_interval;
- /* video state */
- gint format;
- /* the size of the output buffer */
- gint outsize;
+ /* video state */
+ gint format;
+ /* the size of the output buffer */
+ gint outsize;
- /* encoding pattern string */
- gchar *pattern;
+ /* encoding pattern string */
+ gchar *pattern;
- /* fameenc stuff */
- gboolean verbose;
- fame_context_t *fc;
- fame_parameters_t fp;
- fame_yuv_t fy;
- gulong buffer_size;
- unsigned char *buffer;
- gboolean initialized;
-};
+ /* fameenc stuff */
+ gboolean verbose;
+ fame_context_t *fc;
+ fame_parameters_t fp;
+ fame_yuv_t fy;
+ gulong buffer_size;
+ unsigned char *buffer;
+ gboolean initialized;
+ };
-struct _GstFameEncClass {
- GstElementClass parent_class;
-};
+ struct _GstFameEncClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_fameenc_get_type (void);
+ GType gst_fameenc_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_FAMEENC_H__ */
+#endif /* __GST_FAMEENC_H__ */
diff --git a/ext/musicbrainz/gsttrm.c b/ext/musicbrainz/gsttrm.c
index d70f0b6e..484be50f 100644
--- a/ext/musicbrainz/gsttrm.c
+++ b/ext/musicbrainz/gsttrm.c
@@ -27,62 +27,58 @@
#include "gsttrm.h"
/* musicbrainz signals and args */
-enum {
+enum
+{
SIGNAL_SIGNATURE_AVAILABLE,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_SIGNATURE,
ARG_ASCII_SIGNATURE
};
-GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
- "endianness = (int) BYTE_ORDER, "
- "signed = (bool) TRUE, "
- "width = (int) { 8, 16 }, "
- "depth = (int) { 8, 16 }, "
- "rate = (int) [ 8000, 96000 ], "
- "channels = (int) [ 1, 2 ]"
- )
-);
-
-
-GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
- "endianness = (int) BYTE_ORDER, "
- "signed = (bool) TRUE, "
- "width = (int) { 8, 16 }, "
- "depth = (int) { 8, 16 }, "
- "rate = (int) [ 8000, 96000 ], "
- "channels = (int) [ 1, 2 ]"
- )
-);
-
-
-static void gst_musicbrainz_class_init (GstMusicBrainzClass *klass);
-static void gst_musicbrainz_base_init (GstMusicBrainzClass *klass);
-static void gst_musicbrainz_init (GstMusicBrainz *musicbrainz);
-
-static void gst_musicbrainz_chain (GstPad *pad, GstData *data);
-
-static void gst_musicbrainz_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_musicbrainz_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
-
-static GstElementStateReturn
- gst_musicbrainz_change_state (GstElement *element);
+GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "endianness = (int) BYTE_ORDER, "
+ "signed = (bool) TRUE, "
+ "width = (int) { 8, 16 }, "
+ "depth = (int) { 8, 16 }, "
+ "rate = (int) [ 8000, 96000 ], " "channels = (int) [ 1, 2 ]")
+ );
+
+
+GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "endianness = (int) BYTE_ORDER, "
+ "signed = (bool) TRUE, "
+ "width = (int) { 8, 16 }, "
+ "depth = (int) { 8, 16 }, "
+ "rate = (int) [ 8000, 96000 ], " "channels = (int) [ 1, 2 ]")
+ );
+
+
+static void gst_musicbrainz_class_init (GstMusicBrainzClass * klass);
+static void gst_musicbrainz_base_init (GstMusicBrainzClass * klass);
+static void gst_musicbrainz_init (GstMusicBrainz * musicbrainz);
+
+static void gst_musicbrainz_chain (GstPad * pad, GstData * data);
+
+static void gst_musicbrainz_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_musicbrainz_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
+static GstElementStateReturn
+gst_musicbrainz_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
@@ -96,26 +92,25 @@ gst_musicbrainz_get_type (void)
if (!musicbrainz_type) {
static const GTypeInfo musicbrainz_info = {
- sizeof(GstMusicBrainzClass),
+ sizeof (GstMusicBrainzClass),
(GBaseInitFunc) gst_musicbrainz_base_init,
NULL,
(GClassInitFunc) gst_musicbrainz_class_init,
NULL,
NULL,
- sizeof(GstMusicBrainz),
+ sizeof (GstMusicBrainz),
0,
- (GInstanceInitFunc)gst_musicbrainz_init,
+ (GInstanceInitFunc) gst_musicbrainz_init,
};
- musicbrainz_type = g_type_register_static (GST_TYPE_ELEMENT,
- "GstMusicBrainz",
- &musicbrainz_info, 0);
+ musicbrainz_type = g_type_register_static (GST_TYPE_ELEMENT,
+ "GstMusicBrainz", &musicbrainz_info, 0);
}
return musicbrainz_type;
}
static void
-gst_musicbrainz_base_init (GstMusicBrainzClass *klass)
+gst_musicbrainz_base_init (GstMusicBrainzClass * klass)
{
GstElementDetails gst_musicbrainz_details = {
"Compute TRM Id",
@@ -126,9 +121,9 @@ gst_musicbrainz_base_init (GstMusicBrainzClass *klass)
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&src_template));
+ gst_static_pad_template_get (&src_template));
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&sink_template));
+ gst_static_pad_template_get (&sink_template));
gst_element_class_set_details (element_class, &gst_musicbrainz_details);
}
@@ -136,44 +131,45 @@ gst_musicbrainz_base_init (GstMusicBrainzClass *klass)
static void
-gst_musicbrainz_class_init (GstMusicBrainzClass *klass)
+gst_musicbrainz_class_init (GstMusicBrainzClass * 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);
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_SIGNATURE,
- g_param_spec_string ("signature","signature","signature",
- NULL, G_PARAM_READABLE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_ASCII_SIGNATURE,
- g_param_spec_string ("ascii_signature","ascii_signature","ascii_signature",
- NULL, G_PARAM_READABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIGNATURE,
+ g_param_spec_string ("signature", "signature", "signature",
+ NULL, G_PARAM_READABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ASCII_SIGNATURE,
+ g_param_spec_string ("ascii_signature", "ascii_signature",
+ "ascii_signature", NULL, G_PARAM_READABLE));
gobject_class->set_property = gst_musicbrainz_set_property;
gobject_class->get_property = gst_musicbrainz_get_property;
gst_musicbrainz_signals[SIGNAL_SIGNATURE_AVAILABLE] =
- g_signal_new ("signature-available", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstMusicBrainzClass, signature_available), NULL, NULL,
- g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("signature-available", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstMusicBrainzClass,
+ signature_available), NULL, NULL, g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
gstelement_class->change_state = gst_musicbrainz_change_state;
}
static GstPadLinkReturn
-gst_musicbrainz_sinkconnect (GstPad *pad, const GstCaps *caps)
+gst_musicbrainz_sinkconnect (GstPad * pad, const GstCaps * caps)
{
GstMusicBrainz *musicbrainz;
GstStructure *structure;
const gchar *mimetype;
gint width;
- musicbrainz = GST_MUSICBRAINZ (gst_pad_get_parent (pad));
-
+ musicbrainz = GST_MUSICBRAINZ (gst_pad_get_parent (pad));
+
musicbrainz->caps = caps;
structure = gst_caps_get_structure (caps, 0);
@@ -181,35 +177,38 @@ gst_musicbrainz_sinkconnect (GstPad *pad, const GstCaps *caps)
if (!gst_structure_get_int (structure, "depth", &musicbrainz->depth) ||
!gst_structure_get_int (structure, "width", &width))
- return GST_PAD_LINK_REFUSED;
+ return GST_PAD_LINK_REFUSED;
if (musicbrainz->depth != width)
- return GST_PAD_LINK_REFUSED;
+ return GST_PAD_LINK_REFUSED;
if (!gst_structure_get_int (structure, "channels", &musicbrainz->channels))
- return GST_PAD_LINK_REFUSED;
+ return GST_PAD_LINK_REFUSED;
if (!gst_structure_get_int (structure, "rate", &musicbrainz->rate))
- return GST_PAD_LINK_REFUSED;
+ return GST_PAD_LINK_REFUSED;
- trm_SetPCMDataInfo (musicbrainz->trm, musicbrainz->rate, musicbrainz->channels, musicbrainz->depth);
- musicbrainz->linked= TRUE;
+ trm_SetPCMDataInfo (musicbrainz->trm, musicbrainz->rate,
+ musicbrainz->channels, musicbrainz->depth);
+ musicbrainz->linked = TRUE;
- return GST_PAD_LINK_OK;
+ return GST_PAD_LINK_OK;
}
static void
-gst_musicbrainz_init (GstMusicBrainz *musicbrainz)
+gst_musicbrainz_init (GstMusicBrainz * musicbrainz)
{
- musicbrainz->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&sink_template), "sink");
+ musicbrainz->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&sink_template),
+ "sink");
gst_element_add_pad (GST_ELEMENT (musicbrainz), musicbrainz->sinkpad);
gst_pad_set_chain_function (musicbrainz->sinkpad, gst_musicbrainz_chain);
gst_pad_set_link_function (musicbrainz->sinkpad, gst_musicbrainz_sinkconnect);
- musicbrainz->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&src_template), "src");
+ musicbrainz->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&src_template),
+ "src");
gst_element_add_pad (GST_ELEMENT (musicbrainz), musicbrainz->srcpad);
musicbrainz->trm = NULL;
@@ -219,11 +218,11 @@ gst_musicbrainz_init (GstMusicBrainz *musicbrainz)
musicbrainz->signature_available = FALSE;
GST_FLAG_SET (musicbrainz, GST_ELEMENT_EVENT_AWARE);
- /*GST_FLAG_SET(musicbrainz, GST_ELEMENT_THREAD_SUGGESTED);*/
+ /*GST_FLAG_SET(musicbrainz, GST_ELEMENT_THREAD_SUGGESTED); */
}
static void
-gst_trm_handle_event (GstPad *pad, GstData *data)
+gst_trm_handle_event (GstPad * pad, GstData * data)
{
GstEvent *event = GST_EVENT (data);
@@ -231,7 +230,7 @@ gst_trm_handle_event (GstPad *pad, GstData *data)
}
static void
-gst_musicbrainz_chain (GstPad *pad, GstData *data)
+gst_musicbrainz_chain (GstPad * pad, GstData * data)
{
GstMusicBrainz *musicbrainz;
GstBuffer *buf;
@@ -243,33 +242,35 @@ gst_musicbrainz_chain (GstPad *pad, GstData *data)
musicbrainz = GST_MUSICBRAINZ (gst_pad_get_parent (pad));
- if (GST_IS_EVENT (data))
- {
+ if (GST_IS_EVENT (data)) {
gst_trm_handle_event (pad, data);
return;
}
buf = GST_BUFFER (data);
-
+
if (musicbrainz->linked && !musicbrainz->data_available)
- if (gst_pad_query (gst_pad_get_peer (pad), GST_QUERY_TOTAL, &format, &nanos))
- {
+ if (gst_pad_query (gst_pad_get_peer (pad), GST_QUERY_TOTAL, &format,
+ &nanos)) {
musicbrainz->total_time = nanos / GST_SECOND;
- trm_SetSongLength(musicbrainz->trm, musicbrainz->total_time);
+ trm_SetSongLength (musicbrainz->trm, musicbrainz->total_time);
musicbrainz->data_available = TRUE;
gst_pad_try_set_caps (musicbrainz->srcpad, musicbrainz->caps);
}
- if (!musicbrainz->signature_available && trm_GenerateSignature (musicbrainz->trm, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)))
- {
+ if (!musicbrainz->signature_available
+ && trm_GenerateSignature (musicbrainz->trm, GST_BUFFER_DATA (buf),
+ GST_BUFFER_SIZE (buf))) {
GST_DEBUG ("Signature");
- trm_FinalizeSignature(musicbrainz->trm, musicbrainz->signature, NULL);
- trm_ConvertSigToASCII (musicbrainz->trm, musicbrainz->signature, musicbrainz->ascii_signature);
-g_print ("Signature : %s\n", musicbrainz->ascii_signature);
+ trm_FinalizeSignature (musicbrainz->trm, musicbrainz->signature, NULL);
+ trm_ConvertSigToASCII (musicbrainz->trm, musicbrainz->signature,
+ musicbrainz->ascii_signature);
+ g_print ("Signature : %s\n", musicbrainz->ascii_signature);
musicbrainz->signature_available = TRUE;
- g_signal_emit (G_OBJECT(musicbrainz),gst_musicbrainz_signals[SIGNAL_SIGNATURE_AVAILABLE], 0);
+ g_signal_emit (G_OBJECT (musicbrainz),
+ gst_musicbrainz_signals[SIGNAL_SIGNATURE_AVAILABLE], 0);
GST_DEBUG ("Signature : %s", musicbrainz->ascii_signature);
@@ -281,7 +282,8 @@ g_print ("Signature : %s\n", musicbrainz->ascii_signature);
static void
-gst_musicbrainz_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_musicbrainz_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstMusicBrainz *musicbrainz;
@@ -302,23 +304,24 @@ gst_musicbrainz_set_property (GObject *object, guint prop_id, const GValue *valu
}
static void
-gst_musicbrainz_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_musicbrainz_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstMusicBrainz *musicbrainz;
/* it's not null if we got it, but it might not be ours */
- musicbrainz = GST_MUSICBRAINZ(object);
+ musicbrainz = GST_MUSICBRAINZ (object);
switch (prop_id) {
- case ARG_SIGNATURE: {
+ case ARG_SIGNATURE:{
g_value_set_string (value, musicbrainz->signature);
break;
}
- case ARG_ASCII_SIGNATURE: {
+ case ARG_ASCII_SIGNATURE:{
g_value_set_string (value, musicbrainz->ascii_signature);
break;
}
- default: {
+ default:{
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
@@ -327,7 +330,7 @@ gst_musicbrainz_get_property (GObject *object, guint prop_id, GValue *value, GPa
static GstElementStateReturn
-gst_musicbrainz_change_state (GstElement *element)
+gst_musicbrainz_change_state (GstElement * element)
{
GstMusicBrainz *musicbrainz;
@@ -358,22 +361,15 @@ gst_musicbrainz_change_state (GstElement *element)
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return gst_element_register (plugin, "trm",
- GST_RANK_NONE,
- GST_TYPE_MUSICBRAINZ);
+ GST_RANK_NONE, GST_TYPE_MUSICBRAINZ);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "trm",
- "A trm signature producer",
- plugin_init,
- VERSION,
- "GPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "trm",
+ "A trm signature producer",
+ plugin_init, VERSION, "GPL", GST_PACKAGE, GST_ORIGIN)
diff --git a/ext/musicbrainz/gsttrm.h b/ext/musicbrainz/gsttrm.h
index 6516f94d..717826b7 100644
--- a/ext/musicbrainz/gsttrm.h
+++ b/ext/musicbrainz/gsttrm.h
@@ -26,8 +26,9 @@
#include <musicbrainz/mb_c.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_MUSICBRAINZ \
@@ -42,41 +43,43 @@ extern "C" {
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MUSICBRAINZ))
-typedef struct _GstMusicBrainz GstMusicBrainz;
-typedef struct _GstMusicBrainzClass GstMusicBrainzClass;
+ typedef struct _GstMusicBrainz GstMusicBrainz;
+ typedef struct _GstMusicBrainzClass GstMusicBrainzClass;
-struct _GstMusicBrainz {
- GstElement element;
+ struct _GstMusicBrainz
+ {
+ GstElement element;
- GstPad *sinkpad;
- GstPad *srcpad;
- const GstCaps *caps;
+ GstPad *sinkpad;
+ GstPad *srcpad;
+ const GstCaps *caps;
- trm_t trm;
- gchar signature[17];
- gchar ascii_signature[37];
+ trm_t trm;
+ gchar signature[17];
+ gchar ascii_signature[37];
- guint depth;
- guint rate;
- guint channels;
- gboolean linked;
- gboolean data_available;
- gboolean signature_available;
- guint64 total_time;
-};
+ guint depth;
+ guint rate;
+ guint channels;
+ gboolean linked;
+ gboolean data_available;
+ gboolean signature_available;
+ guint64 total_time;
+ };
-struct _GstMusicBrainzClass {
- GstElementClass parent_class;
+ struct _GstMusicBrainzClass
+ {
+ GstElementClass parent_class;
- /* signals */
- void (*signature_available) (GstElement *element);
-};
+ /* signals */
+ void (*signature_available) (GstElement * element);
+ };
-GType gst_musicbrainz_get_type(void);
+ GType gst_musicbrainz_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_MUSICBRAINZE_H__ */
+#endif /* __GST_MUSICBRAINZE_H__ */
diff --git a/ext/nas/nassink.c b/ext/nas/nassink.c
index a61ef72d..6fd0d86c 100644
--- a/ext/nas/nassink.c
+++ b/ext/nas/nassink.c
@@ -32,65 +32,65 @@
#define NAS_SOUND_PORT_DURATION (2)
-GST_DEBUG_CATEGORY(NAS);
+GST_DEBUG_CATEGORY (NAS);
/* Signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_MUTE,
ARG_HOST
};
-static GstStaticPadTemplate sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS(
- "audio/x-raw-int, "
- "endianess = (int) BYTE_ORDER, "
- "signed = (boolean) TRUE, "
- "width = (int) 16, "
- "depth = (int) 16, "
- "rate = (int) [ 1000, 96000 ], "
- "channels = (int) [ 1, 2 ]; "
- "audio/x-raw-int, "
- "signed = (boolean) FALSE, "
- "width = (int) 8, "
- "depth = (int) 8, "
- "rate = (int) [ 1000, 96000 ], "
- "channels = (int) [ 1, 2 ]"
- )
-);
-
-static void gst_nassink_base_init (gpointer g_class);
-static void gst_nassink_class_init (GstNassinkClass *klass);
-static void gst_nassink_init (GstNassink *nassink);
-
-static gboolean gst_nassink_open_audio (GstNassink *sink);
-static void gst_nassink_close_audio (GstNassink *sink);
-static GstElementStateReturn gst_nassink_change_state (GstElement *element);
-static GstCaps* gst_nassink_getcaps (GstPad *pad);
-static gboolean gst_nassink_sync_parms (GstNassink *nassink);
-static GstPadLinkReturn gst_nassink_sinkconnect (GstPad *pad, const GstCaps *caps);
-
-static void gst_nassink_chain (GstPad *pad, GstData *_data);
-
-static void gst_nassink_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_nassink_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
-
-static void NAS_flush (GstNassink *sink);
-static void NAS_sendData (GstNassink *sink, AuUint32 numBytes);
-static AuBool NAS_EventHandler (AuServer *aud, AuEvent *ev, AuEventHandlerRec *handler);
-static AuDeviceID NAS_getDevice (AuServer* aud, int numTracks);
-static int NAS_allocBuffer (GstNassink *sink);
-static int NAS_createFlow (GstNassink *sink, unsigned char format, unsigned short rate, int numTracks);
+static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "endianess = (int) BYTE_ORDER, "
+ "signed = (boolean) TRUE, "
+ "width = (int) 16, "
+ "depth = (int) 16, "
+ "rate = (int) [ 1000, 96000 ], "
+ "channels = (int) [ 1, 2 ]; "
+ "audio/x-raw-int, "
+ "signed = (boolean) FALSE, "
+ "width = (int) 8, "
+ "depth = (int) 8, "
+ "rate = (int) [ 1000, 96000 ], " "channels = (int) [ 1, 2 ]")
+ );
+
+static void gst_nassink_base_init (gpointer g_class);
+static void gst_nassink_class_init (GstNassinkClass * klass);
+static void gst_nassink_init (GstNassink * nassink);
+
+static gboolean gst_nassink_open_audio (GstNassink * sink);
+static void gst_nassink_close_audio (GstNassink * sink);
+static GstElementStateReturn gst_nassink_change_state (GstElement * element);
+static GstCaps *gst_nassink_getcaps (GstPad * pad);
+static gboolean gst_nassink_sync_parms (GstNassink * nassink);
+static GstPadLinkReturn gst_nassink_sinkconnect (GstPad * pad,
+ const GstCaps * caps);
+
+static void gst_nassink_chain (GstPad * pad, GstData * _data);
+
+static void gst_nassink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_nassink_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
+static void NAS_flush (GstNassink * sink);
+static void NAS_sendData (GstNassink * sink, AuUint32 numBytes);
+static AuBool NAS_EventHandler (AuServer * aud, AuEvent * ev,
+ AuEventHandlerRec * handler);
+static AuDeviceID NAS_getDevice (AuServer * aud, int numTracks);
+static int NAS_allocBuffer (GstNassink * sink);
+static int NAS_createFlow (GstNassink * sink, unsigned char format,
+ unsigned short rate, int numTracks);
static GstElementClass *parent_class = NULL;
@@ -101,17 +101,19 @@ gst_nassink_get_type (void)
if (!nassink_type) {
static const GTypeInfo nassink_info = {
- sizeof(GstNassinkClass),
+ sizeof (GstNassinkClass),
gst_nassink_base_init,
NULL,
- (GClassInitFunc)gst_nassink_class_init,
+ (GClassInitFunc) gst_nassink_class_init,
NULL,
NULL,
- sizeof(GstNassink),
+ sizeof (GstNassink),
0,
- (GInstanceInitFunc)gst_nassink_init,
+ (GInstanceInitFunc) gst_nassink_init,
};
- nassink_type = g_type_register_static(GST_TYPE_ELEMENT, "GstNassink", &nassink_info, 0);
+ nassink_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstNassink", &nassink_info,
+ 0);
}
return nassink_type;
@@ -125,59 +127,57 @@ gst_nassink_base_init (gpointer g_class)
"Sink/Audio",
"Plays audio to a Network Audio Server",
"Laurent Vivier <Laurent.Vivier@bull.net>, "
- "Arwed v. Merkatz <v.merkatz@gmx.net>"
+ "Arwed v. Merkatz <v.merkatz@gmx.net>"
};
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sink_factory));
gst_element_class_set_details (element_class, &nassink_details);
- GST_DEBUG_CATEGORY_INIT(NAS, "NAS", 0, NULL);
+ GST_DEBUG_CATEGORY_INIT (NAS, "NAS", 0, NULL);
}
static void
-gst_nassink_class_init (GstNassinkClass *klass)
+gst_nassink_class_init (GstNassinkClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
if (parent_class == NULL)
- parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
+ parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gobject_class->set_property = gst_nassink_set_property;
gobject_class->get_property = gst_nassink_get_property;
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_MUTE,
- g_param_spec_boolean("mute","mute","mute",
- TRUE,G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_HOST,
- g_param_spec_string("host","host","host",
- NULL, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MUTE, g_param_spec_boolean ("mute", "mute", "mute", TRUE, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_HOST, g_param_spec_string ("host", "host", "host", NULL, G_PARAM_READWRITE)); /* CHECKME */
gstelement_class->change_state = gst_nassink_change_state;
}
static void
-gst_nassink_init(GstNassink *nassink)
+gst_nassink_init (GstNassink * nassink)
{
- GST_CAT_DEBUG(NAS,"nassink: init");
- nassink->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&sink_factory), "sink");
- gst_element_add_pad(GST_ELEMENT(nassink), nassink->sinkpad);
- gst_pad_set_chain_function(nassink->sinkpad, GST_DEBUG_FUNCPTR(gst_nassink_chain));
- gst_pad_set_link_function(nassink->sinkpad, gst_nassink_sinkconnect);
- gst_pad_set_getcaps_function(nassink->sinkpad, gst_nassink_getcaps);
+ GST_CAT_DEBUG (NAS, "nassink: init");
+ nassink->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&sink_factory),
+ "sink");
+ gst_element_add_pad (GST_ELEMENT (nassink), nassink->sinkpad);
+ gst_pad_set_chain_function (nassink->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_nassink_chain));
+ gst_pad_set_link_function (nassink->sinkpad, gst_nassink_sinkconnect);
+ gst_pad_set_getcaps_function (nassink->sinkpad, gst_nassink_getcaps);
nassink->mute = FALSE;
nassink->depth = 16;
nassink->tracks = 2;
nassink->rate = 44100;
- nassink->host = g_strdup (getenv("AUDIOSERVER"));
+ nassink->host = g_strdup (getenv ("AUDIOSERVER"));
if (nassink->host == NULL)
- nassink->host = g_strdup (getenv("DISPLAY"));
+ nassink->host = g_strdup (getenv ("DISPLAY"));
nassink->audio = NULL;
nassink->flow = AuNone;
@@ -186,49 +186,51 @@ gst_nassink_init(GstNassink *nassink)
nassink->buf = NULL;
}
-static GstCaps*
-gst_nassink_getcaps (GstPad *pad)
+static GstCaps *
+gst_nassink_getcaps (GstPad * pad)
{
- GstNassink *nassink = GST_NASSINK(gst_pad_get_parent(pad));
- GstCaps *templatecaps = gst_caps_copy(gst_pad_get_pad_template_caps(pad));
+ GstNassink *nassink = GST_NASSINK (gst_pad_get_parent (pad));
+ GstCaps *templatecaps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
GstCaps *caps;
int i;
AuServer *server;
- server = AuOpenServer(nassink->host, 0, NULL, 0, NULL, NULL);
+ server = AuOpenServer (nassink->host, 0, NULL, 0, NULL, NULL);
if (!server)
return templatecaps;
-
+
for (i = 0; i < gst_caps_get_size (templatecaps); i++) {
GstStructure *structure = gst_caps_get_structure (templatecaps, i);
- gst_structure_set (structure, "rate", GST_TYPE_INT_RANGE, AuServerMinSampleRate(server), AuServerMaxSampleRate(server), NULL);
+ gst_structure_set (structure, "rate", GST_TYPE_INT_RANGE,
+ AuServerMinSampleRate (server), AuServerMaxSampleRate (server), NULL);
}
- caps = gst_caps_intersect(templatecaps, gst_pad_get_pad_template_caps(pad));
- gst_caps_free(templatecaps);
+ caps = gst_caps_intersect (templatecaps, gst_pad_get_pad_template_caps (pad));
+ gst_caps_free (templatecaps);
return caps;
-
+
}
static gboolean
-gst_nassink_sync_parms (GstNassink *nassink)
+gst_nassink_sync_parms (GstNassink * nassink)
{
gint ret;
unsigned char format;
+
g_return_val_if_fail (nassink != NULL, FALSE);
g_return_val_if_fail (GST_IS_NASSINK (nassink), FALSE);
- if (nassink->audio == NULL) return TRUE;
+ if (nassink->audio == NULL)
+ return TRUE;
- GST_CAT_DEBUG(NAS,"depth=%i rate=%i", nassink->depth, nassink->rate);
- if (nassink->flow != AuNone)
- {
- GST_CAT_DEBUG(NAS,"flushing buffer");
+ GST_CAT_DEBUG (NAS, "depth=%i rate=%i", nassink->depth, nassink->rate);
+ if (nassink->flow != AuNone) {
+ GST_CAT_DEBUG (NAS, "flushing buffer");
while (nassink->pos && nassink->buf)
- NAS_flush(nassink);
- AuStopFlow( nassink->audio, nassink->flow, NULL);
- AuReleaseScratchFlow(nassink->audio, nassink->flow, NULL);
+ NAS_flush (nassink);
+ AuStopFlow (nassink->audio, nassink->flow, NULL);
+ AuReleaseScratchFlow (nassink->audio, nassink->flow, NULL);
nassink->flow = AuNone;
}
@@ -241,13 +243,13 @@ gst_nassink_sync_parms (GstNassink *nassink)
else
format = AuFormatLinearUnsigned8;
- ret = NAS_createFlow(nassink, format, nassink->rate, nassink->tracks);
+ ret = NAS_createFlow (nassink, format, nassink->rate, nassink->tracks);
return ret >= 0;
}
static GstPadLinkReturn
-gst_nassink_sinkconnect (GstPad *pad, const GstCaps *caps)
+gst_nassink_sinkconnect (GstPad * pad, const GstCaps * caps)
{
GstNassink *nassink;
GstStructure *structure;
@@ -260,14 +262,14 @@ gst_nassink_sinkconnect (GstPad *pad, const GstCaps *caps)
gst_structure_get_int (structure, "channels", &nassink->tracks);
gst_structure_get_int (structure, "rate", &nassink->rate);
- if (!gst_nassink_sync_parms(nassink))
+ if (!gst_nassink_sync_parms (nassink))
return GST_PAD_LINK_REFUSED;
return GST_PAD_LINK_OK;
}
static void
-gst_nassink_chain (GstPad *pad, GstData *_data)
+gst_nassink_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
int pos = 0;
@@ -275,28 +277,29 @@ gst_nassink_chain (GstPad *pad, GstData *_data)
int available;
GstNassink *nassink;
- 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);
nassink = GST_NASSINK (gst_pad_get_parent (pad));
- g_return_if_fail(nassink->buf != NULL);
+ g_return_if_fail (nassink->buf != NULL);
if (GST_BUFFER_DATA (buf) != NULL) {
if (!nassink->mute && nassink->audio != NULL) {
remaining = GST_BUFFER_SIZE (buf);
- while ((nassink->flow != AuNone) && ( remaining > 0)) {
+ while ((nassink->flow != AuNone) && (remaining > 0)) {
+
+ /* number of bytes we can copy to buffer */
- /* number of bytes we can copy to buffer */
-
- available = remaining > nassink->size - nassink->pos ?
- nassink->size - nassink->pos : remaining;
+ available = remaining > nassink->size - nassink->pos ?
+ nassink->size - nassink->pos : remaining;
/* fill the buffer */
- memcpy (nassink->buf + nassink->pos, GST_BUFFER_DATA (buf) + pos, available);
+ memcpy (nassink->buf + nassink->pos, GST_BUFFER_DATA (buf) + pos,
+ available);
nassink->pos += available;
pos += available;
@@ -307,14 +310,14 @@ gst_nassink_chain (GstPad *pad, GstData *_data)
if (remaining > 0) {
while ((nassink->flow != AuNone) && (nassink->pos == nassink->size)) {
- NAS_flush(nassink);
+ NAS_flush (nassink);
}
}
}
/* give some time to event handler */
- AuSync(nassink->audio, AuFalse);
+ AuSync (nassink->audio, AuFalse);
}
}
@@ -322,87 +325,84 @@ gst_nassink_chain (GstPad *pad, GstData *_data)
}
static void
-gst_nassink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_nassink_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstNassink *nassink;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_NASSINK(object));
- nassink = GST_NASSINK(object);
+ g_return_if_fail (GST_IS_NASSINK (object));
+ nassink = GST_NASSINK (object);
switch (prop_id) {
- case ARG_MUTE:
- nassink->mute = g_value_get_boolean (value);
- break;
- case ARG_HOST:
- if (nassink->host != NULL) g_free(nassink->host);
- if (g_value_get_string (value) == NULL)
- nassink->host = NULL;
- else
- nassink->host = g_strdup (g_value_get_string (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ case ARG_MUTE:
+ nassink->mute = g_value_get_boolean (value);
+ break;
+ case ARG_HOST:
+ if (nassink->host != NULL)
+ g_free (nassink->host);
+ if (g_value_get_string (value) == NULL)
+ nassink->host = NULL;
+ else
+ nassink->host = g_strdup (g_value_get_string (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
static void
-gst_nassink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_nassink_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstNassink *nassink;
- g_return_if_fail(GST_IS_NASSINK(object));
+ g_return_if_fail (GST_IS_NASSINK (object));
- nassink = GST_NASSINK(object);
+ nassink = GST_NASSINK (object);
switch (prop_id) {
- case ARG_MUTE:
- g_value_set_boolean (value, nassink->mute);
- break;
- case ARG_HOST:
- g_value_set_string (value, nassink->host);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ case ARG_MUTE:
+ g_value_set_boolean (value, nassink->mute);
+ break;
+ case ARG_HOST:
+ g_value_set_string (value, nassink->host);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
if (!gst_element_register (plugin, "nassink", GST_RANK_NONE,
- GST_TYPE_NASSINK)){
+ GST_TYPE_NASSINK)) {
return FALSE;
}
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "nassink",
- "uses NAS for audio output",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN
-);
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "nassink",
+ "uses NAS for audio output",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN);
static gboolean
-gst_nassink_open_audio (GstNassink *sink)
+gst_nassink_open_audio (GstNassink * sink)
{
/* Open Server */
- sink->audio = AuOpenServer(sink->host, 0, NULL, 0, NULL, NULL);
+ sink->audio = AuOpenServer (sink->host, 0, NULL, 0, NULL, NULL);
if (sink->audio == NULL)
return FALSE;
- sink->device = NAS_getDevice(sink->audio, sink->tracks);
+ sink->device = NAS_getDevice (sink->audio, sink->tracks);
if (sink->device == AuNone) {
- GST_CAT_DEBUG(NAS,"no device with %i tracks found", sink->tracks);
+ GST_CAT_DEBUG (NAS, "no device with %i tracks found", sink->tracks);
return FALSE;
}
@@ -415,65 +415,66 @@ gst_nassink_open_audio (GstNassink *sink)
GST_FLAG_SET (sink, GST_NASSINK_OPEN);
- GST_CAT_DEBUG(NAS,"opened audio device");
+ GST_CAT_DEBUG (NAS, "opened audio device");
return TRUE;
}
static void
-gst_nassink_close_audio (GstNassink *sink)
+gst_nassink_close_audio (GstNassink * sink)
{
- if (sink->audio == NULL) return;
+ if (sink->audio == NULL)
+ return;
if (sink->flow != AuNone) {
while (sink->pos && sink->buf) {
- NAS_flush(sink);
+ NAS_flush (sink);
}
- AuStopFlow( sink->audio, sink->flow, NULL);
- AuReleaseScratchFlow(sink->audio, sink->flow, NULL);
+ AuStopFlow (sink->audio, sink->flow, NULL);
+ AuReleaseScratchFlow (sink->audio, sink->flow, NULL);
sink->flow = AuNone;
}
- if (sink->buf != NULL)
- {
- free(sink->buf);
+ if (sink->buf != NULL) {
+ free (sink->buf);
sink->buf = NULL;
}
- AuCloseServer(sink->audio);
+ AuCloseServer (sink->audio);
sink->audio = NULL;
GST_FLAG_UNSET (sink, GST_NASSINK_OPEN);
- GST_CAT_DEBUG (NAS,"closed audio device");
+ GST_CAT_DEBUG (NAS, "closed audio device");
}
static GstElementStateReturn
-gst_nassink_change_state (GstElement *element)
+gst_nassink_change_state (GstElement * element)
{
GstNassink *nassink;
+
g_return_val_if_fail (GST_IS_NASSINK (element), FALSE);
nassink = GST_NASSINK (element);
switch (GST_STATE_PENDING (element)) {
- case GST_STATE_NULL:
- if (GST_FLAG_IS_SET (element, GST_NASSINK_OPEN))
- gst_nassink_close_audio (nassink);
- break;
+ case GST_STATE_NULL:
+ if (GST_FLAG_IS_SET (element, GST_NASSINK_OPEN))
+ gst_nassink_close_audio (nassink);
+ break;
- case GST_STATE_READY:
- if (!GST_FLAG_IS_SET (element, GST_NASSINK_OPEN))
- gst_nassink_open_audio (nassink);
- break;
+ case GST_STATE_READY:
+ if (!GST_FLAG_IS_SET (element, GST_NASSINK_OPEN))
+ gst_nassink_open_audio (nassink);
+ break;
- case GST_STATE_PAUSED:
- while (nassink->pos && nassink->buf)
- NAS_flush(nassink);
- break;
+ case GST_STATE_PAUSED:
+ while (nassink->pos && nassink->buf)
+ NAS_flush (nassink);
+ break;
- case GST_STATE_PLAYING:
- break;
+ case GST_STATE_PLAYING:
+ break;
}
if (GST_ELEMENT_CLASS (parent_class)->change_state)
@@ -483,111 +484,108 @@ gst_nassink_change_state (GstElement *element)
}
static void
-NAS_flush(GstNassink *sink)
+NAS_flush (GstNassink * sink)
{
AuEvent ev;
- AuNextEvent(sink->audio, AuTrue, &ev);
- AuDispatchEvent(sink->audio, &ev);
+ AuNextEvent (sink->audio, AuTrue, &ev);
+ AuDispatchEvent (sink->audio, &ev);
}
static void
-NAS_sendData(GstNassink *sink, AuUint32 numBytes)
+NAS_sendData (GstNassink * sink, AuUint32 numBytes)
{
if (numBytes < (sink->pos)) {
- AuWriteElement(sink->audio, sink->flow, 0,
- numBytes, sink->buf, AuFalse, NULL);
+ AuWriteElement (sink->audio, sink->flow, 0,
+ numBytes, sink->buf, AuFalse, NULL);
- memmove(sink->buf, sink->buf + numBytes,
- sink->pos - numBytes);
+ memmove (sink->buf, sink->buf + numBytes, sink->pos - numBytes);
sink->pos = sink->pos - numBytes;
- } else
- {
- AuWriteElement(sink->audio, sink->flow, 0,
- sink->pos, sink->buf,
- (numBytes > sink->pos), NULL);
+ } else {
+ AuWriteElement (sink->audio, sink->flow, 0,
+ sink->pos, sink->buf, (numBytes > sink->pos), NULL);
sink->pos = 0;
}
}
static AuBool
-NAS_EventHandler(AuServer *aud, AuEvent *ev, AuEventHandlerRec *handler)
+NAS_EventHandler (AuServer * aud, AuEvent * ev, AuEventHandlerRec * handler)
{
- GstNassink *sink = (GstNassink *)handler->data;
+ GstNassink *sink = (GstNassink *) handler->data;
AuElementNotifyEvent *notify;
switch (ev->type) {
- case AuEventTypeElementNotify:
+ case AuEventTypeElementNotify:
- notify = (AuElementNotifyEvent *) ev;
+ notify = (AuElementNotifyEvent *) ev;
- switch(notify->kind) {
+ switch (notify->kind) {
- case AuElementNotifyKindLowWater:
- NAS_sendData(sink, notify->num_bytes);
- break;
+ case AuElementNotifyKindLowWater:
+ NAS_sendData (sink, notify->num_bytes);
+ break;
- case AuElementNotifyKindState:
+ case AuElementNotifyKindState:
- switch(notify->cur_state) {
+ switch (notify->cur_state) {
- case AuStateStop:
-
- if (sink->flow != AuNone) {
- if (notify->reason == AuReasonEOF)
- AuStopFlow(handler->aud, sink->flow, NULL);
- AuReleaseScratchFlow(handler->aud, sink->flow, NULL);
- sink->flow = AuNone;
- }
- AuUnregisterEventHandler(handler->aud, handler);
- break;
+ case AuStateStop:
- case AuStatePause:
+ if (sink->flow != AuNone) {
+ if (notify->reason == AuReasonEOF)
+ AuStopFlow (handler->aud, sink->flow, NULL);
+ AuReleaseScratchFlow (handler->aud, sink->flow, NULL);
+ sink->flow = AuNone;
+ }
+ AuUnregisterEventHandler (handler->aud, handler);
+ break;
- switch(notify->reason) {
- case AuReasonUnderrun:
- case AuReasonOverrun:
- case AuReasonEOF:
- case AuReasonWatermark:
+ case AuStatePause:
- NAS_sendData(sink, notify->num_bytes);
+ switch (notify->reason) {
+ case AuReasonUnderrun:
+ case AuReasonOverrun:
+ case AuReasonEOF:
+ case AuReasonWatermark:
- break;
+ NAS_sendData (sink, notify->num_bytes);
- case AuReasonHardware:
+ break;
- if (AuSoundRestartHardwarePauses)
- AuStartFlow(handler->aud, sink->flow, NULL);
- else
- AuStopFlow(handler->aud, sink->flow, NULL);
+ case AuReasonHardware:
+ if (AuSoundRestartHardwarePauses)
+ AuStartFlow (handler->aud, sink->flow, NULL);
+ else
+ AuStopFlow (handler->aud, sink->flow, NULL);
+
+ break;
+ }
+ break;
+ }
break;
- }
- break;
}
break;
- }
- break;
}
return AuTrue;
}
static AuDeviceID
-NAS_getDevice(AuServer* aud, int numTracks)
+NAS_getDevice (AuServer * aud, int numTracks)
{
int i;
- for (i = 0; i < AuServerNumDevices(aud); i++) {
- if ( (AuDeviceKind(AuServerDevice(aud, i))
- == AuComponentKindPhysicalOutput) &&
- (AuDeviceNumTracks(AuServerDevice(aud, i)) == numTracks )) {
+ for (i = 0; i < AuServerNumDevices (aud); i++) {
+ if ((AuDeviceKind (AuServerDevice (aud, i))
+ == AuComponentKindPhysicalOutput) &&
+ (AuDeviceNumTracks (AuServerDevice (aud, i)) == numTracks)) {
- return AuDeviceIdentifier(AuServerDevice(aud, i));
+ return AuDeviceIdentifier (AuServerDevice (aud, i));
}
}
@@ -596,13 +594,13 @@ NAS_getDevice(AuServer* aud, int numTracks)
}
static int
-NAS_allocBuffer(GstNassink *sink)
+NAS_allocBuffer (GstNassink * sink)
{
if (sink->buf != NULL) {
- free(sink->buf);
+ free (sink->buf);
}
- sink->buf = (char *) malloc(sink->size);
+ sink->buf = (char *) malloc (sink->size);
if (sink->buf == NULL) {
return -1;
}
@@ -613,14 +611,15 @@ NAS_allocBuffer(GstNassink *sink)
}
static int
-NAS_createFlow(GstNassink *sink, unsigned char format, unsigned short rate, int numTracks)
+NAS_createFlow (GstNassink * sink, unsigned char format, unsigned short rate,
+ int numTracks)
{
AuElement elements[2];
AuUint32 buf_samples;
- sink->flow = AuGetScratchFlow(sink->audio, NULL);
+ sink->flow = AuGetScratchFlow (sink->audio, NULL);
if (sink->flow == 0) {
- GST_CAT_DEBUG(NAS,"couldn't get flow");
+ GST_CAT_DEBUG (NAS, "couldn't get flow");
return -1;
}
@@ -630,17 +629,20 @@ NAS_createFlow(GstNassink *sink, unsigned char format, unsigned short rate, int
int num_elements;
AuStatus status;
AuElement *oldelems;
- oldelems = AuGetElements(sink->audio, sink->flow, &clocked, &num_elements, &status);
+
+ oldelems =
+ AuGetElements (sink->audio, sink->flow, &clocked, &num_elements,
+ &status);
if (num_elements > 0) {
- GST_CAT_DEBUG(NAS,"GetElements status: %i", status);
+ GST_CAT_DEBUG (NAS, "GetElements status: %i", status);
if (oldelems)
- AuFreeElements(sink->audio, num_elements, oldelems);
- gst_nassink_close_audio(sink);
- gst_nassink_open_audio(sink);
- sink->flow = AuGetScratchFlow(sink->audio, NULL);
+ AuFreeElements (sink->audio, num_elements, oldelems);
+ gst_nassink_close_audio (sink);
+ gst_nassink_open_audio (sink);
+ sink->flow = AuGetScratchFlow (sink->audio, NULL);
if (sink->flow == 0) {
- GST_CAT_DEBUG(NAS,"couldn't get flow");
- return -1;
+ GST_CAT_DEBUG (NAS, "couldn't get flow");
+ return -1;
}
}
}
@@ -651,17 +653,20 @@ NAS_createFlow(GstNassink *sink, unsigned char format, unsigned short rate, int
int num_elements;
AuStatus status;
AuElement *oldelems;
- oldelems = AuGetElements(sink->audio, sink->flow, &clocked, &num_elements, &status);
+
+ oldelems =
+ AuGetElements (sink->audio, sink->flow, &clocked, &num_elements,
+ &status);
if (num_elements > 0) {
- GST_CAT_DEBUG(NAS,"GetElements status: %i", status);
+ GST_CAT_DEBUG (NAS, "GetElements status: %i", status);
if (oldelems)
- AuFreeElements(sink->audio, num_elements, oldelems);
- gst_nassink_close_audio(sink);
- gst_nassink_open_audio(sink);
- sink->flow = AuGetScratchFlow(sink->audio, NULL);
+ AuFreeElements (sink->audio, num_elements, oldelems);
+ gst_nassink_close_audio (sink);
+ gst_nassink_open_audio (sink);
+ sink->flow = AuGetScratchFlow (sink->audio, NULL);
if (sink->flow == 0) {
- GST_CAT_DEBUG(NAS,"couldn't get flow");
- return -1;
+ GST_CAT_DEBUG (NAS, "couldn't get flow");
+ return -1;
}
}
}
@@ -669,50 +674,49 @@ NAS_createFlow(GstNassink *sink, unsigned char format, unsigned short rate, int
buf_samples = rate * NAS_SOUND_PORT_DURATION;
- AuMakeElementImportClient( &elements[0], /* element */
- rate, /* rate */
- format, /* format */
- numTracks, /* number of tracks */
- AuTrue, /* discart */
- buf_samples, /* max samples */
- (AuUint32) (buf_samples / 100
- * AuSoundPortLowWaterMark),
- /* low water mark */
- 0, /* num actions */
- NULL);
-
- AuMakeElementExportDevice( &elements[1], /* element */
- 0, /* input */
- sink->device, /* device */
- rate, /* rate */
- AuUnlimitedSamples, /* num samples */
- 0, /* num actions */
- NULL); /* actions */
-
- AuSetElements( sink->audio, /* server */
- sink->flow, /* flow ID */
- AuTrue, /* clocked */
- 2, /* num elements */
- elements, /* elements */
- NULL);
-
- AuRegisterEventHandler( sink->audio, /* server */
- AuEventHandlerIDMask, /* value mask */
- 0, /* type */
- sink->flow, /* flow ID */
- NAS_EventHandler, /* callback */
- (AuPointer)sink); /* data */
-
- sink->size = buf_samples * numTracks * AuSizeofFormat(format);
-
- if (NAS_allocBuffer(sink) < 0) {
-
- AuReleaseScratchFlow(sink->audio, sink->flow, NULL);
+ AuMakeElementImportClient (&elements[0], /* element */
+ rate, /* rate */
+ format, /* format */
+ numTracks, /* number of tracks */
+ AuTrue, /* discart */
+ buf_samples, /* max samples */
+ (AuUint32) (buf_samples / 100 * AuSoundPortLowWaterMark),
+ /* low water mark */
+ 0, /* num actions */
+ NULL);
+
+ AuMakeElementExportDevice (&elements[1], /* element */
+ 0, /* input */
+ sink->device, /* device */
+ rate, /* rate */
+ AuUnlimitedSamples, /* num samples */
+ 0, /* num actions */
+ NULL); /* actions */
+
+ AuSetElements (sink->audio, /* server */
+ sink->flow, /* flow ID */
+ AuTrue, /* clocked */
+ 2, /* num elements */
+ elements, /* elements */
+ NULL);
+
+ AuRegisterEventHandler (sink->audio, /* server */
+ AuEventHandlerIDMask, /* value mask */
+ 0, /* type */
+ sink->flow, /* flow ID */
+ NAS_EventHandler, /* callback */
+ (AuPointer) sink); /* data */
+
+ sink->size = buf_samples * numTracks * AuSizeofFormat (format);
+
+ if (NAS_allocBuffer (sink) < 0) {
+
+ AuReleaseScratchFlow (sink->audio, sink->flow, NULL);
return -1;
}
- AuStartFlow(sink->audio, sink->flow, NULL);
+ AuStartFlow (sink->audio, sink->flow, NULL);
return 0;
}
diff --git a/ext/nas/nassink.h b/ext/nas/nassink.h
index 3206541c..afebe9ba 100644
--- a/ext/nas/nassink.h
+++ b/ext/nas/nassink.h
@@ -24,8 +24,9 @@
#include <gst/gst.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_NASSINK \
@@ -39,51 +40,54 @@ extern "C" {
#define GST_IS_NASSINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_NASSINK))
-typedef enum {
- GST_NASSINK_OPEN = GST_ELEMENT_FLAG_LAST,
- GST_NASSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST+2
-} GstNasSinkFlags;
+ typedef enum
+ {
+ GST_NASSINK_OPEN = GST_ELEMENT_FLAG_LAST,
+ GST_NASSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2
+ } GstNasSinkFlags;
-typedef struct _GstNassink GstNassink;
-typedef struct _GstNassinkClass GstNassinkClass;
+ typedef struct _GstNassink GstNassink;
+ typedef struct _GstNassinkClass GstNassinkClass;
-struct _GstNassink {
- GstElement element;
+ struct _GstNassink
+ {
+ GstElement element;
- GstPad *sinkpad;
+ GstPad *sinkpad;
- /* instance properties */
+ /* instance properties */
- gboolean mute;
- gint depth;
- gint tracks;
- gint rate;
- gchar* host;
+ gboolean mute;
+ gint depth;
+ gint tracks;
+ gint rate;
+ gchar *host;
- /* Server info */
+ /* Server info */
- AuServer *audio;
- AuFlowID flow;
- AuDeviceID device;
+ AuServer *audio;
+ AuFlowID flow;
+ AuDeviceID device;
- /* buffer */
+ /* buffer */
- AuUint32 size;
- AuUint32 pos;
+ AuUint32 size;
+ AuUint32 pos;
- char *buf;
-};
+ char *buf;
+ };
-struct _GstNassinkClass {
- GstElementClass parent_class;
-};
+ struct _GstNassinkClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_nassink_get_type(void);
+ GType gst_nassink_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_NASSINK_H__ */
+#endif /* __GST_NASSINK_H__ */
diff --git a/ext/sdl/sdlvideosink.c b/ext/sdl/sdlvideosink.c
index 57547102..f5d46a4f 100644
--- a/ext/sdl/sdlvideosink.c
+++ b/ext/sdl/sdlvideosink.c
@@ -40,45 +40,39 @@ static GstElementDetails gst_sdlvideosink_details = {
"Ronald Bultje <rbultje@ronald.bitfreak.net>",
};
-static void gst_sdlvideosink_base_init (gpointer g_class);
-static void gst_sdlvideosink_class_init (GstSDLVideoSinkClass *klass);
-static void gst_sdlvideosink_init (GstSDLVideoSink *sdl);
+static void gst_sdlvideosink_base_init (gpointer g_class);
+static void gst_sdlvideosink_class_init (GstSDLVideoSinkClass * klass);
+static void gst_sdlvideosink_init (GstSDLVideoSink * sdl);
-static void gst_sdlvideosink_interface_init (GstImplementsInterfaceClass *klass);
-static gboolean gst_sdlvideosink_supported (GstImplementsInterface *iface,
- GType type);
+static void gst_sdlvideosink_interface_init (GstImplementsInterfaceClass *
+ klass);
+static gboolean gst_sdlvideosink_supported (GstImplementsInterface * iface,
+ GType type);
-static void gst_sdlvideosink_xoverlay_init (GstXOverlayClass *klass);
-static void gst_sdlvideosink_xoverlay_set_xwindow_id
- (GstXOverlay *overlay,
- unsigned long parent);
+static void gst_sdlvideosink_xoverlay_init (GstXOverlayClass * klass);
+static void gst_sdlvideosink_xoverlay_set_xwindow_id
+ (GstXOverlay * overlay, unsigned long parent);
-static gboolean gst_sdlvideosink_lock (GstSDLVideoSink *sdl);
-static void gst_sdlvideosink_unlock (GstSDLVideoSink *sdl);
+static gboolean gst_sdlvideosink_lock (GstSDLVideoSink * sdl);
+static void gst_sdlvideosink_unlock (GstSDLVideoSink * sdl);
-static gboolean gst_sdlvideosink_initsdl (GstSDLVideoSink *sdl);
-static void gst_sdlvideosink_deinitsdl (GstSDLVideoSink *sdl);
+static gboolean gst_sdlvideosink_initsdl (GstSDLVideoSink * sdl);
+static void gst_sdlvideosink_deinitsdl (GstSDLVideoSink * sdl);
-static gboolean gst_sdlvideosink_create (GstSDLVideoSink *sdl);
-static void gst_sdlvideosink_destroy (GstSDLVideoSink *sdl);
+static gboolean gst_sdlvideosink_create (GstSDLVideoSink * sdl);
+static void gst_sdlvideosink_destroy (GstSDLVideoSink * sdl);
static GstPadLinkReturn
- gst_sdlvideosink_sinkconnect (GstPad *pad,
- const GstCaps *caps);
-static GstCaps * gst_sdlvideosink_fixate (GstPad *pad, const GstCaps *caps);
-static void gst_sdlvideosink_chain (GstPad *pad,
- GstData *data);
-
-static void gst_sdlvideosink_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gst_sdlvideosink_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
+gst_sdlvideosink_sinkconnect (GstPad * pad, const GstCaps * caps);
+static GstCaps *gst_sdlvideosink_fixate (GstPad * pad, const GstCaps * caps);
+static void gst_sdlvideosink_chain (GstPad * pad, GstData * data);
+
+static void gst_sdlvideosink_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_sdlvideosink_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
static GstElementStateReturn
- gst_sdlvideosink_change_state (GstElement *element);
+gst_sdlvideosink_change_state (GstElement * element);
static GstPadTemplate *sink_template;
@@ -113,13 +107,12 @@ gst_sdlvideosink_get_type (void)
NULL,
};
- sdlvideosink_type = g_type_register_static(GST_TYPE_VIDEOSINK,
- "GstSDLVideoSink",
- &sdlvideosink_info, 0);
- g_type_add_interface_static(sdlvideosink_type, GST_TYPE_IMPLEMENTS_INTERFACE,
- &iface_info);
- g_type_add_interface_static(sdlvideosink_type, GST_TYPE_X_OVERLAY,
- &xoverlay_info);
+ sdlvideosink_type = g_type_register_static (GST_TYPE_VIDEOSINK,
+ "GstSDLVideoSink", &sdlvideosink_info, 0);
+ g_type_add_interface_static (sdlvideosink_type,
+ GST_TYPE_IMPLEMENTS_INTERFACE, &iface_info);
+ g_type_add_interface_static (sdlvideosink_type, GST_TYPE_X_OVERLAY,
+ &xoverlay_info);
}
return sdlvideosink_type;
@@ -131,36 +124,33 @@ gst_sdlvideosink_base_init (gpointer g_class)
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
GstCaps *capslist;
gint i;
- gulong format[6] = { GST_MAKE_FOURCC('I','4','2','0'),
- GST_MAKE_FOURCC('Y','V','1','2'),
- GST_MAKE_FOURCC('Y','U','Y','2'),
- GST_MAKE_FOURCC('Y','V','Y','U'),
- GST_MAKE_FOURCC('U','Y','V','Y')
- };
+ gulong format[6] = { GST_MAKE_FOURCC ('I', '4', '2', '0'),
+ GST_MAKE_FOURCC ('Y', 'V', '1', '2'),
+ GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'),
+ GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U'),
+ GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y')
+ };
/* make a list of all available caps */
- capslist = gst_caps_new_empty();
+ capslist = gst_caps_new_empty ();
for (i = 0; i < 5; i++) {
- gst_caps_append_structure (capslist,
- gst_structure_new ("video/x-raw-yuv",
- "format", GST_TYPE_FOURCC, format[i],
- "width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
- "height", GST_TYPE_INT_RANGE, 1, G_MAXINT,
- "framerate", GST_TYPE_DOUBLE_RANGE, 0.0, G_MAXDOUBLE,
- NULL));
+ gst_caps_append_structure (capslist,
+ gst_structure_new ("video/x-raw-yuv",
+ "format", GST_TYPE_FOURCC, format[i],
+ "width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
+ "height", GST_TYPE_INT_RANGE, 1, G_MAXINT,
+ "framerate", GST_TYPE_DOUBLE_RANGE, 0.0, G_MAXDOUBLE, NULL));
}
sink_template = gst_pad_template_new ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- capslist);
-
+ GST_PAD_SINK, GST_PAD_ALWAYS, capslist);
+
gst_element_class_add_pad_template (element_class, sink_template);
gst_element_class_set_details (element_class, &gst_sdlvideosink_details);
}
static void
-gst_sdlvideosink_dispose (GObject *obj)
+gst_sdlvideosink_dispose (GObject * obj)
{
g_mutex_free (GST_SDLVIDEOSINK (obj)->lock);
@@ -169,16 +159,16 @@ gst_sdlvideosink_dispose (GObject *obj)
}
static void
-gst_sdlvideosink_class_init (GstSDLVideoSinkClass *klass)
+gst_sdlvideosink_class_init (GstSDLVideoSinkClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstVideoSinkClass *gstvs_class;
- gobject_class = (GObjectClass*) klass;
- gstelement_class = (GstElementClass*) klass;
- gstvs_class = (GstVideoSinkClass*) klass;
-
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ gstvs_class = (GstVideoSinkClass *) klass;
+
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gobject_class->set_property = gst_sdlvideosink_set_property;
@@ -186,19 +176,17 @@ gst_sdlvideosink_class_init (GstSDLVideoSinkClass *klass)
gobject_class->dispose = gst_sdlvideosink_dispose;
gstelement_class->change_state = gst_sdlvideosink_change_state;
-
+
/*gstvs_class->set_video_out = gst_sdlvideosink_set_video_out;
- gstvs_class->push_ui_event = gst_sdlvideosink_push_ui_event;
- gstvs_class->set_geometry = gst_sdlvideosink_set_geometry;*/
+ gstvs_class->push_ui_event = gst_sdlvideosink_push_ui_event;
+ gstvs_class->set_geometry = gst_sdlvideosink_set_geometry; */
}
#if 0
/* FIXME */
static GstBuffer *
-gst_sdlvideosink_buffer_new (GstBufferPool *pool,
- gint64 location,
- guint size,
- gpointer user_data)
+gst_sdlvideosink_buffer_new (GstBufferPool * pool,
+ gint64 location, guint size, gpointer user_data)
{
GstSDLVideoSink *sdlvideosink = GST_SDLVIDEOSINK (user_data);
GstBuffer *buffer;
@@ -206,7 +194,7 @@ gst_sdlvideosink_buffer_new (GstBufferPool *pool,
if (!sdlvideosink->overlay)
return NULL;
- if (!gst_sdlvideosink_lock(sdlvideosink)) {
+ if (!gst_sdlvideosink_lock (sdlvideosink)) {
return NULL;
}
@@ -219,10 +207,9 @@ gst_sdlvideosink_buffer_new (GstBufferPool *pool,
if (sdlvideosink->format == SDL_YV12_OVERLAY ||
sdlvideosink->format == SDL_IYUV_OVERLAY) {
GST_BUFFER_SIZE (buffer) =
- sdlvideosink->width * sdlvideosink->height * 3/2;
+ sdlvideosink->width * sdlvideosink->height * 3 / 2;
} else {
- GST_BUFFER_SIZE (buffer) =
- sdlvideosink->width * sdlvideosink->height * 2;
+ GST_BUFFER_SIZE (buffer) = sdlvideosink->width * sdlvideosink->height * 2;
}
GST_BUFFER_MAXSIZE (buffer) = GST_BUFFER_SIZE (buffer);
@@ -230,21 +217,20 @@ gst_sdlvideosink_buffer_new (GstBufferPool *pool,
}
static void
-gst_sdlvideosink_buffer_free (GstBufferPool *pool,
- GstBuffer *buffer,
- gpointer user_data)
+gst_sdlvideosink_buffer_free (GstBufferPool * pool,
+ GstBuffer * buffer, gpointer user_data)
{
GstSDLVideoSink *sdlvideosink = GST_SDLVIDEOSINK (user_data);
g_mutex_unlock (sdlvideosink->lock);
- gst_sdlvideosink_unlock(sdlvideosink);
+ gst_sdlvideosink_unlock (sdlvideosink);
gst_buffer_default_free (buffer);
}
static GstBufferPool *
-gst_sdlvideosink_get_bufferpool (GstPad *pad)
+gst_sdlvideosink_get_bufferpool (GstPad * pad)
{
GstSDLVideoSink *sdlvideosink = GST_SDLVIDEOSINK (gst_pad_get_parent (pad));
@@ -256,19 +242,19 @@ gst_sdlvideosink_get_bufferpool (GstPad *pad)
#endif
static void
-gst_sdlvideosink_init (GstSDLVideoSink *sdlvideosink)
+gst_sdlvideosink_init (GstSDLVideoSink * sdlvideosink)
{
GST_VIDEOSINK_PAD (sdlvideosink) = gst_pad_new_from_template (sink_template,
- "sink");
+ "sink");
gst_element_add_pad (GST_ELEMENT (sdlvideosink),
- GST_VIDEOSINK_PAD (sdlvideosink));
+ GST_VIDEOSINK_PAD (sdlvideosink));
gst_pad_set_chain_function (GST_VIDEOSINK_PAD (sdlvideosink),
- gst_sdlvideosink_chain);
+ gst_sdlvideosink_chain);
gst_pad_set_link_function (GST_VIDEOSINK_PAD (sdlvideosink),
- gst_sdlvideosink_sinkconnect);
+ gst_sdlvideosink_sinkconnect);
gst_pad_set_fixate_function (GST_VIDEOSINK_PAD (sdlvideosink),
- gst_sdlvideosink_fixate);
+ gst_sdlvideosink_fixate);
sdlvideosink->width = -1;
sdlvideosink->height = -1;
@@ -285,28 +271,26 @@ gst_sdlvideosink_init (GstSDLVideoSink *sdlvideosink)
sdlvideosink->lock = g_mutex_new ();
#if 0
- sdlvideosink->bufferpool = gst_buffer_pool_new (
- NULL, /* free */
- NULL, /* copy */
- (GstBufferPoolBufferNewFunction) gst_sdlvideosink_buffer_new,
- NULL, /* buffer copy, the default is fine */
- (GstBufferPoolBufferFreeFunction) gst_sdlvideosink_buffer_free,
- sdlvideosink);
+ sdlvideosink->bufferpool = gst_buffer_pool_new (NULL, /* free */
+ NULL, /* copy */
+ (GstBufferPoolBufferNewFunction) gst_sdlvideosink_buffer_new, NULL, /* buffer copy, the default is fine */
+ (GstBufferPoolBufferFreeFunction) gst_sdlvideosink_buffer_free,
+ sdlvideosink);
#endif
- GST_FLAG_SET(sdlvideosink, GST_ELEMENT_THREAD_SUGGESTED);
- GST_FLAG_SET(sdlvideosink, GST_ELEMENT_EVENT_AWARE);
+ GST_FLAG_SET (sdlvideosink, GST_ELEMENT_THREAD_SUGGESTED);
+ GST_FLAG_SET (sdlvideosink, GST_ELEMENT_EVENT_AWARE);
}
static void
-gst_sdlvideosink_interface_init (GstImplementsInterfaceClass *klass)
+gst_sdlvideosink_interface_init (GstImplementsInterfaceClass * klass)
{
klass->supported = gst_sdlvideosink_supported;
}
static gboolean
-gst_sdlvideosink_supported (GstImplementsInterface *interface,
- GType iface_type)
+gst_sdlvideosink_supported (GstImplementsInterface * interface,
+ GType iface_type)
{
g_assert (iface_type == GST_TYPE_X_OVERLAY);
@@ -315,13 +299,13 @@ gst_sdlvideosink_supported (GstImplementsInterface *interface,
}
static void
-gst_sdlvideosink_xoverlay_init (GstXOverlayClass *klass)
+gst_sdlvideosink_xoverlay_init (GstXOverlayClass * klass)
{
klass->set_xwindow_id = gst_sdlvideosink_xoverlay_set_xwindow_id;
}
static void
-gst_sdlvideosink_xoverlay_set_xwindow_id (GstXOverlay *overlay,
+gst_sdlvideosink_xoverlay_set_xwindow_id (GstXOverlay * overlay,
unsigned long parent)
{
GstSDLVideoSink *sdlvideosink = GST_SDLVIDEOSINK (overlay);
@@ -344,20 +328,19 @@ gst_sdlvideosink_xoverlay_set_xwindow_id (GstXOverlay *overlay,
static guint32
-gst_sdlvideosink_get_sdl_from_fourcc (GstSDLVideoSink *sdlvideosink,
- guint32 code)
+gst_sdlvideosink_get_sdl_from_fourcc (GstSDLVideoSink * sdlvideosink,
+ guint32 code)
{
- switch (code)
- {
- case GST_MAKE_FOURCC('I','4','2','0'):
+ switch (code) {
+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):
return SDL_IYUV_OVERLAY;
- case GST_MAKE_FOURCC('Y','V','1','2'):
+ case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
return SDL_YV12_OVERLAY;
- case GST_MAKE_FOURCC('Y','U','Y','2'):
+ case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
return SDL_YUY2_OVERLAY;
- case GST_MAKE_FOURCC('U','Y','V','Y'):
+ case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
return SDL_UYVY_OVERLAY;
- case GST_MAKE_FOURCC('Y','V','Y','U'):
+ case GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U'):
return SDL_YVYU_OVERLAY;
default:
return 0;
@@ -366,29 +349,26 @@ gst_sdlvideosink_get_sdl_from_fourcc (GstSDLVideoSink *sdlvideosink,
static gboolean
-gst_sdlvideosink_lock (GstSDLVideoSink *sdlvideosink)
+gst_sdlvideosink_lock (GstSDLVideoSink * sdlvideosink)
{
/* assure that we've got a screen */
if (!sdlvideosink->screen || !sdlvideosink->overlay) {
GST_ELEMENT_ERROR (sdlvideosink, LIBRARY, TOO_LAZY, (NULL),
- ("Tried to lock screen without being set-up"));
+ ("Tried to lock screen without being set-up"));
return FALSE;
}
/* Lock SDL/yuv-overlay */
- if (SDL_MUSTLOCK(sdlvideosink->screen))
- {
- if (SDL_LockSurface(sdlvideosink->screen) < 0)
- {
+ if (SDL_MUSTLOCK (sdlvideosink->screen)) {
+ if (SDL_LockSurface (sdlvideosink->screen) < 0) {
GST_ELEMENT_ERROR (sdlvideosink, LIBRARY, TOO_LAZY, (NULL),
- ("SDL: couldn't lock the SDL video window: %s", SDL_GetError()));
+ ("SDL: couldn't lock the SDL video window: %s", SDL_GetError ()));
return FALSE;
}
}
- if (SDL_LockYUVOverlay(sdlvideosink->overlay) < 0)
- {
+ if (SDL_LockYUVOverlay (sdlvideosink->overlay) < 0) {
GST_ELEMENT_ERROR (sdlvideosink, LIBRARY, TOO_LAZY, (NULL),
- ("SDL: couldn\'t lock the SDL YUV overlay: %s", SDL_GetError()));
+ ("SDL: couldn\'t lock the SDL YUV overlay: %s", SDL_GetError ()));
return FALSE;
}
@@ -399,16 +379,16 @@ gst_sdlvideosink_lock (GstSDLVideoSink *sdlvideosink)
static void
-gst_sdlvideosink_unlock (GstSDLVideoSink *sdlvideosink)
+gst_sdlvideosink_unlock (GstSDLVideoSink * sdlvideosink)
{
/* Unlock SDL_overlay */
- SDL_UnlockYUVOverlay(sdlvideosink->overlay);
- if (SDL_MUSTLOCK(sdlvideosink->screen))
- SDL_UnlockSurface(sdlvideosink->screen);
+ SDL_UnlockYUVOverlay (sdlvideosink->overlay);
+ if (SDL_MUSTLOCK (sdlvideosink->screen))
+ SDL_UnlockSurface (sdlvideosink->screen);
}
static void
-gst_sdlvideosink_deinitsdl (GstSDLVideoSink *sdlvideosink)
+gst_sdlvideosink_deinitsdl (GstSDLVideoSink * sdlvideosink)
{
if (sdlvideosink->init) {
SDL_Quit ();
@@ -417,22 +397,23 @@ gst_sdlvideosink_deinitsdl (GstSDLVideoSink *sdlvideosink)
}
static gboolean
-gst_sdlvideosink_initsdl (GstSDLVideoSink *sdlvideosink)
+gst_sdlvideosink_initsdl (GstSDLVideoSink * sdlvideosink)
{
gst_sdlvideosink_deinitsdl (sdlvideosink);
if (!sdlvideosink->xwindow_id) {
- unsetenv("SDL_WINDOWID");
+ unsetenv ("SDL_WINDOWID");
} else {
char SDL_hack[32];
- sprintf(SDL_hack, "%lu", sdlvideosink->xwindow_id);
- setenv("SDL_WINDOWID", SDL_hack, 1);
+
+ sprintf (SDL_hack, "%lu", sdlvideosink->xwindow_id);
+ setenv ("SDL_WINDOWID", SDL_hack, 1);
}
/* Initialize the SDL library */
- if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0 ) {
+ if (SDL_Init (SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0) {
GST_ELEMENT_ERROR (sdlvideosink, LIBRARY, INIT, (NULL),
- ("Couldn't initialize SDL: %s", SDL_GetError()));
+ ("Couldn't initialize SDL: %s", SDL_GetError ()));
return FALSE;
}
@@ -440,10 +421,10 @@ gst_sdlvideosink_initsdl (GstSDLVideoSink *sdlvideosink)
}
static void
-gst_sdlvideosink_destroy (GstSDLVideoSink *sdlvideosink)
+gst_sdlvideosink_destroy (GstSDLVideoSink * sdlvideosink)
{
if (sdlvideosink->overlay) {
- SDL_FreeYUVOverlay(sdlvideosink->overlay);
+ SDL_FreeYUVOverlay (sdlvideosink->overlay);
sdlvideosink->overlay = NULL;
}
@@ -454,7 +435,7 @@ gst_sdlvideosink_destroy (GstSDLVideoSink *sdlvideosink)
}
static gboolean
-gst_sdlvideosink_create (GstSDLVideoSink *sdlvideosink)
+gst_sdlvideosink_create (GstSDLVideoSink * sdlvideosink)
{
if (GST_VIDEOSINK_HEIGHT (sdlvideosink) <= 0)
GST_VIDEOSINK_HEIGHT (sdlvideosink) = sdlvideosink->height;
@@ -464,34 +445,30 @@ gst_sdlvideosink_create (GstSDLVideoSink *sdlvideosink)
gst_sdlvideosink_destroy (sdlvideosink);
/* create a SDL window of the size requested by the user */
- sdlvideosink->screen = SDL_SetVideoMode(GST_VIDEOSINK_WIDTH (sdlvideosink),
- GST_VIDEOSINK_HEIGHT (sdlvideosink), 0, SDL_HWSURFACE | SDL_RESIZABLE);
- if (sdlvideosink->screen == NULL)
- {
+ sdlvideosink->screen = SDL_SetVideoMode (GST_VIDEOSINK_WIDTH (sdlvideosink),
+ GST_VIDEOSINK_HEIGHT (sdlvideosink), 0, SDL_HWSURFACE | SDL_RESIZABLE);
+ if (sdlvideosink->screen == NULL) {
GST_ELEMENT_ERROR (sdlvideosink, LIBRARY, TOO_LAZY, (NULL),
- ("SDL: Couldn't set %dx%d: %s", GST_VIDEOSINK_WIDTH (sdlvideosink),
- GST_VIDEOSINK_HEIGHT (sdlvideosink), SDL_GetError()));
+ ("SDL: Couldn't set %dx%d: %s", GST_VIDEOSINK_WIDTH (sdlvideosink),
+ GST_VIDEOSINK_HEIGHT (sdlvideosink), SDL_GetError ()));
return FALSE;
}
/* create a new YUV overlay */
- sdlvideosink->overlay = SDL_CreateYUVOverlay(sdlvideosink->width,
- sdlvideosink->height, sdlvideosink->format, sdlvideosink->screen);
- if ( sdlvideosink->overlay == NULL )
- {
+ sdlvideosink->overlay = SDL_CreateYUVOverlay (sdlvideosink->width,
+ sdlvideosink->height, sdlvideosink->format, sdlvideosink->screen);
+ if (sdlvideosink->overlay == NULL) {
GST_ELEMENT_ERROR (sdlvideosink, LIBRARY, TOO_LAZY, (NULL),
- ("SDL: Couldn't create SDL YUV overlay (%dx%d \'" GST_FOURCC_FORMAT "\'): %s",
- sdlvideosink->width, sdlvideosink->height,
- GST_FOURCC_ARGS(sdlvideosink->format), SDL_GetError()));
+ ("SDL: Couldn't create SDL YUV overlay (%dx%d \'" GST_FOURCC_FORMAT
+ "\'): %s", sdlvideosink->width, sdlvideosink->height,
+ GST_FOURCC_ARGS (sdlvideosink->format), SDL_GetError ()));
return FALSE;
- }
- else
- {
- GST_DEBUG("Using a %dx%d %dbpp SDL screen with a %dx%d \'" GST_FOURCC_FORMAT "\' YUV overlay",
- GST_VIDEOSINK_WIDTH (sdlvideosink), GST_VIDEOSINK_HEIGHT (sdlvideosink),
- sdlvideosink->screen->format->BitsPerPixel,
- sdlvideosink->width, sdlvideosink->height,
- GST_FOURCC_ARGS(sdlvideosink->format));
+ } else {
+ GST_DEBUG ("Using a %dx%d %dbpp SDL screen with a %dx%d \'"
+ GST_FOURCC_FORMAT "\' YUV overlay", GST_VIDEOSINK_WIDTH (sdlvideosink),
+ GST_VIDEOSINK_HEIGHT (sdlvideosink),
+ sdlvideosink->screen->format->BitsPerPixel, sdlvideosink->width,
+ sdlvideosink->height, GST_FOURCC_ARGS (sdlvideosink->format));
}
sdlvideosink->rect.x = 0;
@@ -499,24 +476,24 @@ gst_sdlvideosink_create (GstSDLVideoSink *sdlvideosink)
sdlvideosink->rect.w = GST_VIDEOSINK_WIDTH (sdlvideosink);
sdlvideosink->rect.h = GST_VIDEOSINK_HEIGHT (sdlvideosink);
- SDL_DisplayYUVOverlay(sdlvideosink->overlay, &(sdlvideosink->rect));
+ SDL_DisplayYUVOverlay (sdlvideosink->overlay, &(sdlvideosink->rect));
GST_DEBUG ("sdlvideosink: setting %08x (" GST_FOURCC_FORMAT ")",
- sdlvideosink->format, GST_FOURCC_ARGS(sdlvideosink->format));
+ sdlvideosink->format, GST_FOURCC_ARGS (sdlvideosink->format));
gst_x_overlay_got_desired_size (GST_X_OVERLAY (sdlvideosink),
- GST_VIDEOSINK_WIDTH (sdlvideosink),
- GST_VIDEOSINK_HEIGHT (sdlvideosink));
+ GST_VIDEOSINK_WIDTH (sdlvideosink), GST_VIDEOSINK_HEIGHT (sdlvideosink));
return TRUE;
}
static GstCaps *
-gst_sdlvideosink_fixate (GstPad *pad, const GstCaps *caps)
+gst_sdlvideosink_fixate (GstPad * pad, const GstCaps * caps)
{
GstStructure *structure;
GstCaps *newcaps;
- if (gst_caps_get_size (caps) > 1) return NULL;
+ if (gst_caps_get_size (caps) > 1)
+ return NULL;
newcaps = gst_caps_copy (caps);
structure = gst_caps_get_structure (newcaps, 0);
@@ -528,7 +505,7 @@ gst_sdlvideosink_fixate (GstPad *pad, const GstCaps *caps)
return newcaps;
}
if (gst_caps_structure_fixate_field_nearest_double (structure, "framerate",
- 30.0)) {
+ 30.0)) {
return newcaps;
}
@@ -537,8 +514,7 @@ gst_sdlvideosink_fixate (GstPad *pad, const GstCaps *caps)
}
static GstPadLinkReturn
-gst_sdlvideosink_sinkconnect (GstPad *pad,
- const GstCaps *vscapslist)
+gst_sdlvideosink_sinkconnect (GstPad * pad, const GstCaps * vscapslist)
{
GstSDLVideoSink *sdlvideosink;
guint32 format;
@@ -549,11 +525,11 @@ gst_sdlvideosink_sinkconnect (GstPad *pad,
structure = gst_caps_get_structure (vscapslist, 0);
gst_structure_get_fourcc (structure, "format", &format);
sdlvideosink->format =
- gst_sdlvideosink_get_sdl_from_fourcc (sdlvideosink, format);
+ gst_sdlvideosink_get_sdl_from_fourcc (sdlvideosink, format);
gst_structure_get_int (structure, "width", &sdlvideosink->width);
gst_structure_get_int (structure, "height", &sdlvideosink->height);
- if (!sdlvideosink->format || !gst_sdlvideosink_create(sdlvideosink))
+ if (!sdlvideosink->format || !gst_sdlvideosink_create (sdlvideosink))
return GST_PAD_LINK_REFUSED;
return GST_PAD_LINK_OK;
@@ -561,7 +537,7 @@ gst_sdlvideosink_sinkconnect (GstPad *pad,
static void
-gst_sdlvideosink_chain (GstPad *pad, GstData *_data)
+gst_sdlvideosink_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstSDLVideoSink *sdlvideosink;
@@ -581,7 +557,7 @@ gst_sdlvideosink_chain (GstPad *pad, GstData *_data)
case GST_EVENT_DISCONTINUOUS:
offset = GST_EVENT_DISCONT_OFFSET (event, 0).value;
/*gst_clock_handle_discont (sdlvideosink->clock,
- (guint64) GST_EVENT_DISCONT_OFFSET (event, 0).value);*/
+ (guint64) GST_EVENT_DISCONT_OFFSET (event, 0).value); */
break;
default:
gst_pad_event_default (pad, event);
@@ -596,61 +572,59 @@ gst_sdlvideosink_chain (GstPad *pad, GstData *_data)
}
if (GST_BUFFER_DATA (buf) != sdlvideosink->overlay->pixels[0]) {
- if (!gst_sdlvideosink_lock(sdlvideosink)) {
+ if (!gst_sdlvideosink_lock (sdlvideosink)) {
return;
}
/* buf->yuv - FIXME: bufferpool! */
if (sdlvideosink->format == SDL_IYUV_OVERLAY ||
- sdlvideosink->format == SDL_YV12_OVERLAY)
- {
+ sdlvideosink->format == SDL_YV12_OVERLAY) {
memcpy (sdlvideosink->overlay->pixels[0], GST_BUFFER_DATA (buf),
- sdlvideosink->width * sdlvideosink->height);
+ sdlvideosink->width * sdlvideosink->height);
memcpy (sdlvideosink->overlay->pixels[1],
- GST_BUFFER_DATA (buf) + sdlvideosink->width*sdlvideosink->height,
- sdlvideosink->width * sdlvideosink->height / 4);
+ GST_BUFFER_DATA (buf) + sdlvideosink->width * sdlvideosink->height,
+ sdlvideosink->width * sdlvideosink->height / 4);
memcpy (sdlvideosink->overlay->pixels[2],
- GST_BUFFER_DATA (buf) + sdlvideosink->width*sdlvideosink->height*5/4,
- sdlvideosink->width * sdlvideosink->height / 4);
+ GST_BUFFER_DATA (buf) +
+ sdlvideosink->width * sdlvideosink->height * 5 / 4,
+ sdlvideosink->width * sdlvideosink->height / 4);
} else {
memcpy (sdlvideosink->overlay->pixels[0], GST_BUFFER_DATA (buf),
- sdlvideosink->width * sdlvideosink->height * 2);
+ sdlvideosink->width * sdlvideosink->height * 2);
}
- gst_sdlvideosink_unlock(sdlvideosink);
+ gst_sdlvideosink_unlock (sdlvideosink);
}
- gst_buffer_unref(buf);
+ gst_buffer_unref (buf);
/* Show, baby, show! */
- SDL_DisplayYUVOverlay(sdlvideosink->overlay, &(sdlvideosink->rect));
+ SDL_DisplayYUVOverlay (sdlvideosink->overlay, &(sdlvideosink->rect));
- while (SDL_PollEvent(&sdl_event))
- {
- switch(sdl_event.type)
- {
+ while (SDL_PollEvent (&sdl_event)) {
+ switch (sdl_event.type) {
case SDL_VIDEORESIZE:
- /* create a SDL window of the size requested by the user */
- GST_VIDEOSINK_WIDTH (sdlvideosink) = sdl_event.resize.w;
- GST_VIDEOSINK_HEIGHT (sdlvideosink) = sdl_event.resize.h;
- gst_sdlvideosink_create(sdlvideosink);
- break;
+ /* create a SDL window of the size requested by the user */
+ GST_VIDEOSINK_WIDTH (sdlvideosink) = sdl_event.resize.w;
+ GST_VIDEOSINK_HEIGHT (sdlvideosink) = sdl_event.resize.h;
+ gst_sdlvideosink_create (sdlvideosink);
+ break;
}
}
}
static void
-gst_sdlvideosink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_sdlvideosink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstSDLVideoSink *sdlvideosink;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_SDLVIDEOSINK (object));
- sdlvideosink = GST_SDLVIDEOSINK(object);
+ sdlvideosink = GST_SDLVIDEOSINK (object);
- switch (prop_id)
- {
+ switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -659,13 +633,14 @@ gst_sdlvideosink_set_property (GObject *object, guint prop_id, const GValue *val
static void
-gst_sdlvideosink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_sdlvideosink_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstSDLVideoSink *sdlvideosink;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_SDLVIDEOSINK (object));
- sdlvideosink = GST_SDLVIDEOSINK(object);
+ sdlvideosink = GST_SDLVIDEOSINK (object);
switch (prop_id) {
default:
@@ -676,17 +651,17 @@ gst_sdlvideosink_get_property (GObject *object, guint prop_id, GValue *value, GP
static GstElementStateReturn
-gst_sdlvideosink_change_state (GstElement *element)
+gst_sdlvideosink_change_state (GstElement * element)
{
GstSDLVideoSink *sdlvideosink;
+
g_return_val_if_fail (GST_IS_SDLVIDEOSINK (element), GST_STATE_FAILURE);
- sdlvideosink = GST_SDLVIDEOSINK(element);
+ sdlvideosink = GST_SDLVIDEOSINK (element);
- switch (GST_STATE_TRANSITION (element))
- {
+ switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
if (!gst_sdlvideosink_initsdl (sdlvideosink))
- return GST_STATE_FAILURE;
+ return GST_STATE_FAILURE;
GST_FLAG_SET (sdlvideosink, GST_SDLVIDEOSINK_OPEN);
break;
case GST_STATE_PAUSED_TO_READY:
@@ -696,7 +671,7 @@ gst_sdlvideosink_change_state (GstElement *element)
gst_sdlvideosink_deinitsdl (sdlvideosink);
GST_FLAG_UNSET (sdlvideosink, GST_SDLVIDEOSINK_OPEN);
break;
- default: /* do nothing */
+ default: /* do nothing */
break;
}
@@ -708,25 +683,20 @@ gst_sdlvideosink_change_state (GstElement *element)
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
/* Loading the library containing GstVideoSink, our parent object */
if (!gst_library_load ("gstvideo"))
return FALSE;
- if (!gst_element_register (plugin, "sdlvideosink", GST_RANK_NONE, GST_TYPE_SDLVIDEOSINK))
+ if (!gst_element_register (plugin, "sdlvideosink", GST_RANK_NONE,
+ GST_TYPE_SDLVIDEOSINK))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "sdlvideosink",
- "SDL Video Sink",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "sdlvideosink",
+ "SDL Video Sink", plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
diff --git a/ext/sdl/sdlvideosink.h b/ext/sdl/sdlvideosink.h
index ad682385..5c42abc4 100644
--- a/ext/sdl/sdlvideosink.h
+++ b/ext/sdl/sdlvideosink.h
@@ -25,7 +25,6 @@
#include <SDL.h>
G_BEGIN_DECLS
-
#define GST_TYPE_SDLVIDEOSINK \
(gst_sdlvideosink_get_type())
#define GST_SDLVIDEOSINK(obj) \
@@ -36,9 +35,9 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SDLVIDEOSINK))
#define GST_IS_SDLVIDEOSINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SDLVIDEOSINK))
-
-typedef enum {
- GST_SDLVIDEOSINK_OPEN = GST_ELEMENT_FLAG_LAST,
+ typedef enum
+{
+ GST_SDLVIDEOSINK_OPEN = GST_ELEMENT_FLAG_LAST,
GST_SDLVIDEOSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
} GstSDLVideoSinkFlags;
@@ -46,11 +45,12 @@ typedef enum {
typedef struct _GstSDLVideoSink GstSDLVideoSink;
typedef struct _GstSDLVideoSinkClass GstSDLVideoSinkClass;
-struct _GstSDLVideoSink {
+struct _GstSDLVideoSink
+{
GstVideoSink videosink;
guint32 format;
- gint width, height; /* the size of the incoming YUV stream */
+ gint width, height; /* the size of the incoming YUV stream */
unsigned long xwindow_id;
gboolean init;
@@ -62,13 +62,13 @@ struct _GstSDLVideoSink {
GMutex *lock;
};
-struct _GstSDLVideoSinkClass {
+struct _GstSDLVideoSinkClass
+{
GstVideoSinkClass parent_class;
};
-GType gst_sdlsink_get_type(void);
+GType gst_sdlsink_get_type (void);
G_END_DECLS
-
#endif /* __GST_SDLVIDEOSINK_H__ */
diff --git a/ext/shout/gstshout.c b/ext/shout/gstshout.c
index 0a8ee186..3deb8cc6 100644
--- a/ext/shout/gstshout.c
+++ b/ext/shout/gstshout.c
@@ -41,52 +41,54 @@ static char *SHOUT_ERRORS[] = {
};
/* IcecastSend signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
- ARG_IP, /* the ip of the server */
- ARG_PORT, /* the encoder port number on the server */
- ARG_PASSWORD, /* the encoder password on the server */
- ARG_PUBLIC, /* is this stream public? */
- ARG_NAME, /* Name of the stream */
- ARG_DESCRIPTION, /* Description of the stream */
- ARG_GENRE, /* Genre of the stream */
- ARG_MOUNT, /* mountpoint of stream (icecast only) */
- ARG_DUMPFILE, /* Dumpfile on the server for this stream (icecast only) */
- ARG_ICY, /* use icy headers for login? (for use with shoutcast) */
- ARG_AIM, /* AIM number (shoutcast only) */
- ARG_ICQ, /* ICQ number (shoutcast only) */
- ARG_IRC, /* IRC server (shoutcast only) */
+ ARG_IP, /* the ip of the server */
+ ARG_PORT, /* the encoder port number on the server */
+ ARG_PASSWORD, /* the encoder password on the server */
+ ARG_PUBLIC, /* is this stream public? */
+ ARG_NAME, /* Name of the stream */
+ ARG_DESCRIPTION, /* Description of the stream */
+ ARG_GENRE, /* Genre of the stream */
+ ARG_MOUNT, /* mountpoint of stream (icecast only) */
+ ARG_DUMPFILE, /* Dumpfile on the server for this stream (icecast only) */
+ ARG_ICY, /* use icy headers for login? (for use with shoutcast) */
+ ARG_AIM, /* AIM number (shoutcast only) */
+ ARG_ICQ, /* ICQ number (shoutcast only) */
+ ARG_IRC, /* IRC server (shoutcast only) */
};
static GstStaticPadTemplate sink_template_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/mpeg, "
- "mpegversion = (int) 1, "
- "layer = (int) [ 1, 3 ]"
- )
-);
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/mpeg, "
+ "mpegversion = (int) 1, " "layer = (int) [ 1, 3 ]")
+ );
-static void gst_icecastsend_class_init (GstIcecastSendClass *klass);
-static void gst_icecastsend_base_init (GstIcecastSendClass *klass);
-static void gst_icecastsend_init (GstIcecastSend *icecastsend);
+static void gst_icecastsend_class_init (GstIcecastSendClass * klass);
+static void gst_icecastsend_base_init (GstIcecastSendClass * klass);
+static void gst_icecastsend_init (GstIcecastSend * icecastsend);
-static void gst_icecastsend_chain (GstPad *pad, GstData *_data);
+static void gst_icecastsend_chain (GstPad * pad, GstData * _data);
-static void gst_icecastsend_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_icecastsend_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void gst_icecastsend_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_icecastsend_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static
- GstElementStateReturn gst_icecastsend_change_state (GstElement *element);
+static
+ GstElementStateReturn gst_icecastsend_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_icecastsend_signals[LAST_SIGNAL] = { 0 }; */
GType
@@ -102,87 +104,63 @@ gst_icecastsend_get_type (void)
sizeof (GstIcecastSend), 0,
(GInstanceInitFunc) gst_icecastsend_init,
};
- icecastsend_type = g_type_register_static(GST_TYPE_ELEMENT, "GstIcecastSend", &icecastsend_info, 0);
+ icecastsend_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstIcecastSend",
+ &icecastsend_info, 0);
}
return icecastsend_type;
}
static void
-gst_icecastsend_base_init (GstIcecastSendClass *klass)
+gst_icecastsend_base_init (GstIcecastSendClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&sink_template_factory));
+ gst_static_pad_template_get (&sink_template_factory));
gst_element_class_set_details (element_class, &icecastsend_details);
}
static void
-gst_icecastsend_class_init (GstIcecastSendClass *klass)
+gst_icecastsend_class_init (GstIcecastSendClass * 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);
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_IP,
- g_param_spec_string("ip","ip","ip",
- NULL, G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_PORT,
- g_param_spec_int("port","port","port",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_IP, g_param_spec_string ("ip", "ip", "ip", NULL, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PORT, g_param_spec_int ("port", "port", "port", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_PASSWORD,
- g_param_spec_string("password","password","password",
- NULL, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PASSWORD, g_param_spec_string ("password", "password", "password", NULL, G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_PUBLIC,
- g_param_spec_boolean("public","public","public",
- TRUE, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PUBLIC, g_param_spec_boolean ("public", "public", "public", TRUE, G_PARAM_READWRITE)); /* CHECKME */
/* metadata */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_NAME,
- g_param_spec_string("name","name","name",
- NULL, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NAME, g_param_spec_string ("name", "name", "name", NULL, G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_DESCRIPTION,
- g_param_spec_string("description","description","description",
- NULL, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DESCRIPTION, g_param_spec_string ("description", "description", "description", NULL, G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_GENRE,
- g_param_spec_string("genre","genre","genre",
- NULL, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_GENRE, g_param_spec_string ("genre", "genre", "genre", NULL, G_PARAM_READWRITE)); /* CHECKME */
/* icecast only */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_MOUNT,
- g_param_spec_string("mount","mount","mount",
- NULL, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MOUNT, g_param_spec_string ("mount", "mount", "mount", NULL, G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_DUMPFILE,
- g_param_spec_string("dumpfile","dumpfile","dumpfile",
- NULL, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMPFILE, g_param_spec_string ("dumpfile", "dumpfile", "dumpfile", NULL, G_PARAM_READWRITE)); /* CHECKME */
/* shoutcast only */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_ICY,
- g_param_spec_boolean("icy","icy","icy",
- FALSE, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ICY, g_param_spec_boolean ("icy", "icy", "icy", FALSE, G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_AIM,
- g_param_spec_string("aim","aim","aim",
- NULL, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_AIM, g_param_spec_string ("aim", "aim", "aim", NULL, G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_ICQ,
- g_param_spec_string("icq","icq","icq",
- NULL, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ICQ, g_param_spec_string ("icq", "icq", "icq", NULL, G_PARAM_READWRITE)); /* CHECKME */
+
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_IRC, g_param_spec_string ("irc", "irc", "irc", NULL, G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_IRC,
- g_param_spec_string("irc","irc","irc",
- NULL, G_PARAM_READWRITE)); /* CHECKME */
-
gobject_class->set_property = gst_icecastsend_set_property;
gobject_class->get_property = gst_icecastsend_get_property;
@@ -190,14 +168,15 @@ gst_icecastsend_class_init (GstIcecastSendClass *klass)
}
static void
-gst_icecastsend_init (GstIcecastSend *icecastsend)
+gst_icecastsend_init (GstIcecastSend * icecastsend)
{
GstElementClass *klass = GST_ELEMENT_GET_CLASS (icecastsend);
-
- icecastsend->sinkpad = gst_pad_new_from_template (
- gst_element_class_get_pad_template (klass, "sink"), "sink");
- gst_element_add_pad(GST_ELEMENT(icecastsend),icecastsend->sinkpad);
- gst_pad_set_chain_function(icecastsend->sinkpad,gst_icecastsend_chain);
+
+ icecastsend->sinkpad =
+ gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
+ "sink"), "sink");
+ gst_element_add_pad (GST_ELEMENT (icecastsend), icecastsend->sinkpad);
+ gst_pad_set_chain_function (icecastsend->sinkpad, gst_icecastsend_chain);
icecastsend->ip = g_strdup ("127.0.0.1");
icecastsend->port = 8000;
@@ -215,15 +194,15 @@ gst_icecastsend_init (GstIcecastSend *icecastsend)
}
static void
-gst_icecastsend_chain (GstPad *pad, GstData *_data)
+gst_icecastsend_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstIcecastSend *icecastsend;
glong ret;
- 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);
icecastsend = GST_ICECASTSEND (GST_OBJECT_PARENT (pad));
@@ -231,7 +210,7 @@ gst_icecastsend_chain (GstPad *pad, GstData *_data)
g_return_if_fail (GST_IS_ICECASTSEND (icecastsend));
ret = shout_send_data (&icecastsend->conn, GST_BUFFER_DATA (buf),
- GST_BUFFER_SIZE (buf));
+ GST_BUFFER_SIZE (buf));
if (!ret) {
g_warning ("send error: %i...\n", icecastsend->conn.error);
}
@@ -242,19 +221,20 @@ gst_icecastsend_chain (GstPad *pad, GstData *_data)
}
static void
-gst_icecastsend_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_icecastsend_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstIcecastSend *icecastsend;
- g_return_if_fail(GST_IS_ICECASTSEND(object));
- icecastsend = GST_ICECASTSEND(object);
+ g_return_if_fail (GST_IS_ICECASTSEND (object));
+ icecastsend = GST_ICECASTSEND (object);
switch (prop_id) {
case ARG_IP:
if (icecastsend->ip)
g_free (icecastsend->ip);
icecastsend->ip = g_strdup (g_value_get_string (value));
- break;
+ break;
case ARG_PORT:
icecastsend->port = g_value_get_int (value);
break;
@@ -264,58 +244,58 @@ gst_icecastsend_set_property (GObject *object, guint prop_id, const GValue *valu
icecastsend->password = g_strdup (g_value_get_string (value));
break;
- case ARG_PUBLIC: /* is this stream public? */
- icecastsend->public=g_value_get_boolean (value);
+ case ARG_PUBLIC: /* is this stream public? */
+ icecastsend->public = g_value_get_boolean (value);
break;
- case ARG_NAME: /* Name of the stream */
+ case ARG_NAME: /* Name of the stream */
if (icecastsend->name)
g_free (icecastsend->name);
icecastsend->name = g_strdup (g_value_get_string (value));
break;
- case ARG_DESCRIPTION: /* Description of the stream */
+ case ARG_DESCRIPTION: /* Description of the stream */
if (icecastsend->description)
g_free (icecastsend->description);
icecastsend->description = g_strdup (g_value_get_string (value));
break;
- case ARG_GENRE: /* Genre of the stream */
+ case ARG_GENRE: /* Genre of the stream */
if (icecastsend->genre)
g_free (icecastsend->genre);
icecastsend->genre = g_strdup (g_value_get_string (value));
break;
- case ARG_MOUNT: /* mountpoint of stream (icecast only) */
+ case ARG_MOUNT: /* mountpoint of stream (icecast only) */
if (icecastsend->mount)
g_free (icecastsend->mount);
icecastsend->mount = g_strdup (g_value_get_string (value));
break;
- case ARG_DUMPFILE: /* Dumpfile on the server for this stream (icecast only) */
+ case ARG_DUMPFILE: /* Dumpfile on the server for this stream (icecast only) */
if (icecastsend->dumpfile)
g_free (icecastsend->dumpfile);
icecastsend->dumpfile = g_strdup (g_value_get_string (value));
break;
- case ARG_ICY: /* use icy headers for login? (for use with shoutcast) */
+ case ARG_ICY: /* use icy headers for login? (for use with shoutcast) */
icecastsend->icy = g_value_get_boolean (value);
break;
- case ARG_AIM: /* AIM number (shoutcast only) */
+ case ARG_AIM: /* AIM number (shoutcast only) */
if (icecastsend->aim)
g_free (icecastsend->aim);
icecastsend->aim = g_strdup (g_value_get_string (value));
break;
- case ARG_ICQ: /* ICQ number (shoutcast only) */
+ case ARG_ICQ: /* ICQ number (shoutcast only) */
if (icecastsend->icq)
g_free (icecastsend->icq);
icecastsend->icq = g_strdup (g_value_get_string (value));
break;
- case ARG_IRC: /* IRC server (shoutcast only) */
+ case ARG_IRC: /* IRC server (shoutcast only) */
if (icecastsend->irc)
g_free (icecastsend->irc);
icecastsend->irc = g_strdup (g_value_get_string (value));
@@ -327,13 +307,14 @@ gst_icecastsend_set_property (GObject *object, guint prop_id, const GValue *valu
}
static void
-gst_icecastsend_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_icecastsend_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstIcecastSend *icecastsend;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_ICECASTSEND(object));
- icecastsend = GST_ICECASTSEND(object);
+ g_return_if_fail (GST_IS_ICECASTSEND (object));
+ icecastsend = GST_ICECASTSEND (object);
switch (prop_id) {
case ARG_IP:
@@ -345,43 +326,43 @@ gst_icecastsend_get_property (GObject *object, guint prop_id, GValue *value, GPa
case ARG_PASSWORD:
g_value_set_string (value, icecastsend->password);
break;
- case ARG_PUBLIC: /* is this stream public? */
+ case ARG_PUBLIC: /* is this stream public? */
g_value_set_boolean (value, icecastsend->public);
break;
- case ARG_NAME: /* Name of the stream */
+ case ARG_NAME: /* Name of the stream */
g_value_set_string (value, icecastsend->name);
break;
- case ARG_DESCRIPTION: /* Description of the stream */
+ case ARG_DESCRIPTION: /* Description of the stream */
g_value_set_string (value, icecastsend->description);
break;
- case ARG_GENRE: /* Genre of the stream */
+ case ARG_GENRE: /* Genre of the stream */
g_value_set_string (value, icecastsend->genre);
break;
- case ARG_MOUNT: /* mountpoint of stream (icecast only) */
+ case ARG_MOUNT: /* mountpoint of stream (icecast only) */
g_value_set_string (value, icecastsend->mount);
break;
- case ARG_DUMPFILE: /* Dumpfile on the server for this stream (icecast only) */
+ case ARG_DUMPFILE: /* Dumpfile on the server for this stream (icecast only) */
g_value_set_string (value, icecastsend->dumpfile);
break;
- case ARG_ICY: /* use icy headers for login? (for use with shoutcast) */
+ case ARG_ICY: /* use icy headers for login? (for use with shoutcast) */
g_value_set_boolean (value, icecastsend->icy);
break;
- case ARG_AIM: /* AIM number (shoutcast only) */
+ case ARG_AIM: /* AIM number (shoutcast only) */
g_value_set_string (value, icecastsend->aim);
break;
- case ARG_ICQ: /* ICQ number (shoutcast only) */
+ case ARG_ICQ: /* ICQ number (shoutcast only) */
g_value_set_string (value, icecastsend->icq);
break;
- case ARG_IRC: /* IRC server (shoutcast only) */
+ case ARG_IRC: /* IRC server (shoutcast only) */
g_value_set_string (value, icecastsend->irc);
break;
@@ -392,55 +373,53 @@ gst_icecastsend_get_property (GObject *object, guint prop_id, GValue *value, GPa
}
static GstElementStateReturn
-gst_icecastsend_change_state (GstElement *element)
+gst_icecastsend_change_state (GstElement * element)
{
GstIcecastSend *icecastsend;
g_return_val_if_fail (GST_IS_ICECASTSEND (element), GST_STATE_FAILURE);
- icecastsend = GST_ICECASTSEND(element);
+ icecastsend = GST_ICECASTSEND (element);
GST_DEBUG ("state pending %d", GST_STATE_PENDING (element));
/* if going down into NULL state, close the file if it's open */
switch (GST_STATE_TRANSITION (element)) {
- case GST_STATE_READY_TO_NULL:
- shout_init_connection (&icecastsend->conn);
-
- /* --- FIXME: shout requires an ip, and fails if it is given a host. */
- /* may want to put convert_to_ip(icecastsend->ip) here */
- icecastsend->conn.ip = icecastsend->ip;
- /* --- */
-
- icecastsend->conn.port = icecastsend->port;
- icecastsend->conn.password = icecastsend->password;
- icecastsend->conn.ispublic = icecastsend->public;
- icecastsend->conn.name = icecastsend->name;
- icecastsend->conn.description = icecastsend->description;
- icecastsend->conn.genre = icecastsend->genre;
- icecastsend->conn.mount = icecastsend->mount;
- icecastsend->conn.dumpfile = icecastsend->dumpfile;
- icecastsend->conn.icy_compat = icecastsend->icy;
- /* --- FIXME: libshout 1.0.5 doesn't have the two next fields */
- /* icecastsend->conn.aim = icecastsend->aim;
- icecastsend->conn.irc = icecastsend->irc;*/
-
- if (shout_connect (&icecastsend->conn)) {
- g_print ("connected to server...\n");
- }
- else {
- g_warning ("couldn't connect to server... (%i: %s)\n",
- icecastsend->conn.error,
- SHOUT_ERRORS[icecastsend->conn.error]);
- shout_disconnect (&icecastsend->conn);
- return GST_STATE_FAILURE;
- }
- break;
- case GST_STATE_PAUSED_TO_READY:
- shout_disconnect (&icecastsend->conn);
- break;
- default:
- break;
+ case GST_STATE_READY_TO_NULL:
+ shout_init_connection (&icecastsend->conn);
+
+ /* --- FIXME: shout requires an ip, and fails if it is given a host. */
+ /* may want to put convert_to_ip(icecastsend->ip) here */
+ icecastsend->conn.ip = icecastsend->ip;
+ /* --- */
+
+ icecastsend->conn.port = icecastsend->port;
+ icecastsend->conn.password = icecastsend->password;
+ icecastsend->conn.ispublic = icecastsend->public;
+ icecastsend->conn.name = icecastsend->name;
+ icecastsend->conn.description = icecastsend->description;
+ icecastsend->conn.genre = icecastsend->genre;
+ icecastsend->conn.mount = icecastsend->mount;
+ icecastsend->conn.dumpfile = icecastsend->dumpfile;
+ icecastsend->conn.icy_compat = icecastsend->icy;
+ /* --- FIXME: libshout 1.0.5 doesn't have the two next fields */
+ /* icecastsend->conn.aim = icecastsend->aim;
+ icecastsend->conn.irc = icecastsend->irc; */
+
+ if (shout_connect (&icecastsend->conn)) {
+ g_print ("connected to server...\n");
+ } else {
+ g_warning ("couldn't connect to server... (%i: %s)\n",
+ icecastsend->conn.error, SHOUT_ERRORS[icecastsend->conn.error]);
+ shout_disconnect (&icecastsend->conn);
+ return GST_STATE_FAILURE;
+ }
+ break;
+ case GST_STATE_PAUSED_TO_READY:
+ shout_disconnect (&icecastsend->conn);
+ break;
+ default:
+ break;
}
/* if we haven't failed already, give the parent class a chance to ;-) */
@@ -451,20 +430,15 @@ gst_icecastsend_change_state (GstElement *element)
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return gst_element_register (plugin, "icecastsend",
- GST_RANK_NONE, GST_TYPE_ICECASTSEND);
+ GST_RANK_NONE, GST_TYPE_ICECASTSEND);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "icecastsend",
- "Sends data to an icecast server using libshout",
- plugin_init,
- VERSION,
- "GPL",
- "libshout",
- "http://developer.icecast.org/libshout/"
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "icecastsend",
+ "Sends data to an icecast server using libshout",
+ plugin_init,
+ VERSION, "GPL", "libshout", "http://developer.icecast.org/libshout/")
diff --git a/ext/shout/gstshout.h b/ext/shout/gstshout.h
index 129fcba8..210b6b5d 100644
--- a/ext/shout/gstshout.h
+++ b/ext/shout/gstshout.h
@@ -25,40 +25,43 @@
#include <shout/shout.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
/* Definition of structure storing data for this element. */
-typedef struct _GstIcecastSend GstIcecastSend;
-struct _GstIcecastSend {
- GstElement element;
-
- GstPad *sinkpad,*srcpad;
-
- shout_conn_t conn;
-
- gchar *ip;
- guint port;
- gchar *password;
- gboolean public;
- gchar *name;
- gchar *description;
- gchar *genre;
- gchar *mount;
- gchar *dumpfile;
- gboolean icy;
- gchar *aim;
- gchar *icq;
- gchar *irc;
-
-};
+ typedef struct _GstIcecastSend GstIcecastSend;
+ struct _GstIcecastSend
+ {
+ GstElement element;
+
+ GstPad *sinkpad, *srcpad;
+
+ shout_conn_t conn;
+
+ gchar *ip;
+ guint port;
+ gchar *password;
+ gboolean public;
+ gchar *name;
+ gchar *description;
+ gchar *genre;
+ gchar *mount;
+ gchar *dumpfile;
+ gboolean icy;
+ gchar *aim;
+ gchar *icq;
+ gchar *irc;
+
+ };
/* Standard definition defining a class for this element. */
-typedef struct _GstIcecastSendClass GstIcecastSendClass;
-struct _GstIcecastSendClass {
- GstElementClass parent_class;
-};
+ typedef struct _GstIcecastSendClass GstIcecastSendClass;
+ struct _GstIcecastSendClass
+ {
+ GstElementClass parent_class;
+ };
/* Standard macros for defining types for this element. */
#define GST_TYPE_ICECASTSEND \
@@ -73,12 +76,12 @@ struct _GstIcecastSendClass {
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ICECASTSEND))
/* Standard function returning type information. */
-GType gst_icecastsend_get_type(void);
+ GType gst_icecastsend_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_ICECASTSEND_H__ */
+#endif /* __GST_ICECASTSEND_H__ */
diff --git a/ext/smoothwave/demo-osssrc.c b/ext/smoothwave/demo-osssrc.c
index 457900d7..c39bc72c 100644
--- a/ext/smoothwave/demo-osssrc.c
+++ b/ext/smoothwave/demo-osssrc.c
@@ -3,11 +3,13 @@
extern gboolean _gst_plugin_spew;
-gboolean idle_func(gpointer data);
+gboolean idle_func (gpointer data);
GtkWidget *drawingarea;
-int main(int argc,char *argv[]) {
+int
+main (int argc, char *argv[])
+{
GstElement *bin;
GstElementFactory *srcfactory;
GstElement *src;
@@ -16,46 +18,47 @@ int main(int argc,char *argv[]) {
GtkWidget *wave_widget;
GtkWidget *appwindow;
- gst_init(&argc,&argv);
- gst_plugin_load("libsmoothwave.so");
- gtk_init(&argc,&argv);
+ gst_init (&argc, &argv);
+ gst_plugin_load ("libsmoothwave.so");
+ gtk_init (&argc, &argv);
- bin = gst_pipeline_new("bin");
+ bin = gst_pipeline_new ("bin");
- srcfactory = gst_element_factory_find("sinesrc");
- g_return_val_if_fail(srcfactory != NULL, -1);
- wavefactory = gst_element_factory_find("smoothwave");
- g_return_val_if_fail(wavefactory != NULL, -1);
+ srcfactory = gst_element_factory_find ("sinesrc");
+ g_return_val_if_fail (srcfactory != NULL, -1);
+ wavefactory = gst_element_factory_find ("smoothwave");
+ g_return_val_if_fail (wavefactory != NULL, -1);
- src = gst_element_factory_create(srcfactory,"src");
+ src = gst_element_factory_create (srcfactory, "src");
//g_object_set(G_OBJECT(src),"bytes_per_read",(gulong)2048,NULL);
- wave = gst_element_factory_create(wavefactory,"wave");
- g_object_set(G_OBJECT(wave),"width",256,"height",100,NULL);
+ wave = gst_element_factory_create (wavefactory, "wave");
+ g_object_set (G_OBJECT (wave), "width", 256, "height", 100, NULL);
- gst_bin_add(GST_BIN(bin),GST_ELEMENT(src));
- gst_bin_add(GST_BIN(bin),GST_ELEMENT(wave));
+ gst_bin_add (GST_BIN (bin), GST_ELEMENT (src));
+ gst_bin_add (GST_BIN (bin), GST_ELEMENT (wave));
- gst_pad_link(gst_element_get_pad(src,"src"),
- gst_element_get_pad(wave,"sink"));
+ gst_pad_link (gst_element_get_pad (src, "src"),
+ gst_element_get_pad (wave, "sink"));
- appwindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- g_object_get(G_OBJECT(wave),"widget",&wave_widget,NULL);
- gtk_container_add(GTK_CONTAINER(appwindow), wave_widget);
- gtk_widget_show_all(appwindow);
+ appwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ g_object_get (G_OBJECT (wave), "widget", &wave_widget, NULL);
+ gtk_container_add (GTK_CONTAINER (appwindow), wave_widget);
+ gtk_widget_show_all (appwindow);
- gst_element_set_state(GST_ELEMENT(bin),GST_STATE_READY);
- gst_element_set_state(GST_ELEMENT(bin),GST_STATE_PLAYING);
+ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_READY);
+ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING);
- g_idle_add(idle_func,bin);
+ g_idle_add (idle_func, bin);
- gtk_main();
+ gtk_main ();
return 0;
}
-gboolean idle_func(gpointer data)
+gboolean
+idle_func (gpointer data)
{
- gst_bin_iterate(GST_BIN(data));
+ gst_bin_iterate (GST_BIN (data));
return TRUE;
}
diff --git a/ext/smoothwave/gstsmoothwave.c b/ext/smoothwave/gstsmoothwave.c
index 57c267e5..2abbdec2 100644
--- a/ext/smoothwave/gstsmoothwave.c
+++ b/ext/smoothwave/gstsmoothwave.c
@@ -25,37 +25,41 @@
#include "gstsmoothwave.h"
-static GstElementDetails gst_smoothwave_details = GST_ELEMENT_DETAILS (
- "Smooth waveform",
- "Visualization",
- "Fading grayscale waveform display",
- "Erik Walthinsen <omega@cse.ogi.edu>"
-);
+static GstElementDetails gst_smoothwave_details =
+GST_ELEMENT_DETAILS ("Smooth waveform",
+ "Visualization",
+ "Fading grayscale waveform display",
+ "Erik Walthinsen <omega@cse.ogi.edu>");
/* SmoothWave signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_WIDTH,
ARG_HEIGHT,
ARG_WIDGET,
};
-static void gst_smoothwave_base_init (gpointer g_class);
-static void gst_smoothwave_class_init (GstSmoothWaveClass *klass);
-static void gst_smoothwave_init (GstSmoothWave *smoothwave);
+static void gst_smoothwave_base_init (gpointer g_class);
+static void gst_smoothwave_class_init (GstSmoothWaveClass * klass);
+static void gst_smoothwave_init (GstSmoothWave * smoothwave);
-static void gst_smoothwave_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_smoothwave_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void gst_smoothwave_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_smoothwave_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_smoothwave_chain (GstPad *pad, GstData *_data);
+static void gst_smoothwave_chain (GstPad * pad, GstData * _data);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_smoothwave_signals[LAST_SIGNAL] = { 0 }; */
@@ -66,17 +70,19 @@ gst_smoothwave_get_type (void)
if (!smoothwave_type) {
static const GTypeInfo smoothwave_info = {
- sizeof(GstSmoothWaveClass),
+ sizeof (GstSmoothWaveClass),
gst_smoothwave_base_init,
NULL,
- (GClassInitFunc)gst_smoothwave_class_init,
+ (GClassInitFunc) gst_smoothwave_class_init,
NULL,
NULL,
- sizeof(GstSmoothWave),
+ sizeof (GstSmoothWave),
0,
- (GInstanceInitFunc)gst_smoothwave_init,
+ (GInstanceInitFunc) gst_smoothwave_init,
};
- smoothwave_type = g_type_register_static(GST_TYPE_ELEMENT, "GstSmoothWave", &smoothwave_info, 0);
+ smoothwave_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstSmoothWave",
+ &smoothwave_info, 0);
}
return smoothwave_type;
}
@@ -90,83 +96,77 @@ gst_smoothwave_base_init (gpointer g_class)
}
static void
-gst_smoothwave_class_init (GstSmoothWaveClass *klass)
+gst_smoothwave_class_init (GstSmoothWaveClass * 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);
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_WIDTH,
- g_param_spec_int("width","width","width",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_HEIGHT,
- g_param_spec_int("height","height","height",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_WIDGET,
- g_param_spec_object("widget","widget","widget",
- GTK_TYPE_WIDGET,G_PARAM_READABLE)); /* CHECKME! */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_WIDTH, g_param_spec_int ("width", "width", "width", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_HEIGHT, g_param_spec_int ("height", "height", "height", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_WIDGET, g_param_spec_object ("widget", "widget", "widget", GTK_TYPE_WIDGET, G_PARAM_READABLE)); /* CHECKME! */
gobject_class->set_property = gst_smoothwave_set_property;
gobject_class->get_property = gst_smoothwave_get_property;
}
static void
-gst_smoothwave_init (GstSmoothWave *smoothwave)
+gst_smoothwave_init (GstSmoothWave * smoothwave)
{
int i;
guint32 palette[256];
- smoothwave->sinkpad = gst_pad_new("sink",GST_PAD_SINK);
- gst_element_add_pad(GST_ELEMENT(smoothwave),smoothwave->sinkpad);
- gst_pad_set_chain_function(smoothwave->sinkpad,gst_smoothwave_chain);
- smoothwave->srcpad = gst_pad_new("src",GST_PAD_SRC);
- gst_element_add_pad(GST_ELEMENT(smoothwave),smoothwave->srcpad);
+ smoothwave->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
+ gst_element_add_pad (GST_ELEMENT (smoothwave), smoothwave->sinkpad);
+ gst_pad_set_chain_function (smoothwave->sinkpad, gst_smoothwave_chain);
+ smoothwave->srcpad = gst_pad_new ("src", GST_PAD_SRC);
+ gst_element_add_pad (GST_ELEMENT (smoothwave), smoothwave->srcpad);
/* smoothwave->meta = NULL; */
smoothwave->width = 512;
smoothwave->height = 256;
- gdk_rgb_init();
+ gdk_rgb_init ();
/* gtk_widget_set_default_colormap (gdk_rgb_get_cmap()); */
/* gtk_widget_set_default_visual (gdk_rgb_get_visual()); */
/* GST_DEBUG ("creating palette"); */
- for (i=0;i<256;i++)
+ for (i = 0; i < 256; i++)
palette[i] = (i << 16) || (i << 8);
/* GST_DEBUG ("creating cmap"); */
- smoothwave->cmap = gdk_rgb_cmap_new(palette,256);
+ smoothwave->cmap = gdk_rgb_cmap_new (palette, 256);
/* GST_DEBUG ("created cmap"); */
/* gtk_widget_set_default_colormap (smoothwave->cmap); */
- smoothwave->image = gtk_drawing_area_new();
- gtk_drawing_area_size(GTK_DRAWING_AREA(smoothwave->image),
- smoothwave->width,smoothwave->height);
- gtk_widget_show(smoothwave->image);
+ smoothwave->image = gtk_drawing_area_new ();
+ gtk_drawing_area_size (GTK_DRAWING_AREA (smoothwave->image),
+ smoothwave->width, smoothwave->height);
+ gtk_widget_show (smoothwave->image);
- smoothwave->imagebuffer = g_malloc(smoothwave->width*smoothwave->height);
- memset(smoothwave->imagebuffer,0,smoothwave->width*smoothwave->height);
+ smoothwave->imagebuffer = g_malloc (smoothwave->width * smoothwave->height);
+ memset (smoothwave->imagebuffer, 0, smoothwave->width * smoothwave->height);
}
static void
-gst_smoothwave_chain (GstPad *pad, GstData *_data)
+gst_smoothwave_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstSmoothWave *smoothwave;
gint16 *samples;
- gint samplecount,i;
+ gint samplecount, i;
register guint32 *ptr;
gint qheight;
- 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);
/* g_return_if_fail(GST_IS_BUFFER(buf)); */
- smoothwave = GST_SMOOTHWAVE(GST_OBJECT_PARENT (pad));
+ smoothwave = GST_SMOOTHWAVE (GST_OBJECT_PARENT (pad));
/* first deal with audio metadata */
#if 0
@@ -175,36 +175,35 @@ gst_smoothwave_chain (GstPad *pad, GstData *_data)
/* FIXME: need to unref the old metadata so it goes away */
}
/* we just make a copy of the pointer */
- smoothwave->meta = (MetaAudioRaw *)(buf->meta);
+ smoothwave->meta = (MetaAudioRaw *) (buf->meta);
/* FIXME: now we have to ref the metadata so it doesn't go away */
}
#endif
/* g_return_if_fail(smoothwave->meta != NULL); */
- samples = (gint16 *)GST_BUFFER_DATA(buf);
+ samples = (gint16 *) GST_BUFFER_DATA (buf);
/* samplecount = buf->datasize / (smoothwave->meta->channels * sizeof(gint16)); */
- samplecount = GST_BUFFER_SIZE(buf) / (2 * sizeof(gint16));
+ samplecount = GST_BUFFER_SIZE (buf) / (2 * sizeof (gint16));
- qheight = smoothwave->height/4;
+ qheight = smoothwave->height / 4;
/* GST_DEBUG ("traversing %d",smoothwave->width); */
- for (i=0;i<MAX(smoothwave->width,samplecount);i++) {
- gint16 y1 = (gint32)(samples[i*2] * qheight) / 32768 +
- qheight;
- gint16 y2 = (gint32)(samples[(i*2)+1] * qheight) / 32768 +
- (qheight*3);
- smoothwave->imagebuffer[y1*smoothwave->width + i] = 0xff;
- smoothwave->imagebuffer[y2*smoothwave->width + i] = 0xff;
+ for (i = 0; i < MAX (smoothwave->width, samplecount); i++) {
+ gint16 y1 = (gint32) (samples[i * 2] * qheight) / 32768 + qheight;
+ gint16 y2 = (gint32) (samples[(i * 2) + 1] * qheight) / 32768 +
+ (qheight * 3);
+ smoothwave->imagebuffer[y1 * smoothwave->width + i] = 0xff;
+ smoothwave->imagebuffer[y2 * smoothwave->width + i] = 0xff;
/* smoothwave->imagebuffer[i+(smoothwave->width*5)] = i; */
}
- ptr = (guint32 *)smoothwave->imagebuffer;
- for (i=0;i<(smoothwave->width*smoothwave->height)/4;i++) {
- if (*ptr){
+ ptr = (guint32 *) smoothwave->imagebuffer;
+ for (i = 0; i < (smoothwave->width * smoothwave->height) / 4; i++) {
+ if (*ptr) {
*ptr -= ((*ptr & 0xf0f0f0f0ul) >> 4) + ((*ptr & 0xe0e0e0e0ul) >> 5);
ptr++;
- }else{
+ } else {
ptr++;
}
}
@@ -223,40 +222,40 @@ gst_smoothwave_chain (GstPad *pad, GstData *_data)
GDK_RGB_DITHER_NONE,
smoothwave->imagebuffer,smoothwave->width,
smoothwave->cmap);*/
- gdk_draw_gray_image(smoothwave->image->window,
- smoothwave->image->style->fg_gc[GTK_STATE_NORMAL],
- 0,0,smoothwave->width,smoothwave->height,
- GDK_RGB_DITHER_NORMAL,
- smoothwave->imagebuffer,smoothwave->width);
+ gdk_draw_gray_image (smoothwave->image->window,
+ smoothwave->image->style->fg_gc[GTK_STATE_NORMAL],
+ 0, 0, smoothwave->width, smoothwave->height,
+ GDK_RGB_DITHER_NORMAL, smoothwave->imagebuffer, smoothwave->width);
/* gst_trace_add_entry(NULL,0,buf,"smoothwave: calculated smoothwave"); */
- gst_buffer_unref(buf);
+ gst_buffer_unref (buf);
}
static void
-gst_smoothwave_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_smoothwave_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstSmoothWave *smoothwave;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_SMOOTHWAVE(object));
- smoothwave = GST_SMOOTHWAVE(object);
+ g_return_if_fail (GST_IS_SMOOTHWAVE (object));
+ smoothwave = GST_SMOOTHWAVE (object);
switch (prop_id) {
case ARG_WIDTH:
smoothwave->width = g_value_get_int (value);
- gtk_drawing_area_size(GTK_DRAWING_AREA(smoothwave->image),
- smoothwave->width,smoothwave->height);
- gtk_widget_set_usize(GTK_WIDGET(smoothwave->image),
- smoothwave->width,smoothwave->height);
+ gtk_drawing_area_size (GTK_DRAWING_AREA (smoothwave->image),
+ smoothwave->width, smoothwave->height);
+ gtk_widget_set_usize (GTK_WIDGET (smoothwave->image),
+ smoothwave->width, smoothwave->height);
break;
case ARG_HEIGHT:
smoothwave->height = g_value_get_int (value);
- gtk_drawing_area_size(GTK_DRAWING_AREA(smoothwave->image),
- smoothwave->width,smoothwave->height);
- gtk_widget_set_usize(GTK_WIDGET(smoothwave->image),
- smoothwave->width,smoothwave->height);
+ gtk_drawing_area_size (GTK_DRAWING_AREA (smoothwave->image),
+ smoothwave->width, smoothwave->height);
+ gtk_widget_set_usize (GTK_WIDGET (smoothwave->image),
+ smoothwave->width, smoothwave->height);
break;
default:
break;
@@ -264,27 +263,28 @@ gst_smoothwave_set_property (GObject *object, guint prop_id, const GValue *value
}
static void
-gst_smoothwave_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_smoothwave_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstSmoothWave *smoothwave;
/* it's not null if we got it, but it might not be ours */
- smoothwave = GST_SMOOTHWAVE(object);
+ smoothwave = GST_SMOOTHWAVE (object);
switch (prop_id) {
- case ARG_WIDTH: {
+ case ARG_WIDTH:{
g_value_set_int (value, smoothwave->width);
break;
}
- case ARG_HEIGHT: {
+ case ARG_HEIGHT:{
g_value_set_int (value, smoothwave->height);
break;
}
- case ARG_WIDGET: {
+ case ARG_WIDGET:{
g_value_set_object (value, smoothwave->image);
break;
}
- default: {
+ default:{
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
@@ -294,21 +294,17 @@ gst_smoothwave_get_property (GObject *object, guint prop_id, GValue *value, GPar
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- if (!gst_element_register (plugin, "smoothwave", GST_RANK_NONE, GST_TYPE_SMOOTHWAVE))
+ if (!gst_element_register (plugin, "smoothwave", GST_RANK_NONE,
+ GST_TYPE_SMOOTHWAVE))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "smoothwave",
- "Fading greyscale waveform display",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "smoothwave",
+ "Fading greyscale waveform display",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
diff --git a/ext/smoothwave/gstsmoothwave.h b/ext/smoothwave/gstsmoothwave.h
index 87165131..df4d8763 100644
--- a/ext/smoothwave/gstsmoothwave.h
+++ b/ext/smoothwave/gstsmoothwave.h
@@ -26,8 +26,9 @@
#include <gtk/gtk.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_SMOOTHWAVE \
@@ -41,31 +42,33 @@ extern "C" {
#define GST_IS_SMOOTHWAVE_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SMOOTHWAVE))
-typedef struct _GstSmoothWave GstSmoothWave;
-typedef struct _GstSmoothWaveClass GstSmoothWaveClass;
+ typedef struct _GstSmoothWave GstSmoothWave;
+ typedef struct _GstSmoothWaveClass GstSmoothWaveClass;
-struct _GstSmoothWave {
- GstElement element;
+ struct _GstSmoothWave
+ {
+ GstElement element;
- GstPad *sinkpad,*srcpad;
+ GstPad *sinkpad, *srcpad;
- gint width,height;
+ gint width, height;
- GdkRgbCmap *cmap;
- GtkWidget *image;
- guchar *imagebuffer;
-};
+ GdkRgbCmap *cmap;
+ GtkWidget *image;
+ guchar *imagebuffer;
+ };
-struct _GstSmoothWaveClass {
- GstElementClass parent_class;
-};
+ struct _GstSmoothWaveClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_smoothwave_get_type(void);
+ GType gst_smoothwave_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_SMOOTHWAVE_H__ */
+#endif /* __GST_SMOOTHWAVE_H__ */
diff --git a/ext/snapshot/gstsnapshot.c b/ext/snapshot/gstsnapshot.c
index 7362d56c..66c505bc 100644
--- a/ext/snapshot/gstsnapshot.c
+++ b/ext/snapshot/gstsnapshot.c
@@ -37,58 +37,62 @@ static GstElementDetails snapshot_details = {
};
static GstStaticPadTemplate snapshot_src_factory =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_VIDEO_CAPS_BGR)
-);
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_BGR)
+ );
static GstStaticPadTemplate snapshot_sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_VIDEO_CAPS_BGR)
-);
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_BGR)
+ );
/* Snapshot signals and args */
-enum {
+enum
+{
/* FILL ME */
SNAPSHOT_SIGNAL,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_FRAME,
ARG_LOCATION
};
-static GType gst_snapshot_get_type (void);
-static void gst_snapshot_base_init (gpointer g_class);
-static void gst_snapshot_class_init (GstSnapshotClass *klass);
-static void gst_snapshot_init (GstSnapshot *snapshot);
+static GType gst_snapshot_get_type (void);
+static void gst_snapshot_base_init (gpointer g_class);
+static void gst_snapshot_class_init (GstSnapshotClass * klass);
+static void gst_snapshot_init (GstSnapshot * snapshot);
-static void gst_snapshot_chain (GstPad *pad, GstData *_data);
+static void gst_snapshot_chain (GstPad * pad, GstData * _data);
-static void gst_snapshot_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_snapshot_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
-static void snapshot_handler(GstElement *element);
+static void gst_snapshot_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_snapshot_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+static void snapshot_handler (GstElement * element);
static GstElementClass *parent_class = NULL;
-static guint gst_snapshot_signals[LAST_SIGNAL] = { 0 };
+static guint gst_snapshot_signals[LAST_SIGNAL] = { 0 };
-static void user_error_fn(png_structp png_ptr, png_const_charp error_msg)
+static void
+user_error_fn (png_structp png_ptr, png_const_charp error_msg)
{
- g_warning("%s", error_msg);
+ g_warning ("%s", error_msg);
}
-static void user_warning_fn(png_structp png_ptr, png_const_charp warning_msg)
+static void
+user_warning_fn (png_structp png_ptr, png_const_charp warning_msg)
{
- g_warning("%s", warning_msg);
+ g_warning ("%s", warning_msg);
}
GType
@@ -98,17 +102,19 @@ gst_snapshot_get_type (void)
if (!snapshot_type) {
static const GTypeInfo snapshot_info = {
- sizeof(GstSnapshotClass),
+ sizeof (GstSnapshotClass),
gst_snapshot_base_init,
NULL,
- (GClassInitFunc)gst_snapshot_class_init,
+ (GClassInitFunc) gst_snapshot_class_init,
NULL,
NULL,
- sizeof(GstSnapshot),
+ sizeof (GstSnapshot),
0,
- (GInstanceInitFunc)gst_snapshot_init,
+ (GInstanceInitFunc) gst_snapshot_init,
};
- snapshot_type = g_type_register_static(GST_TYPE_ELEMENT, "GstSnapshot", &snapshot_info, 0);
+ snapshot_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstSnapshot", &snapshot_info,
+ 0);
}
return snapshot_type;
}
@@ -118,34 +124,36 @@ gst_snapshot_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&snapshot_sink_factory));
- gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&snapshot_src_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&snapshot_sink_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&snapshot_src_factory));
gst_element_class_set_details (element_class, &snapshot_details);
}
static void
-gst_snapshot_class_init (GstSnapshotClass *klass)
+gst_snapshot_class_init (GstSnapshotClass * 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);
+
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FRAME,
+ g_param_spec_long ("frame", "frame", "frame",
+ 0, G_MAXLONG, 0, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATION,
+ g_param_spec_string ("location", "location", "location",
+ 0, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_FRAME,
- g_param_spec_long("frame","frame","frame",
- 0, G_MAXLONG, 0, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_LOCATION,
- g_param_spec_string("location","location","location",
- 0,G_PARAM_READWRITE));
-
gst_snapshot_signals[SNAPSHOT_SIGNAL] =
- g_signal_new("snapshot", G_TYPE_FROM_CLASS(klass),
- G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET(GstSnapshotClass, snapshot),
- NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("snapshot", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstSnapshotClass, snapshot),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
klass->snapshot = snapshot_handler;
@@ -154,17 +162,17 @@ gst_snapshot_class_init (GstSnapshotClass *klass)
}
static void
-snapshot_handler(GstElement *element)
+snapshot_handler (GstElement * element)
{
GstSnapshot *snapshot;
- snapshot = GST_SNAPSHOT( element );
- snapshot->snapshot_asked=TRUE;
+ snapshot = GST_SNAPSHOT (element);
+ snapshot->snapshot_asked = TRUE;
}
static gboolean
-gst_snapshot_sinkconnect (GstPad *pad, const GstCaps *caps)
+gst_snapshot_sinkconnect (GstPad * pad, const GstCaps * caps)
{
GstSnapshot *filter;
gdouble fps;
@@ -173,125 +181,129 @@ gst_snapshot_sinkconnect (GstPad *pad, const GstCaps *caps)
filter = GST_SNAPSHOT (gst_pad_get_parent (pad));
structure = gst_caps_get_structure (caps, 0);
- gst_structure_get_int (structure, "width", &filter->width);
- gst_structure_get_int (structure, "height", &filter->height);
- gst_structure_get_double (structure, "framerate", &fps);
- gst_structure_get_fourcc (structure, "format", &filter->format);
+ gst_structure_get_int (structure, "width", &filter->width);
+ gst_structure_get_int (structure, "height", &filter->height);
+ gst_structure_get_double (structure, "framerate", &fps);
+ gst_structure_get_fourcc (structure, "format", &filter->format);
filter->to_bpp = 24;
- filter->png_struct_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, (png_voidp)NULL, user_error_fn, user_warning_fn);
- if ( filter->png_struct_ptr == NULL )
- g_warning( "Failed to initialize png structure");
+ filter->png_struct_ptr =
+ png_create_write_struct (PNG_LIBPNG_VER_STRING, (png_voidp) NULL,
+ user_error_fn, user_warning_fn);
+ if (filter->png_struct_ptr == NULL)
+ g_warning ("Failed to initialize png structure");
+
+ filter->png_info_ptr = png_create_info_struct (filter->png_struct_ptr);
- filter->png_info_ptr = png_create_info_struct( filter->png_struct_ptr );
+ if (setjmp (filter->png_struct_ptr->jmpbuf))
+ png_destroy_write_struct (&filter->png_struct_ptr, &filter->png_info_ptr);
- if (setjmp( filter->png_struct_ptr->jmpbuf))
- png_destroy_write_struct(&filter->png_struct_ptr, &filter->png_info_ptr);
-
gst_pad_try_set_caps (filter->srcpad, caps);
return GST_PAD_LINK_OK;
}
static void
-gst_snapshot_init (GstSnapshot *snapshot)
+gst_snapshot_init (GstSnapshot * snapshot)
{
- snapshot->sinkpad = gst_pad_new_from_template (gst_static_pad_template_get (&snapshot_sink_factory), "sink");
+ snapshot->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&snapshot_sink_factory), "sink");
gst_pad_set_link_function (snapshot->sinkpad, gst_snapshot_sinkconnect);
gst_pad_set_chain_function (snapshot->sinkpad, gst_snapshot_chain);
gst_element_add_pad (GST_ELEMENT (snapshot), snapshot->sinkpad);
- snapshot->srcpad = gst_pad_new_from_template (gst_static_pad_template_get (&snapshot_src_factory), "src");
+ snapshot->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&snapshot_src_factory), "src");
gst_element_add_pad (GST_ELEMENT (snapshot), snapshot->srcpad);
snapshot->cur_frame = 0;
- snapshot->frame=-1;
- snapshot->snapshot_asked=FALSE;
+ snapshot->frame = -1;
+ snapshot->snapshot_asked = FALSE;
}
static void
-gst_snapshot_chain (GstPad *pad, GstData *_data)
+gst_snapshot_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstSnapshot *snapshot;
guchar *data;
gulong size;
gint i;
- png_byte *row_pointers[ MAX_HEIGHT ];
+ png_byte *row_pointers[MAX_HEIGHT];
FILE *fp;
- 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);
snapshot = GST_SNAPSHOT (GST_OBJECT_PARENT (pad));
- data = GST_BUFFER_DATA(buf);
- size = GST_BUFFER_SIZE(buf);
+ data = GST_BUFFER_DATA (buf);
+ size = GST_BUFFER_SIZE (buf);
- GST_DEBUG ("snapshot: have buffer of %d\n", GST_BUFFER_SIZE(buf));
+ GST_DEBUG ("snapshot: have buffer of %d\n", GST_BUFFER_SIZE (buf));
snapshot->cur_frame++;
if (snapshot->cur_frame == snapshot->frame ||
- snapshot->snapshot_asked == TRUE )
- {
+ snapshot->snapshot_asked == TRUE) {
snapshot->snapshot_asked = FALSE;
- GST_INFO ("dumpfile : %s\n", snapshot->location );
- fp = fopen( snapshot->location, "wb" );
- if ( fp == NULL )
- g_warning(" Can not open %s\n", snapshot->location );
- else
- {
- png_set_filter( snapshot->png_struct_ptr, 0, PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE );
- png_init_io(snapshot->png_struct_ptr, fp);
- png_set_compression_level( snapshot->png_struct_ptr, 9);
- png_set_IHDR(
- snapshot->png_struct_ptr,
- snapshot->png_info_ptr,
- snapshot->width,
- snapshot->height,
- snapshot->to_bpp/3,
- PNG_COLOR_TYPE_RGB,
- PNG_INTERLACE_NONE,
- PNG_COMPRESSION_TYPE_DEFAULT,
- PNG_FILTER_TYPE_DEFAULT
- );
-
- for ( i = 0; i < snapshot->height; i++ )
- row_pointers[i] = data + (snapshot->width * i * snapshot->to_bpp/8 );
-
- png_write_info( snapshot->png_struct_ptr, snapshot->png_info_ptr );
- png_write_image( snapshot->png_struct_ptr, row_pointers );
- png_write_end( snapshot->png_struct_ptr, NULL );
- png_destroy_info_struct ( snapshot->png_struct_ptr, &snapshot->png_info_ptr );
- png_destroy_write_struct( &snapshot->png_struct_ptr, (png_infopp)NULL );
- fclose( fp );
- g_signal_emit (G_OBJECT (snapshot),
- gst_snapshot_signals[SNAPSHOT_SIGNAL], 0);
+ GST_INFO ("dumpfile : %s\n", snapshot->location);
+ fp = fopen (snapshot->location, "wb");
+ if (fp == NULL)
+ g_warning (" Can not open %s\n", snapshot->location);
+ else {
+ png_set_filter (snapshot->png_struct_ptr, 0,
+ PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE);
+ png_init_io (snapshot->png_struct_ptr, fp);
+ png_set_compression_level (snapshot->png_struct_ptr, 9);
+ png_set_IHDR (snapshot->png_struct_ptr,
+ snapshot->png_info_ptr,
+ snapshot->width,
+ snapshot->height,
+ snapshot->to_bpp / 3,
+ PNG_COLOR_TYPE_RGB,
+ PNG_INTERLACE_NONE,
+ PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
+
+ for (i = 0; i < snapshot->height; i++)
+ row_pointers[i] = data + (snapshot->width * i * snapshot->to_bpp / 8);
+
+ png_write_info (snapshot->png_struct_ptr, snapshot->png_info_ptr);
+ png_write_image (snapshot->png_struct_ptr, row_pointers);
+ png_write_end (snapshot->png_struct_ptr, NULL);
+ png_destroy_info_struct (snapshot->png_struct_ptr,
+ &snapshot->png_info_ptr);
+ png_destroy_write_struct (&snapshot->png_struct_ptr, (png_infopp) NULL);
+ fclose (fp);
+ g_signal_emit (G_OBJECT (snapshot),
+ gst_snapshot_signals[SNAPSHOT_SIGNAL], 0);
}
}
- gst_pad_push(snapshot->srcpad,GST_DATA (buf ));
+ gst_pad_push (snapshot->srcpad, GST_DATA (buf));
}
static void
-gst_snapshot_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_snapshot_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstSnapshot *snapshot;
- g_return_if_fail(GST_IS_SNAPSHOT(object));
- snapshot = GST_SNAPSHOT(object);
+ g_return_if_fail (GST_IS_SNAPSHOT (object));
+ snapshot = GST_SNAPSHOT (object);
switch (prop_id) {
case ARG_LOCATION:
- snapshot->location = g_strdup(g_value_get_string (value));
+ snapshot->location = g_strdup (g_value_get_string (value));
break;
case ARG_FRAME:
- snapshot->frame = g_value_get_long(value);
+ snapshot->frame = g_value_get_long (value);
break;
default:
break;
@@ -299,19 +311,20 @@ gst_snapshot_set_property (GObject *object, guint prop_id, const GValue *value,
}
static void
-gst_snapshot_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_snapshot_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstSnapshot *snapshot;
- g_return_if_fail(GST_IS_SNAPSHOT(object));
- snapshot = GST_SNAPSHOT(object);
+ g_return_if_fail (GST_IS_SNAPSHOT (object));
+ snapshot = GST_SNAPSHOT (object);
switch (prop_id) {
case ARG_LOCATION:
- g_value_set_string(value, snapshot->location);
+ g_value_set_string (value, snapshot->location);
break;
case ARG_FRAME:
- g_value_set_long(value, snapshot->frame);
+ g_value_set_long (value, snapshot->frame);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -321,21 +334,17 @@ gst_snapshot_get_property (GObject *object, guint prop_id, GValue *value, GParam
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- if (!gst_element_register (plugin, "snapshot", GST_RANK_NONE, GST_TYPE_SNAPSHOT))
+ if (!gst_element_register (plugin, "snapshot", GST_RANK_NONE,
+ GST_TYPE_SNAPSHOT))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "snapshot",
- "Dump a frame to a png file",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "snapshot",
+ "Dump a frame to a png file",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
diff --git a/ext/snapshot/gstsnapshot.h b/ext/snapshot/gstsnapshot.h
index 0ca1fb93..23cca911 100644
--- a/ext/snapshot/gstsnapshot.h
+++ b/ext/snapshot/gstsnapshot.h
@@ -26,8 +26,9 @@
#include <png.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_SNAPSHOT \
@@ -41,36 +42,38 @@ extern "C" {
#define GST_IS_SNAPSHOT_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SNAPSHOT))
-typedef struct _GstSnapshot GstSnapshot;
-typedef struct _GstSnapshotClass GstSnapshotClass;
+ typedef struct _GstSnapshot GstSnapshot;
+ typedef struct _GstSnapshotClass GstSnapshotClass;
-struct _GstSnapshot {
- GstElement element;
+ struct _GstSnapshot
+ {
+ GstElement element;
- guint32 format;
- gint width;
- gint height;
- gint to_bpp;
- glong frame;
- glong cur_frame;
- const gchar *location;
- gboolean snapshot_asked;
+ guint32 format;
+ gint width;
+ gint height;
+ gint to_bpp;
+ glong frame;
+ glong cur_frame;
+ const gchar *location;
+ gboolean snapshot_asked;
- png_structp png_struct_ptr;
- png_infop png_info_ptr;
+ png_structp png_struct_ptr;
+ png_infop png_info_ptr;
- GstPad *sinkpad,*srcpad;
-};
+ GstPad *sinkpad, *srcpad;
+ };
-struct _GstSnapshotClass {
- GstElementClass parent_class;
+ struct _GstSnapshotClass
+ {
+ GstElementClass parent_class;
- void (*snapshot) (GstElement *elem);
-};
+ void (*snapshot) (GstElement * elem);
+ };
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_SNAPSHOT_H__ */
+#endif /* __GST_SNAPSHOT_H__ */
diff --git a/ext/sndfile/gstsf.c b/ext/sndfile/gstsf.c
index cc7e3d14..f9e88623 100644
--- a/ext/sndfile/gstsf.c
+++ b/ext/sndfile/gstsf.c
@@ -45,7 +45,8 @@ static GstElementDetails sfsink_details = {
"Andy Wingo <wingo at pobox dot com>",
};
-enum {
+enum
+{
ARG_0,
ARG_LOCATION,
ARG_MAJOR_TYPE,
@@ -54,41 +55,37 @@ enum {
ARG_CREATE_PADS
};
-static GstStaticPadTemplate sf_src_factory =
-GST_STATIC_PAD_TEMPLATE (
- "src%d",
- GST_PAD_SRC,
- GST_PAD_REQUEST,
- GST_STATIC_CAPS (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS)
-);
-
-static GstStaticPadTemplate sf_sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink%d",
- GST_PAD_SINK,
- GST_PAD_REQUEST,
- GST_STATIC_CAPS (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS)
-);
+static GstStaticPadTemplate sf_src_factory = GST_STATIC_PAD_TEMPLATE ("src%d",
+ GST_PAD_SRC,
+ GST_PAD_REQUEST,
+ GST_STATIC_CAPS (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS)
+ );
+
+static GstStaticPadTemplate sf_sink_factory = GST_STATIC_PAD_TEMPLATE ("sink%d",
+ GST_PAD_SINK,
+ GST_PAD_REQUEST,
+ GST_STATIC_CAPS (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS)
+ );
#define GST_TYPE_SF_MAJOR_TYPES (gst_sf_major_types_get_type())
static GType
-gst_sf_major_types_get_type (void)
+gst_sf_major_types_get_type (void)
{
static GType sf_major_types_type = 0;
static GEnumValue *sf_major_types = NULL;
-
- if (!sf_major_types_type)
- {
+
+ if (!sf_major_types_type) {
SF_FORMAT_INFO format_info;
- int k, count ;
+ int k, count;
- sf_command (NULL, SFC_GET_FORMAT_MAJOR_COUNT, &count, sizeof (int)) ;
+ sf_command (NULL, SFC_GET_FORMAT_MAJOR_COUNT, &count, sizeof (int));
sf_major_types = g_new0 (GEnumValue, count + 1);
-
- for (k = 0 ; k < count ; k++) {
- format_info.format = k ;
- sf_command (NULL, SFC_GET_FORMAT_MAJOR, &format_info, sizeof (format_info));
+
+ for (k = 0; k < count; k++) {
+ format_info.format = k;
+ sf_command (NULL, SFC_GET_FORMAT_MAJOR, &format_info,
+ sizeof (format_info));
sf_major_types[k].value = format_info.format;
sf_major_types[k].value_name = g_strdup (format_info.name);
sf_major_types[k].value_nick = g_strdup (format_info.extension);
@@ -96,75 +93,81 @@ gst_sf_major_types_get_type (void)
/* Irritatingly enough, there exist major_types with the same extension. Let's
just hope that sndfile gives us the list in alphabetical order, as it
currently does. */
- if (k > 0 && strcmp (sf_major_types[k].value_nick, sf_major_types[k-1].value_nick) == 0) {
- g_free (sf_major_types[k].value_nick);
- sf_major_types[k].value_nick = g_strconcat (sf_major_types[k-1].value_nick, "-",
- sf_major_types[k].value_name, NULL);
- g_strcanon (sf_major_types[k].value_nick,
- G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-", '-');
+ if (k > 0
+ && strcmp (sf_major_types[k].value_nick,
+ sf_major_types[k - 1].value_nick) == 0) {
+ g_free (sf_major_types[k].value_nick);
+ sf_major_types[k].value_nick =
+ g_strconcat (sf_major_types[k - 1].value_nick, "-",
+ sf_major_types[k].value_name, NULL);
+ g_strcanon (sf_major_types[k].value_nick,
+ G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-", '-');
}
}
- sf_major_types_type = g_enum_register_static ("GstSndfileMajorTypes", sf_major_types);
+ sf_major_types_type =
+ g_enum_register_static ("GstSndfileMajorTypes", sf_major_types);
}
return sf_major_types_type;
}
#define GST_TYPE_SF_MINOR_TYPES (gst_sf_minor_types_get_type())
static GType
-gst_sf_minor_types_get_type (void)
+gst_sf_minor_types_get_type (void)
{
static GType sf_minor_types_type = 0;
static GEnumValue *sf_minor_types = NULL;
-
- if (!sf_minor_types_type)
- {
+
+ if (!sf_minor_types_type) {
SF_FORMAT_INFO format_info;
- int k, count ;
+ int k, count;
- sf_command (NULL, SFC_GET_FORMAT_SUBTYPE_COUNT, &count, sizeof (int)) ;
+ sf_command (NULL, SFC_GET_FORMAT_SUBTYPE_COUNT, &count, sizeof (int));
sf_minor_types = g_new0 (GEnumValue, count + 1);
-
- for (k = 0 ; k < count ; k++) {
- format_info.format = k ;
- sf_command (NULL, SFC_GET_FORMAT_SUBTYPE, &format_info, sizeof (format_info));
+
+ for (k = 0; k < count; k++) {
+ format_info.format = k;
+ sf_command (NULL, SFC_GET_FORMAT_SUBTYPE, &format_info,
+ sizeof (format_info));
sf_minor_types[k].value = format_info.format;
sf_minor_types[k].value_name = g_strdup (format_info.name);
sf_minor_types[k].value_nick = g_ascii_strdown (format_info.name, -1);
- g_strcanon (sf_minor_types[k].value_nick, G_CSET_a_2_z G_CSET_DIGITS "-", '-');
+ g_strcanon (sf_minor_types[k].value_nick, G_CSET_a_2_z G_CSET_DIGITS "-",
+ '-');
}
- sf_minor_types_type = g_enum_register_static ("GstSndfileMinorTypes", sf_minor_types);
+ sf_minor_types_type =
+ g_enum_register_static ("GstSndfileMinorTypes", sf_minor_types);
}
return sf_minor_types_type;
}
-static void gst_sfsrc_base_init (gpointer g_class);
-static void gst_sfsink_base_init (gpointer g_class);
-static void gst_sf_class_init (GstSFClass *klass);
-static void gst_sf_init (GstSF *this);
-static void gst_sf_dispose (GObject *object);
-static void gst_sf_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_sf_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_sfsrc_base_init (gpointer g_class);
+static void gst_sfsink_base_init (gpointer g_class);
+static void gst_sf_class_init (GstSFClass * klass);
+static void gst_sf_init (GstSF * this);
+static void gst_sf_dispose (GObject * object);
+static void gst_sf_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_sf_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static GstClock* gst_sf_get_clock (GstElement *element);
-static void gst_sf_set_clock (GstElement *element, GstClock *clock);
-static GstPad* gst_sf_request_new_pad (GstElement *element, GstPadTemplate *templ,
- const gchar *unused);
-static void gst_sf_release_request_pad (GstElement *element, GstPad *pad);
-static GstElementStateReturn gst_sf_change_state (GstElement *element);
+static GstClock *gst_sf_get_clock (GstElement * element);
+static void gst_sf_set_clock (GstElement * element, GstClock * clock);
+static GstPad *gst_sf_request_new_pad (GstElement * element,
+ GstPadTemplate * templ, const gchar * unused);
+static void gst_sf_release_request_pad (GstElement * element, GstPad * pad);
+static GstElementStateReturn gst_sf_change_state (GstElement * element);
-static GstPadLinkReturn gst_sf_link (GstPad *pad, const GstCaps *caps);
+static GstPadLinkReturn gst_sf_link (GstPad * pad, const GstCaps * caps);
-static void gst_sf_loop (GstElement *element);
+static void gst_sf_loop (GstElement * element);
-static GstClockTime gst_sf_get_time (GstClock *clock, gpointer data);
+static GstClockTime gst_sf_get_time (GstClock * clock, gpointer data);
-static gboolean gst_sf_open_file (GstSF *this);
-static void gst_sf_close_file (GstSF *this);
+static gboolean gst_sf_open_file (GstSF * this);
+static void gst_sf_close_file (GstSF * this);
static GstElementClass *parent_class = NULL;
@@ -175,20 +178,20 @@ GST_DEBUG_CATEGORY_STATIC (gstsf_debug);
GST_CAT_LEVEL_LOG (gstsf_debug, GST_LEVEL_INFO, obj, __VA_ARGS__)
GType
-gst_sf_get_type (void)
+gst_sf_get_type (void)
{
static GType sf_type = 0;
if (!sf_type) {
static const GTypeInfo sf_info = {
- sizeof (GstSFClass), NULL,
+ sizeof (GstSFClass), NULL,
NULL,
- (GClassInitFunc)NULL, /* don't even initialize the class */
+ (GClassInitFunc) NULL, /* don't even initialize the class */
NULL,
NULL,
sizeof (GstSF),
0,
- (GInstanceInitFunc)NULL /* abstract base class */
+ (GInstanceInitFunc) NULL /* abstract base class */
};
sf_type = g_type_register_static (GST_TYPE_ELEMENT, "GstSF", &sf_info, 0);
}
@@ -196,7 +199,7 @@ gst_sf_get_type (void)
}
GType
-gst_sfsrc_get_type (void)
+gst_sfsrc_get_type (void)
{
static GType sfsrc_type = 0;
@@ -212,13 +215,14 @@ gst_sfsrc_get_type (void)
0,
(GInstanceInitFunc) gst_sf_init,
};
- sfsrc_type = g_type_register_static (GST_TYPE_SF, "GstSFSrc", &sfsrc_info, 0);
+ sfsrc_type =
+ g_type_register_static (GST_TYPE_SF, "GstSFSrc", &sfsrc_info, 0);
}
return sfsrc_type;
}
GType
-gst_sfsink_get_type (void)
+gst_sfsink_get_type (void)
{
static GType sfsink_type = 0;
@@ -234,7 +238,8 @@ gst_sfsink_get_type (void)
0,
(GInstanceInitFunc) gst_sf_init,
};
- sfsink_type = g_type_register_static (GST_TYPE_SF, "GstSFSink", &sfsink_info, 0);
+ sfsink_type =
+ g_type_register_static (GST_TYPE_SF, "GstSFSink", &sfsink_info, 0);
}
return sfsink_type;
}
@@ -244,7 +249,8 @@ gst_sfsrc_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&sf_src_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&sf_src_factory));
gst_element_class_set_details (element_class, &sfsrc_details);
}
@@ -253,44 +259,47 @@ gst_sfsink_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&sf_sink_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&sf_sink_factory));
gst_element_class_set_details (element_class, &sfsink_details);
}
static void
-gst_sf_class_init (GstSFClass *klass)
+gst_sf_class_init (GstSFClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GParamSpec *pspec;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
/* although this isn't really the parent class, that's ok; GstSF doesn't
override any methods */
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gst_element_class_install_std_props (gstelement_class, "location",
- ARG_LOCATION, G_PARAM_READWRITE, NULL);
+ ARG_LOCATION, G_PARAM_READWRITE, NULL);
pspec = g_param_spec_enum
- ("major-type", "Major type", "Major output type", GST_TYPE_SF_MAJOR_TYPES,
- SF_FORMAT_WAV, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
+ ("major-type", "Major type", "Major output type", GST_TYPE_SF_MAJOR_TYPES,
+ SF_FORMAT_WAV, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
g_object_class_install_property (gobject_class, ARG_MAJOR_TYPE, pspec);
pspec = g_param_spec_enum
- ("minor-type", "Minor type", "Minor output type", GST_TYPE_SF_MINOR_TYPES,
- SF_FORMAT_FLOAT, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
+ ("minor-type", "Minor type", "Minor output type", GST_TYPE_SF_MINOR_TYPES,
+ SF_FORMAT_FLOAT, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
g_object_class_install_property (gobject_class, ARG_MINOR_TYPE, pspec);
if (G_TYPE_FROM_CLASS (klass) == GST_TYPE_SFSRC) {
pspec = g_param_spec_boolean ("loop", "Loop?", "Loop the output?",
- FALSE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
+ FALSE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
g_object_class_install_property (gobject_class, ARG_LOOP, pspec);
- pspec = g_param_spec_boolean ("create-pads", "Create pads?", "Create one pad for each channel in the sound file?",
- TRUE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
+ pspec =
+ g_param_spec_boolean ("create-pads", "Create pads?",
+ "Create one pad for each channel in the sound file?", TRUE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
g_object_class_install_property (gobject_class, ARG_CREATE_PADS, pspec);
}
-
+
gobject_class->dispose = gst_sf_dispose;
gobject_class->set_property = gst_sf_set_property;
gobject_class->get_property = gst_sf_get_property;
@@ -302,8 +311,8 @@ gst_sf_class_init (GstSFClass *klass)
gstelement_class->release_pad = gst_sf_release_request_pad;
}
-static void
-gst_sf_init (GstSF *this)
+static void
+gst_sf_init (GstSF * this)
{
gst_element_set_loop_function (GST_ELEMENT (this), gst_sf_loop);
this->provided_clock = gst_audio_clock_new ("sfclock", gst_sf_get_time, this);
@@ -311,9 +320,9 @@ gst_sf_init (GstSF *this)
}
static void
-gst_sf_dispose (GObject *object)
+gst_sf_dispose (GObject * object)
{
- GstSF *this = (GstSF*)object;
+ GstSF *this = (GstSF *) object;
gst_object_unparent (GST_OBJECT (this->provided_clock));
@@ -321,24 +330,25 @@ gst_sf_dispose (GObject *object)
}
static void
-gst_sf_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_sf_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstSF *this = GST_SF (object);
switch (prop_id) {
case ARG_LOCATION:
if (GST_FLAG_IS_SET (object, GST_SF_OPEN))
- gst_sf_close_file (this);
+ gst_sf_close_file (this);
if (this->filename)
g_free (this->filename);
if (g_value_get_string (value))
- this->filename = g_strdup (g_value_get_string (value));
+ this->filename = g_strdup (g_value_get_string (value));
else
- this->filename = NULL;
+ this->filename = NULL;
if (this->filename)
- gst_sf_open_file (this);
+ gst_sf_open_file (this);
break;
case ARG_MAJOR_TYPE:
@@ -356,9 +366,10 @@ gst_sf_set_property (GObject *object, guint prop_id, const GValue *value, GParam
case ARG_CREATE_PADS:
this->create_pads = g_value_get_boolean (value);
if (this->file && this->create_pads) {
- int i;
- for (i=g_list_length (this->channels); i<this->numchannels; i++)
- gst_element_get_request_pad ((GstElement*)this, "src%d");
+ int i;
+
+ for (i = g_list_length (this->channels); i < this->numchannels; i++)
+ gst_element_get_request_pad ((GstElement *) this, "src%d");
}
break;
@@ -367,11 +378,12 @@ gst_sf_set_property (GObject *object, guint prop_id, const GValue *value, GParam
}
}
-static void
-gst_sf_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+static void
+gst_sf_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstSF *this = GST_SF (object);
-
+
switch (prop_id) {
case ARG_LOCATION:
g_value_set_string (value, this->filename);
@@ -399,8 +411,8 @@ gst_sf_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *
}
}
-static GstClock*
-gst_sf_get_clock (GstElement *element)
+static GstClock *
+gst_sf_get_clock (GstElement * element)
{
GstSF *this = GST_SF (element);
@@ -408,15 +420,15 @@ gst_sf_get_clock (GstElement *element)
}
static void
-gst_sf_set_clock (GstElement *element, GstClock *clock)
+gst_sf_set_clock (GstElement * element, GstClock * clock)
{
GstSF *this = GST_SF (element);
-
+
this->clock = clock;
}
-static GstClockTime
-gst_sf_get_time (GstClock *clock, gpointer data)
+static GstClockTime
+gst_sf_get_time (GstClock * clock, gpointer data)
{
GstSF *this = GST_SF (data);
@@ -424,7 +436,7 @@ gst_sf_get_time (GstClock *clock, gpointer data)
}
static GstElementStateReturn
-gst_sf_change_state (GstElement *element)
+gst_sf_change_state (GstElement * element)
{
GstSF *this = GST_SF (element);
@@ -437,13 +449,14 @@ gst_sf_change_state (GstElement *element)
gst_audio_clock_set_active (GST_AUDIO_CLOCK (this->provided_clock), TRUE);
break;
case GST_STATE_PLAYING_TO_PAUSED:
- gst_audio_clock_set_active (GST_AUDIO_CLOCK (this->provided_clock), FALSE);
+ gst_audio_clock_set_active (GST_AUDIO_CLOCK (this->provided_clock),
+ FALSE);
break;
case GST_STATE_PAUSED_TO_READY:
break;
case GST_STATE_READY_TO_NULL:
if (GST_FLAG_IS_SET (this, GST_SF_OPEN))
- gst_sf_close_file (this);
+ gst_sf_close_file (this);
break;
}
@@ -453,9 +466,9 @@ gst_sf_change_state (GstElement *element)
return GST_STATE_SUCCESS;
}
-static GstPad*
-gst_sf_request_new_pad (GstElement *element, GstPadTemplate *templ,
- const gchar *unused)
+static GstPad *
+gst_sf_request_new_pad (GstElement * element, GstPadTemplate * templ,
+ const gchar * unused)
{
gchar *name;
GstSF *this;
@@ -463,7 +476,7 @@ gst_sf_request_new_pad (GstElement *element, GstPadTemplate *templ,
this = GST_SF (element);
channel = g_new0 (GstSFChannel, 1);
-
+
if (templ->direction == GST_PAD_SINK) {
/* we have an SFSink */
name = g_strdup_printf ("sink%d", this->channelcount);
@@ -476,14 +489,14 @@ gst_sf_request_new_pad (GstElement *element, GstPadTemplate *templ,
/* we have an SFSrc */
name = g_strdup_printf ("src%d", this->channelcount);
}
-
+
channel->pad = gst_pad_new_from_template (templ, name);
gst_element_add_pad (GST_ELEMENT (this), channel->pad);
gst_pad_set_link_function (channel->pad, gst_sf_link);
-
+
this->channels = g_list_append (this->channels, channel);
this->channelcount++;
-
+
INFO_OBJ (element, "added pad %s\n", name);
g_free (name);
@@ -491,20 +504,21 @@ gst_sf_request_new_pad (GstElement *element, GstPadTemplate *templ,
}
static void
-gst_sf_release_request_pad (GstElement *element, GstPad *pad)
+gst_sf_release_request_pad (GstElement * element, GstPad * pad)
{
GstSF *this;
GstSFChannel *channel = NULL;
GList *l;
this = GST_SF (element);
-
+
if (GST_STATE (element) == GST_STATE_PLAYING) {
- g_warning ("You can't release a request pad if the element is PLAYING, sorry.");
+ g_warning
+ ("You can't release a request pad if the element is PLAYING, sorry.");
return;
}
- for (l=this->channels; l; l=l->next) {
+ for (l = this->channels; l; l = l->next) {
if (GST_SF_CHANNEL (l)->pad == pad) {
channel = GST_SF_CHANNEL (l);
break;
@@ -525,55 +539,58 @@ gst_sf_release_request_pad (GstElement *element, GstPad *pad)
}
static GstPadLinkReturn
-gst_sf_link (GstPad *pad, const GstCaps *caps)
+gst_sf_link (GstPad * pad, const GstCaps * caps)
{
- GstSF *this = (GstSF*)GST_OBJECT_PARENT (pad);
+ GstSF *this = (GstSF *) GST_OBJECT_PARENT (pad);
GstStructure *structure;
structure = gst_caps_get_structure (caps, 0);
-
- gst_structure_get_int (structure, "rate", &this->rate);
- gst_structure_get_int (structure, "buffer-frames", &this->buffer_frames);
+
+ gst_structure_get_int (structure, "rate", &this->rate);
+ gst_structure_get_int (structure, "buffer-frames", &this->buffer_frames);
INFO_OBJ (this, "linked pad %s:%s with fixed caps, rate=%d, frames=%d",
- GST_DEBUG_PAD_NAME (pad), this->rate, this->buffer_frames);
+ GST_DEBUG_PAD_NAME (pad), this->rate, this->buffer_frames);
if (this->numchannels) {
/* we can go ahead and allocate our buffer */
if (this->buffer)
g_free (this->buffer);
- this->buffer = g_malloc (this->numchannels * this->buffer_frames * sizeof (float));
- memset (this->buffer, 0, this->numchannels * this->buffer_frames * sizeof (float));
+ this->buffer =
+ g_malloc (this->numchannels * this->buffer_frames * sizeof (float));
+ memset (this->buffer, 0,
+ this->numchannels * this->buffer_frames * sizeof (float));
}
return GST_PAD_LINK_OK;
}
static gboolean
-gst_sf_open_file (GstSF *this)
+gst_sf_open_file (GstSF * this)
{
int mode;
SF_INFO info;
-
+
g_return_val_if_fail (!GST_FLAG_IS_SET (this, GST_SF_OPEN), FALSE);
this->time = 0;
if (!this->filename) {
GST_ELEMENT_ERROR (this, RESOURCE, NOT_FOUND,
- (_("No filename specified.")),
- (NULL));
+ (_("No filename specified.")), (NULL));
return FALSE;
}
-
+
if (GST_IS_SFSRC (this)) {
mode = SFM_READ;
info.format = 0;
} else {
if (!this->rate) {
- INFO_OBJ (this, "Not opening %s yet because caps are not set", this->filename);
+ INFO_OBJ (this, "Not opening %s yet because caps are not set",
+ this->filename);
return FALSE;
} else if (!this->numchannels) {
- INFO_OBJ (this, "Not opening %s yet because we have no input channels", this->filename);
+ INFO_OBJ (this, "Not opening %s yet because we have no input channels",
+ this->filename);
return FALSE;
}
@@ -584,12 +601,12 @@ gst_sf_open_file (GstSF *this)
info.format = this->format;
INFO_OBJ (this, "Opening %s with rate %d, %d channels, format 0x%x",
- this->filename, info.samplerate, info.channels, info.format);
+ this->filename, info.samplerate, info.channels, info.format);
if (!sf_format_check (&info)) {
GST_ELEMENT_ERROR (this, STREAM, ENCODE, (NULL),
- ("Input parameters (rate:%d, channels:%d, format:0x%x) invalid",
- info.samplerate, info.channels, info.format));
+ ("Input parameters (rate:%d, channels:%d, format:0x%x) invalid",
+ info.samplerate, info.channels, info.format));
return FALSE;
}
}
@@ -598,13 +615,14 @@ gst_sf_open_file (GstSF *this)
if (!this->file) {
GST_ELEMENT_ERROR (this, RESOURCE, OPEN_WRITE,
- (_("Could not open file \"%s\" for writing."), this->filename),
- ("soundfile error: %s", sf_strerror (NULL)));
+ (_("Could not open file \"%s\" for writing."), this->filename),
+ ("soundfile error: %s", sf_strerror (NULL)));
return FALSE;
}
if (GST_IS_SFSRC (this)) {
GList *l = NULL;
+
/* the number of channels in the file can be different than the number of
* pads */
this->numchannels = info.channels;
@@ -612,11 +630,12 @@ gst_sf_open_file (GstSF *this)
if (this->create_pads) {
int i;
- for (i=g_list_length (this->channels); i<this->numchannels; i++)
- gst_element_get_request_pad ((GstElement*)this, "src%d");
+
+ for (i = g_list_length (this->channels); i < this->numchannels; i++)
+ gst_element_get_request_pad ((GstElement *) this, "src%d");
}
-
- for (l=this->channels; l; l=l->next)
+
+ for (l = this->channels; l; l = l->next)
/* queue the need to set caps */
GST_SF_CHANNEL (l)->caps_set = FALSE;
}
@@ -627,7 +646,7 @@ gst_sf_open_file (GstSF *this)
}
static void
-gst_sf_close_file (GstSF *this)
+gst_sf_close_file (GstSF * this)
{
int err = 0;
@@ -637,8 +656,8 @@ gst_sf_close_file (GstSF *this)
if ((err = sf_close (this->file)))
GST_ELEMENT_ERROR (this, RESOURCE, CLOSE,
- ("Could not close file file \"%s\".", this->filename),
- ("soundfile error: %s", strerror (err)));
+ ("Could not close file file \"%s\".", this->filename),
+ ("soundfile error: %s", strerror (err)));
else
GST_FLAG_UNSET (this, GST_SF_OPEN);
@@ -648,16 +667,17 @@ gst_sf_close_file (GstSF *this)
this->buffer = NULL;
}
-static void
-gst_sf_loop (GstElement *element)
+static void
+gst_sf_loop (GstElement * element)
{
GstSF *this;
GList *l = NULL;
- this = (GstSF*)element;
-
+ this = (GstSF *) element;
+
if (this->channels == NULL) {
- GST_ELEMENT_ERROR (element, CORE, PAD, (NULL), ("You must connect at least one pad to sndfile elements."));
+ GST_ELEMENT_ERROR (element, CORE, PAD, (NULL),
+ ("You must connect at least one pad to sndfile elements."));
return;
}
@@ -674,15 +694,17 @@ gst_sf_loop (GstElement *element)
if (!GST_FLAG_IS_SET (this, GST_SF_OPEN))
if (!gst_sf_open_file (this))
- return; /* we've already set gst_element_error */
+ return; /* we've already set gst_element_error */
if (buffer_frames == 0) {
/* we have to set the caps later */
buffer_frames = this->buffer_frames = 1024;
}
if (buf == NULL) {
- buf = this->buffer = g_malloc (this->numchannels * this->buffer_frames * sizeof (float));
- memset (this->buffer, 0, this->numchannels * this->buffer_frames * sizeof (float));
+ buf = this->buffer =
+ g_malloc (this->numchannels * this->buffer_frames * sizeof (float));
+ memset (this->buffer, 0,
+ this->numchannels * this->buffer_frames * sizeof (float));
}
read = sf_readf_float (this->file, buf, buffer_frames);
@@ -690,49 +712,52 @@ gst_sf_loop (GstElement *element)
eos = 1;
if (read)
- for (i=0,l=this->channels; l; l=l->next,i++) {
- channel = GST_SF_CHANNEL (l);
-
- /* don't push on disconnected pads -- useful for ::create-pads=TRUE*/
- if (!GST_PAD_PEER (channel->pad))
- continue;
-
- if (!channel->caps_set) {
- GstCaps *caps = gst_caps_copy (GST_PAD_CAPS (GST_SF_CHANNEL (l)->pad));
- if (!caps)
- caps = gst_caps_copy
- (GST_PAD_TEMPLATE_CAPS (GST_PAD_PAD_TEMPLATE (GST_SF_CHANNEL (l)->pad)));
- gst_caps_set_simple (caps,
- "rate", G_TYPE_INT, this->rate,
- "buffer-frames", G_TYPE_INT, this->buffer_frames,
- NULL);
- if (!gst_pad_try_set_caps (GST_SF_CHANNEL (l)->pad, caps)) {
- GST_ELEMENT_ERROR (this, CORE, NEGOTIATION, (NULL),
- ("Opened file with sample rate %d, but could not set caps", this->rate));
- gst_sf_close_file (this);
- return;
- }
- channel->caps_set = TRUE;
- }
-
- out = gst_buffer_new_and_alloc (read * sizeof(float));
- data = (gfloat*)GST_BUFFER_DATA (out);
- for (j=0; j<read; j++)
- data[j] = buf[j * nchannels + i % nchannels];
- gst_pad_push (channel->pad, GST_DATA (out));
+ for (i = 0, l = this->channels; l; l = l->next, i++) {
+ channel = GST_SF_CHANNEL (l);
+
+ /* don't push on disconnected pads -- useful for ::create-pads=TRUE */
+ if (!GST_PAD_PEER (channel->pad))
+ continue;
+
+ if (!channel->caps_set) {
+ GstCaps *caps =
+ gst_caps_copy (GST_PAD_CAPS (GST_SF_CHANNEL (l)->pad));
+ if (!caps)
+ caps = gst_caps_copy
+ (GST_PAD_TEMPLATE_CAPS (GST_PAD_PAD_TEMPLATE (GST_SF_CHANNEL
+ (l)->pad)));
+ gst_caps_set_simple (caps, "rate", G_TYPE_INT, this->rate,
+ "buffer-frames", G_TYPE_INT, this->buffer_frames, NULL);
+ if (!gst_pad_try_set_caps (GST_SF_CHANNEL (l)->pad, caps)) {
+ GST_ELEMENT_ERROR (this, CORE, NEGOTIATION, (NULL),
+ ("Opened file with sample rate %d, but could not set caps",
+ this->rate));
+ gst_sf_close_file (this);
+ return;
+ }
+ channel->caps_set = TRUE;
+ }
+
+ out = gst_buffer_new_and_alloc (read * sizeof (float));
+ data = (gfloat *) GST_BUFFER_DATA (out);
+ for (j = 0; j < read; j++)
+ data[j] = buf[j * nchannels + i % nchannels];
+ gst_pad_push (channel->pad, GST_DATA (out));
}
this->time += read * (GST_SECOND / this->rate);
- gst_audio_clock_update_time ((GstAudioClock*)this->provided_clock, this->time);
+ gst_audio_clock_update_time ((GstAudioClock *) this->provided_clock,
+ this->time);
if (eos) {
if (this->loop) {
- sf_seek (this->file, (sf_count_t)0, SEEK_SET);
- eos = 0;
+ sf_seek (this->file, (sf_count_t) 0, SEEK_SET);
+ eos = 0;
} else {
- for (l=this->channels; l; l=l->next)
- gst_pad_push (GST_SF_CHANNEL (l)->pad, GST_DATA (gst_event_new (GST_EVENT_EOS)));
- gst_element_set_eos (element);
+ for (l = this->channels; l; l = l->next)
+ gst_pad_push (GST_SF_CHANNEL (l)->pad,
+ GST_DATA (gst_event_new (GST_EVENT_EOS)));
+ gst_element_set_eos (element);
}
}
} else {
@@ -751,63 +776,66 @@ gst_sf_loop (GstElement *element)
num_to_write = buffer_frames;
- INFO_OBJ (this, "looping, buffer_frames=%d, nchannels=%d", buffer_frames, nchannels);
+ INFO_OBJ (this, "looping, buffer_frames=%d, nchannels=%d", buffer_frames,
+ nchannels);
- for (i=0,l=this->channels; l; l=l->next,i++) {
+ for (i = 0, l = this->channels; l; l = l->next, i++) {
channel = GST_SF_CHANNEL (l);
-
+
pull_again:
in = GST_BUFFER (gst_pad_pull (channel->pad));
if (buffer_frames == 0) {
- /* pulling a buffer from the pad should have caused capsnego to occur,
- which then would set this->buffer_frames to a new value */
- buffer_frames = this->buffer_frames;
- if (buffer_frames == 0) {
- GST_ELEMENT_ERROR (element, CORE, NEGOTIATION, (NULL),
- ("format wasn't negotiated before chain function"));
- return;
- }
- buf = this->buffer;
- num_to_write = buffer_frames;
+ /* pulling a buffer from the pad should have caused capsnego to occur,
+ which then would set this->buffer_frames to a new value */
+ buffer_frames = this->buffer_frames;
+ if (buffer_frames == 0) {
+ GST_ELEMENT_ERROR (element, CORE, NEGOTIATION, (NULL),
+ ("format wasn't negotiated before chain function"));
+ return;
+ }
+ buf = this->buffer;
+ num_to_write = buffer_frames;
}
if (!GST_FLAG_IS_SET (this, GST_SF_OPEN))
- if (!gst_sf_open_file (this))
- return; /* we've already set gst_element_error */
+ if (!gst_sf_open_file (this))
+ return; /* we've already set gst_element_error */
if (GST_IS_EVENT (in)) {
- switch (GST_EVENT_TYPE (in)) {
- case GST_EVENT_EOS:
- case GST_EVENT_INTERRUPT:
- num_to_write = 0;
- break;
- default:
- goto pull_again;
- break;
- }
+ switch (GST_EVENT_TYPE (in)) {
+ case GST_EVENT_EOS:
+ case GST_EVENT_INTERRUPT:
+ num_to_write = 0;
+ break;
+ default:
+ goto pull_again;
+ break;
+ }
}
-
+
if (num_to_write) {
- data = (gfloat*)GST_BUFFER_DATA (in);
- num_to_write = MIN (num_to_write, GST_BUFFER_SIZE (in) / sizeof (gfloat));
- for (j=0; j<num_to_write; j++)
- buf[j * nchannels + i % nchannels] = data[j];
+ data = (gfloat *) GST_BUFFER_DATA (in);
+ num_to_write =
+ MIN (num_to_write, GST_BUFFER_SIZE (in) / sizeof (gfloat));
+ for (j = 0; j < num_to_write; j++)
+ buf[j * nchannels + i % nchannels] = data[j];
}
- gst_data_unref ((GstData*)in);
+ gst_data_unref ((GstData *) in);
}
if (num_to_write) {
written = sf_writef_float (this->file, buf, num_to_write);
if (written != num_to_write)
- GST_ELEMENT_ERROR (element, RESOURCE, WRITE,
- (_("Could not write to file \"%s\"."), this->filename),
- ("soundfile error: %s", sf_strerror (this->file)));
+ GST_ELEMENT_ERROR (element, RESOURCE, WRITE,
+ (_("Could not write to file \"%s\"."), this->filename),
+ ("soundfile error: %s", sf_strerror (this->file)));
}
this->time += num_to_write * (GST_SECOND / this->rate);
- gst_audio_clock_update_time ((GstAudioClock*)this->provided_clock, this->time);
+ gst_audio_clock_update_time ((GstAudioClock *) this->provided_clock,
+ this->time);
if (num_to_write != buffer_frames)
gst_element_set_eos (element);
@@ -815,14 +843,14 @@ gst_sf_loop (GstElement *element)
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
if (!gst_library_load ("gstaudio"))
return FALSE;
GST_DEBUG_CATEGORY_INIT (gstsf_debug, "sf",
- GST_DEBUG_FG_WHITE | GST_DEBUG_BG_GREEN | GST_DEBUG_BOLD,
- "libsndfile plugin");
+ GST_DEBUG_FG_WHITE | GST_DEBUG_BG_GREEN | GST_DEBUG_BOLD,
+ "libsndfile plugin");
if (!gst_element_register (plugin, "sfsrc", GST_RANK_NONE, GST_TYPE_SFSRC))
return FALSE;
@@ -838,13 +866,8 @@ plugin_init (GstPlugin *plugin)
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "gstsf",
- "Sndfile plugin library",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "gstsf",
+ "Sndfile plugin library",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
diff --git a/ext/sndfile/gstsf.h b/ext/sndfile/gstsf.h
index a2531112..13517625 100644
--- a/ext/sndfile/gstsf.h
+++ b/ext/sndfile/gstsf.h
@@ -27,8 +27,6 @@
G_BEGIN_DECLS
-
-
#define GST_TYPE_SF \
(gst_sf_get_type())
#define GST_SF(obj) \
@@ -39,7 +37,6 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SF))
#define GST_IS_SF_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SF))
-
#define GST_TYPE_SFSRC \
(gst_sfsrc_get_type())
#define GST_SFSRC(obj) \
@@ -50,7 +47,6 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SFSRC))
#define GST_IS_SFSRC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SFSRC))
-
#define GST_TYPE_SFSINK \
(gst_sfsink_get_type())
#define GST_SFSINK(obj) \
@@ -61,16 +57,17 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SFSINK))
#define GST_IS_SFSINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SFSINK))
-
typedef struct _GstSF GstSF;
typedef struct _GstSFClass GstSFClass;
-typedef enum {
- GST_SF_OPEN = GST_ELEMENT_FLAG_LAST,
- GST_SF_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
+typedef enum
+{
+ GST_SF_OPEN = GST_ELEMENT_FLAG_LAST,
+ GST_SF_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
} GstSFlags;
-typedef struct {
+typedef struct
+{
GstPad *pad;
gint num;
gboolean caps_set;
@@ -78,7 +75,8 @@ typedef struct {
#define GST_SF_CHANNEL(l) ((GstSFChannel*)l->data)
-struct _GstSF {
+struct _GstSF
+{
GstElement element;
GList *channels;
@@ -102,16 +100,15 @@ struct _GstSF {
guint64 time;
};
-struct _GstSFClass {
+struct _GstSFClass
+{
GstElementClass parent_class;
};
-GType gst_sf_get_type (void);
-GType gst_sfsrc_get_type (void);
-GType gst_sfsink_get_type (void);
+GType gst_sf_get_type (void);
+GType gst_sfsrc_get_type (void);
+GType gst_sfsink_get_type (void);
G_END_DECLS
-
-
#endif /* __GST_SFSINK_H__ */
diff --git a/ext/swfdec/gstswfdec.c b/ext/swfdec/gstswfdec.c
index d958c882..06723d1e 100644
--- a/ext/swfdec/gstswfdec.c
+++ b/ext/swfdec/gstswfdec.c
@@ -26,80 +26,77 @@
#include <gst/video/video.h>
/* elementfactory information */
-static GstElementDetails gst_swfdec_details = GST_ELEMENT_DETAILS (
- "SWF video decoder",
- "Codec/Decoder/Video",
- "Uses libswfdec to decode Flash video streams",
- "David Schleef <ds@schleef.org>"
-);
+static GstElementDetails gst_swfdec_details =
+GST_ELEMENT_DETAILS ("SWF video decoder",
+ "Codec/Decoder/Video",
+ "Uses libswfdec to decode Flash video streams",
+ "David Schleef <ds@schleef.org>");
/* Swfdec signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
/* FILL ME */
};
static GstStaticPadTemplate video_template_factory =
-GST_STATIC_PAD_TEMPLATE (
- "video_00",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_VIDEO_CAPS_BGRx)
-);
+GST_STATIC_PAD_TEMPLATE ("video_00",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_BGRx)
+ );
static GstStaticPadTemplate audio_template_factory =
-GST_STATIC_PAD_TEMPLATE (
- "audio_00",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
- "rate = (int) 44100, "
- "channels = (int) 2, "
- "endianness = (int) BYTE_ORDER, "
- "width = (int) 16, "
- "depth = (int) 16, "
- "signed = (boolean) true, "
- "buffer-frames = (int) [ 1, MAX ]")
-);
+GST_STATIC_PAD_TEMPLATE ("audio_00",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "rate = (int) 44100, "
+ "channels = (int) 2, "
+ "endianness = (int) BYTE_ORDER, "
+ "width = (int) 16, "
+ "depth = (int) 16, "
+ "signed = (boolean) true, " "buffer-frames = (int) [ 1, MAX ]")
+ );
static GstStaticPadTemplate sink_template_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ( "application/x-shockwave-flash")
-);
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("application/x-shockwave-flash")
+ );
-static void gst_swfdec_base_init (gpointer g_class);
-static void gst_swfdec_class_init (GstSwfdecClass *klass);
-static void gst_swfdec_init (GstSwfdec *swfdec);
+static void gst_swfdec_base_init (gpointer g_class);
+static void gst_swfdec_class_init (GstSwfdecClass * klass);
+static void gst_swfdec_init (GstSwfdec * swfdec);
-static void gst_swfdec_dispose (GObject *object);
+static void gst_swfdec_dispose (GObject * object);
-static void gst_swfdec_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_swfdec_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_swfdec_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_swfdec_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
#if 0
-static gboolean gst_swfdec_src_event (GstPad *pad, GstEvent *event);
+static gboolean gst_swfdec_src_event (GstPad * pad, GstEvent * event);
#endif
-static gboolean gst_swfdec_src_query (GstPad *pad, GstQueryType type,
- GstFormat *format, gint64 *value);
+static gboolean gst_swfdec_src_query (GstPad * pad, GstQueryType type,
+ GstFormat * format, gint64 * value);
#if 0
-static gboolean gst_swfdec_convert_sink (GstPad *pad, GstFormat src_format, gint64 src_value,
- GstFormat *dest_format, gint64 *dest_value);
-static gboolean gst_swfdec_convert_src (GstPad *pad, GstFormat src_format, gint64 src_value,
- GstFormat *dest_format, gint64 *dest_value);
+static gboolean gst_swfdec_convert_sink (GstPad * pad, GstFormat src_format,
+ gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
+static gboolean gst_swfdec_convert_src (GstPad * pad, GstFormat src_format,
+ gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
#endif
-static GstElementStateReturn gst_swfdec_change_state (GstElement *element);
+static GstElementStateReturn gst_swfdec_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
@@ -111,55 +108,56 @@ gst_swfdec_get_type (void)
if (!swfdec_type) {
static const GTypeInfo swfdec_info = {
- sizeof(GstSwfdecClass),
+ sizeof (GstSwfdecClass),
gst_swfdec_base_init,
NULL,
- (GClassInitFunc)gst_swfdec_class_init,
+ (GClassInitFunc) gst_swfdec_class_init,
NULL,
NULL,
- sizeof(GstSwfdec),
+ sizeof (GstSwfdec),
0,
- (GInstanceInitFunc)gst_swfdec_init,
+ (GInstanceInitFunc) gst_swfdec_init,
};
- swfdec_type = g_type_register_static(GST_TYPE_ELEMENT, "GstSwfdec", &swfdec_info, 0);
+ swfdec_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstSwfdec", &swfdec_info, 0);
}
return swfdec_type;
}
static void
-gst_swfdec_base_init(gpointer g_class)
+gst_swfdec_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_set_details (element_class, &gst_swfdec_details);
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&video_template_factory));
+ gst_static_pad_template_get (&video_template_factory));
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&audio_template_factory));
+ gst_static_pad_template_get (&audio_template_factory));
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&sink_template_factory));
+ gst_static_pad_template_get (&sink_template_factory));
}
static void
-gst_swfdec_class_init(GstSwfdecClass *klass)
+gst_swfdec_class_init (GstSwfdecClass * 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_swfdec_set_property;
- gobject_class->get_property = gst_swfdec_get_property;
- gobject_class->dispose = gst_swfdec_dispose;
+ gobject_class->set_property = gst_swfdec_set_property;
+ gobject_class->get_property = gst_swfdec_get_property;
+ gobject_class->dispose = gst_swfdec_dispose;
gstelement_class->change_state = gst_swfdec_change_state;
}
static GstCaps *
-gst_swfdec_video_getcaps (GstPad *pad)
+gst_swfdec_video_getcaps (GstPad * pad)
{
GstSwfdec *swfdec;
GstCaps *caps;
@@ -169,15 +167,14 @@ gst_swfdec_video_getcaps (GstPad *pad)
caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
if (swfdec->have_format) {
gst_caps_set_simple (caps,
- "framerate", G_TYPE_DOUBLE, swfdec->frame_rate,
- NULL);
+ "framerate", G_TYPE_DOUBLE, swfdec->frame_rate, NULL);
}
return caps;
}
static GstPadLinkReturn
-gst_swfdec_video_link (GstPad *pad, const GstCaps *caps)
+gst_swfdec_video_link (GstPad * pad, const GstCaps * caps)
{
GstSwfdec *swfdec;
GstStructure *structure;
@@ -215,164 +212,162 @@ copy_image (void *dest, void *src, int width, int height)
{
guint8 *d = dest;
guint8 *s = src;
- int x,y;
+ int x, y;
- for(y=0;y<height;y++){
- for(x=0;x<width;x++){
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++) {
d[0] = s[2];
d[1] = s[1];
d[2] = s[0];
d[3] = 0;
- d+=4;
- s+=3;
+ d += 4;
+ s += 3;
}
}
-
+
}
static void
-gst_swfdec_loop(GstElement *element)
+gst_swfdec_loop (GstElement * element)
{
- GstSwfdec *swfdec;
- GstBuffer *buf = NULL;
- int ret;
+ GstSwfdec *swfdec;
+ GstBuffer *buf = NULL;
+ int ret;
- g_return_if_fail(element != NULL);
- g_return_if_fail(GST_IS_SWFDEC(element));
+ g_return_if_fail (element != NULL);
+ g_return_if_fail (GST_IS_SWFDEC (element));
- swfdec = GST_SWFDEC(element);
+ swfdec = GST_SWFDEC (element);
- if(!swfdec->videopad){
- }
+ if (!swfdec->videopad) {
+ }
- ret = swfdec_decoder_parse(swfdec->state);
- if(ret==SWF_NEEDBITS){
- buf = GST_BUFFER (gst_pad_pull(swfdec->sinkpad));
- if(GST_IS_EVENT(buf)){
- switch (GST_EVENT_TYPE (buf)) {
- case GST_EVENT_EOS:
- GST_DEBUG("got eos");
- break;
- default:
- GST_DEBUG("got event");
- break;
- }
-
- }else{
- if(!GST_BUFFER_DATA(buf)){
- GST_DEBUG("expected non-null buffer");
- }
- ret = swfdec_decoder_addbits(swfdec->state,
- GST_BUFFER_DATA(buf), GST_BUFFER_SIZE(buf));
- }
- }
+ ret = swfdec_decoder_parse (swfdec->state);
+ if (ret == SWF_NEEDBITS) {
+ buf = GST_BUFFER (gst_pad_pull (swfdec->sinkpad));
+ if (GST_IS_EVENT (buf)) {
+ switch (GST_EVENT_TYPE (buf)) {
+ case GST_EVENT_EOS:
+ GST_DEBUG ("got eos");
+ break;
+ default:
+ GST_DEBUG ("got event");
+ break;
+ }
- if(ret==SWF_CHANGE){
- GstCaps *caps;
- GstPadLinkReturn link_ret;
-
- swfdec_decoder_get_image_size(swfdec->state,
- &swfdec->width, &swfdec->height);
- swfdec_decoder_get_rate(swfdec->state, &swfdec->rate);
- swfdec->interval = GST_SECOND / swfdec->rate;
-
- caps = gst_caps_copy (gst_pad_get_pad_template_caps (
- swfdec->videopad));
- swfdec_decoder_get_rate (swfdec->state, &swfdec->frame_rate);
- gst_caps_set_simple (caps,
- "framerate", G_TYPE_DOUBLE, swfdec->frame_rate,
- "height",G_TYPE_INT,swfdec->height,
- "width",G_TYPE_INT,swfdec->width,
- NULL);
- link_ret = gst_pad_try_set_caps (swfdec->videopad, caps);
- if (GST_PAD_LINK_SUCCESSFUL (link_ret)){
- /* good */
- } else {
- GST_ELEMENT_ERROR (swfdec, CORE, NEGOTIATION, (NULL), (NULL));
- return;
- }
- swfdec->have_format = TRUE;
-
- return;
- }
+ } else {
+ if (!GST_BUFFER_DATA (buf)) {
+ GST_DEBUG ("expected non-null buffer");
+ }
+ ret = swfdec_decoder_addbits (swfdec->state,
+ GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
+ }
+ }
- if(ret==SWF_IMAGE){
- GstBuffer *newbuf = NULL;
- unsigned char *data;
- int len;
+ if (ret == SWF_CHANGE) {
+ GstCaps *caps;
+ GstPadLinkReturn link_ret;
- /* video stuff */
- //newbuf = gst_buffer_new();
- //GST_BUFFER_SIZE(newbuf) = swfdec->width * swfdec->height * 3;
+ swfdec_decoder_get_image_size (swfdec->state,
+ &swfdec->width, &swfdec->height);
+ swfdec_decoder_get_rate (swfdec->state, &swfdec->rate);
+ swfdec->interval = GST_SECOND / swfdec->rate;
- newbuf = gst_pad_alloc_buffer (swfdec->videopad, GST_BUFFER_OFFSET_NONE,
- swfdec->width * 4 * swfdec->height);
+ caps = gst_caps_copy (gst_pad_get_pad_template_caps (swfdec->videopad));
+ swfdec_decoder_get_rate (swfdec->state, &swfdec->frame_rate);
+ gst_caps_set_simple (caps,
+ "framerate", G_TYPE_DOUBLE, swfdec->frame_rate,
+ "height", G_TYPE_INT, swfdec->height,
+ "width", G_TYPE_INT, swfdec->width, NULL);
+ link_ret = gst_pad_try_set_caps (swfdec->videopad, caps);
+ if (GST_PAD_LINK_SUCCESSFUL (link_ret)) {
+ /* good */
+ } else {
+ GST_ELEMENT_ERROR (swfdec, CORE, NEGOTIATION, (NULL), (NULL));
+ return;
+ }
+ swfdec->have_format = TRUE;
- swfdec_decoder_get_image(swfdec->state, &data);
- copy_image (GST_BUFFER_DATA (newbuf), data, swfdec->width,
- swfdec->height);
- free (data);
- //GST_BUFFER_DATA(newbuf) = data;
+ return;
+ }
- swfdec->timestamp += swfdec->interval;
- GST_BUFFER_TIMESTAMP(newbuf) = swfdec->timestamp;
+ if (ret == SWF_IMAGE) {
+ GstBuffer *newbuf = NULL;
+ unsigned char *data;
+ int len;
- gst_pad_push(swfdec->videopad, GST_DATA (newbuf));
+ /* video stuff */
+ //newbuf = gst_buffer_new();
+ //GST_BUFFER_SIZE(newbuf) = swfdec->width * swfdec->height * 3;
- /* audio stuff */
+ newbuf = gst_pad_alloc_buffer (swfdec->videopad, GST_BUFFER_OFFSET_NONE,
+ swfdec->width * 4 * swfdec->height);
- data = swfdec_decoder_get_sound_chunk(swfdec->state, &len);
- while(data){
- newbuf = gst_buffer_new();
+ swfdec_decoder_get_image (swfdec->state, &data);
+ copy_image (GST_BUFFER_DATA (newbuf), data, swfdec->width, swfdec->height);
+ free (data);
+ //GST_BUFFER_DATA(newbuf) = data;
- GST_BUFFER_SIZE(newbuf) = len;
- GST_BUFFER_DATA(newbuf) = data;
- GST_BUFFER_TIMESTAMP(newbuf) = swfdec->timestamp;
+ swfdec->timestamp += swfdec->interval;
+ GST_BUFFER_TIMESTAMP (newbuf) = swfdec->timestamp;
- gst_pad_push(swfdec->audiopad, GST_DATA (newbuf));
+ gst_pad_push (swfdec->videopad, GST_DATA (newbuf));
- data = swfdec_decoder_get_sound_chunk(swfdec->state, &len);
- }
- }
+ /* audio stuff */
- if(ret==SWF_EOF){
- gst_pad_push(swfdec->videopad, GST_DATA (gst_event_new (GST_EVENT_EOS)));
- gst_pad_push(swfdec->audiopad, GST_DATA (gst_event_new (GST_EVENT_EOS)));
- }
+ data = swfdec_decoder_get_sound_chunk (swfdec->state, &len);
+ while (data) {
+ newbuf = gst_buffer_new ();
+
+ GST_BUFFER_SIZE (newbuf) = len;
+ GST_BUFFER_DATA (newbuf) = data;
+ GST_BUFFER_TIMESTAMP (newbuf) = swfdec->timestamp;
+
+ gst_pad_push (swfdec->audiopad, GST_DATA (newbuf));
+
+ data = swfdec_decoder_get_sound_chunk (swfdec->state, &len);
+ }
+ }
+
+ if (ret == SWF_EOF) {
+ gst_pad_push (swfdec->videopad, GST_DATA (gst_event_new (GST_EVENT_EOS)));
+ gst_pad_push (swfdec->audiopad, GST_DATA (gst_event_new (GST_EVENT_EOS)));
+ }
}
static void
-gst_swfdec_init (GstSwfdec *swfdec)
+gst_swfdec_init (GstSwfdec * swfdec)
{
/* create the sink and src pads */
- swfdec->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&sink_template_factory), "sink");
+ swfdec->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&sink_template_factory), "sink");
gst_element_add_pad (GST_ELEMENT (swfdec), swfdec->sinkpad);
- swfdec->videopad = gst_pad_new_from_template(
- gst_static_pad_template_get (&video_template_factory),
- "video_00");
+ swfdec->videopad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&video_template_factory), "video_00");
gst_pad_set_query_function (swfdec->videopad,
- GST_DEBUG_FUNCPTR (gst_swfdec_src_query));
+ GST_DEBUG_FUNCPTR (gst_swfdec_src_query));
gst_pad_set_getcaps_function (swfdec->videopad, gst_swfdec_video_getcaps);
gst_pad_set_link_function (swfdec->videopad, gst_swfdec_video_link);
- gst_element_add_pad(GST_ELEMENT(swfdec), swfdec->videopad);
+ gst_element_add_pad (GST_ELEMENT (swfdec), swfdec->videopad);
- swfdec->audiopad = gst_pad_new_from_template(
- gst_static_pad_template_get (&audio_template_factory),
- "audio_00");
+ swfdec->audiopad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&audio_template_factory), "audio_00");
gst_pad_set_query_function (swfdec->audiopad,
- GST_DEBUG_FUNCPTR (gst_swfdec_src_query));
+ GST_DEBUG_FUNCPTR (gst_swfdec_src_query));
+
+ gst_element_add_pad (GST_ELEMENT (swfdec), swfdec->audiopad);
- gst_element_add_pad(GST_ELEMENT(swfdec), swfdec->audiopad);
-
- gst_element_set_loop_function(GST_ELEMENT(swfdec), gst_swfdec_loop);
+ gst_element_set_loop_function (GST_ELEMENT (swfdec), gst_swfdec_loop);
/* initialize the swfdec decoder state */
- swfdec->state = swfdec_decoder_new();
- g_return_if_fail(swfdec->state != NULL);
+ swfdec->state = swfdec_decoder_new ();
+ g_return_if_fail (swfdec->state != NULL);
- swfdec_decoder_set_colorspace(swfdec->state, SWF_COLORSPACE_RGB888);
+ swfdec_decoder_set_colorspace (swfdec->state, SWF_COLORSPACE_RGB888);
GST_FLAG_SET (GST_ELEMENT (swfdec), GST_ELEMENT_EVENT_AWARE);
@@ -380,7 +375,7 @@ gst_swfdec_init (GstSwfdec *swfdec)
}
static void
-gst_swfdec_dispose (GObject *object)
+gst_swfdec_dispose (GObject * object)
{
//GstSwfdec *swfdec = GST_SWFDEC (object);
@@ -392,27 +387,27 @@ gst_swfdec_dispose (GObject *object)
#if 0
static gboolean
-gst_swfdec_convert_sink (GstPad *pad, GstFormat src_format, gint64 src_value,
- GstFormat *dest_format, gint64 *dest_value)
+gst_swfdec_convert_sink (GstPad * pad, GstFormat src_format, gint64 src_value,
+ GstFormat * dest_format, gint64 * dest_value)
{
gboolean res = TRUE;
GstSwfdec *swfdec;
-
+
swfdec = GST_SWFDEC (gst_pad_get_parent (pad));
switch (src_format) {
case GST_FORMAT_BYTES:
switch (*dest_format) {
- case GST_FORMAT_TIME:
- default:
- res = FALSE;
+ case GST_FORMAT_TIME:
+ default:
+ res = FALSE;
}
break;
case GST_FORMAT_TIME:
switch (*dest_format) {
- case GST_FORMAT_BYTES:
- default:
- res = FALSE;
+ case GST_FORMAT_BYTES:
+ default:
+ res = FALSE;
}
break;
default:
@@ -424,53 +419,54 @@ gst_swfdec_convert_sink (GstPad *pad, GstFormat src_format, gint64 src_value,
#if 0
static gboolean
-gst_swfdec_convert_src (GstPad *pad, GstFormat src_format, gint64 src_value,
- GstFormat *dest_format, gint64 *dest_value)
+gst_swfdec_convert_src (GstPad * pad, GstFormat src_format, gint64 src_value,
+ GstFormat * dest_format, gint64 * dest_value)
{
gboolean res = TRUE;
GstSwfdec *swfdec;
-
+
swfdec = GST_SWFDEC (gst_pad_get_parent (pad));
switch (src_format) {
case GST_FORMAT_BYTES:
switch (*dest_format) {
- case GST_FORMAT_TIME:
- default:
- res = FALSE;
+ case GST_FORMAT_TIME:
+ default:
+ res = FALSE;
}
break;
case GST_FORMAT_TIME:
switch (*dest_format) {
- case GST_FORMAT_BYTES:
- *dest_value = src_value * 6 * (swfdec->width * swfdec->height >> 2) *
- video_rates[swfdec->decoder->frame_rate_code] / GST_SECOND;
+ case GST_FORMAT_BYTES:
+ *dest_value = src_value * 6 * (swfdec->width * swfdec->height >> 2) *
+ video_rates[swfdec->decoder->frame_rate_code] / GST_SECOND;
break;
- case GST_FORMAT_DEFAULT:
- *dest_value = src_value * video_rates[swfdec->decoder->frame_rate_code] / GST_SECOND;
+ case GST_FORMAT_DEFAULT:
+ *dest_value =
+ src_value * video_rates[swfdec->decoder->frame_rate_code] /
+ GST_SECOND;
break;
- default:
- res = FALSE;
+ default:
+ res = FALSE;
}
break;
case GST_FORMAT_DEFAULT:
switch (*dest_format) {
- case GST_FORMAT_TIME:
+ case GST_FORMAT_TIME:
if (video_rates[swfdec->decoder->frame_rate_code] != 0.0) {
*dest_value = src_value * GST_SECOND /
- video_rates[swfdec->decoder->frame_rate_code];
- }
- else
+ video_rates[swfdec->decoder->frame_rate_code];
+ } else
res = FALSE;
break;
- case GST_FORMAT_BYTES:
+ case GST_FORMAT_BYTES:
*dest_value = src_value * 6 * (swfdec->width * swfdec->height >> 2);
break;
- case GST_FORMAT_DEFAULT:
+ case GST_FORMAT_DEFAULT:
*dest_value = src_value;
break;
- default:
- res = FALSE;
+ default:
+ res = FALSE;
}
break;
default:
@@ -480,9 +476,9 @@ gst_swfdec_convert_src (GstPad *pad, GstFormat src_format, gint64 src_value,
}
#endif
-static gboolean
-gst_swfdec_src_query (GstPad *pad, GstQueryType type,
- GstFormat *format, gint64 *value)
+static gboolean
+gst_swfdec_src_query (GstPad * pad, GstQueryType type,
+ GstFormat * format, gint64 * value)
{
gboolean res = TRUE;
GstSwfdec *swfdec;
@@ -493,31 +489,31 @@ gst_swfdec_src_query (GstPad *pad, GstQueryType type,
case GST_QUERY_TOTAL:
{
switch (*format) {
- case GST_FORMAT_TIME:
+ case GST_FORMAT_TIME:
{
int n_frames;
int ret;
- res = FALSE;
- ret = swfdec_decoder_get_n_frames(swfdec->state, &n_frames);
- if(ret == SWF_OK){
+ res = FALSE;
+ ret = swfdec_decoder_get_n_frames (swfdec->state, &n_frames);
+ if (ret == SWF_OK) {
*value = n_frames * swfdec->interval;
- res = TRUE;
+ res = TRUE;
}
- break;
+ break;
}
- default:
+ default:
res = FALSE;
- break;
+ break;
}
break;
}
case GST_QUERY_POSITION:
{
switch (*format) {
- default:
- res = FALSE;
- break;
+ default:
+ res = FALSE;
+ break;
}
break;
}
@@ -530,35 +526,34 @@ gst_swfdec_src_query (GstPad *pad, GstQueryType type,
}
#if 0
-static gboolean
-gst_swfdec_src_event (GstPad *pad, GstEvent *event)
+static gboolean
+gst_swfdec_src_event (GstPad * pad, GstEvent * event)
{
gboolean res = TRUE;
GstSwfdec *swfdec;
static const GstFormat formats[] = { GST_FORMAT_TIME, GST_FORMAT_BYTES };
-#define MAX_SEEK_FORMATS 1 /* we can only do time seeking for now */
+#define MAX_SEEK_FORMATS 1 /* we can only do time seeking for now */
gint i;
swfdec = GST_SWFDEC (gst_pad_get_parent (pad));
switch (GST_EVENT_TYPE (event)) {
- /* the all-formats seek logic */
+ /* the all-formats seek logic */
case GST_EVENT_SEEK:
{
gint64 src_offset;
gboolean flush;
GstFormat format;
-
+
format = GST_FORMAT_TIME;
/* first bring the src_format to TIME */
if (!gst_pad_convert (pad,
- GST_EVENT_SEEK_FORMAT (event), GST_EVENT_SEEK_OFFSET (event),
- &format, &src_offset))
- {
- /* didn't work, probably unsupported seek format then */
- res = FALSE;
- break;
+ GST_EVENT_SEEK_FORMAT (event), GST_EVENT_SEEK_OFFSET (event),
+ &format, &src_offset)) {
+ /* didn't work, probably unsupported seek format then */
+ res = FALSE;
+ break;
}
/* shave off the flush flag, we'll need it later */
@@ -569,24 +564,26 @@ gst_swfdec_src_event (GstPad *pad, GstEvent *event)
/* while we did not exhaust our seek formats without result */
for (i = 0; i < MAX_SEEK_FORMATS && !res; i++) {
- gint64 desired_offset;
-
- format = formats[i];
-
- /* try to convert requested format to one we can seek with on the sinkpad */
- if (gst_pad_convert (swfdec->sinkpad, GST_FORMAT_TIME, src_offset, &format, &desired_offset))
- {
- GstEvent *seek_event;
-
- /* conversion succeeded, create the seek */
- seek_event = gst_event_new_seek (formats[i] | GST_SEEK_METHOD_SET | flush, desired_offset);
- /* do the seekk */
- if (gst_pad_send_event (GST_PAD_PEER (swfdec->sinkpad), seek_event)) {
- /* seek worked, we're done, loop will exit */
- res = TRUE;
- }
- }
- /* at this point, either the seek worked or res == FALSE */
+ gint64 desired_offset;
+
+ format = formats[i];
+
+ /* try to convert requested format to one we can seek with on the sinkpad */
+ if (gst_pad_convert (swfdec->sinkpad, GST_FORMAT_TIME, src_offset,
+ &format, &desired_offset)) {
+ GstEvent *seek_event;
+
+ /* conversion succeeded, create the seek */
+ seek_event =
+ gst_event_new_seek (formats[i] | GST_SEEK_METHOD_SET | flush,
+ desired_offset);
+ /* do the seekk */
+ if (gst_pad_send_event (GST_PAD_PEER (swfdec->sinkpad), seek_event)) {
+ /* seek worked, we're done, loop will exit */
+ res = TRUE;
+ }
+ }
+ /* at this point, either the seek worked or res == FALSE */
}
break;
}
@@ -600,11 +597,11 @@ gst_swfdec_src_event (GstPad *pad, GstEvent *event)
#endif
static GstElementStateReturn
-gst_swfdec_change_state (GstElement *element)
+gst_swfdec_change_state (GstElement * element)
{
GstSwfdec *swfdec = GST_SWFDEC (element);
- switch (GST_STATE_TRANSITION (element)) {
+ switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
break;
case GST_STATE_READY_TO_PAUSED:
@@ -633,7 +630,7 @@ gst_swfdec_change_state (GstElement *element)
/* if we are not closed by an EOS event do so now, this cen send a few frames but
* we are prepared to not really send them (see above) */
if (!swfdec->closed) {
- /*swf_close (swfdec->decoder); */
+ /*swf_close (swfdec->decoder); */
swfdec->closed = TRUE;
}
//gst_swfdec_vo_destroy (swfdec);
@@ -650,7 +647,8 @@ gst_swfdec_change_state (GstElement *element)
}
static void
-gst_swfdec_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_swfdec_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstSwfdec *src;
@@ -665,7 +663,8 @@ gst_swfdec_set_property (GObject *object, guint prop_id, const GValue *value, GP
}
static void
-gst_swfdec_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_swfdec_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstSwfdec *swfdec;
@@ -680,19 +679,14 @@ gst_swfdec_get_property (GObject *object, guint prop_id, GValue *value, GParamSp
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- return gst_element_register (plugin, "swfdec", GST_RANK_PRIMARY, GST_TYPE_SWFDEC);
+ return gst_element_register (plugin, "swfdec", GST_RANK_PRIMARY,
+ GST_TYPE_SWFDEC);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "swfdec",
- "Uses libswfdec to decode Flash video streams",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "swfdec",
+ "Uses libswfdec to decode Flash video streams",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
diff --git a/ext/swfdec/gstswfdec.h b/ext/swfdec/gstswfdec.h
index 05015682..dab1ac17 100644
--- a/ext/swfdec/gstswfdec.h
+++ b/ext/swfdec/gstswfdec.h
@@ -26,8 +26,9 @@
#include <swfdec.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_SWFDEC \
@@ -41,47 +42,49 @@ extern "C" {
#define GST_IS_SWFDEC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SWFDEC))
-typedef struct _GstSwfdec GstSwfdec;
-typedef struct _GstSwfdecClass GstSwfdecClass;
+ typedef struct _GstSwfdec GstSwfdec;
+ typedef struct _GstSwfdecClass GstSwfdecClass;
-struct _GstSwfdec {
- GstElement element;
+ struct _GstSwfdec
+ {
+ GstElement element;
- /* pads */
- GstPad *sinkpad;
- GstPad *videopad;
- GstPad *audiopad;
+ /* pads */
+ GstPad *sinkpad;
+ GstPad *videopad;
+ GstPad *audiopad;
- SwfdecDecoder *state;
- gboolean closed;
+ SwfdecDecoder *state;
+ gboolean closed;
- /* the timestamp of the next frame */
- gboolean first;
- gboolean have_format;
+ /* the timestamp of the next frame */
+ gboolean first;
+ gboolean have_format;
- double rate;
- gint64 timestamp;
- gint64 interval;
- double frame_rate;
+ double rate;
+ gint64 timestamp;
+ gint64 interval;
+ double frame_rate;
- /* video state */
- gint format;
- gint width;
- gint height;
- gint64 total_frames;
+ /* video state */
+ gint format;
+ gint width;
+ gint height;
+ gint64 total_frames;
-};
+ };
-struct _GstSwfdecClass {
- GstElementClass parent_class;
-};
+ struct _GstSwfdecClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_swfdec_get_type(void);
+ GType gst_swfdec_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_SWFDEC_H__ */
+#endif /* __GST_SWFDEC_H__ */
diff --git a/ext/tarkin/bitcoder.h b/ext/tarkin/bitcoder.h
index 312cd887..fe1e6eae 100644
--- a/ext/tarkin/bitcoder.h
+++ b/ext/tarkin/bitcoder.h
@@ -15,7 +15,7 @@
#define ENTROPY_ENCODER_FLUSH(coder) bitcoder_flush(coder)
#define ENTROPY_DECODER_INIT(coder,bitstream,limit) \
bitcoder_decoder_init(coder,bitstream,limit)
-#define ENTROPY_DECODER_DONE(coder) /* nothing to do ... */
+#define ENTROPY_DECODER_DONE(coder) /* nothing to do ... */
#define ENTROPY_CODER_BITSTREAM(coder) (coder)->bitstream
#define ENTROPY_CODER_SYMBOL(coder) 1
@@ -25,106 +25,107 @@
#endif
-typedef struct {
- int32_t bit_count; /* number of valid bits in byte */
- uint8_t byte; /* buffer to save bits */
- uint32_t byte_count; /* number of bytes written */
- uint8_t *bitstream;
- uint32_t limit; /* don't write more bytes to bitstream ... */
- int eos; /* end of stream reached */
+typedef struct
+{
+ int32_t bit_count; /* number of valid bits in byte */
+ uint8_t byte; /* buffer to save bits */
+ uint32_t byte_count; /* number of bytes written */
+ uint8_t *bitstream;
+ uint32_t limit; /* don't write more bytes to bitstream ... */
+ int eos; /* end of stream reached */
} BitCoderState;
-static inline
-void bitcoder_encoder_init (BitCoderState *s, uint32_t limit)
+static inline void
+bitcoder_encoder_init (BitCoderState * s, uint32_t limit)
{
- s->bit_count = 0;
- s->byte = 0;
- s->byte_count = 0;
- s->bitstream = (uint8_t*) MALLOC (limit);
- s->limit = limit;
- s->eos = 0;
+ s->bit_count = 0;
+ s->byte = 0;
+ s->byte_count = 0;
+ s->bitstream = (uint8_t *) MALLOC (limit);
+ s->limit = limit;
+ s->eos = 0;
}
-static inline
-void bitcoder_encoder_done (BitCoderState *s)
+static inline void
+bitcoder_encoder_done (BitCoderState * s)
{
- FREE (s->bitstream);
+ FREE (s->bitstream);
}
-static inline
-void bitcoder_decoder_init (BitCoderState *s, uint8_t *bitstream, uint32_t limit)
+static inline void
+bitcoder_decoder_init (BitCoderState * s, uint8_t * bitstream, uint32_t limit)
{
- s->bit_count = -1;
- s->byte = 0;
- s->byte_count = 0;
- s->bitstream = bitstream;
- s->limit = limit;
- s->eos = 0;
+ s->bit_count = -1;
+ s->byte = 0;
+ s->byte_count = 0;
+ s->bitstream = bitstream;
+ s->limit = limit;
+ s->eos = 0;
}
-static inline
-uint32_t bitcoder_flush (BitCoderState *s)
+static inline uint32_t
+bitcoder_flush (BitCoderState * s)
{
- if (s->bit_count > 0 && s->byte_count < s->limit)
- s->bitstream [s->byte_count++] = s->byte << (8 - s->bit_count);
+ if (s->bit_count > 0 && s->byte_count < s->limit)
+ s->bitstream[s->byte_count++] = s->byte << (8 - s->bit_count);
/*printf ("%s: %i bytes written.\n", __FUNCTION__, s->byte_count); */
/*printf ("%s: last bit %i\n", __FUNCTION__, s->bit_count); */
- return s->byte_count;
+ return s->byte_count;
}
-static inline
-void bitcoder_write_bit (BitCoderState *s, int bit)
+static inline void
+bitcoder_write_bit (BitCoderState * s, int bit)
{
- s->byte <<= 1;
- s->byte |= bit & 1;
-
- s->bit_count++;
-
- if (s->bit_count == 8) {
- if (s->byte_count < s->limit) {
- s->bitstream [s->byte_count++] = s->byte;
- s->bit_count = 0;
- } else {
- s->eos = 1;
- }
- }
+ s->byte <<= 1;
+ s->byte |= bit & 1;
+
+ s->bit_count++;
+
+ if (s->bit_count == 8) {
+ if (s->byte_count < s->limit) {
+ s->bitstream[s->byte_count++] = s->byte;
+ s->bit_count = 0;
+ } else {
+ s->eos = 1;
+ }
+ }
}
-static inline
-int bitcoder_read_bit (BitCoderState *s)
+static inline int
+bitcoder_read_bit (BitCoderState * s)
{
- int ret;
+ int ret;
- if (s->bit_count <= 0) {
- if (!s->bitstream) {
- s->eos = 1;
- return 0;
- }
+ if (s->bit_count <= 0) {
+ if (!s->bitstream) {
+ s->eos = 1;
+ return 0;
+ }
- if (s->byte_count < s->limit) {
- s->byte = s->bitstream [s->byte_count++];
- } else {
- s->eos = 1;
- s->byte = 0;
- }
+ if (s->byte_count < s->limit) {
+ s->byte = s->bitstream[s->byte_count++];
+ } else {
+ s->eos = 1;
+ s->byte = 0;
+ }
- s->bit_count = 8;
- }
+ s->bit_count = 8;
+ }
- ret = s->byte >> 7;
- s->byte <<= 1;
- s->bit_count--;
+ ret = s->byte >> 7;
+ s->byte <<= 1;
+ s->bit_count--;
- return ret & 1;
+ return ret & 1;
}
@@ -132,17 +133,16 @@ int bitcoder_read_bit (BitCoderState *s)
-static inline
-void bit_print (TYPE byte)
+static inline void
+bit_print (TYPE byte)
{
- int bit = 8*sizeof(TYPE);
+ int bit = 8 * sizeof (TYPE);
- do {
- bit--;
- printf ((byte & (1 << bit)) ? "1" : "0");
- } while (bit);
- printf ("\n");
+ do {
+ bit--;
+ printf ((byte & (1 << bit)) ? "1" : "0");
+ } while (bit);
+ printf ("\n");
}
#endif
-
diff --git a/ext/tarkin/golomb.h b/ext/tarkin/golomb.h
index 95e63c30..47c23b44 100644
--- a/ext/tarkin/golomb.h
+++ b/ext/tarkin/golomb.h
@@ -5,128 +5,126 @@
#include "bitcoder.h"
-static inline
-unsigned int required_bits (unsigned int x)
+static inline unsigned int
+required_bits (unsigned int x)
{
- int bits = 31;
+ int bits = 31;
- while ((x & (1 << bits)) == 0 && bits)
- bits--;
+ while ((x & (1 << bits)) == 0 && bits)
+ bits--;
- return bits;
+ return bits;
}
-static inline
-void write_number_binary (BitCoderState *b, unsigned int x, int bits, int u)
+static inline void
+write_number_binary (BitCoderState * b, unsigned int x, int bits, int u)
{
/*printf ("wrote %i with %i bits (%i+%i)\n", x, u+bits, u, bits); */
- while (bits) {
- bits--;
- bitcoder_write_bit (b, (x >> bits) & 1);
- }
+ while (bits) {
+ bits--;
+ bitcoder_write_bit (b, (x >> bits) & 1);
+ }
}
-static inline
-unsigned int read_number_binary (BitCoderState *b, int bits)
+static inline unsigned int
+read_number_binary (BitCoderState * b, int bits)
{
- unsigned int x = 0;
+ unsigned int x = 0;
- while (bits) {
- bits--;
- x |= bitcoder_read_bit (b) << bits;
- }
+ while (bits) {
+ bits--;
+ x |= bitcoder_read_bit (b) << bits;
+ }
- return x;
+ return x;
}
-static inline
-void golomb_write_number (BitCoderState *b, unsigned int x, int bits)
+static inline void
+golomb_write_number (BitCoderState * b, unsigned int x, int bits)
{
- unsigned int q, r;
-int i = 0;
+ unsigned int q, r;
+ int i = 0;
- assert (x > 0);
+ assert (x > 0);
- while ((q = (x - 1) >> bits) > 0) {
- bitcoder_write_bit (b, 1); /* fast temporary adaption, write */
- bits++; /* unary representation of q */
-i++;
- };
+ while ((q = (x - 1) >> bits) > 0) {
+ bitcoder_write_bit (b, 1); /* fast temporary adaption, write */
+ bits++; /* unary representation of q */
+ i++;
+ };
- bitcoder_write_bit (b, 0);
+ bitcoder_write_bit (b, 0);
- r = x - 1 - (q << bits);
+ r = x - 1 - (q << bits);
- write_number_binary (b, r, bits, i+1);
+ write_number_binary (b, r, bits, i + 1);
}
-static inline
-unsigned int golomb_read_number (BitCoderState *b, int bits)
+static inline unsigned int
+golomb_read_number (BitCoderState * b, int bits)
{
- unsigned int q = 0, r, x;
+ unsigned int q = 0, r, x;
- while (bitcoder_read_bit (b) != 0) {
- bits++;
- }
+ while (bitcoder_read_bit (b) != 0) {
+ bits++;
+ }
- r = read_number_binary (b, bits);
- x = (q << bits) + r + 1;
+ r = read_number_binary (b, bits);
+ x = (q << bits) + r + 1;
- return x;
+ return x;
}
-typedef struct {
- uint8_t count;
- uint8_t bits; /* a 5.3 fixed point integer */
+typedef struct
+{
+ uint8_t count;
+ uint8_t bits; /* a 5.3 fixed point integer */
} GolombAdaptiveCoderState;
#define GOLOMB_ADAPTIVE_CODER_STATE_INITIALIZER { 8<<3, 0 }
-static const int golomb_w_tab [] = { 256, 128, 64 };
+static const int golomb_w_tab[] = { 256, 128, 64 };
-static inline
-void golombcoder_encode_number (GolombAdaptiveCoderState *g,
- BitCoderState *b,
- unsigned int x)
+static inline void
+golombcoder_encode_number (GolombAdaptiveCoderState * g,
+ BitCoderState * b, unsigned int x)
{
- golomb_write_number (b, x, g->bits >> 3);
+ golomb_write_number (b, x, g->bits >> 3);
- g->bits = ((256 - golomb_w_tab[g->count]) * (int) g->bits +
- golomb_w_tab[g->count] * (required_bits(x)<<3)) / 256;
- g->count++;
+ g->bits = ((256 - golomb_w_tab[g->count]) * (int) g->bits +
+ golomb_w_tab[g->count] * (required_bits (x) << 3)) / 256;
+ g->count++;
- if (g->count > 2)
- g->count = 2;
+ if (g->count > 2)
+ g->count = 2;
}
-static inline
-unsigned int golombcoder_decode_number (GolombAdaptiveCoderState *g,
- BitCoderState *b)
+static inline unsigned int
+golombcoder_decode_number (GolombAdaptiveCoderState * g, BitCoderState * b)
{
- unsigned int x;
+ unsigned int x;
- x = golomb_read_number (b, g->bits >> 3);
+ x = golomb_read_number (b, g->bits >> 3);
- g->bits = ((256 - golomb_w_tab[g->count]) * g->bits +
- golomb_w_tab[g->count] * (required_bits(x)<<3)) / 256;
- g->count++;
+ g->bits = ((256 - golomb_w_tab[g->count]) * g->bits +
+ golomb_w_tab[g->count] * (required_bits (x) << 3)) / 256;
+ g->count++;
- if (g->count > 2)
- g->count = 2;
+ if (g->count > 2)
+ g->count = 2;
- return x;
+ return x;
}
#endif
-
diff --git a/ext/tarkin/gsttarkin.c b/ext/tarkin/gsttarkin.c
index c98873f3..a87575d9 100644
--- a/ext/tarkin/gsttarkin.c
+++ b/ext/tarkin/gsttarkin.c
@@ -25,24 +25,21 @@
#include "gsttarkindec.h"
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- if (!gst_element_register (plugin, "tarkinenc", GST_RANK_NONE, GST_TYPE_TARKINENC))
+ if (!gst_element_register (plugin, "tarkinenc", GST_RANK_NONE,
+ GST_TYPE_TARKINENC))
return FALSE;
- if (!gst_element_register (plugin, "tarkindec", GST_RANK_NONE, GST_TYPE_TARKINDEC))
+ if (!gst_element_register (plugin, "tarkindec", GST_RANK_NONE,
+ GST_TYPE_TARKINDEC))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "tarkin",
- "Tarkin plugin library",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "tarkin",
+ "Tarkin plugin library",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
diff --git a/ext/tarkin/gsttarkindec.c b/ext/tarkin/gsttarkindec.c
index 9f411a57..b9f98784 100644
--- a/ext/tarkin/gsttarkindec.c
+++ b/ext/tarkin/gsttarkindec.c
@@ -33,8 +33,7 @@ GstElementDetails tarkindec_details = {
"Ogg Tarkin decoder",
"Filter/Video/Decoder",
"Decodes video in OGG Tarkin format",
- "Monty <monty@xiph.org>, "
- "Wim Taymans <wim.taymans@chello.be>",
+ "Monty <monty@xiph.org>, " "Wim Taymans <wim.taymans@chello.be>",
};
/* TarkinDec signals and args */
@@ -50,21 +49,21 @@ enum
ARG_BITRATE,
};
-static void gst_tarkindec_base_init (gpointer g_class);
-static void gst_tarkindec_class_init (TarkinDecClass *klass);
-static void gst_tarkindec_init (TarkinDec *arkindec);
+static void gst_tarkindec_base_init (gpointer g_class);
+static void gst_tarkindec_class_init (TarkinDecClass * klass);
+static void gst_tarkindec_init (TarkinDec * arkindec);
-static void gst_tarkindec_chain (GstPad *pad, GstData *_data);
-static void gst_tarkindec_setup (TarkinDec *tarkindec);
-static GstElementStateReturn
- gst_tarkindec_change_state (GstElement *element);
+static void gst_tarkindec_chain (GstPad * pad, GstData * _data);
+static void gst_tarkindec_setup (TarkinDec * tarkindec);
+static GstElementStateReturn gst_tarkindec_change_state (GstElement * element);
-static void gst_tarkindec_get_property (GObject *object, guint prop_id, GValue *value,
- GParamSpec *pspec);
-static void gst_tarkindec_set_property (GObject *object, guint prop_id, const GValue *value,
- GParamSpec *pspec);
+static void gst_tarkindec_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+static void gst_tarkindec_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_tarkindec_signals[LAST_SIGNAL] = { 0 }; */
GType
@@ -74,7 +73,7 @@ tarkindec_get_type (void)
if (!tarkindec_type) {
static const GTypeInfo tarkindec_info = {
- sizeof (TarkinDecClass),
+ sizeof (TarkinDecClass),
gst_tarkindec_base_init,
NULL,
(GClassInitFunc) gst_tarkindec_class_init,
@@ -85,38 +84,35 @@ tarkindec_get_type (void)
(GInstanceInitFunc) gst_tarkindec_init,
};
- tarkindec_type = g_type_register_static (GST_TYPE_ELEMENT, "TarkinDec", &tarkindec_info, 0);
+ tarkindec_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "TarkinDec", &tarkindec_info,
+ 0);
}
return tarkindec_type;
}
-static GstCaps*
+static GstCaps *
tarkin_caps_factory (void)
{
- return
- gst_caps_new (
- "tarkin_tarkin",
- "application/ogg",
- NULL);
+ return gst_caps_new ("tarkin_tarkin", "application/ogg", NULL);
}
-static GstCaps*
+static GstCaps *
raw_caps_factory (void)
{
return
- GST_CAPS_NEW (
- "tarkin_raw",
- "video/x-raw-rgb",
- "bpp", GST_PROPS_INT (24),
- "depth", GST_PROPS_INT (24),
+ GST_CAPS_NEW ("tarkin_raw",
+ "video/x-raw-rgb",
+ "bpp", GST_PROPS_INT (24),
+ "depth", GST_PROPS_INT (24),
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
- "red_mask", GST_PROPS_INT (0xff0000),
+ "red_mask", GST_PROPS_INT (0xff0000),
"green_mask", GST_PROPS_INT (0xff00),
- "blue_mask", GST_PROPS_INT (0xff),
- "width", GST_PROPS_INT_RANGE (0, G_MAXINT),
- "height", GST_PROPS_INT_RANGE (0, G_MAXINT),
- "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)
- );
+ "blue_mask", GST_PROPS_INT (0xff),
+ "width", GST_PROPS_INT_RANGE (0, G_MAXINT),
+ "height", GST_PROPS_INT_RANGE (0, G_MAXINT),
+ "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)
+ );
}
static void
@@ -128,16 +124,10 @@ gst_tarkindec_base_init (gpointer g_class)
raw_caps = raw_caps_factory ();
tarkin_caps = tarkin_caps_factory ();
- dec_sink_template = gst_pad_template_new ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- tarkin_caps,
- NULL);
- dec_src_template = gst_pad_template_new ("src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- raw_caps,
- NULL);
+ dec_sink_template = gst_pad_template_new ("sink",
+ GST_PAD_SINK, GST_PAD_ALWAYS, tarkin_caps, NULL);
+ dec_src_template = gst_pad_template_new ("src",
+ GST_PAD_SRC, GST_PAD_ALWAYS, raw_caps, NULL);
gst_element_class_add_pad_template (element_class, dec_sink_template);
gst_element_class_add_pad_template (element_class, dec_src_template);
@@ -145,7 +135,7 @@ gst_tarkindec_base_init (gpointer g_class)
}
static void
-gst_tarkindec_class_init (TarkinDecClass *klass)
+gst_tarkindec_class_init (TarkinDecClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
@@ -153,9 +143,9 @@ gst_tarkindec_class_init (TarkinDecClass *klass)
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BITRATE,
- g_param_spec_int ("bitrate", "bitrate", "bitrate",
- G_MININT, G_MAXINT, 3000, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BITRATE,
+ g_param_spec_int ("bitrate", "bitrate", "bitrate",
+ G_MININT, G_MAXINT, 3000, G_PARAM_READWRITE));
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
@@ -184,10 +174,10 @@ gst_tarkindec_init (TarkinDec * tarkindec)
}
static void
-gst_tarkindec_setup (TarkinDec *tarkindec)
+gst_tarkindec_setup (TarkinDec * tarkindec)
{
tarkindec->tarkin_stream = tarkin_stream_new ();
-
+
ogg_sync_init (&tarkindec->oy);
ogg_stream_init (&tarkindec->os, 1);
tarkin_info_init (&tarkindec->ti);
@@ -197,7 +187,7 @@ gst_tarkindec_setup (TarkinDec *tarkindec)
}
static void
-gst_tarkindec_chain (GstPad *pad, GstData *_data)
+gst_tarkindec_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
TarkinDec *tarkindec;
@@ -209,7 +199,8 @@ gst_tarkindec_chain (GstPad *pad, GstData *_data)
tarkindec = GST_TARKINDEC (gst_pad_get_parent (pad));
if (!tarkindec->setup) {
- GST_ELEMENT_ERROR (tarkindec, CORE, NEGOTATION, (NULL), ("decoder not initialized (input is not tarkin?)"));
+ GST_ELEMENT_ERROR (tarkindec, CORE, NEGOTATION, (NULL),
+ ("decoder not initialized (input is not tarkin?)"));
if (GST_IS_BUFFER (buf))
gst_buffer_unref (buf);
else
@@ -224,61 +215,50 @@ gst_tarkindec_chain (GstPad *pad, GstData *_data)
gst_pad_event_default (pad, GST_EVENT (buf));
break;
}
- }
- else {
+ } else {
gchar *data;
gulong size;
gchar *buffer;
guchar *rgb;
TarkinTime date;
TarkinVideoLayerDesc *layer;
-
+
/* data to decode */
data = GST_BUFFER_DATA (buf);
size = GST_BUFFER_SIZE (buf);
- buffer = ogg_sync_buffer(&tarkindec->oy, size);
+ buffer = ogg_sync_buffer (&tarkindec->oy, size);
memcpy (buffer, data, size);
- ogg_sync_wrote(&tarkindec->oy, size);
+ ogg_sync_wrote (&tarkindec->oy, size);
if (ogg_sync_pageout (&tarkindec->oy, &tarkindec->og)) {
ogg_stream_pagein (&tarkindec->os, &tarkindec->og);
while (ogg_stream_packetout (&tarkindec->os, &tarkindec->op)) {
- if (tarkindec->op.e_o_s)
- break;
- if (tarkindec->nheader < 3) { /* 3 first packets to headerin */
- tarkin_synthesis_headerin (&tarkindec->ti, &tarkindec->tc, &tarkindec->op);
+ if (tarkindec->op.e_o_s)
+ break;
+ if (tarkindec->nheader < 3) { /* 3 first packets to headerin */
+ tarkin_synthesis_headerin (&tarkindec->ti, &tarkindec->tc,
+ &tarkindec->op);
if (tarkindec->nheader == 2) {
tarkin_synthesis_init (tarkindec->tarkin_stream, &tarkindec->ti);
- }
- tarkindec->nheader++;
- } else {
+ }
+ tarkindec->nheader++;
+ } else {
tarkin_synthesis_packetin (tarkindec->tarkin_stream, &tarkindec->op);
-
- while (tarkin_synthesis_frameout (tarkindec->tarkin_stream, &rgb, 0, &date) == 0) {
- GstBuffer *outbuf;
+
+ while (tarkin_synthesis_frameout (tarkindec->tarkin_stream, &rgb, 0,
+ &date) == 0) {
+ GstBuffer *outbuf;
layer = &tarkindec->tarkin_stream->layer->desc;
if (!GST_PAD_CAPS (tarkindec->srcpad)) {
- if (gst_pad_try_set_caps (tarkindec->srcpad,
- GST_CAPS_NEW (
- "tarkin_raw",
- "video/x-raw-rgb",
- "bpp", GST_PROPS_INT (24),
- "depth", GST_PROPS_INT (24),
- "endianness", GST_PROPS_INT (G_BYTE_ORDER),
- "red_mask", GST_PROPS_INT (0xff0000),
- "green_mask", GST_PROPS_INT (0xff00),
- "blue_mask", GST_PROPS_INT (0xff),
- "width", GST_PROPS_INT (layer->width),
- "height", GST_PROPS_INT (layer->height),
- "framerate", GST_PROPS_FLOAT (0.) /* FIXME!!! */
- )) <= 0)
- {
- GST_ELEMENT_ERROR (tarkindec, CORE, NEGOTATION, (NULL), ("could not output format"));
+ if (gst_pad_try_set_caps (tarkindec->srcpad, GST_CAPS_NEW ("tarkin_raw", "video/x-raw-rgb", "bpp", GST_PROPS_INT (24), "depth", GST_PROPS_INT (24), "endianness", GST_PROPS_INT (G_BYTE_ORDER), "red_mask", GST_PROPS_INT (0xff0000), "green_mask", GST_PROPS_INT (0xff00), "blue_mask", GST_PROPS_INT (0xff), "width", GST_PROPS_INT (layer->width), "height", GST_PROPS_INT (layer->height), "framerate", GST_PROPS_FLOAT (0.) /* FIXME!!! */
+ )) <= 0) {
+ GST_ELEMENT_ERROR (tarkindec, CORE, NEGOTATION, (NULL),
+ ("could not output format"));
gst_buffer_unref (buf);
return;
}
@@ -288,10 +268,10 @@ gst_tarkindec_chain (GstPad *pad, GstData *_data)
GST_BUFFER_SIZE (outbuf) = layer->width * layer->height * 3;
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_DONTFREE);
gst_pad_push (tarkindec->srcpad, GST_DATA (outbuf));
-
+
tarkin_synthesis_freeframe (tarkindec->tarkin_stream, rgb);
- }
- }
+ }
+ }
}
}
gst_buffer_unref (buf);
@@ -299,7 +279,7 @@ gst_tarkindec_chain (GstPad *pad, GstData *_data)
}
static GstElementStateReturn
-gst_tarkindec_change_state (GstElement *element)
+gst_tarkindec_change_state (GstElement * element)
{
TarkinDec *tarkindec;
@@ -314,12 +294,13 @@ gst_tarkindec_change_state (GstElement *element)
default:
break;
}
-
+
return parent_class->change_state (element);
}
static void
-gst_tarkindec_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_tarkindec_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
TarkinDec *tarkindec;
@@ -338,8 +319,8 @@ gst_tarkindec_get_property (GObject *object, guint prop_id, GValue *value, GPara
}
static void
-gst_tarkindec_set_property (GObject *object, guint prop_id, const GValue *value,
- GParamSpec *pspec)
+gst_tarkindec_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
TarkinDec *tarkindec;
diff --git a/ext/tarkin/gsttarkindec.h b/ext/tarkin/gsttarkindec.h
index b1baf4f3..77b8954d 100644
--- a/ext/tarkin/gsttarkindec.h
+++ b/ext/tarkin/gsttarkindec.h
@@ -27,8 +27,9 @@
#include "tarkin.h"
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_TARKINDEC \
(tarkindec_get_type())
@@ -41,42 +42,44 @@ extern "C" {
#define GST_IS_TARKINDEC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TARKINDEC))
-typedef struct _TarkinDec TarkinDec;
-typedef struct _TarkinDecClass TarkinDecClass;
+ typedef struct _TarkinDec TarkinDec;
+ typedef struct _TarkinDecClass TarkinDecClass;
-struct _TarkinDec {
- GstElement element;
+ struct _TarkinDec
+ {
+ GstElement element;
- GstPad *sinkpad,*srcpad;
+ GstPad *sinkpad, *srcpad;
- ogg_sync_state oy;
- ogg_stream_state os;
- ogg_page og;
- ogg_packet op;
+ ogg_sync_state oy;
+ ogg_stream_state os;
+ ogg_page og;
+ ogg_packet op;
- TarkinStream *tarkin_stream;
- TarkinComment tc;
- TarkinInfo ti;
- TarkinVideoLayerDesc layer[1];
+ TarkinStream *tarkin_stream;
+ TarkinComment tc;
+ TarkinInfo ti;
+ TarkinVideoLayerDesc layer[1];
- gint frame_num;
- gint nheader;
-
- gboolean eos;
- gint bitrate;
- gboolean setup;
-};
+ gint frame_num;
+ gint nheader;
-struct _TarkinDecClass {
- GstElementClass parent_class;
-};
+ gboolean eos;
+ gint bitrate;
+ gboolean setup;
+ };
-GType tarkindec_get_type(void);
+ struct _TarkinDecClass
+ {
+ GstElementClass parent_class;
+ };
+
+ GType tarkindec_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __TARKINDEC_H__ */
+#endif /* __TARKINDEC_H__ */
diff --git a/ext/tarkin/gsttarkinenc.c b/ext/tarkin/gsttarkinenc.c
index 18947ea4..4c62303d 100644
--- a/ext/tarkin/gsttarkinenc.c
+++ b/ext/tarkin/gsttarkinenc.c
@@ -33,8 +33,7 @@ GstElementDetails tarkinenc_details = {
"Ogg Tarkin encoder",
"Filter/Video/Encoder",
"Encodes video in OGG Tarkin format",
- "Monty <monty@xiph.org>, "
- "Wim Taymans <wim.taymans@chello.be>",
+ "Monty <monty@xiph.org>, " "Wim Taymans <wim.taymans@chello.be>",
};
/* TarkinEnc signals and args */
@@ -52,19 +51,20 @@ enum
ARG_A_MOMENTS,
};
-static void gst_tarkinenc_base_init (gpointer g_class);
-static void gst_tarkinenc_class_init (TarkinEncClass *klass);
-static void gst_tarkinenc_init (TarkinEnc *arkinenc);
+static void gst_tarkinenc_base_init (gpointer g_class);
+static void gst_tarkinenc_class_init (TarkinEncClass * klass);
+static void gst_tarkinenc_init (TarkinEnc * arkinenc);
-static void gst_tarkinenc_chain (GstPad *pad, GstData *_data);
-static void gst_tarkinenc_setup (TarkinEnc *tarkinenc);
+static void gst_tarkinenc_chain (GstPad * pad, GstData * _data);
+static void gst_tarkinenc_setup (TarkinEnc * tarkinenc);
-static void gst_tarkinenc_get_property (GObject *object, guint prop_id, GValue *value,
- GParamSpec *pspec);
-static void gst_tarkinenc_set_property (GObject *object, guint prop_id, const GValue *value,
- GParamSpec *pspec);
+static void gst_tarkinenc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+static void gst_tarkinenc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_tarkinenc_signals[LAST_SIGNAL] = { 0 }; */
GType
@@ -74,7 +74,7 @@ tarkinenc_get_type (void)
if (!tarkinenc_type) {
static const GTypeInfo tarkinenc_info = {
- sizeof (TarkinEncClass),
+ sizeof (TarkinEncClass),
gst_tarkinenc_base_init,
NULL,
(GClassInitFunc) gst_tarkinenc_class_init,
@@ -85,38 +85,35 @@ tarkinenc_get_type (void)
(GInstanceInitFunc) gst_tarkinenc_init,
};
- tarkinenc_type = g_type_register_static (GST_TYPE_ELEMENT, "TarkinEnc", &tarkinenc_info, 0);
+ tarkinenc_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "TarkinEnc", &tarkinenc_info,
+ 0);
}
return tarkinenc_type;
}
-static GstCaps*
+static GstCaps *
tarkin_caps_factory (void)
{
- return
- gst_caps_new (
- "tarkin_tarkin",
- "application/ogg",
- NULL);
+ return gst_caps_new ("tarkin_tarkin", "application/ogg", NULL);
}
-static GstCaps*
+static GstCaps *
raw_caps_factory (void)
{
return
- GST_CAPS_NEW (
- "tarkin_raw",
- "video/x-raw-rgb",
- "bpp", GST_PROPS_INT (24),
- "depth", GST_PROPS_INT (24),
+ GST_CAPS_NEW ("tarkin_raw",
+ "video/x-raw-rgb",
+ "bpp", GST_PROPS_INT (24),
+ "depth", GST_PROPS_INT (24),
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
- "red_mask", GST_PROPS_INT (0xff0000),
+ "red_mask", GST_PROPS_INT (0xff0000),
"green_mask", GST_PROPS_INT (0xff00),
- "blue_mask", GST_PROPS_INT (0xff),
- "width", GST_PROPS_INT_RANGE (0, G_MAXINT),
- "height", GST_PROPS_INT_RANGE (0, G_MAXINT),
- "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)
- );
+ "blue_mask", GST_PROPS_INT (0xff),
+ "width", GST_PROPS_INT_RANGE (0, G_MAXINT),
+ "height", GST_PROPS_INT_RANGE (0, G_MAXINT),
+ "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)
+ );
}
static void
@@ -124,20 +121,14 @@ gst_tarkinenc_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
GstCaps *raw_caps, *tarkin_caps;
-
+
raw_caps = raw_caps_factory ();
tarkin_caps = tarkin_caps_factory ();
- enc_sink_template = gst_pad_template_new ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- raw_caps,
- NULL);
- enc_src_template = gst_pad_template_new ("src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- tarkin_caps,
- NULL);
+ enc_sink_template = gst_pad_template_new ("sink",
+ GST_PAD_SINK, GST_PAD_ALWAYS, raw_caps, NULL);
+ enc_src_template = gst_pad_template_new ("src",
+ GST_PAD_SRC, GST_PAD_ALWAYS, tarkin_caps, NULL);
gst_element_class_add_pad_template (element_class, enc_sink_template);
gst_element_class_add_pad_template (element_class, enc_src_template);
@@ -145,7 +136,7 @@ gst_tarkinenc_base_init (gpointer g_class)
}
static void
-gst_tarkinenc_class_init (TarkinEncClass *klass)
+gst_tarkinenc_class_init (TarkinEncClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
@@ -153,17 +144,17 @@ gst_tarkinenc_class_init (TarkinEncClass *klass)
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BITRATE,
- g_param_spec_int ("bitrate", "bitrate", "bitrate",
- G_MININT, G_MAXINT, 3000, G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_S_MOMENTS,
- g_param_spec_int ("s_moments", "Synthesis Moments",
- "Number of vanishing moments for the synthesis filter",
- 1, 4, 2, G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_A_MOMENTS,
- g_param_spec_int ("a_moments", "Analysis Moments",
- "Number of vanishing moments for the analysis filter",
- 1, 4, 2, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BITRATE,
+ g_param_spec_int ("bitrate", "bitrate", "bitrate",
+ G_MININT, G_MAXINT, 3000, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_S_MOMENTS,
+ g_param_spec_int ("s_moments", "Synthesis Moments",
+ "Number of vanishing moments for the synthesis filter",
+ 1, 4, 2, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_A_MOMENTS,
+ g_param_spec_int ("a_moments", "Analysis Moments",
+ "Number of vanishing moments for the analysis filter",
+ 1, 4, 2, G_PARAM_READWRITE));
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
@@ -172,7 +163,7 @@ gst_tarkinenc_class_init (TarkinEncClass *klass)
}
static GstPadLinkReturn
-gst_tarkinenc_sinkconnect (GstPad *pad, GstCaps *caps)
+gst_tarkinenc_sinkconnect (GstPad * pad, GstCaps * caps)
{
TarkinEnc *tarkinenc;
@@ -216,12 +207,14 @@ gst_tarkinenc_init (TarkinEnc * tarkinenc)
tarkinenc->setup = FALSE;
}
-TarkinError free_frame (void *s, void *ptr)
+TarkinError
+free_frame (void *s, void *ptr)
{
- return(TARKIN_OK);
+ return (TARKIN_OK);
}
-TarkinError packet_out (void *stream, ogg_packet *op)
+TarkinError
+packet_out (void *stream, ogg_packet * op)
{
ogg_page og;
TarkinStream *s = stream;
@@ -230,7 +223,7 @@ TarkinError packet_out (void *stream, ogg_packet *op)
ogg_stream_packetin (&te->os, op);
- if(op->e_o_s){
+ if (op->e_o_s) {
ogg_stream_flush (&te->os, &og);
outbuf = gst_buffer_new ();
GST_BUFFER_DATA (outbuf) = og.header;
@@ -243,7 +236,7 @@ TarkinError packet_out (void *stream, ogg_packet *op)
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_DONTFREE);
gst_pad_push (te->srcpad, GST_DATA (outbuf));
} else {
- while (ogg_stream_pageout (&te->os, &og)){
+ while (ogg_stream_pageout (&te->os, &og)) {
outbuf = gst_buffer_new ();
GST_BUFFER_DATA (outbuf) = og.header;
GST_BUFFER_SIZE (outbuf) = og.header_len;
@@ -261,7 +254,7 @@ TarkinError packet_out (void *stream, ogg_packet *op)
static void
-gst_tarkinenc_setup (TarkinEnc *tarkinenc)
+gst_tarkinenc_setup (TarkinEnc * tarkinenc)
{
gint i;
GstBuffer *outbuf;
@@ -271,20 +264,20 @@ gst_tarkinenc_setup (TarkinEnc *tarkinenc)
tarkinenc->ti.inter.numerator = 1;
tarkinenc->ti.inter.denominator = 1;
-
+
tarkin_comment_init (&tarkinenc->tc);
tarkin_comment_add_tag (&tarkinenc->tc, "TITLE", "GStreamer produced file");
tarkin_comment_add_tag (&tarkinenc->tc, "ARTIST", "C coders ;)");
tarkinenc->tarkin_stream = tarkin_stream_new ();
- tarkin_analysis_init (tarkinenc->tarkin_stream,
- &tarkinenc->ti, free_frame, packet_out, (void*)tarkinenc);
- tarkin_analysis_add_layer(tarkinenc->tarkin_stream, &tarkinenc->layer[0]);
-
- tarkin_analysis_headerout (tarkinenc->tarkin_stream, &tarkinenc->tc,
- tarkinenc->op, &tarkinenc->op[1], &tarkinenc->op[2]);
- for(i = 0; i < 3; i++){
- ogg_stream_packetin(&tarkinenc->os, &tarkinenc->op[i]);
+ tarkin_analysis_init (tarkinenc->tarkin_stream,
+ &tarkinenc->ti, free_frame, packet_out, (void *) tarkinenc);
+ tarkin_analysis_add_layer (tarkinenc->tarkin_stream, &tarkinenc->layer[0]);
+
+ tarkin_analysis_headerout (tarkinenc->tarkin_stream, &tarkinenc->tc,
+ tarkinenc->op, &tarkinenc->op[1], &tarkinenc->op[2]);
+ for (i = 0; i < 3; i++) {
+ ogg_stream_packetin (&tarkinenc->os, &tarkinenc->op[i]);
}
ogg_stream_flush (&tarkinenc->os, &tarkinenc->og);
@@ -307,7 +300,7 @@ gst_tarkinenc_setup (TarkinEnc *tarkinenc)
}
static void
-gst_tarkinenc_chain (GstPad *pad, GstData *_data)
+gst_tarkinenc_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
TarkinEnc *tarkinenc;
@@ -319,7 +312,8 @@ gst_tarkinenc_chain (GstPad *pad, GstData *_data)
tarkinenc = GST_TARKINENC (gst_pad_get_parent (pad));
if (!tarkinenc->setup) {
- GST_ELEMENT_ERROR (tarkinenc, CORE, NEGOTIATION, (NULL), ("encoder not initialized (input is not tarkin?)"));
+ GST_ELEMENT_ERROR (tarkinenc, CORE, NEGOTIATION, (NULL),
+ ("encoder not initialized (input is not tarkin?)"));
if (GST_IS_BUFFER (buf))
gst_buffer_unref (buf);
else
@@ -330,19 +324,18 @@ gst_tarkinenc_chain (GstPad *pad, GstData *_data)
if (GST_IS_EVENT (buf)) {
switch (GST_EVENT_TYPE (buf)) {
case GST_EVENT_EOS:
- tarkin_analysis_framein (tarkinenc->tarkin_stream, NULL, 0, NULL); /* EOS */
- tarkin_comment_clear (&tarkinenc->tc);
- tarkin_stream_destroy (tarkinenc->tarkin_stream);
+ tarkin_analysis_framein (tarkinenc->tarkin_stream, NULL, 0, NULL); /* EOS */
+ tarkin_comment_clear (&tarkinenc->tc);
+ tarkin_stream_destroy (tarkinenc->tarkin_stream);
default:
gst_pad_event_default (pad, GST_EVENT (buf));
break;
}
- }
- else {
+ } else {
gchar *data;
gulong size;
TarkinTime date;
-
+
/* data to encode */
data = GST_BUFFER_DATA (buf);
size = GST_BUFFER_SIZE (buf);
@@ -357,7 +350,8 @@ gst_tarkinenc_chain (GstPad *pad, GstData *_data)
}
static void
-gst_tarkinenc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_tarkinenc_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
TarkinEnc *tarkinenc;
@@ -382,8 +376,8 @@ gst_tarkinenc_get_property (GObject *object, guint prop_id, GValue *value, GPara
}
static void
-gst_tarkinenc_set_property (GObject *object, guint prop_id, const GValue *value,
- GParamSpec *pspec)
+gst_tarkinenc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
TarkinEnc *tarkinenc;
@@ -403,9 +397,8 @@ gst_tarkinenc_set_property (GObject *object, guint prop_id, const GValue *value,
s_moments = g_value_get_int (value);
if (s_moments != 1 || s_moments != 2 || s_moments != 4) {
g_warning ("tarkinenc: s_moments must be 1, 2 or 4");
- }
- else {
- tarkinenc->s_moments = s_moments;
+ } else {
+ tarkinenc->s_moments = s_moments;
}
break;
}
@@ -416,9 +409,8 @@ gst_tarkinenc_set_property (GObject *object, guint prop_id, const GValue *value,
a_moments = g_value_get_int (value);
if (a_moments != 1 || a_moments != 2 || a_moments != 4) {
g_warning ("tarkinenc: a_moments must be 1, 2 or 4");
- }
- else {
- tarkinenc->a_moments = a_moments;
+ } else {
+ tarkinenc->a_moments = a_moments;
}
break;
}
diff --git a/ext/tarkin/gsttarkinenc.h b/ext/tarkin/gsttarkinenc.h
index b6252a88..9e03e5ca 100644
--- a/ext/tarkin/gsttarkinenc.h
+++ b/ext/tarkin/gsttarkinenc.h
@@ -27,8 +27,9 @@
#include "tarkin.h"
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_TARKINENC \
(tarkinenc_get_type())
@@ -41,43 +42,45 @@ extern "C" {
#define GST_IS_TARKINENC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TARKINENC))
-typedef struct _TarkinEnc TarkinEnc;
-typedef struct _TarkinEncClass TarkinEncClass;
+ typedef struct _TarkinEnc TarkinEnc;
+ typedef struct _TarkinEncClass TarkinEncClass;
-struct _TarkinEnc {
- GstElement element;
+ struct _TarkinEnc
+ {
+ GstElement element;
- GstPad *sinkpad,*srcpad;
+ GstPad *sinkpad, *srcpad;
- ogg_stream_state os; /* take physical pages, weld into a logical
- stream of packets */
- ogg_page og; /* one Ogg bitstream page. Tarkin packets are inside */
- ogg_packet op[3]; /* one raw packet of data for decode */
+ ogg_stream_state os; /* take physical pages, weld into a logical
+ stream of packets */
+ ogg_page og; /* one Ogg bitstream page. Tarkin packets are inside */
+ ogg_packet op[3]; /* one raw packet of data for decode */
- TarkinStream *tarkin_stream;
- TarkinComment tc;
- TarkinInfo ti;
- TarkinVideoLayerDesc layer[1];
+ TarkinStream *tarkin_stream;
+ TarkinComment tc;
+ TarkinInfo ti;
+ TarkinVideoLayerDesc layer[1];
- gint frame_num;
-
- gboolean eos;
- gint bitrate;
- gint s_moments;
- gint a_moments;
- gboolean setup;
-};
+ gint frame_num;
-struct _TarkinEncClass {
- GstElementClass parent_class;
-};
+ gboolean eos;
+ gint bitrate;
+ gint s_moments;
+ gint a_moments;
+ gboolean setup;
+ };
-GType tarkinenc_get_type(void);
+ struct _TarkinEncClass
+ {
+ GstElementClass parent_class;
+ };
+
+ GType tarkinenc_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __TARKINENC_H__ */
+#endif /* __TARKINENC_H__ */
diff --git a/ext/tarkin/info.c b/ext/tarkin/info.c
index 60f02bd8..3b0871a3 100644
--- a/ext/tarkin/info.c
+++ b/ext/tarkin/info.c
@@ -31,272 +31,320 @@
#include "mem.h"
/* helpers */
-static void _v_writestring(oggpack_buffer *o,char *s, int bytes){
- while(bytes--){
- oggpack_write(o,*s++,8);
+static void
+_v_writestring (oggpack_buffer * o, char *s, int bytes)
+{
+ while (bytes--) {
+ oggpack_write (o, *s++, 8);
}
}
-static void _v_readstring(oggpack_buffer *o,char *buf,int bytes){
- while(bytes--){
- *buf++=oggpack_read(o,8);
+static void
+_v_readstring (oggpack_buffer * o, char *buf, int bytes)
+{
+ while (bytes--) {
+ *buf++ = oggpack_read (o, 8);
}
}
-void tarkin_comment_init(TarkinComment *vc){
- memset(vc,0,sizeof(*vc));
+void
+tarkin_comment_init (TarkinComment * vc)
+{
+ memset (vc, 0, sizeof (*vc));
}
-void tarkin_comment_add(TarkinComment *vc,char *comment){
- vc->user_comments=REALLOC(vc->user_comments,
- (vc->comments+2)*sizeof(*vc->user_comments));
- vc->comment_lengths=REALLOC(vc->comment_lengths,
- (vc->comments+2)*sizeof(*vc->comment_lengths));
- vc->comment_lengths[vc->comments]=strlen(comment);
- vc->user_comments[vc->comments]=MALLOC(vc->comment_lengths[vc->comments]+1);
- strcpy(vc->user_comments[vc->comments], comment);
+void
+tarkin_comment_add (TarkinComment * vc, char *comment)
+{
+ vc->user_comments = REALLOC (vc->user_comments,
+ (vc->comments + 2) * sizeof (*vc->user_comments));
+ vc->comment_lengths = REALLOC (vc->comment_lengths,
+ (vc->comments + 2) * sizeof (*vc->comment_lengths));
+ vc->comment_lengths[vc->comments] = strlen (comment);
+ vc->user_comments[vc->comments] =
+ MALLOC (vc->comment_lengths[vc->comments] + 1);
+ strcpy (vc->user_comments[vc->comments], comment);
vc->comments++;
- vc->user_comments[vc->comments]=NULL;
+ vc->user_comments[vc->comments] = NULL;
}
-void tarkin_comment_add_tag(TarkinComment *vc, char *tag, char *contents){
- char *comment=alloca(strlen(tag)+strlen(contents)+2); /* +2 for = and \0 */
- strcpy(comment, tag);
- strcat(comment, "=");
- strcat(comment, contents);
- tarkin_comment_add(vc, comment);
+void
+tarkin_comment_add_tag (TarkinComment * vc, char *tag, char *contents)
+{
+ char *comment = alloca (strlen (tag) + strlen (contents) + 2); /* +2 for = and \0 */
+
+ strcpy (comment, tag);
+ strcat (comment, "=");
+ strcat (comment, contents);
+ tarkin_comment_add (vc, comment);
}
/* This is more or less the same as strncasecmp - but that doesn't exist
* everywhere, and this is a fairly trivial function, so we include it */
-static int tagcompare(const char *s1, const char *s2, int n){
- int c=0;
- while(c < n){
- if(toupper(s1[c]) != toupper(s2[c]))
+static int
+tagcompare (const char *s1, const char *s2, int n)
+{
+ int c = 0;
+
+ while (c < n) {
+ if (toupper (s1[c]) != toupper (s2[c]))
return !0;
c++;
}
return 0;
}
-char *tarkin_comment_query(TarkinComment *vc, char *tag, int count){
+char *
+tarkin_comment_query (TarkinComment * vc, char *tag, int count)
+{
long i;
int found = 0;
- int taglen = strlen(tag)+1; /* +1 for the = we append */
- char *fulltag = alloca(taglen+ 1);
-
- strcpy(fulltag, tag);
- strcat(fulltag, "=");
-
- for(i=0;i<vc->comments;i++){
- if(!tagcompare(vc->user_comments[i], fulltag, taglen)){
- if(count == found)
- /* We return a pointer to the data, not a copy */
- return vc->user_comments[i] + taglen;
+ int taglen = strlen (tag) + 1; /* +1 for the = we append */
+ char *fulltag = alloca (taglen + 1);
+
+ strcpy (fulltag, tag);
+ strcat (fulltag, "=");
+
+ for (i = 0; i < vc->comments; i++) {
+ if (!tagcompare (vc->user_comments[i], fulltag, taglen)) {
+ if (count == found)
+ /* We return a pointer to the data, not a copy */
+ return vc->user_comments[i] + taglen;
else
- found++;
+ found++;
}
}
- return NULL; /* didn't find anything */
+ return NULL; /* didn't find anything */
}
-int tarkin_comment_query_count(TarkinComment *vc, char *tag){
- int i,count=0;
- int taglen = strlen(tag)+1; /* +1 for the = we append */
- char *fulltag = alloca(taglen+1);
- strcpy(fulltag,tag);
- strcat(fulltag, "=");
+int
+tarkin_comment_query_count (TarkinComment * vc, char *tag)
+{
+ int i, count = 0;
+ int taglen = strlen (tag) + 1; /* +1 for the = we append */
+ char *fulltag = alloca (taglen + 1);
- for(i=0;i<vc->comments;i++){
- if(!tagcompare(vc->user_comments[i], fulltag, taglen))
+ strcpy (fulltag, tag);
+ strcat (fulltag, "=");
+
+ for (i = 0; i < vc->comments; i++) {
+ if (!tagcompare (vc->user_comments[i], fulltag, taglen))
count++;
}
return count;
}
-void tarkin_comment_clear(TarkinComment *vc){
- if(vc){
+void
+tarkin_comment_clear (TarkinComment * vc)
+{
+ if (vc) {
long i;
- for(i=0;i<vc->comments;i++)
- if(vc->user_comments[i])FREE(vc->user_comments[i]);
- if(vc->user_comments)FREE(vc->user_comments);
- if(vc->comment_lengths)FREE(vc->comment_lengths);
- if(vc->vendor)FREE(vc->vendor);
+
+ for (i = 0; i < vc->comments; i++)
+ if (vc->user_comments[i])
+ FREE (vc->user_comments[i]);
+ if (vc->user_comments)
+ FREE (vc->user_comments);
+ if (vc->comment_lengths)
+ FREE (vc->comment_lengths);
+ if (vc->vendor)
+ FREE (vc->vendor);
}
- memset(vc,0,sizeof(*vc));
+ memset (vc, 0, sizeof (*vc));
}
/* used by synthesis, which has a full, alloced vi */
-void tarkin_info_init(TarkinInfo *vi){
- memset(vi,0,sizeof(*vi));
+void
+tarkin_info_init (TarkinInfo * vi)
+{
+ memset (vi, 0, sizeof (*vi));
}
-void tarkin_info_clear(TarkinInfo *vi){
- memset(vi,0,sizeof(*vi));
+void
+tarkin_info_clear (TarkinInfo * vi)
+{
+ memset (vi, 0, sizeof (*vi));
}
/* Header packing/unpacking ********************************************/
-static int _tarkin_unpack_info(TarkinInfo *vi,oggpack_buffer *opb)
+static int
+_tarkin_unpack_info (TarkinInfo * vi, oggpack_buffer * opb)
{
#ifdef DBG_OGG
- printf("dbg_ogg: Decoding Info: ");
+ printf ("dbg_ogg: Decoding Info: ");
#endif
- vi->version=oggpack_read(opb,32);
- if(vi->version!=0)return(-TARKIN_VERSION);
+ vi->version = oggpack_read (opb, 32);
+ if (vi->version != 0)
+ return (-TARKIN_VERSION);
+
+ vi->n_layers = oggpack_read (opb, 8);
+ vi->inter.numerator = oggpack_read (opb, 32);
+ vi->inter.denominator = oggpack_read (opb, 32);
- vi->n_layers=oggpack_read(opb,8);
- vi->inter.numerator=oggpack_read(opb,32);
- vi->inter.denominator=oggpack_read(opb,32);
-
- vi->bitrate_upper=oggpack_read(opb,32);
- vi->bitrate_nominal=oggpack_read(opb,32);
- vi->bitrate_lower=oggpack_read(opb,32);
+ vi->bitrate_upper = oggpack_read (opb, 32);
+ vi->bitrate_nominal = oggpack_read (opb, 32);
+ vi->bitrate_lower = oggpack_read (opb, 32);
#ifdef DBG_OGG
- printf(" n_layers %d, interleave: %d/%d, ",
- vi->n_layers, vi->inter.numerator, vi->inter.denominator);
+ printf (" n_layers %d, interleave: %d/%d, ",
+ vi->n_layers, vi->inter.numerator, vi->inter.denominator);
#endif
-
- if(vi->inter.numerator<1)goto err_out;
- if(vi->inter.denominator<1)goto err_out;
- if(vi->n_layers<1)goto err_out;
-
- if(oggpack_read(opb,1)!=1)goto err_out; /* EOP check */
+
+ if (vi->inter.numerator < 1)
+ goto err_out;
+ if (vi->inter.denominator < 1)
+ goto err_out;
+ if (vi->n_layers < 1)
+ goto err_out;
+
+ if (oggpack_read (opb, 1) != 1)
+ goto err_out; /* EOP check */
#ifdef DBG_OGG
- printf("Success\n");
+ printf ("Success\n");
#endif
- return(0);
- err_out:
+ return (0);
+err_out:
#ifdef DBG_OGG
- printf("Failed\n");
+ printf ("Failed\n");
#endif
- tarkin_info_clear(vi);
- return(-TARKIN_BAD_HEADER);
+ tarkin_info_clear (vi);
+ return (-TARKIN_BAD_HEADER);
}
-static int _tarkin_unpack_comment(TarkinComment *vc,oggpack_buffer *opb)
+static int
+_tarkin_unpack_comment (TarkinComment * vc, oggpack_buffer * opb)
{
- int i;
- int vendorlen=oggpack_read(opb,32);
+ int i;
+ int vendorlen = oggpack_read (opb, 32);
#ifdef DBG_OGG
- printf("dbg_ogg: Decoding comment: ");
+ printf ("dbg_ogg: Decoding comment: ");
#endif
- if(vendorlen<0)goto err_out;
- vc->vendor=_ogg_calloc(vendorlen+1,1);
- _v_readstring(opb,vc->vendor,vendorlen);
- vc->comments=oggpack_read(opb,32);
- if(vc->comments<0)goto err_out;
- vc->user_comments=_ogg_calloc(vc->comments+1,sizeof(*vc->user_comments));
- vc->comment_lengths=_ogg_calloc(vc->comments+1,
- sizeof(*vc->comment_lengths));
-
- for(i=0;i<vc->comments;i++){
- int len=oggpack_read(opb,32);
- if(len<0)goto err_out;
- vc->comment_lengths[i]=len;
- vc->user_comments[i]=_ogg_calloc(len+1,1);
- _v_readstring(opb,vc->user_comments[i],len);
- }
- if(oggpack_read(opb,1)!=1)goto err_out; /* EOP check */
+ if (vendorlen < 0)
+ goto err_out;
+ vc->vendor = _ogg_calloc (vendorlen + 1, 1);
+ _v_readstring (opb, vc->vendor, vendorlen);
+ vc->comments = oggpack_read (opb, 32);
+ if (vc->comments < 0)
+ goto err_out;
+ vc->user_comments =
+ _ogg_calloc (vc->comments + 1, sizeof (*vc->user_comments));
+ vc->comment_lengths =
+ _ogg_calloc (vc->comments + 1, sizeof (*vc->comment_lengths));
+
+ for (i = 0; i < vc->comments; i++) {
+ int len = oggpack_read (opb, 32);
+
+ if (len < 0)
+ goto err_out;
+ vc->comment_lengths[i] = len;
+ vc->user_comments[i] = _ogg_calloc (len + 1, 1);
+ _v_readstring (opb, vc->user_comments[i], len);
+ }
+ if (oggpack_read (opb, 1) != 1)
+ goto err_out; /* EOP check */
#ifdef DBG_OGG
- printf("Success, read %d comments\n", vc->comments);
+ printf ("Success, read %d comments\n", vc->comments);
#endif
- return(0);
- err_out:
+ return (0);
+err_out:
#ifdef DBG_OGG
- printf("Failed\n");
+ printf ("Failed\n");
#endif
- tarkin_comment_clear(vc);
- return(-TARKIN_BAD_HEADER);
+ tarkin_comment_clear (vc);
+ return (-TARKIN_BAD_HEADER);
}
/* the real encoding details are here, currently TarkinVideoLayerDesc. */
-static int _tarkin_unpack_layer_desc(TarkinInfo *vi,oggpack_buffer *opb){
- int i,j;
- vi->layer = CALLOC (vi->n_layers, (sizeof(*vi->layer)));
- memset(vi->layer,0, vi->n_layers * sizeof(*vi->layer));
+static int
+_tarkin_unpack_layer_desc (TarkinInfo * vi, oggpack_buffer * opb)
+{
+ int i, j;
+
+ vi->layer = CALLOC (vi->n_layers, (sizeof (*vi->layer)));
+ memset (vi->layer, 0, vi->n_layers * sizeof (*vi->layer));
#ifdef DBG_OGG
- printf("ogg: Decoding layers description: ");
+ printf ("ogg: Decoding layers description: ");
#endif
- for(i=0;i<vi->n_layers;i++){
+ for (i = 0; i < vi->n_layers; i++) {
TarkinVideoLayer *layer = vi->layer + i;
- layer->desc.width = oggpack_read(opb,32);
- layer->desc.height = oggpack_read(opb,32);
- layer->desc.a_moments = oggpack_read(opb,32);
- layer->desc.s_moments = oggpack_read(opb,32);
- layer->desc.frames_per_buf = oggpack_read(opb,32);
- layer->desc.bitstream_len = oggpack_read(opb,32);
- layer->desc.format = oggpack_read(opb,32);
+
+ layer->desc.width = oggpack_read (opb, 32);
+ layer->desc.height = oggpack_read (opb, 32);
+ layer->desc.a_moments = oggpack_read (opb, 32);
+ layer->desc.s_moments = oggpack_read (opb, 32);
+ layer->desc.frames_per_buf = oggpack_read (opb, 32);
+ layer->desc.bitstream_len = oggpack_read (opb, 32);
+ layer->desc.format = oggpack_read (opb, 32);
switch (layer->desc.format) {
- case TARKIN_GRAYSCALE:
- layer->n_comp = 1;
- layer->color_fwd_xform = grayscale_to_y;
- layer->color_inv_xform = y_to_grayscale;
- break;
- case TARKIN_RGB24:
- layer->n_comp = 3;
- layer->color_fwd_xform = rgb24_to_yuv;
- layer->color_inv_xform = yuv_to_rgb24;
- break;
- case TARKIN_RGB32:
- layer->n_comp = 3;
- layer->color_fwd_xform = rgb32_to_yuv;
- layer->color_inv_xform = yuv_to_rgb32;
- break;
- case TARKIN_RGBA:
- layer->n_comp = 4;
- layer->color_fwd_xform = rgba_to_yuv;
- layer->color_inv_xform = yuv_to_rgba;
- break;
- default:
- return -TARKIN_INVALID_COLOR_FORMAT;
+ case TARKIN_GRAYSCALE:
+ layer->n_comp = 1;
+ layer->color_fwd_xform = grayscale_to_y;
+ layer->color_inv_xform = y_to_grayscale;
+ break;
+ case TARKIN_RGB24:
+ layer->n_comp = 3;
+ layer->color_fwd_xform = rgb24_to_yuv;
+ layer->color_inv_xform = yuv_to_rgb24;
+ break;
+ case TARKIN_RGB32:
+ layer->n_comp = 3;
+ layer->color_fwd_xform = rgb32_to_yuv;
+ layer->color_inv_xform = yuv_to_rgb32;
+ break;
+ case TARKIN_RGBA:
+ layer->n_comp = 4;
+ layer->color_fwd_xform = rgba_to_yuv;
+ layer->color_inv_xform = yuv_to_rgba;
+ break;
+ default:
+ return -TARKIN_INVALID_COLOR_FORMAT;
};
- layer->waveletbuf = (Wavelet3DBuf**) CALLOC (layer->n_comp,
- sizeof(Wavelet3DBuf*));
-
- layer->packet = MALLOC (layer->n_comp * sizeof(*layer->packet));
- memset(layer->packet, 0, layer->n_comp * sizeof(*layer->packet));
-
- for (j=0; j<layer->n_comp; j++){
- layer->waveletbuf[j] = wavelet_3d_buf_new (layer->desc.width,
- layer->desc.height,
- layer->desc.frames_per_buf);
- layer->packet[j].data = MALLOC(layer->desc.bitstream_len);
- layer->packet[j].storage = layer->desc.bitstream_len;
+ layer->waveletbuf = (Wavelet3DBuf **) CALLOC (layer->n_comp,
+ sizeof (Wavelet3DBuf *));
+
+ layer->packet = MALLOC (layer->n_comp * sizeof (*layer->packet));
+ memset (layer->packet, 0, layer->n_comp * sizeof (*layer->packet));
+
+ for (j = 0; j < layer->n_comp; j++) {
+ layer->waveletbuf[j] = wavelet_3d_buf_new (layer->desc.width,
+ layer->desc.height, layer->desc.frames_per_buf);
+ layer->packet[j].data = MALLOC (layer->desc.bitstream_len);
+ layer->packet[j].storage = layer->desc.bitstream_len;
}
- vi->max_bitstream_len += layer->desc.bitstream_len
- + 2 * 10 * sizeof(uint32_t) * layer->n_comp; /* truncation tables */
+ vi->max_bitstream_len += layer->desc.bitstream_len + 2 * 10 * sizeof (uint32_t) * layer->n_comp; /* truncation tables */
#ifdef DBG_OGG
- printf("\n layer%d: size %dx%dx%d, format %d, a_m %d, s_m %d, %d fpb\n",
- i, layer->desc.width, layer->desc.height, layer->n_comp,
- layer->desc.format, layer->desc.a_moments, layer->desc.s_moments,
- layer->desc.frames_per_buf);
+ printf
+ ("\n layer%d: size %dx%dx%d, format %d, a_m %d, s_m %d, %d fpb\n",
+ i, layer->desc.width, layer->desc.height, layer->n_comp,
+ layer->desc.format, layer->desc.a_moments, layer->desc.s_moments,
+ layer->desc.frames_per_buf);
#endif
- } /* for each layer */
-
- if(oggpack_read(opb,1)!=1)goto err_out; /* EOP check */
+ } /* for each layer */
+
+ if (oggpack_read (opb, 1) != 1)
+ goto err_out; /* EOP check */
#ifdef DBG_OGG
- printf("Success\n");
+ printf ("Success\n");
#endif
-
- return(0);
- err_out:
+
+ return (0);
+err_out:
#ifdef DBG_OGG
- printf("Failed\n");
+ printf ("Failed\n");
#endif
- tarkin_info_clear(vi);
- return(-TARKIN_BAD_HEADER);
+ tarkin_info_clear (vi);
+ return (-TARKIN_BAD_HEADER);
}
/* The Tarkin header is in three packets; the initial small packet in
@@ -304,252 +352,270 @@ static int _tarkin_unpack_layer_desc(TarkinInfo *vi,oggpack_buffer *opb){
with bitstream comments and a third packet that holds the
layer description structures. */
-TarkinError tarkin_synthesis_headerin(TarkinInfo *vi,TarkinComment *vc,ogg_packet *op){
+TarkinError
+tarkin_synthesis_headerin (TarkinInfo * vi, TarkinComment * vc, ogg_packet * op)
+{
oggpack_buffer opb;
-
- if(op){
- oggpack_readinit(&opb,op->packet,op->bytes);
+
+ if (op) {
+ oggpack_readinit (&opb, op->packet, op->bytes);
/* Which of the three types of header is this? */
/* Also verify header-ness, tarkin */
{
char buffer[6];
- int packtype=oggpack_read(&opb,8);
- memset(buffer,0,6);
- _v_readstring(&opb,buffer,6);
- if(memcmp(buffer,"tarkin",6)){
- /* not a tarkin header */
- return(-TARKIN_NOT_TARKIN);
- }
- switch(packtype){
- case 0x01: /* least significant *bit* is read first */
- if(!op->b_o_s){
- /* Not the initial packet */
- return(-TARKIN_BAD_HEADER);
- }
- if(vi->inter.numerator!=0){
- /* previously initialized info header */
- return(-TARKIN_BAD_HEADER);
- }
-
- return(_tarkin_unpack_info(vi,&opb));
-
- case 0x03: /* least significant *bit* is read first */
- if(vi->inter.denominator==0){
- /* um... we didn't get the initial header */
- return(-TARKIN_BAD_HEADER);
- }
-
- return(_tarkin_unpack_comment(vc,&opb));
-
- case 0x05: /* least significant *bit* is read first */
- if(vi->inter.numerator == 0 || vc->vendor==NULL){
- /* um... we didn;t get the initial header or comments yet */
- return(-TARKIN_BAD_HEADER);
- }
-
- return(_tarkin_unpack_layer_desc(vi,&opb));
+ int packtype = oggpack_read (&opb, 8);
- default:
- /* Not a valid tarkin header type */
- return(-TARKIN_BAD_HEADER);
- break;
+ memset (buffer, 0, 6);
+ _v_readstring (&opb, buffer, 6);
+ if (memcmp (buffer, "tarkin", 6)) {
+ /* not a tarkin header */
+ return (-TARKIN_NOT_TARKIN);
+ }
+ switch (packtype) {
+ case 0x01: /* least significant *bit* is read first */
+ if (!op->b_o_s) {
+ /* Not the initial packet */
+ return (-TARKIN_BAD_HEADER);
+ }
+ if (vi->inter.numerator != 0) {
+ /* previously initialized info header */
+ return (-TARKIN_BAD_HEADER);
+ }
+
+ return (_tarkin_unpack_info (vi, &opb));
+
+ case 0x03: /* least significant *bit* is read first */
+ if (vi->inter.denominator == 0) {
+ /* um... we didn't get the initial header */
+ return (-TARKIN_BAD_HEADER);
+ }
+
+ return (_tarkin_unpack_comment (vc, &opb));
+
+ case 0x05: /* least significant *bit* is read first */
+ if (vi->inter.numerator == 0 || vc->vendor == NULL) {
+ /* um... we didn;t get the initial header or comments yet */
+ return (-TARKIN_BAD_HEADER);
+ }
+
+ return (_tarkin_unpack_layer_desc (vi, &opb));
+
+ default:
+ /* Not a valid tarkin header type */
+ return (-TARKIN_BAD_HEADER);
+ break;
}
}
}
- return(-TARKIN_BAD_HEADER);
+ return (-TARKIN_BAD_HEADER);
}
/* pack side **********************************************************/
-static int _tarkin_pack_info(oggpack_buffer *opb,TarkinInfo *vi){
+static int
+_tarkin_pack_info (oggpack_buffer * opb, TarkinInfo * vi)
+{
- /* preamble */
- oggpack_write(opb,0x01,8);
- _v_writestring(opb,"tarkin", 6);
+ /* preamble */
+ oggpack_write (opb, 0x01, 8);
+ _v_writestring (opb, "tarkin", 6);
/* basic information about the stream */
- oggpack_write(opb,0x00,32);
- oggpack_write(opb,vi->n_layers,8);
- oggpack_write(opb,vi->inter.numerator,32);
- oggpack_write(opb,vi->inter.denominator,32);
+ oggpack_write (opb, 0x00, 32);
+ oggpack_write (opb, vi->n_layers, 8);
+ oggpack_write (opb, vi->inter.numerator, 32);
+ oggpack_write (opb, vi->inter.denominator, 32);
- oggpack_write(opb,vi->bitrate_upper,32);
- oggpack_write(opb,vi->bitrate_nominal,32);
- oggpack_write(opb,vi->bitrate_lower,32);
+ oggpack_write (opb, vi->bitrate_upper, 32);
+ oggpack_write (opb, vi->bitrate_nominal, 32);
+ oggpack_write (opb, vi->bitrate_lower, 32);
- oggpack_write(opb,1,1);
+ oggpack_write (opb, 1, 1);
#ifdef DBG_OGG
- printf("dbg_ogg: Putting out info, inter %d/%d, n_layers %d\n",
- vi->inter.numerator,vi->inter.denominator,vi->n_layers);
+ printf ("dbg_ogg: Putting out info, inter %d/%d, n_layers %d\n",
+ vi->inter.numerator, vi->inter.denominator, vi->n_layers);
#endif
- return(0);
+ return (0);
}
-static int _tarkin_pack_comment(oggpack_buffer *opb,TarkinComment *vc){
- char temp[]="libTarkin debugging edition 20011104";
- int bytes = strlen(temp);
+static int
+_tarkin_pack_comment (oggpack_buffer * opb, TarkinComment * vc)
+{
+ char temp[] = "libTarkin debugging edition 20011104";
+ int bytes = strlen (temp);
- /* preamble */
- oggpack_write(opb,0x03,8);
- _v_writestring(opb,"tarkin", 6);
+ /* preamble */
+ oggpack_write (opb, 0x03, 8);
+ _v_writestring (opb, "tarkin", 6);
/* vendor */
- oggpack_write(opb,bytes,32);
- _v_writestring(opb,temp, bytes);
-
+ oggpack_write (opb, bytes, 32);
+ _v_writestring (opb, temp, bytes);
+
/* comments */
- oggpack_write(opb,vc->comments,32);
- if(vc->comments){
+ oggpack_write (opb, vc->comments, 32);
+ if (vc->comments) {
int i;
- for(i=0;i<vc->comments;i++){
- if(vc->user_comments[i]){
- oggpack_write(opb,vc->comment_lengths[i],32);
- _v_writestring(opb,vc->user_comments[i], vc->comment_lengths[i]);
- }else{
- oggpack_write(opb,0,32);
+
+ for (i = 0; i < vc->comments; i++) {
+ if (vc->user_comments[i]) {
+ oggpack_write (opb, vc->comment_lengths[i], 32);
+ _v_writestring (opb, vc->user_comments[i], vc->comment_lengths[i]);
+ } else {
+ oggpack_write (opb, 0, 32);
}
}
}
- oggpack_write(opb,1,1);
+ oggpack_write (opb, 1, 1);
#ifdef DBG_OGG
- printf("dbg_ogg: Putting out %d comments\n", vc->comments);
+ printf ("dbg_ogg: Putting out %d comments\n", vc->comments);
#endif
-
- return(0);
+
+ return (0);
}
-
-static int _tarkin_pack_layer_desc(oggpack_buffer *opb,TarkinInfo *vi)
+
+static int
+_tarkin_pack_layer_desc (oggpack_buffer * opb, TarkinInfo * vi)
{
int i;
TarkinVideoLayer *layer;
#ifdef DBG_OGG
- printf("dbg_ogg: Putting out layers description:\n");
+ printf ("dbg_ogg: Putting out layers description:\n");
#endif
- oggpack_write(opb,0x05,8);
- _v_writestring(opb,"tarkin", 6);
+ oggpack_write (opb, 0x05, 8);
+ _v_writestring (opb, "tarkin", 6);
- for(i=0;i<vi->n_layers;i++){
+ for (i = 0; i < vi->n_layers; i++) {
layer = vi->layer + i;
- oggpack_write(opb,layer->desc.width,32);
- oggpack_write(opb,layer->desc.height,32);
- oggpack_write(opb,layer->desc.a_moments,32);
- oggpack_write(opb,layer->desc.s_moments,32);
- oggpack_write(opb,layer->desc.frames_per_buf,32);
- oggpack_write(opb,layer->desc.bitstream_len,32);
- oggpack_write(opb,layer->desc.format,32);
+ oggpack_write (opb, layer->desc.width, 32);
+ oggpack_write (opb, layer->desc.height, 32);
+ oggpack_write (opb, layer->desc.a_moments, 32);
+ oggpack_write (opb, layer->desc.s_moments, 32);
+ oggpack_write (opb, layer->desc.frames_per_buf, 32);
+ oggpack_write (opb, layer->desc.bitstream_len, 32);
+ oggpack_write (opb, layer->desc.format, 32);
#ifdef DBG_OGG
- printf(" res. %dx%d, format %d, a_m %d, s_m %d, fpb %d\n",
- layer->desc.width, layer->desc.height, layer->desc.format,
- layer->desc.a_moments, layer->desc.s_moments,
- layer->desc.frames_per_buf);
+ printf (" res. %dx%d, format %d, a_m %d, s_m %d, fpb %d\n",
+ layer->desc.width, layer->desc.height, layer->desc.format,
+ layer->desc.a_moments, layer->desc.s_moments,
+ layer->desc.frames_per_buf);
#endif
-
+
}
- oggpack_write(opb,1,1);
+ oggpack_write (opb, 1, 1);
#ifdef DBG_OGG
- printf(" wrote %ld bytes.\n", oggpack_bytes(opb));
+ printf (" wrote %ld bytes.\n", oggpack_bytes (opb));
#endif
-
- return(0);
-}
-int tarkin_comment_header_out(TarkinComment *vc, ogg_packet *op)
+ return (0);
+}
+
+int
+tarkin_comment_header_out (TarkinComment * vc, ogg_packet * op)
{
oggpack_buffer opb;
- oggpack_writeinit(&opb);
- if(_tarkin_pack_comment(&opb,vc)) return -TARKIN_NOT_IMPLEMENTED;
+ oggpack_writeinit (&opb);
+ if (_tarkin_pack_comment (&opb, vc))
+ return -TARKIN_NOT_IMPLEMENTED;
- op->packet = MALLOC(oggpack_bytes(&opb));
- memcpy(op->packet, opb.buffer, oggpack_bytes(&opb));
+ op->packet = MALLOC (oggpack_bytes (&opb));
+ memcpy (op->packet, opb.buffer, oggpack_bytes (&opb));
- op->bytes=oggpack_bytes(&opb);
- op->b_o_s=0;
- op->e_o_s=0;
- op->granulepos=0;
+ op->bytes = oggpack_bytes (&opb);
+ op->b_o_s = 0;
+ op->e_o_s = 0;
+ op->granulepos = 0;
return 0;
}
-TarkinError tarkin_analysis_headerout(TarkinStream *v,
- TarkinComment *vc,
- ogg_packet *op,
- ogg_packet *op_comm,
- ogg_packet *op_code)
+TarkinError
+tarkin_analysis_headerout (TarkinStream * v,
+ TarkinComment * vc,
+ ogg_packet * op, ogg_packet * op_comm, ogg_packet * op_code)
{
- int ret=-TARKIN_NOT_IMPLEMENTED;
- TarkinInfo * vi;
- oggpack_buffer opb;
- tarkin_header_store *b=&v->headers;
-
- vi = v->ti;
-
- /* first header packet **********************************************/
-
- oggpack_writeinit(&opb);
- if(_tarkin_pack_info(&opb,vi))goto err_out;
-
- /* build the packet */
- if(b->header)FREE(b->header);
- b->header=MALLOC(oggpack_bytes(&opb));
- memcpy(b->header,opb.buffer,oggpack_bytes(&opb));
- op->packet=b->header;
- op->bytes=oggpack_bytes(&opb);
- op->b_o_s=1;
- op->e_o_s=0;
- op->granulepos=0;
-
- /* second header packet (comments) **********************************/
-
- oggpack_reset(&opb);
- if(_tarkin_pack_comment(&opb,vc))goto err_out;
-
- if(b->header1)FREE(b->header1);
- b->header1=MALLOC(oggpack_bytes(&opb));
- memcpy(b->header1,opb.buffer,oggpack_bytes(&opb));
- op_comm->packet=b->header1;
- op_comm->bytes=oggpack_bytes(&opb);
- op_comm->b_o_s=0;
- op_comm->e_o_s=0;
- op_comm->granulepos=0;
-
- /* third header packet (modes/codebooks) ****************************/
-
- oggpack_reset(&opb);
- if(_tarkin_pack_layer_desc(&opb,vi))goto err_out;
-
- if(b->header2)FREE(b->header2);
- b->header2=MALLOC(oggpack_bytes(&opb));
- memcpy(b->header2,opb.buffer,oggpack_bytes(&opb));
- op_code->packet=b->header2;
- op_code->bytes=oggpack_bytes(&opb);
- op_code->b_o_s=0;
- op_code->e_o_s=0;
- op_code->granulepos=0;
-
- oggpack_writeclear(&opb);
- return(0);
- err_out:
- oggpack_writeclear(&opb);
- memset(op,0,sizeof(*op));
- memset(op_comm,0,sizeof(*op_comm));
- memset(op_code,0,sizeof(*op_code));
-
- if(b->header)FREE(b->header);
- if(b->header1)FREE(b->header1);
- if(b->header2)FREE(b->header2);
- b->header=NULL;
- b->header1=NULL;
- b->header2=NULL;
- return(ret);
+ int ret = -TARKIN_NOT_IMPLEMENTED;
+ TarkinInfo *vi;
+ oggpack_buffer opb;
+ tarkin_header_store *b = &v->headers;
+
+ vi = v->ti;
+
+ /* first header packet ********************************************* */
+
+ oggpack_writeinit (&opb);
+ if (_tarkin_pack_info (&opb, vi))
+ goto err_out;
+
+ /* build the packet */
+ if (b->header)
+ FREE (b->header);
+ b->header = MALLOC (oggpack_bytes (&opb));
+ memcpy (b->header, opb.buffer, oggpack_bytes (&opb));
+ op->packet = b->header;
+ op->bytes = oggpack_bytes (&opb);
+ op->b_o_s = 1;
+ op->e_o_s = 0;
+ op->granulepos = 0;
+
+ /* second header packet (comments) ********************************* */
+
+ oggpack_reset (&opb);
+ if (_tarkin_pack_comment (&opb, vc))
+ goto err_out;
+
+ if (b->header1)
+ FREE (b->header1);
+ b->header1 = MALLOC (oggpack_bytes (&opb));
+ memcpy (b->header1, opb.buffer, oggpack_bytes (&opb));
+ op_comm->packet = b->header1;
+ op_comm->bytes = oggpack_bytes (&opb);
+ op_comm->b_o_s = 0;
+ op_comm->e_o_s = 0;
+ op_comm->granulepos = 0;
+
+ /* third header packet (modes/codebooks) *************************** */
+
+ oggpack_reset (&opb);
+ if (_tarkin_pack_layer_desc (&opb, vi))
+ goto err_out;
+
+ if (b->header2)
+ FREE (b->header2);
+ b->header2 = MALLOC (oggpack_bytes (&opb));
+ memcpy (b->header2, opb.buffer, oggpack_bytes (&opb));
+ op_code->packet = b->header2;
+ op_code->bytes = oggpack_bytes (&opb);
+ op_code->b_o_s = 0;
+ op_code->e_o_s = 0;
+ op_code->granulepos = 0;
+
+ oggpack_writeclear (&opb);
+ return (0);
+err_out:
+ oggpack_writeclear (&opb);
+ memset (op, 0, sizeof (*op));
+ memset (op_comm, 0, sizeof (*op_comm));
+ memset (op_code, 0, sizeof (*op_code));
+
+ if (b->header)
+ FREE (b->header);
+ if (b->header1)
+ FREE (b->header1);
+ if (b->header2)
+ FREE (b->header2);
+ b->header = NULL;
+ b->header1 = NULL;
+ b->header2 = NULL;
+ return (ret);
}
-
diff --git a/ext/tarkin/mem.c b/ext/tarkin/mem.c
index 2c304b7a..6b337ef3 100644
--- a/ext/tarkin/mem.c
+++ b/ext/tarkin/mem.c
@@ -10,11 +10,12 @@
#if defined(DBG_MEMLEAKS)
-typedef struct {
- void *mem;
- char *allocated_in_func;
- char *allocated_in_file;
- unsigned int allocated_in_line;
+typedef struct
+{
+ void *mem;
+ char *allocated_in_func;
+ char *allocated_in_file;
+ unsigned int allocated_in_line;
} MemDesc;
@@ -23,124 +24,129 @@ static int alloc_count = 0;
static MemDesc *alloc_list = NULL;
-static
-void dbg_memleaks_done (int exitcode, void *dummy)
+static void
+dbg_memleaks_done (int exitcode, void *dummy)
{
- unsigned int i;
- (void) dummy;
-
- if (exitcode == 0 && alloc_count != 0) {
- fprintf (stderr, "\nmemory leak detected !!!\n");
- fprintf (stderr, "\nalloc_count == %i\n\n", alloc_count);
- for (i=0; i<alloc_count; i++) {
- MemDesc *d = &alloc_list[i];
- fprintf (stderr, "chunk %p allocated in %s (%s: %u) not free'd !!\n",
- d->mem, d->allocated_in_func, d->allocated_in_file,
- d->allocated_in_line);
- }
- free(alloc_list);
- }
- fprintf (stderr, "\n");
+ unsigned int i;
+
+ (void) dummy;
+
+ if (exitcode == 0 && alloc_count != 0) {
+ fprintf (stderr, "\nmemory leak detected !!!\n");
+ fprintf (stderr, "\nalloc_count == %i\n\n", alloc_count);
+ for (i = 0; i < alloc_count; i++) {
+ MemDesc *d = &alloc_list[i];
+
+ fprintf (stderr, "chunk %p allocated in %s (%s: %u) not free'd !!\n",
+ d->mem, d->allocated_in_func, d->allocated_in_file,
+ d->allocated_in_line);
+ }
+ free (alloc_list);
+ }
+ fprintf (stderr, "\n");
}
-static
-void dbg_memleaks_init (void)
+static void
+dbg_memleaks_init (void)
{
- on_exit (dbg_memleaks_done, NULL);
- initialized = 1;
+ on_exit (dbg_memleaks_done, NULL);
+ initialized = 1;
}
-void* dbg_malloc (char* file, int line, char *func, size_t bytes)
+void *
+dbg_malloc (char *file, int line, char *func, size_t bytes)
{
- void *mem = (void*) malloc (bytes);
- MemDesc *d;
+ void *mem = (void *) malloc (bytes);
+ MemDesc *d;
- if (!initialized)
- dbg_memleaks_init();
+ if (!initialized)
+ dbg_memleaks_init ();
- alloc_count++;
- alloc_list = realloc (alloc_list, alloc_count * sizeof(MemDesc));
+ alloc_count++;
+ alloc_list = realloc (alloc_list, alloc_count * sizeof (MemDesc));
- d = &alloc_list[alloc_count-1];
- d->mem = mem;
- d->allocated_in_func = func;
- d->allocated_in_file = file;
- d->allocated_in_line = line;
+ d = &alloc_list[alloc_count - 1];
+ d->mem = mem;
+ d->allocated_in_func = func;
+ d->allocated_in_file = file;
+ d->allocated_in_line = line;
- return mem;
+ return mem;
}
-void* dbg_calloc (char* file, int line, char *func, size_t count, size_t bytes)
+void *
+dbg_calloc (char *file, int line, char *func, size_t count, size_t bytes)
{
- void *mem = (void*) calloc (count, bytes);
- MemDesc *d;
+ void *mem = (void *) calloc (count, bytes);
+ MemDesc *d;
- if (!initialized)
- dbg_memleaks_init();
+ if (!initialized)
+ dbg_memleaks_init ();
- alloc_count++;
- alloc_list = realloc (alloc_list, alloc_count * sizeof(MemDesc));
+ alloc_count++;
+ alloc_list = realloc (alloc_list, alloc_count * sizeof (MemDesc));
- d = &alloc_list[alloc_count-1];
- d->mem = mem;
- d->allocated_in_func = func;
- d->allocated_in_file = file;
- d->allocated_in_line = line;
+ d = &alloc_list[alloc_count - 1];
+ d->mem = mem;
+ d->allocated_in_func = func;
+ d->allocated_in_file = file;
+ d->allocated_in_line = line;
- return mem;
+ return mem;
}
-void* dbg_realloc (char *file, int line, char *func, char *what,
- void *mem, size_t bytes)
+void *
+dbg_realloc (char *file, int line, char *func, char *what,
+ void *mem, size_t bytes)
{
- unsigned int i;
-
- for (i=0; i<alloc_count; i++) {
- if (alloc_list[i].mem == mem) {
- alloc_list[i].mem = (void*) realloc (mem, bytes);
- return alloc_list[i].mem;
- }
- }
-
- if (mem != NULL) {
- fprintf (stderr,
- "%s: trying to reallocate unknown chunk %p (%s)\n"
- " in %s (%s: %u) !!!\n",
- __FUNCTION__, mem, what, func, file, line);
- exit (-1);
- }
-
- return dbg_malloc(file, line, func, bytes);
+ unsigned int i;
+
+ for (i = 0; i < alloc_count; i++) {
+ if (alloc_list[i].mem == mem) {
+ alloc_list[i].mem = (void *) realloc (mem, bytes);
+ return alloc_list[i].mem;
+ }
+ }
+
+ if (mem != NULL) {
+ fprintf (stderr,
+ "%s: trying to reallocate unknown chunk %p (%s)\n"
+ " in %s (%s: %u) !!!\n",
+ __FUNCTION__, mem, what, func, file, line);
+ exit (-1);
+ }
+
+ return dbg_malloc (file, line, func, bytes);
}
-void dbg_free (char *file, int line, char *func, char *what, void *mem)
+void
+dbg_free (char *file, int line, char *func, char *what, void *mem)
{
- unsigned int i;
-
- if (!initialized)
- dbg_memleaks_init();
-
- for (i=0; i<alloc_count; i++) {
- if (alloc_list[i].mem == mem) {
- free (mem);
- alloc_count--;
- memmove (&alloc_list[i], &alloc_list[i+1],
- (alloc_count - i) * sizeof(MemDesc));
- return;
- }
- }
-
- fprintf (stderr, "%s: trying to free unknown chunk %p (%s)\n"
- " in %s (%s: %u) !!!\n",
- __FUNCTION__, mem, what, func, file, line);
- exit (-1);
+ unsigned int i;
+
+ if (!initialized)
+ dbg_memleaks_init ();
+
+ for (i = 0; i < alloc_count; i++) {
+ if (alloc_list[i].mem == mem) {
+ free (mem);
+ alloc_count--;
+ memmove (&alloc_list[i], &alloc_list[i + 1],
+ (alloc_count - i) * sizeof (MemDesc));
+ return;
+ }
+ }
+
+ fprintf (stderr, "%s: trying to free unknown chunk %p (%s)\n"
+ " in %s (%s: %u) !!!\n",
+ __FUNCTION__, mem, what, func, file, line);
+ exit (-1);
}
#endif
-
diff --git a/ext/tarkin/mem.h b/ext/tarkin/mem.h
index f218f8e4..f6e4c726 100644
--- a/ext/tarkin/mem.h
+++ b/ext/tarkin/mem.h
@@ -9,9 +9,11 @@
#if defined(DBG_MEMLEAKS)
-extern void* dbg_malloc (char *file, int line, char *func, size_t bytes);
-extern void* dbg_calloc (char *file, int line, char *func, size_t count, size_t bytes);
-extern void* dbg_realloc (char *file, int line, char *func, char *what, void *mem, size_t bytes);
+extern void *dbg_malloc (char *file, int line, char *func, size_t bytes);
+extern void *dbg_calloc (char *file, int line, char *func, size_t count,
+ size_t bytes);
+extern void *dbg_realloc (char *file, int line, char *func, char *what,
+ void *mem, size_t bytes);
extern void dbg_free (char *file, int line, char *func, char *what, void *mem);
#define MALLOC(bytes) dbg_malloc(__FILE__,__LINE__,__FUNCTION__,bytes)
@@ -29,4 +31,3 @@ extern void dbg_free (char *file, int line, char *func, char *what, void *mem);
#endif
#endif
-
diff --git a/ext/tarkin/rle.h b/ext/tarkin/rle.h
index 7cf79517..6ccef22b 100644
--- a/ext/tarkin/rle.h
+++ b/ext/tarkin/rle.h
@@ -19,7 +19,7 @@
#define ENTROPY_ENCODER_FLUSH(coder) rlecoder_encoder_flush(coder)
#define ENTROPY_DECODER_INIT(coder,bitstream,limit) \
rlecoder_decoder_init(coder,bitstream,limit)
-#define ENTROPY_DECODER_DONE(coder) /* nothing to do ... */
+#define ENTROPY_DECODER_DONE(coder) /* nothing to do ... */
#define ENTROPY_CODER_BITSTREAM(coder) ((coder)->bitcoder.bitstream)
#define ENTROPY_CODER_EOS(coder) ((coder)->bitcoder.eos)
@@ -31,12 +31,13 @@
-typedef struct {
- int symbol;
- uint32_t count; /* have seen count symbol's */
- BitCoderState bitcoder;
- GolombAdaptiveCoderState golomb_state [2]; /* 2 states for 2 symbols... */
- int have_seen_1;
+typedef struct
+{
+ int symbol;
+ uint32_t count; /* have seen count symbol's */
+ BitCoderState bitcoder;
+ GolombAdaptiveCoderState golomb_state[2]; /* 2 states for 2 symbols... */
+ int have_seen_1;
} RLECoderState;
@@ -44,100 +45,99 @@ typedef struct {
/*
* bit should be 0 or 1 !!!
*/
-static inline
-void rlecoder_write_bit (RLECoderState *s, int bit)
+static inline void
+rlecoder_write_bit (RLECoderState * s, int bit)
{
- assert (bit == 0 || bit == 1);
-
- if (s->symbol == -1) {
- s->symbol = bit & 1;
- s->count = 1;
- s->have_seen_1 = bit;
- bitcoder_write_bit (&s->bitcoder, bit);
- }
-
- if (s->symbol != bit) {
- golombcoder_encode_number (&s->golomb_state[s->symbol],
- &s->bitcoder, s->count);
- s->symbol = ~s->symbol & 1;
- s->have_seen_1 = 1;
- s->count = 1;
- } else
- s->count++;
+ assert (bit == 0 || bit == 1);
+
+ if (s->symbol == -1) {
+ s->symbol = bit & 1;
+ s->count = 1;
+ s->have_seen_1 = bit;
+ bitcoder_write_bit (&s->bitcoder, bit);
+ }
+
+ if (s->symbol != bit) {
+ golombcoder_encode_number (&s->golomb_state[s->symbol],
+ &s->bitcoder, s->count);
+ s->symbol = ~s->symbol & 1;
+ s->have_seen_1 = 1;
+ s->count = 1;
+ } else
+ s->count++;
}
-static inline
-int rlecoder_read_bit (RLECoderState *s)
+static inline int
+rlecoder_read_bit (RLECoderState * s)
{
- if (s->count == 0) {
- s->symbol = ~s->symbol & 1;
- s->count = golombcoder_decode_number (&s->golomb_state[s->symbol],
- &s->bitcoder);
- if (s->bitcoder.eos) {
- s->symbol = 0;
- s->count = ~0;
- }
- }
- s->count--;
- return (s->symbol);
+ if (s->count == 0) {
+ s->symbol = ~s->symbol & 1;
+ s->count = golombcoder_decode_number (&s->golomb_state[s->symbol],
+ &s->bitcoder);
+ if (s->bitcoder.eos) {
+ s->symbol = 0;
+ s->count = ~0;
+ }
+ }
+ s->count--;
+ return (s->symbol);
}
int coder_id = 0;
FILE *file = NULL;
-static inline
-void rlecoder_encoder_init (RLECoderState *s, uint32_t limit)
+static inline void
+rlecoder_encoder_init (RLECoderState * s, uint32_t limit)
{
- bitcoder_encoder_init (&s->bitcoder, limit);
- s->symbol = -1;
- s->have_seen_1 = 0;
- s->golomb_state[0].count = 0;
- s->golomb_state[1].count = 0;
- s->golomb_state[0].bits = 5 << 3;
- s->golomb_state[1].bits = 5 << 3;
+ bitcoder_encoder_init (&s->bitcoder, limit);
+ s->symbol = -1;
+ s->have_seen_1 = 0;
+ s->golomb_state[0].count = 0;
+ s->golomb_state[1].count = 0;
+ s->golomb_state[0].bits = 5 << 3;
+ s->golomb_state[1].bits = 5 << 3;
}
/**
* once you called this, you better should not encode any more symbols ...
*/
-static inline
-uint32_t rlecoder_encoder_flush (RLECoderState *s)
+static inline uint32_t
+rlecoder_encoder_flush (RLECoderState * s)
{
- if (s->symbol == -1 || !s->have_seen_1)
- return 0;
+ if (s->symbol == -1 || !s->have_seen_1)
+ return 0;
- golombcoder_encode_number (&s->golomb_state[s->symbol],
- &s->bitcoder, s->count);
- return bitcoder_flush (&s->bitcoder);
+ golombcoder_encode_number (&s->golomb_state[s->symbol],
+ &s->bitcoder, s->count);
+ return bitcoder_flush (&s->bitcoder);
}
-static inline
-void rlecoder_decoder_init (RLECoderState *s, uint8_t *bitstream, uint32_t limit)
+static inline void
+rlecoder_decoder_init (RLECoderState * s, uint8_t * bitstream, uint32_t limit)
{
- bitcoder_decoder_init (&s->bitcoder, bitstream, limit);
- s->golomb_state[0].count = 0;
- s->golomb_state[1].count = 0;
- s->golomb_state[0].bits = 5 << 3;
- s->golomb_state[1].bits = 5 << 3;
- s->symbol = bitcoder_read_bit (&s->bitcoder);
- s->count = golombcoder_decode_number (&s->golomb_state[s->symbol],
- &s->bitcoder) - 1;
- if (s->bitcoder.eos) {
- s->symbol = 0;
- s->count = ~0;
- }
+ bitcoder_decoder_init (&s->bitcoder, bitstream, limit);
+ s->golomb_state[0].count = 0;
+ s->golomb_state[1].count = 0;
+ s->golomb_state[0].bits = 5 << 3;
+ s->golomb_state[1].bits = 5 << 3;
+ s->symbol = bitcoder_read_bit (&s->bitcoder);
+ s->count = golombcoder_decode_number (&s->golomb_state[s->symbol],
+ &s->bitcoder) - 1;
+ if (s->bitcoder.eos) {
+ s->symbol = 0;
+ s->count = ~0;
+ }
}
-static inline
-void rlecoder_encoder_done (RLECoderState *s)
+static inline void
+rlecoder_encoder_done (RLECoderState * s)
{
- bitcoder_encoder_done (&s->bitcoder);
+ bitcoder_encoder_done (&s->bitcoder);
}
#endif
-
diff --git a/ext/tarkin/tarkin.c b/ext/tarkin/tarkin.c
index 163fa87c..b15b5512 100644
--- a/ext/tarkin/tarkin.c
+++ b/ext/tarkin/tarkin.c
@@ -16,244 +16,249 @@
-TarkinStream* tarkin_stream_new ()
+TarkinStream *
+tarkin_stream_new ()
{
- TarkinStream *s = (TarkinStream*) CALLOC (1, sizeof(TarkinStream));
+ TarkinStream *s = (TarkinStream *) CALLOC (1, sizeof (TarkinStream));
- if (!s)
- return NULL;
- memset(s,0,sizeof(*s));
+ if (!s)
+ return NULL;
+ memset (s, 0, sizeof (*s));
- s->frames_per_buf = N_FRAMES;
+ s->frames_per_buf = N_FRAMES;
- return s;
+ return s;
}
-void tarkin_stream_destroy (TarkinStream *s)
+void
+tarkin_stream_destroy (TarkinStream * s)
{
- uint32_t i, j;
-
- if (!s)
- return;
-
- for (i=0; i<s->n_layers; i++) {
- if (s->layer[i].waveletbuf) {
- for (j=0; j<s->layer[i].n_comp; j++) {
- wavelet_3d_buf_destroy (s->layer[i].waveletbuf[j]);
- FREE (s->layer[i].packet[j].data);
- }
- FREE(s->layer[i].waveletbuf);
- FREE(s->layer[i].packet);
+ uint32_t i, j;
+
+ if (!s)
+ return;
+
+ for (i = 0; i < s->n_layers; i++) {
+ if (s->layer[i].waveletbuf) {
+ for (j = 0; j < s->layer[i].n_comp; j++) {
+ wavelet_3d_buf_destroy (s->layer[i].waveletbuf[j]);
+ FREE (s->layer[i].packet[j].data);
}
- }
-
- if (s->layer)
- FREE(s->layer);
+ FREE (s->layer[i].waveletbuf);
+ FREE (s->layer[i].packet);
+ }
+ }
+
+ if (s->layer)
+ FREE (s->layer);
- if (s->headers.header)
- FREE(s->headers.header);
+ if (s->headers.header)
+ FREE (s->headers.header);
- if (s->headers.header1)
- FREE(s->headers.header1);
+ if (s->headers.header1)
+ FREE (s->headers.header1);
- if (s->headers.header2)
- FREE(s->headers.header2);
+ if (s->headers.header2)
+ FREE (s->headers.header2);
- FREE(s);
+ FREE (s);
}
-int tarkin_analysis_init(TarkinStream *s, TarkinInfo *ti,
- TarkinError (*free_frame)(void *s, void *ptr),
- TarkinError (*packet_out)(void *s, ogg_packet *ptr),
- void *user_ptr)
+int
+tarkin_analysis_init (TarkinStream * s, TarkinInfo * ti,
+ TarkinError (*free_frame) (void *s, void *ptr),
+ TarkinError (*packet_out) (void *s, ogg_packet * ptr), void *user_ptr)
{
- if((!ti->inter.numerator)||(!ti->inter.denominator))return (-TARKIN_FAULT);
- if((!free_frame) || (!packet_out)) return (-TARKIN_FAULT);
- s->ti = ti;
- s->free_frame = free_frame;
- s->packet_out = packet_out;
- s->user_ptr = user_ptr;
- return(0);
+ if ((!ti->inter.numerator) || (!ti->inter.denominator))
+ return (-TARKIN_FAULT);
+ if ((!free_frame) || (!packet_out))
+ return (-TARKIN_FAULT);
+ s->ti = ti;
+ s->free_frame = free_frame;
+ s->packet_out = packet_out;
+ s->user_ptr = user_ptr;
+ return (0);
}
-extern int tarkin_analysis_add_layer(TarkinStream *s,
- TarkinVideoLayerDesc *tvld)
+extern int
+tarkin_analysis_add_layer (TarkinStream * s, TarkinVideoLayerDesc * tvld)
{
- int i;
- TarkinVideoLayer *layer;
- if(s->n_layers) {
- s->layer = REALLOC(s->layer,(s->n_layers+1) * sizeof(*s->layer));
- } else {
- s->layer = MALLOC(sizeof(*s->layer));
- }
- layer = s->layer + s->n_layers;
- memset(layer,0,sizeof(*s->layer));
- memcpy (&layer->desc , tvld, sizeof(TarkinVideoLayerDesc));
-
- s->n_layers++;
- s->ti->n_layers = s->n_layers;
- s->ti->layer = s->layer;
-
- switch (layer->desc.format) {
- case TARKIN_GRAYSCALE:
- layer->n_comp = 1;
- layer->color_fwd_xform = grayscale_to_y;
- layer->color_inv_xform = y_to_grayscale;
- break;
- case TARKIN_RGB24:
- layer->n_comp = 3;
- layer->color_fwd_xform = rgb24_to_yuv;
- layer->color_inv_xform = yuv_to_rgb24;
- break;
- case TARKIN_RGB32:
- layer->n_comp = 3;
- layer->color_fwd_xform = rgb32_to_yuv;
- layer->color_inv_xform = yuv_to_rgb32;
- break;
- case TARKIN_RGBA:
- layer->n_comp = 4;
- layer->color_fwd_xform = rgba_to_yuv;
- layer->color_inv_xform = yuv_to_rgba;
- break;
- default:
- return -TARKIN_INVALID_COLOR_FORMAT;
- };
-
-#ifdef DBG_OGG
- printf("dbg_ogg:add_layer %d with %d components\n",
- s->n_layers, layer->n_comp);
-#endif
-
- layer->waveletbuf = (Wavelet3DBuf**) CALLOC (layer->n_comp,
- sizeof(Wavelet3DBuf*));
-
- layer->packet = MALLOC (layer->n_comp * sizeof(*layer->packet));
- memset(layer->packet, 0, layer->n_comp * sizeof(*layer->packet));
-
- for (i=0; i<layer->n_comp; i++){
- layer->waveletbuf[i] = wavelet_3d_buf_new (layer->desc.width,
- layer->desc.height,
- layer->desc.frames_per_buf);
- layer->packet[i].data = MALLOC(layer->desc.bitstream_len);
- layer->packet[i].storage = layer->desc.bitstream_len;
- }
- /*
- max_bitstream_len += layer->desc.bitstream_len
- + 2 * 10 * sizeof(uint32_t) * layer->n_comp;
+ int i;
+ TarkinVideoLayer *layer;
+
+ if (s->n_layers) {
+ s->layer = REALLOC (s->layer, (s->n_layers + 1) * sizeof (*s->layer));
+ } else {
+ s->layer = MALLOC (sizeof (*s->layer));
+ }
+ layer = s->layer + s->n_layers;
+ memset (layer, 0, sizeof (*s->layer));
+ memcpy (&layer->desc, tvld, sizeof (TarkinVideoLayerDesc));
+
+ s->n_layers++;
+ s->ti->n_layers = s->n_layers;
+ s->ti->layer = s->layer;
+
+ switch (layer->desc.format) {
+ case TARKIN_GRAYSCALE:
+ layer->n_comp = 1;
+ layer->color_fwd_xform = grayscale_to_y;
+ layer->color_inv_xform = y_to_grayscale;
+ break;
+ case TARKIN_RGB24:
+ layer->n_comp = 3;
+ layer->color_fwd_xform = rgb24_to_yuv;
+ layer->color_inv_xform = yuv_to_rgb24;
+ break;
+ case TARKIN_RGB32:
+ layer->n_comp = 3;
+ layer->color_fwd_xform = rgb32_to_yuv;
+ layer->color_inv_xform = yuv_to_rgb32;
+ break;
+ case TARKIN_RGBA:
+ layer->n_comp = 4;
+ layer->color_fwd_xform = rgba_to_yuv;
+ layer->color_inv_xform = yuv_to_rgba;
+ break;
+ default:
+ return -TARKIN_INVALID_COLOR_FORMAT;
+ };
+
+#ifdef DBG_OGG
+ printf ("dbg_ogg:add_layer %d with %d components\n",
+ s->n_layers, layer->n_comp);
+#endif
+
+ layer->waveletbuf = (Wavelet3DBuf **) CALLOC (layer->n_comp,
+ sizeof (Wavelet3DBuf *));
+
+ layer->packet = MALLOC (layer->n_comp * sizeof (*layer->packet));
+ memset (layer->packet, 0, layer->n_comp * sizeof (*layer->packet));
+
+ for (i = 0; i < layer->n_comp; i++) {
+ layer->waveletbuf[i] = wavelet_3d_buf_new (layer->desc.width,
+ layer->desc.height, layer->desc.frames_per_buf);
+ layer->packet[i].data = MALLOC (layer->desc.bitstream_len);
+ layer->packet[i].storage = layer->desc.bitstream_len;
+ }
+ /*
+ max_bitstream_len += layer->desc.bitstream_len
+ + 2 * 10 * sizeof(uint32_t) * layer->n_comp;
*/
- return (TARKIN_OK);
+ return (TARKIN_OK);
}
-TarkinError _analysis_packetout(TarkinStream *s, uint32_t layer_id,
- uint32_t comp)
+TarkinError
+_analysis_packetout (TarkinStream * s, uint32_t layer_id, uint32_t comp)
{
- ogg_packet op;
- oggpack_buffer opb;
- uint8_t *data;
- uint32_t data_len;
- int i;
- data = s->layer[layer_id].packet[comp].data;
- data_len = s->layer[layer_id].packet[comp].data_len;
-
- oggpack_writeinit(&opb);
- oggpack_write(&opb,0,8); /* No feature flags for now */
- oggpack_write(&opb,layer_id,12);
- oggpack_write(&opb,comp,12);
- for(i=0;i<data_len;i++)
- oggpack_write(&opb,*(data + i), 8);
-
- op.b_o_s = 0;
- op.e_o_s = data_len?0:1;
- op.granulepos = 0;
- op.bytes = oggpack_bytes(&opb)+4;
- op.packet = opb.buffer;
+ ogg_packet op;
+ oggpack_buffer opb;
+ uint8_t *data;
+ uint32_t data_len;
+ int i;
+
+ data = s->layer[layer_id].packet[comp].data;
+ data_len = s->layer[layer_id].packet[comp].data_len;
+
+ oggpack_writeinit (&opb);
+ oggpack_write (&opb, 0, 8); /* No feature flags for now */
+ oggpack_write (&opb, layer_id, 12);
+ oggpack_write (&opb, comp, 12);
+ for (i = 0; i < data_len; i++)
+ oggpack_write (&opb, *(data + i), 8);
+
+ op.b_o_s = 0;
+ op.e_o_s = data_len ? 0 : 1;
+ op.granulepos = 0;
+ op.bytes = oggpack_bytes (&opb) + 4;
+ op.packet = opb.buffer;
#ifdef DBG_OGG
- printf("dbg_ogg: writing packet layer %d, comp %d, data_len %d %s\n",
- layer_id, comp, data_len, op.e_o_s?"eos":"");
+ printf ("dbg_ogg: writing packet layer %d, comp %d, data_len %d %s\n",
+ layer_id, comp, data_len, op.e_o_s ? "eos" : "");
#endif
- s->layer[layer_id].packet[comp].data_len = 0; /* so direct call => eos */
- return(s->packet_out(s,&op));
+ s->layer[layer_id].packet[comp].data_len = 0; /* so direct call => eos */
+ return (s->packet_out (s, &op));
}
-void _stream_flush (TarkinStream *s)
+void
+_stream_flush (TarkinStream * s)
{
- uint32_t i, j;
+ uint32_t i, j;
- s->current_frame_in_buf=0;
+ s->current_frame_in_buf = 0;
- for (i=0; i<s->n_layers; i++) {
- TarkinVideoLayer *layer = &s->layer[i];
+ for (i = 0; i < s->n_layers; i++) {
+ TarkinVideoLayer *layer = &s->layer[i];
- for (j=0; j<layer->n_comp; j++) {
- uint32_t comp_bitstream_len;
- TarkinPacket *packet = layer->packet + j;
+ for (j = 0; j < layer->n_comp; j++) {
+ uint32_t comp_bitstream_len;
+ TarkinPacket *packet = layer->packet + j;
- /**
+ /**
* implicit 6:1:1 subsampling
*/
- if (j == 0)
- comp_bitstream_len = 6*layer->desc.bitstream_len/(layer->n_comp+5);
- else
- comp_bitstream_len = layer->desc.bitstream_len/(layer->n_comp+5);
-
- if(packet->storage < comp_bitstream_len) {
- packet->storage = comp_bitstream_len;
- packet->data = REALLOC (packet->data, comp_bitstream_len);
- }
-
- wavelet_3d_buf_dump ("color-%d-%03d.pgm",
- s->current_frame, j,
- layer->waveletbuf[j], j == 0 ? 0 : 128);
-
- wavelet_3d_buf_fwd_xform (layer->waveletbuf[j],
- layer->desc.a_moments,
- layer->desc.s_moments);
-
- wavelet_3d_buf_dump ("coeff-%d-%03d.pgm",
- s->current_frame, j,
- layer->waveletbuf[j], 128);
-
- packet->data_len = wavelet_3d_buf_encode_coeff (layer->waveletbuf[j],
- packet->data,
- comp_bitstream_len);
-
- _analysis_packetout (s, i, j);
+ if (j == 0)
+ comp_bitstream_len =
+ 6 * layer->desc.bitstream_len / (layer->n_comp + 5);
+ else
+ comp_bitstream_len = layer->desc.bitstream_len / (layer->n_comp + 5);
+
+ if (packet->storage < comp_bitstream_len) {
+ packet->storage = comp_bitstream_len;
+ packet->data = REALLOC (packet->data, comp_bitstream_len);
}
- }
+
+ wavelet_3d_buf_dump ("color-%d-%03d.pgm",
+ s->current_frame, j, layer->waveletbuf[j], j == 0 ? 0 : 128);
+
+ wavelet_3d_buf_fwd_xform (layer->waveletbuf[j],
+ layer->desc.a_moments, layer->desc.s_moments);
+
+ wavelet_3d_buf_dump ("coeff-%d-%03d.pgm",
+ s->current_frame, j, layer->waveletbuf[j], 128);
+
+ packet->data_len = wavelet_3d_buf_encode_coeff (layer->waveletbuf[j],
+ packet->data, comp_bitstream_len);
+
+ _analysis_packetout (s, i, j);
+ }
+ }
}
-uint32_t tarkin_analysis_framein (TarkinStream *s, uint8_t *frame,
- uint32_t layer_id, TarkinTime *date)
+uint32_t
+tarkin_analysis_framein (TarkinStream * s, uint8_t * frame,
+ uint32_t layer_id, TarkinTime * date)
{
- TarkinVideoLayer *layer;
-
- if(!frame) return (_analysis_packetout(s, 0, 0)); /* eos */
- if((layer_id>=s->n_layers) || (date->denominator==0)) return (TARKIN_FAULT);
-
- layer = s->layer + layer_id;
- layer->color_fwd_xform (frame, layer->waveletbuf,
- s->current_frame_in_buf);
- /* We don't use this feature for now, neither date... */
- s->free_frame(s,frame);
-
- s->current_frame_in_buf++;
-
- if (s->current_frame_in_buf == s->frames_per_buf)
- _stream_flush (s);
-
+ TarkinVideoLayer *layer;
+
+ if (!frame)
+ return (_analysis_packetout (s, 0, 0)); /* eos */
+ if ((layer_id >= s->n_layers) || (date->denominator == 0))
+ return (TARKIN_FAULT);
+
+ layer = s->layer + layer_id;
+ layer->color_fwd_xform (frame, layer->waveletbuf, s->current_frame_in_buf);
+ /* We don't use this feature for now, neither date... */
+ s->free_frame (s, frame);
+
+ s->current_frame_in_buf++;
+
+ if (s->current_frame_in_buf == s->frames_per_buf)
+ _stream_flush (s);
+
#ifdef DBG_OGG
- printf("dbg_ogg: framein at pos %d/%d, n° %d,%d on layer %d\n",
- date->numerator, date->denominator,
- layer->frameno, s->current_frame, layer_id);
+ printf ("dbg_ogg: framein at pos %d/%d, n° %d,%d on layer %d\n",
+ date->numerator, date->denominator,
+ layer->frameno, s->current_frame, layer_id);
#endif
-
- layer->frameno++;
- return (++s->current_frame);
+
+ layer->frameno++;
+ return (++s->current_frame);
}
@@ -265,158 +270,151 @@ uint32_t tarkin_analysis_framein (TarkinStream *s, uint8_t *frame,
-TarkinError tarkin_stream_get_layer_desc (TarkinStream *s,
- uint32_t layer_id,
- TarkinVideoLayerDesc *desc)
+TarkinError
+tarkin_stream_get_layer_desc (TarkinStream * s,
+ uint32_t layer_id, TarkinVideoLayerDesc * desc)
{
- if (layer_id > s->n_layers-1)
- return -TARKIN_INVALID_LAYER;
+ if (layer_id > s->n_layers - 1)
+ return -TARKIN_INVALID_LAYER;
- memcpy (desc, &(s->layer[layer_id].desc), sizeof(TarkinVideoLayerDesc));
+ memcpy (desc, &(s->layer[layer_id].desc), sizeof (TarkinVideoLayerDesc));
- return TARKIN_OK;
+ return TARKIN_OK;
}
-TarkinError tarkin_synthesis_init (TarkinStream *s, TarkinInfo *ti)
+TarkinError
+tarkin_synthesis_init (TarkinStream * s, TarkinInfo * ti)
{
- s->ti = ti;
- s->layer = ti->layer; /* It was malloc()ed by headerin() */
- s->n_layers = ti->n_layers;
- return (TARKIN_OK);
+ s->ti = ti;
+ s->layer = ti->layer; /* It was malloc()ed by headerin() */
+ s->n_layers = ti->n_layers;
+ return (TARKIN_OK);
}
-TarkinError tarkin_synthesis_packetin (TarkinStream *s, ogg_packet *op)
+TarkinError
+tarkin_synthesis_packetin (TarkinStream * s, ogg_packet * op)
{
- uint32_t i, layer_id, comp, data_len;
- uint32_t flags, junk;
- int nread;
- oggpack_buffer opb;
- TarkinPacket *packet;
+ uint32_t i, layer_id, comp, data_len;
+ uint32_t flags, junk;
+ int nread;
+ oggpack_buffer opb;
+ TarkinPacket *packet;
+
#ifdef DBG_OGG
- printf("dbg_ogg: Reading packet n° %lld, granulepos %lld, len %ld, %s%s\n",
- op->packetno, op->granulepos, op->bytes,
- op->b_o_s?"b_o_s":"", op->e_o_s?"e_o_s":"");
+ printf ("dbg_ogg: Reading packet n° %lld, granulepos %lld, len %ld, %s%s\n",
+ op->packetno, op->granulepos, op->bytes,
+ op->b_o_s ? "b_o_s" : "", op->e_o_s ? "e_o_s" : "");
#endif
- oggpack_readinit(&opb,op->packet,op->bytes);
- flags = oggpack_read(&opb,8);
- layer_id = oggpack_read(&opb,12); /* Theses are required for */
- comp = oggpack_read(&opb,12); /* data hole handling (or maybe
- * packetno would be enough ?) */
- nread = 4;
-
- if(flags){ /* This is void "infinite future features" feature ;) */
- if(flags & 1<<7){
- junk = flags;
- while (junk & 1<<7)
- junk = oggpack_read(&opb,8); /* allow for many future flags
- that must be correctly ordonned. */
- }
- /* This shows how to get a feature's data:
- if (flags & TARKIN_FLAGS_EXAMPLE){
- tp->example = oggpack_read(&opb,32);
- junk = tp->example & 3<<30;
- tp->example &= 0x4fffffff;
- }
+ oggpack_readinit (&opb, op->packet, op->bytes);
+ flags = oggpack_read (&opb, 8);
+ layer_id = oggpack_read (&opb, 12); /* Theses are required for */
+ comp = oggpack_read (&opb, 12); /* data hole handling (or maybe
+ * packetno would be enough ?) */
+ nread = 4;
+
+ if (flags) { /* This is void "infinite future features" feature ;) */
+ if (flags & 1 << 7) {
+ junk = flags;
+ while (junk & 1 << 7)
+ junk = oggpack_read (&opb, 8); /* allow for many future flags
+ that must be correctly ordonned. */
+ }
+ /* This shows how to get a feature's data:
+ if (flags & TARKIN_FLAGS_EXAMPLE){
+ tp->example = oggpack_read(&opb,32);
+ junk = tp->example & 3<<30;
+ tp->example &= 0x4fffffff;
+ }
*/
- for(junk=1<<31;junk & 1<<31;) /* and many future data */
- while((junk=oggpack_read(&opb,32)) & 1<<30);
- /* That is, feature data comes in 30 bit chunks. We also have
- * 31 potentially usefull bits in last chunk. */
- }
-
- nread = (opb.ptr - opb.buffer);
- data_len = op->bytes - nread;
-
-#ifdef DBG_OGG
- printf(" layer_id %d, comp %d, meta-data %dB, w3d data %dB.\n",
- layer_id, comp,nread, data_len);
-#endif
+ for (junk = 1 << 31; junk & 1 << 31;) /* and many future data */
+ while ((junk = oggpack_read (&opb, 32)) & 1 << 30);
+ /* That is, feature data comes in 30 bit chunks. We also have
+ * 31 potentially usefull bits in last chunk. */
+ }
- /* We now have for shure our data. */
- packet = &s->layer[layer_id].packet[comp];
- if(packet->data_len)return(-TARKIN_UNUSED); /* Previous data wasn't used */
-
- if(packet->storage < data_len){
- packet->storage = data_len + 255;
- packet->data = REALLOC (packet->data, packet->storage);
- }
-
- for(i=0;i < data_len ; i++)
- packet->data[i] = oggpack_read(&opb,8);
-
- packet->data_len = data_len;
-
- return(TARKIN_OK);
-}
-
-TarkinError tarkin_synthesis_frameout(TarkinStream *s,
- uint8_t **frame,
- uint32_t layer_id, TarkinTime *date)
-{
- int j;
- TarkinVideoLayer *layer = &s->layer[layer_id];
- if (s->current_frame_in_buf == 0) {
- *frame = MALLOC (layer->desc.width * layer->desc.height * layer->n_comp);
- for (j=0; j<layer->n_comp; j++) {
- TarkinPacket *packet = layer->packet + j;
-
- if(packet->data_len == 0)goto err_out ;
-
- wavelet_3d_buf_decode_coeff (layer->waveletbuf[j], packet->data,
- packet->data_len);
-
- wavelet_3d_buf_dump ("rcoeff-%d-%03d.pgm",
- s->current_frame, j, layer->waveletbuf[j],
- 128);
-
- wavelet_3d_buf_inv_xform (layer->waveletbuf[j],
- layer->desc.a_moments,
- layer->desc.s_moments);
-
- wavelet_3d_buf_dump ("rcolor-%d-%03d.pgm",
- s->current_frame, j,
- layer->waveletbuf[j], j == 0 ? 0 : 128);
- }
+ nread = (opb.ptr - opb.buffer);
+ data_len = op->bytes - nread;
- /* We did successfylly read a block from this layer, acknowledge it. */
- for (j=0; j < layer->n_comp; j++)
- layer->packet[j].data_len = 0;
- }
-
- layer->color_inv_xform (layer->waveletbuf, *frame,
- s->current_frame_in_buf);
- s->current_frame_in_buf++;
- s->current_frame++;
-
- if (s->current_frame_in_buf == s->frames_per_buf)
- s->current_frame_in_buf=0;
-
- date->numerator = layer->frameno * s->ti->inter.numerator;
- date->denominator = s->ti->inter.denominator;
#ifdef DBG_OGG
- printf("dbg_ogg: outputting frame pos %d/%d from layer %d.\n",
- date->numerator, date->denominator, layer_id);
+ printf (" layer_id %d, comp %d, meta-data %dB, w3d data %dB.\n",
+ layer_id, comp, nread, data_len);
#endif
- layer->frameno++;
- return (TARKIN_OK);
-err_out:
- FREE(*frame);
- return (TARKIN_NEED_MORE);
+
+ /* We now have for shure our data. */
+ packet = &s->layer[layer_id].packet[comp];
+ if (packet->data_len)
+ return (-TARKIN_UNUSED); /* Previous data wasn't used */
+
+ if (packet->storage < data_len) {
+ packet->storage = data_len + 255;
+ packet->data = REALLOC (packet->data, packet->storage);
+ }
+
+ for (i = 0; i < data_len; i++)
+ packet->data[i] = oggpack_read (&opb, 8);
+
+ packet->data_len = data_len;
+
+ return (TARKIN_OK);
}
-int tarkin_synthesis_freeframe(TarkinStream *s, uint8_t *frame)
+TarkinError
+tarkin_synthesis_frameout (TarkinStream * s,
+ uint8_t ** frame, uint32_t layer_id, TarkinTime * date)
{
- FREE(frame);
-
- return(TARKIN_OK);
-}
+ int j;
+ TarkinVideoLayer *layer = &s->layer[layer_id];
+ if (s->current_frame_in_buf == 0) {
+ *frame = MALLOC (layer->desc.width * layer->desc.height * layer->n_comp);
+ for (j = 0; j < layer->n_comp; j++) {
+ TarkinPacket *packet = layer->packet + j;
+ if (packet->data_len == 0)
+ goto err_out;
+ wavelet_3d_buf_decode_coeff (layer->waveletbuf[j], packet->data,
+ packet->data_len);
+ wavelet_3d_buf_dump ("rcoeff-%d-%03d.pgm",
+ s->current_frame, j, layer->waveletbuf[j], 128);
+ wavelet_3d_buf_inv_xform (layer->waveletbuf[j],
+ layer->desc.a_moments, layer->desc.s_moments);
+ wavelet_3d_buf_dump ("rcolor-%d-%03d.pgm",
+ s->current_frame, j, layer->waveletbuf[j], j == 0 ? 0 : 128);
+ }
+ /* We did successfylly read a block from this layer, acknowledge it. */
+ for (j = 0; j < layer->n_comp; j++)
+ layer->packet[j].data_len = 0;
+ }
+ layer->color_inv_xform (layer->waveletbuf, *frame, s->current_frame_in_buf);
+ s->current_frame_in_buf++;
+ s->current_frame++;
+ if (s->current_frame_in_buf == s->frames_per_buf)
+ s->current_frame_in_buf = 0;
+ date->numerator = layer->frameno * s->ti->inter.numerator;
+ date->denominator = s->ti->inter.denominator;
+#ifdef DBG_OGG
+ printf ("dbg_ogg: outputting frame pos %d/%d from layer %d.\n",
+ date->numerator, date->denominator, layer_id);
+#endif
+ layer->frameno++;
+ return (TARKIN_OK);
+err_out:
+ FREE (*frame);
+ return (TARKIN_NEED_MORE);
+}
+
+int
+tarkin_synthesis_freeframe (TarkinStream * s, uint8_t * frame)
+{
+ FREE (frame);
+
+ return (TARKIN_OK);
+}
diff --git a/ext/tarkin/tarkin.h b/ext/tarkin/tarkin.h
index 633f9a14..680ba4b9 100644
--- a/ext/tarkin/tarkin.h
+++ b/ext/tarkin/tarkin.h
@@ -18,105 +18,115 @@
/* Theses determine what infos the packet comes with */
#define TARKIN_PACK_EXAMPLE 1
-typedef struct {
- uint8_t *data;
- uint32_t data_len;
- uint32_t storage;
-} TarkinPacket;
-
-
-typedef enum {
- TARKIN_GRAYSCALE,
- TARKIN_RGB24, /* tight packed RGB */
- TARKIN_RGB32, /* 32bit, no alphachannel */
- TARKIN_RGBA, /* dito w/ alphachannel */
- TARKIN_YUV2, /* 16 bits YUV */
- TARKIN_YUV12, /* 12 bits YUV */
- TARKIN_FYUV, /* Tarkin's Fast YUV-like? */
+typedef struct
+{
+ uint8_t *data;
+ uint32_t data_len;
+ uint32_t storage;
+} TarkinPacket;
+
+
+typedef enum
+{
+ TARKIN_GRAYSCALE,
+ TARKIN_RGB24, /* tight packed RGB */
+ TARKIN_RGB32, /* 32bit, no alphachannel */
+ TARKIN_RGBA, /* dito w/ alphachannel */
+ TARKIN_YUV2, /* 16 bits YUV */
+ TARKIN_YUV12, /* 12 bits YUV */
+ TARKIN_FYUV, /* Tarkin's Fast YUV-like? */
} TarkinColorFormat;
#define TARKIN_INTERNAL_FORMAT TARKIN_FYUV
-typedef enum {
- TARKIN_OK = 0,
- TARKIN_IO_ERROR,
- TARKIN_SIGNATURE_NOT_FOUND,
- TARKIN_INVALID_LAYER,
- TARKIN_INVALID_COLOR_FORMAT,
- TARKIN_VERSION,
- TARKIN_BAD_HEADER,
- TARKIN_NOT_TARKIN,
- TARKIN_FAULT,
- TARKIN_UNUSED,
- TARKIN_NEED_MORE,
- TARKIN_NOT_IMPLEMENTED
+typedef enum
+{
+ TARKIN_OK = 0,
+ TARKIN_IO_ERROR,
+ TARKIN_SIGNATURE_NOT_FOUND,
+ TARKIN_INVALID_LAYER,
+ TARKIN_INVALID_COLOR_FORMAT,
+ TARKIN_VERSION,
+ TARKIN_BAD_HEADER,
+ TARKIN_NOT_TARKIN,
+ TARKIN_FAULT,
+ TARKIN_UNUSED,
+ TARKIN_NEED_MORE,
+ TARKIN_NOT_IMPLEMENTED
} TarkinError;
-typedef struct {
- uint32_t width;
- uint32_t height;
- uint32_t a_moments;
- uint32_t s_moments;
- uint32_t frames_per_buf;
- uint32_t bitstream_len; /* for all color components, bytes */
- TarkinColorFormat format;
+typedef struct
+{
+ uint32_t width;
+ uint32_t height;
+ uint32_t a_moments;
+ uint32_t s_moments;
+ uint32_t frames_per_buf;
+ uint32_t bitstream_len; /* for all color components, bytes */
+ TarkinColorFormat format;
} TarkinVideoLayerDesc;
-typedef struct {
- TarkinVideoLayerDesc desc;
- uint32_t n_comp; /* number of color components */
- Wavelet3DBuf **waveletbuf;
- TarkinPacket *packet;
- uint32_t current_frame_in_buf;
- uint32_t frameno;
+typedef struct
+{
+ TarkinVideoLayerDesc desc;
+ uint32_t n_comp; /* number of color components */
+ Wavelet3DBuf **waveletbuf;
+ TarkinPacket *packet;
+ uint32_t current_frame_in_buf;
+ uint32_t frameno;
- void (*color_fwd_xform) (uint8_t *rgba, Wavelet3DBuf *yuva [], uint32_t count);
- void (*color_inv_xform) (Wavelet3DBuf *yuva [], uint8_t *rgba, uint32_t count);
+ void (*color_fwd_xform) (uint8_t * rgba, Wavelet3DBuf * yuva[],
+ uint32_t count);
+ void (*color_inv_xform) (Wavelet3DBuf * yuva[], uint8_t * rgba,
+ uint32_t count);
} TarkinVideoLayer;
-typedef struct {
- uint32_t numerator;
- uint32_t denominator;
-} TarkinTime; /* Let's say the unit is 1 second */
-
-typedef struct TarkinInfo {
- int version;
- int n_layers;
- TarkinVideoLayer *layer;
- TarkinTime inter; /* numerator == O if per-frame time info. */
- int frames_per_block;
- int comp_per_block; /* AKA "packets per block" for now */
- uint32_t max_bitstream_len;
+typedef struct
+{
+ uint32_t numerator;
+ uint32_t denominator;
+} TarkinTime; /* Let's say the unit is 1 second */
+
+typedef struct TarkinInfo
+{
+ int version;
+ int n_layers;
+ TarkinVideoLayer *layer;
+ TarkinTime inter; /* numerator == O if per-frame time info. */
+ int frames_per_block;
+ int comp_per_block; /* AKA "packets per block" for now */
+ uint32_t max_bitstream_len;
/* The below bitrate declarations are *hints*.
Combinations of the three values carry the following implications:
-
+
all three set to the same value:
- implies a fixed rate bitstream
+ implies a fixed rate bitstream
only nominal set:
- implies a VBR stream that averages the nominal bitrate. No hard
- upper/lower limit
+ implies a VBR stream that averages the nominal bitrate. No hard
+ upper/lower limit
upper and or lower set:
- implies a VBR bitstream that obeys the bitrate limits. nominal
- may also be set to give a nominal rate.
+ implies a VBR bitstream that obeys the bitrate limits. nominal
+ may also be set to give a nominal rate.
none set:
- the coder does not care to speculate.
- */
+ the coder does not care to speculate.
+ */
- long bitrate_upper;
- long bitrate_nominal;
- long bitrate_lower;
- long bitrate_window;
+ long bitrate_upper;
+ long bitrate_nominal;
+ long bitrate_lower;
+ long bitrate_window;
} TarkinInfo;
/* This is used for encoding */
-typedef struct {
- unsigned char *header;
- unsigned char *header1;
- unsigned char *header2;
+typedef struct
+{
+ unsigned char *header;
+ unsigned char *header1;
+ unsigned char *header2;
} tarkin_header_store;
@@ -124,31 +134,33 @@ typedef struct {
/* Some of the fields in TarkinStream are redundent with TarkinInfo ones
* and will probably get deleted, namely n_layers and frames_per_buf */
-typedef struct TarkinStream {
- uint32_t n_layers;
- TarkinVideoLayer *layer;
- uint32_t current_frame;
- uint32_t current_frame_in_buf;
- ogg_int64_t packetno;
- uint32_t frames_per_buf;
- uint32_t max_bitstream_len;
- TarkinInfo *ti;
- tarkin_header_store headers;
- /* These callbacks are only used for encoding */
- TarkinError (*free_frame)(void *tarkinstream, void *ptr);
- /* These thing allows not to buffer but it needs global var in caller. */
- TarkinError (*packet_out)(void *tarkinstream, ogg_packet *ptr);
- void * user_ptr;
+typedef struct TarkinStream
+{
+ uint32_t n_layers;
+ TarkinVideoLayer *layer;
+ uint32_t current_frame;
+ uint32_t current_frame_in_buf;
+ ogg_int64_t packetno;
+ uint32_t frames_per_buf;
+ uint32_t max_bitstream_len;
+ TarkinInfo *ti;
+ tarkin_header_store headers;
+ /* These callbacks are only used for encoding */
+ TarkinError (*free_frame) (void *tarkinstream, void *ptr);
+ /* These thing allows not to buffer but it needs global var in caller. */
+ TarkinError (*packet_out) (void *tarkinstream, ogg_packet * ptr);
+ void *user_ptr;
} TarkinStream;
-typedef struct TarkinComment{
+typedef struct TarkinComment
+{
/* unlimited user comment fields. libtarkin writes 'libtarkin'
whatever vendor is set to in encode */
char **user_comments;
- int *comment_lengths;
- int comments;
- char *vendor;
+ int *comment_lengths;
+ int comments;
+ char *vendor;
} TarkinComment;
@@ -161,17 +173,17 @@ typedef struct TarkinComment{
/* Theses are the very same than Vorbis versions, they could be shared. */
-extern TarkinStream* tarkin_stream_new ();
-extern void tarkin_stream_destroy (TarkinStream *s);
-extern void tarkin_info_init(TarkinInfo *vi);
-extern void tarkin_info_clear(TarkinInfo *vi);
-extern void tarkin_comment_init(TarkinComment *vc);
-extern void tarkin_comment_add(TarkinComment *vc, char *comment);
-extern void tarkin_comment_add_tag(TarkinComment *vc,
- char *tag, char *contents);
-extern char *tarkin_comment_query(TarkinComment *vc, char *tag, int count);
-extern int tarkin_comment_query_count(TarkinComment *vc, char *tag);
-extern void tarkin_comment_clear(TarkinComment *vc);
+extern TarkinStream *tarkin_stream_new ();
+extern void tarkin_stream_destroy (TarkinStream * s);
+extern void tarkin_info_init (TarkinInfo * vi);
+extern void tarkin_info_clear (TarkinInfo * vi);
+extern void tarkin_comment_init (TarkinComment * vc);
+extern void tarkin_comment_add (TarkinComment * vc, char *comment);
+extern void tarkin_comment_add_tag (TarkinComment * vc,
+ char *tag, char *contents);
+extern char *tarkin_comment_query (TarkinComment * vc, char *tag, int count);
+extern int tarkin_comment_query_count (TarkinComment * vc, char *tag);
+extern void tarkin_comment_clear (TarkinComment * vc);
/* Tarkin PRIMITIVES: analysis layer ****************************/
/* Tarkin encoding is done this way : you init it passing a fresh
@@ -181,59 +193,50 @@ extern void tarkin_comment_clear(TarkinComment *vc);
* is called when a packet is ready. The pointers given as arguments to
* these callback functions are of course only valid at the function call
* time. The user_ptr is stored in s and can be used by packet_out(). */
-extern int tarkin_analysis_init(TarkinStream *s,
- TarkinInfo *ti,
- TarkinError (*free_frame)(void *tarkinstream, void *ptr),
- TarkinError (*packet_out)(void *tarkinstream, ogg_packet *ptr),
- void *user_ptr
- );
+extern int tarkin_analysis_init (TarkinStream * s,
+ TarkinInfo * ti,
+ TarkinError (*free_frame) (void *tarkinstream, void *ptr),
+ TarkinError (*packet_out) (void *tarkinstream, ogg_packet * ptr),
+ void *user_ptr);
/* Then you need to add at least a layer in your stream, passing a
* TarkinVideoLayerDesc renseigned at least on the width, height and
* format parameters. */
-extern int tarkin_analysis_add_layer(TarkinStream *s,
- TarkinVideoLayerDesc *tvld);
+extern int tarkin_analysis_add_layer (TarkinStream * s,
+ TarkinVideoLayerDesc * tvld);
/* At that point you are ready to get headers out the lib by calling
* tarkin_analysis_headerout() passing it a renseigned TarkinComment
* structure. It does fill your 3 ogg_packet headers, which are valid
* till next call */
-extern int TarkinCommentheader_out(TarkinComment *vc, ogg_packet *op);
-extern TarkinError tarkin_analysis_headerout(TarkinStream *s,
- TarkinComment *vc,
- ogg_packet *op,
- ogg_packet *op_comm,
- ogg_packet *op_code);
+extern int TarkinCommentheader_out (TarkinComment * vc, ogg_packet * op);
+extern TarkinError tarkin_analysis_headerout (TarkinStream * s,
+ TarkinComment * vc,
+ ogg_packet * op, ogg_packet * op_comm, ogg_packet * op_code);
/* You are now ready to pass in frames to the codec, however don't free
* them before the codec told you so. It'll tell you when packets are
* ready to be taken out. When you have no more frame, simply pass NULL.
* If you encode multiple layers you have to do it synchronously, putting
* one frame from each layer at a time. */
-extern uint32_t tarkin_analysis_framein(TarkinStream *s,
- uint8_t *frame, /* NULL for EOS */
- uint32_t layer,
- TarkinTime *date);
+extern uint32_t tarkin_analysis_framein (TarkinStream * s, uint8_t * frame, /* NULL for EOS */
+ uint32_t layer, TarkinTime * date);
/* Tarkin PRIMITIVES: synthesis layer *******************************/
/* For decoding, you needs first to give the three first packet of the
* stream to tarkin_synthesis_headerin() which will fill for you blank
* TarkinInfo and TarkinComment. */
-extern TarkinError tarkin_synthesis_headerin(TarkinInfo *vi,TarkinComment *vc,
- ogg_packet *op);
+extern TarkinError tarkin_synthesis_headerin (TarkinInfo * vi,
+ TarkinComment * vc, ogg_packet * op);
/* Then you can init your stream with your TarkinInfo struct. */
-extern TarkinError tarkin_synthesis_init(TarkinStream *s,TarkinInfo *ti);
+extern TarkinError tarkin_synthesis_init (TarkinStream * s, TarkinInfo * ti);
+
/* All subsequent packets are to this be passed to tarkin_synthesis_packetin*/
-extern TarkinError tarkin_synthesis_packetin(TarkinStream *s, ogg_packet *op);
+extern TarkinError tarkin_synthesis_packetin (TarkinStream * s,
+ ogg_packet * op);
/* and then tarkin_synthesis_frameout gives you ptr on next frame, or NULL. It
* also fills for you date. */
-extern TarkinError tarkin_synthesis_frameout(TarkinStream *s,
- uint8_t **frame, uint32_t layer_id, TarkinTime *date);
+extern TarkinError tarkin_synthesis_frameout (TarkinStream * s,
+ uint8_t ** frame, uint32_t layer_id, TarkinTime * date);
/* When you're done with a frame, tell it to the codec with this. */
-extern int tarkin_synthesis_freeframe(TarkinStream *s, uint8_t *frame);
+extern int tarkin_synthesis_freeframe (TarkinStream * s, uint8_t * frame);
#endif
-
-
-
-
-
-
diff --git a/ext/tarkin/wavelet.c b/ext/tarkin/wavelet.c
index 9288e15b..cecce80a 100644
--- a/ext/tarkin/wavelet.c
+++ b/ext/tarkin/wavelet.c
@@ -15,88 +15,90 @@
-Wavelet3DBuf* wavelet_3d_buf_new (uint32_t width, uint32_t height,
- uint32_t frames)
+Wavelet3DBuf *
+wavelet_3d_buf_new (uint32_t width, uint32_t height, uint32_t frames)
{
- Wavelet3DBuf* buf = (Wavelet3DBuf*) MALLOC (sizeof (Wavelet3DBuf));
- uint32_t _w = width;
- uint32_t _h = height;
- uint32_t _f = frames;
- int level;
-
- if (!buf)
- return NULL;
-
- buf->data = (TYPE*) MALLOC (width * height * frames * sizeof (TYPE));
-
- if (!buf->data) {
- wavelet_3d_buf_destroy (buf);
- return NULL;
- }
-
- buf->width = width;
- buf->height = height;
- buf->frames = frames;
- buf->scales = 1;
-
- while (_w > 1 || _h > 1 || _f > 1) {
- buf->scales++;
- _w = (_w+1)/2;
- _h = (_h+1)/2;
- _f = (_f+1)/2;
- }
-
- buf->w = (uint32_t*) MALLOC (buf->scales * sizeof (uint32_t));
- buf->h = (uint32_t*) MALLOC (buf->scales * sizeof (uint32_t));
- buf->f = (uint32_t*) MALLOC (buf->scales * sizeof (uint32_t));
- buf->offset = (uint32_t (*) [8]) MALLOC (8 * buf->scales * sizeof (uint32_t));
-
- buf->scratchbuf = (TYPE*) MALLOC (MAX3(width, height, frames) * sizeof (TYPE));
-
- if (!buf->w || !buf->h || !buf->f || !buf->offset || !buf->scratchbuf) {
- wavelet_3d_buf_destroy (buf);
- return NULL;
- }
-
- buf->w [buf->scales-1] = width;
- buf->h [buf->scales-1] = height;
- buf->f [buf->scales-1] = frames;
-
- for (level=buf->scales-2; level>=0; level--) {
- buf->w [level] = (buf->w [level+1] + 1) / 2;
- buf->h [level] = (buf->h [level+1] + 1) / 2;
- buf->f [level] = (buf->f [level+1] + 1) / 2;
- buf->offset[level][0] = 0;
- buf->offset[level][1] = buf->w [level];
- buf->offset[level][2] = buf->h [level] * width;
- buf->offset[level][3] = buf->f [level] * width * height;
- buf->offset[level][4] = buf->offset [level][2] + buf->w [level];
- buf->offset[level][5] = buf->offset [level][3] + buf->w [level];
- buf->offset[level][6] = buf->offset [level][3] + buf->offset [level][2];
- buf->offset[level][7] = buf->offset [level][6] + buf->w [level];
- }
-
- return buf;
+ Wavelet3DBuf *buf = (Wavelet3DBuf *) MALLOC (sizeof (Wavelet3DBuf));
+ uint32_t _w = width;
+ uint32_t _h = height;
+ uint32_t _f = frames;
+ int level;
+
+ if (!buf)
+ return NULL;
+
+ buf->data = (TYPE *) MALLOC (width * height * frames * sizeof (TYPE));
+
+ if (!buf->data) {
+ wavelet_3d_buf_destroy (buf);
+ return NULL;
+ }
+
+ buf->width = width;
+ buf->height = height;
+ buf->frames = frames;
+ buf->scales = 1;
+
+ while (_w > 1 || _h > 1 || _f > 1) {
+ buf->scales++;
+ _w = (_w + 1) / 2;
+ _h = (_h + 1) / 2;
+ _f = (_f + 1) / 2;
+ }
+
+ buf->w = (uint32_t *) MALLOC (buf->scales * sizeof (uint32_t));
+ buf->h = (uint32_t *) MALLOC (buf->scales * sizeof (uint32_t));
+ buf->f = (uint32_t *) MALLOC (buf->scales * sizeof (uint32_t));
+ buf->offset = (uint32_t (*)[8]) MALLOC (8 * buf->scales * sizeof (uint32_t));
+
+ buf->scratchbuf =
+ (TYPE *) MALLOC (MAX3 (width, height, frames) * sizeof (TYPE));
+
+ if (!buf->w || !buf->h || !buf->f || !buf->offset || !buf->scratchbuf) {
+ wavelet_3d_buf_destroy (buf);
+ return NULL;
+ }
+
+ buf->w[buf->scales - 1] = width;
+ buf->h[buf->scales - 1] = height;
+ buf->f[buf->scales - 1] = frames;
+
+ for (level = buf->scales - 2; level >= 0; level--) {
+ buf->w[level] = (buf->w[level + 1] + 1) / 2;
+ buf->h[level] = (buf->h[level + 1] + 1) / 2;
+ buf->f[level] = (buf->f[level + 1] + 1) / 2;
+ buf->offset[level][0] = 0;
+ buf->offset[level][1] = buf->w[level];
+ buf->offset[level][2] = buf->h[level] * width;
+ buf->offset[level][3] = buf->f[level] * width * height;
+ buf->offset[level][4] = buf->offset[level][2] + buf->w[level];
+ buf->offset[level][5] = buf->offset[level][3] + buf->w[level];
+ buf->offset[level][6] = buf->offset[level][3] + buf->offset[level][2];
+ buf->offset[level][7] = buf->offset[level][6] + buf->w[level];
+ }
+
+ return buf;
}
-void wavelet_3d_buf_destroy (Wavelet3DBuf* buf)
+void
+wavelet_3d_buf_destroy (Wavelet3DBuf * buf)
{
- if (buf) {
- if (buf->data)
- FREE (buf->data);
- if (buf->w)
- FREE (buf->w);
- if (buf->h)
- FREE (buf->h);
- if (buf->f)
- FREE (buf->f);
- if (buf->offset)
- FREE (buf->offset);
- if (buf->scratchbuf)
- FREE (buf->scratchbuf);
- FREE (buf);
- }
+ if (buf) {
+ if (buf->data)
+ FREE (buf->data);
+ if (buf->w)
+ FREE (buf->w);
+ if (buf->h)
+ FREE (buf->h);
+ if (buf->f)
+ FREE (buf->f);
+ if (buf->offset)
+ FREE (buf->offset);
+ if (buf->scratchbuf)
+ FREE (buf->scratchbuf);
+ FREE (buf);
+ }
}
@@ -104,22 +106,19 @@ void wavelet_3d_buf_destroy (Wavelet3DBuf* buf)
#include "pnm.h"
-void wavelet_3d_buf_dump (char *fmt,
- uint32_t first_frame_in_buf,
- uint32_t id,
- Wavelet3DBuf* buf,
- int16_t offset)
+void
+wavelet_3d_buf_dump (char *fmt,
+ uint32_t first_frame_in_buf,
+ uint32_t id, Wavelet3DBuf * buf, int16_t offset)
{
- char fname [256];
- uint32_t f;
+ char fname[256];
+ uint32_t f;
- for (f=0; f<buf->frames; f++) {
- snprintf (fname, 256, fmt, id, first_frame_in_buf + f);
+ for (f = 0; f < buf->frames; f++) {
+ snprintf (fname, 256, fmt, id, first_frame_in_buf + f);
- write_pgm16 (fname, buf->data + f * buf->width * buf->height,
- buf->width, buf->height, offset);
- }
+ write_pgm16 (fname, buf->data + f * buf->width * buf->height,
+ buf->width, buf->height, offset);
+ }
}
#endif
-
-
diff --git a/ext/tarkin/wavelet.h b/ext/tarkin/wavelet.h
index 914c2799..13d84e8b 100644
--- a/ext/tarkin/wavelet.h
+++ b/ext/tarkin/wavelet.h
@@ -4,24 +4,25 @@
#include <stdint.h>
-typedef struct {
- TYPE *data;
- uint32_t width;
- uint32_t height;
- uint32_t frames;
- uint32_t scales;
- uint32_t *w;
- uint32_t *h;
- uint32_t *f;
- uint32_t (*offset)[8];
- TYPE *scratchbuf;
+typedef struct
+{
+ TYPE *data;
+ uint32_t width;
+ uint32_t height;
+ uint32_t frames;
+ uint32_t scales;
+ uint32_t *w;
+ uint32_t *h;
+ uint32_t *f;
+ uint32_t (*offset)[8];
+ TYPE *scratchbuf;
} Wavelet3DBuf;
-extern Wavelet3DBuf* wavelet_3d_buf_new (uint32_t width, uint32_t height,
- uint32_t frames);
+extern Wavelet3DBuf *wavelet_3d_buf_new (uint32_t width, uint32_t height,
+ uint32_t frames);
-extern void wavelet_3d_buf_destroy (Wavelet3DBuf* buf);
+extern void wavelet_3d_buf_destroy (Wavelet3DBuf * buf);
/**
* transform buf->data
@@ -29,25 +30,21 @@ extern void wavelet_3d_buf_destroy (Wavelet3DBuf* buf);
* highpass filter,
* s_moments the one of the synthesizing lowpass filter.
*/
-extern void wavelet_3d_buf_fwd_xform (Wavelet3DBuf* buf,
- int a_moments, int s_moments);
-extern void wavelet_3d_buf_inv_xform (Wavelet3DBuf* buf,
- int a_moments, int s_moments);
+extern void wavelet_3d_buf_fwd_xform (Wavelet3DBuf * buf,
+ int a_moments, int s_moments);
+extern void wavelet_3d_buf_inv_xform (Wavelet3DBuf * buf,
+ int a_moments, int s_moments);
-extern int wavelet_3d_buf_encode_coeff (const Wavelet3DBuf* buf,
- uint8_t *bitstream,
- uint32_t limit);
+extern int wavelet_3d_buf_encode_coeff (const Wavelet3DBuf * buf,
+ uint8_t * bitstream, uint32_t limit);
-extern void wavelet_3d_buf_decode_coeff (Wavelet3DBuf* buf,
- uint8_t *bitstream,
- uint32_t limit);
+extern void wavelet_3d_buf_decode_coeff (Wavelet3DBuf * buf,
+ uint8_t * bitstream, uint32_t limit);
#if defined(DBG_XFORM)
extern void wavelet_3d_buf_dump (char *fmt,
- uint32_t first_frame_in_buf,
- uint32_t id,
- Wavelet3DBuf* buf,
- int16_t offset);
+ uint32_t first_frame_in_buf,
+ uint32_t id, Wavelet3DBuf * buf, int16_t offset);
#else
#define wavelet_3d_buf_dump(x...)
#endif
diff --git a/ext/tarkin/wavelet_coeff.c b/ext/tarkin/wavelet_coeff.c
index 581f48f0..95da5cad 100644
--- a/ext/tarkin/wavelet_coeff.c
+++ b/ext/tarkin/wavelet_coeff.c
@@ -11,500 +11,507 @@
#define GRAY_CODES 1
#if defined(GRAY_CODES)
-static inline
-uint16_t binary_to_gray (uint16_t x) { return x ^ (x >> 1); }
+static inline uint16_t
+binary_to_gray (uint16_t x)
+{
+ return x ^ (x >> 1);
+}
+
+static inline uint16_t
+gray_to_binary (uint16_t x)
+{
+ int i;
-static inline
-uint16_t gray_to_binary (uint16_t x)
-{ int i; for (i=1; i<16; i+=i) x ^= x >> i; return x; }
+ for (i = 1; i < 16; i += i)
+ x ^= x >> i;
+ return x;
+}
#endif
-static inline
-void encode_coeff (ENTROPY_CODER significand_bitstream [],
- ENTROPY_CODER insignificand_bitstream [],
- TYPE coeff)
+static inline void
+encode_coeff (ENTROPY_CODER significand_bitstream[],
+ ENTROPY_CODER insignificand_bitstream[], TYPE coeff)
{
- int sign = (coeff >> (8*sizeof(TYPE)-1)) & 1;
+ int sign = (coeff >> (8 * sizeof (TYPE) - 1)) & 1;
+
#if defined(GRAY_CODES)
- TYPE significance = binary_to_gray(coeff);
+ TYPE significance = binary_to_gray (coeff);
#else
- static TYPE mask [2] = { 0, ~0 };
- TYPE significance = coeff ^ mask[sign];
+ static TYPE mask[2] = { 0, ~0 };
+ TYPE significance = coeff ^ mask[sign];
#endif
- int i = TYPE_BITS;
+ int i = TYPE_BITS;
- do {
- i--;
- OUTPUT_BIT(&significand_bitstream[i], (significance >> i) & 1);
- } while (!((significance >> i) & 1) && i > 0);
+ do {
+ i--;
+ OUTPUT_BIT (&significand_bitstream[i], (significance >> i) & 1);
+ } while (!((significance >> i) & 1) && i > 0);
- OUTPUT_BIT(&significand_bitstream[i], sign);
+ OUTPUT_BIT (&significand_bitstream[i], sign);
- while (--i >= 0)
- OUTPUT_BIT(&insignificand_bitstream[i], (significance >> i) & 1);
+ while (--i >= 0)
+ OUTPUT_BIT (&insignificand_bitstream[i], (significance >> i) & 1);
}
-static inline
-TYPE decode_coeff (ENTROPY_CODER significand_bitstream [],
- ENTROPY_CODER insignificand_bitstream [])
+static inline TYPE
+decode_coeff (ENTROPY_CODER significand_bitstream[],
+ ENTROPY_CODER insignificand_bitstream[])
{
#if !defined(GRAY_CODES)
- static TYPE mask [2] = { 0, ~0 };
+ static TYPE mask[2] = { 0, ~0 };
#endif
- TYPE significance = 0;
- int sign;
- int i = TYPE_BITS;
+ TYPE significance = 0;
+ int sign;
+ int i = TYPE_BITS;
- do {
- i--;
- significance |= INPUT_BIT(&significand_bitstream[i]) << i;
+ do {
+ i--;
+ significance |= INPUT_BIT (&significand_bitstream[i]) << i;
/* if (ENTROPY_CODER_EOS(&significand_bitstream[i])) */
/* return 0; */
- } while (!significance && i > 0);
+ } while (!significance && i > 0);
- sign = INPUT_BIT(&significand_bitstream[i]);
+ sign = INPUT_BIT (&significand_bitstream[i]);
/* if (ENTROPY_CODER_EOS(&significand_bitstream[i])) */
/* return 0; */
- while (--i >= 0)
- significance |= INPUT_BIT(&insignificand_bitstream[i]) << i;
+ while (--i >= 0)
+ significance |= INPUT_BIT (&insignificand_bitstream[i]) << i;
#if defined(GRAY_CODES)
- significance |= sign << (8*sizeof(TYPE)-1);
- return gray_to_binary(significance);
+ significance |= sign << (8 * sizeof (TYPE) - 1);
+ return gray_to_binary (significance);
#else
- return (significance ^ mask[sign]);
+ return (significance ^ mask[sign]);
#endif
}
-static inline
-uint32_t skip_0coeffs (Wavelet3DBuf* buf,
- ENTROPY_CODER s_stream [],
- ENTROPY_CODER i_stream [],
- uint32_t limit)
+static inline uint32_t
+skip_0coeffs (Wavelet3DBuf * buf,
+ ENTROPY_CODER s_stream[], ENTROPY_CODER i_stream[], uint32_t limit)
{
- int i;
- uint32_t skip = limit;
-
- for (i=0; i<TYPE_BITS; i++) {
- if (ENTROPY_CODER_SYMBOL(&s_stream[i]) != 0) {
- return 0;
- } else {
- uint32_t runlength = ENTROPY_CODER_RUNLENGTH(&s_stream[i]);
- if (i==0)
- runlength /= 2; /* sign bits are in this bitplane ... */
- if (skip > runlength)
- skip = runlength;
- if (skip <= 2)
- return 0;
- }
- }
-
- ENTROPY_CODER_SKIP(&s_stream[0], 2*skip); /* kill sign+significance bits */
-
- for (i=1; i<TYPE_BITS; i++)
- ENTROPY_CODER_SKIP(&s_stream[i], skip);
-
- return skip;
+ int i;
+ uint32_t skip = limit;
+
+ for (i = 0; i < TYPE_BITS; i++) {
+ if (ENTROPY_CODER_SYMBOL (&s_stream[i]) != 0) {
+ return 0;
+ } else {
+ uint32_t runlength = ENTROPY_CODER_RUNLENGTH (&s_stream[i]);
+
+ if (i == 0)
+ runlength /= 2; /* sign bits are in this bitplane ... */
+ if (skip > runlength)
+ skip = runlength;
+ if (skip <= 2)
+ return 0;
+ }
+ }
+
+ ENTROPY_CODER_SKIP (&s_stream[0], 2 * skip); /* kill sign+significance bits */
+
+ for (i = 1; i < TYPE_BITS; i++)
+ ENTROPY_CODER_SKIP (&s_stream[i], skip);
+
+ return skip;
}
#if 1
-static inline
-void encode_quadrant (const Wavelet3DBuf* buf,
- int level, int quadrant, uint32_t w, uint32_t h, uint32_t f,
- ENTROPY_CODER significand_bitstream [],
- ENTROPY_CODER insignificand_bitstream [])
+static inline void
+encode_quadrant (const Wavelet3DBuf * buf,
+ int level, int quadrant, uint32_t w, uint32_t h, uint32_t f,
+ ENTROPY_CODER significand_bitstream[],
+ ENTROPY_CODER insignificand_bitstream[])
{
- uint32_t x, y, z;
-
- for (z=0; z<f; z++) {
- for (y=0; y<h; y++) {
- for (x=0; x<w; x++) {
- unsigned int index = buf->offset [level] [quadrant]
- + z * buf->width * buf->height
- + y * buf->width + x;
-
- encode_coeff (significand_bitstream, insignificand_bitstream,
- buf->data [index]);
- }
+ uint32_t x, y, z;
+
+ for (z = 0; z < f; z++) {
+ for (y = 0; y < h; y++) {
+ for (x = 0; x < w; x++) {
+ unsigned int index = buf->offset[level][quadrant]
+ + z * buf->width * buf->height + y * buf->width + x;
+
+ encode_coeff (significand_bitstream, insignificand_bitstream,
+ buf->data[index]);
}
- }
+ }
+ }
}
-static
-void encode_coefficients (const Wavelet3DBuf* buf,
- ENTROPY_CODER s_stream [],
- ENTROPY_CODER i_stream [])
+static void
+encode_coefficients (const Wavelet3DBuf * buf,
+ ENTROPY_CODER s_stream[], ENTROPY_CODER i_stream[])
{
- int level;
-
- encode_coeff (s_stream, i_stream, buf->data[0]);
-
- for (level=0; level<buf->scales-1; level++) {
- uint32_t w, h, f, w1, h1, f1;
-
- w = buf->w [level];
- h = buf->h [level];
- f = buf->f [level];
- w1 = buf->w [level+1] - w;
- h1 = buf->h [level+1] - h;
- f1 = buf->f [level+1] - f;
-
- if (w1 > 0) encode_quadrant(buf,level,1,w1,h,f,s_stream,i_stream);
- if (h1 > 0) encode_quadrant(buf,level,2,w,h1,f,s_stream,i_stream);
- if (f1 > 0) encode_quadrant(buf,level,3,w,h,f1,s_stream,i_stream);
- if (w1 > 0 && h1 > 0) encode_quadrant(buf,level,4,w1,h1,f,s_stream,i_stream);
- if (w1 > 0 && f1 > 0) encode_quadrant(buf,level,5,w1,h,f1,s_stream,i_stream);
- if (h1 > 0 && f1 > 0) encode_quadrant(buf,level,6,w,h1,f1,s_stream,i_stream);
- if (h1 > 0 && f1 > 0 && f1 > 0)
- encode_quadrant (buf,level,7,w1,h1,f1,s_stream,i_stream);
- }
+ int level;
+
+ encode_coeff (s_stream, i_stream, buf->data[0]);
+
+ for (level = 0; level < buf->scales - 1; level++) {
+ uint32_t w, h, f, w1, h1, f1;
+
+ w = buf->w[level];
+ h = buf->h[level];
+ f = buf->f[level];
+ w1 = buf->w[level + 1] - w;
+ h1 = buf->h[level + 1] - h;
+ f1 = buf->f[level + 1] - f;
+
+ if (w1 > 0)
+ encode_quadrant (buf, level, 1, w1, h, f, s_stream, i_stream);
+ if (h1 > 0)
+ encode_quadrant (buf, level, 2, w, h1, f, s_stream, i_stream);
+ if (f1 > 0)
+ encode_quadrant (buf, level, 3, w, h, f1, s_stream, i_stream);
+ if (w1 > 0 && h1 > 0)
+ encode_quadrant (buf, level, 4, w1, h1, f, s_stream, i_stream);
+ if (w1 > 0 && f1 > 0)
+ encode_quadrant (buf, level, 5, w1, h, f1, s_stream, i_stream);
+ if (h1 > 0 && f1 > 0)
+ encode_quadrant (buf, level, 6, w, h1, f1, s_stream, i_stream);
+ if (h1 > 0 && f1 > 0 && f1 > 0)
+ encode_quadrant (buf, level, 7, w1, h1, f1, s_stream, i_stream);
+ }
}
-static inline
-void decode_quadrant (Wavelet3DBuf* buf,
- int level, int quadrant, uint32_t w, uint32_t h, uint32_t f,
- ENTROPY_CODER s_stream [],
- ENTROPY_CODER i_stream [])
+static inline void
+decode_quadrant (Wavelet3DBuf * buf,
+ int level, int quadrant, uint32_t w, uint32_t h, uint32_t f,
+ ENTROPY_CODER s_stream[], ENTROPY_CODER i_stream[])
{
- uint32_t x, y, z;
+ uint32_t x, y, z;
- z = 0;
- do {
- y = 0;
+ z = 0;
+ do {
+ y = 0;
+ do {
+ x = 0;
do {
- x = 0;
- do {
- uint32_t skip;
- uint32_t index = buf->offset [level] [quadrant]
- + z * buf->width * buf->height
- + y * buf->width + x;
-
- buf->data [index] = decode_coeff (s_stream, i_stream);
-
- skip = skip_0coeffs (buf, s_stream, i_stream,
- (w-x-1)+(h-y-1)*w+(f-z-1)*w*h);
- if (skip > 0) {
- x += skip;
- while (x >= w) {
- y++; x -= w;
- while (y >= h) {
- z++; y -= h;
- if (z >= f)
- return;
- }
- }
- }
- x++;
- } while (x < w);
- y++;
- } while (y < h);
- z++;
- } while (z < f);
+ uint32_t skip;
+ uint32_t index = buf->offset[level][quadrant]
+ + z * buf->width * buf->height + y * buf->width + x;
+
+ buf->data[index] = decode_coeff (s_stream, i_stream);
+
+ skip = skip_0coeffs (buf, s_stream, i_stream,
+ (w - x - 1) + (h - y - 1) * w + (f - z - 1) * w * h);
+ if (skip > 0) {
+ x += skip;
+ while (x >= w) {
+ y++;
+ x -= w;
+ while (y >= h) {
+ z++;
+ y -= h;
+ if (z >= f)
+ return;
+ }
+ }
+ }
+ x++;
+ } while (x < w);
+ y++;
+ } while (y < h);
+ z++;
+ } while (z < f);
}
-static
-void decode_coefficients (Wavelet3DBuf* buf,
- ENTROPY_CODER s_stream [],
- ENTROPY_CODER i_stream [])
+static void
+decode_coefficients (Wavelet3DBuf * buf,
+ ENTROPY_CODER s_stream[], ENTROPY_CODER i_stream[])
{
- int level;
-
- buf->data[0] = decode_coeff (s_stream, i_stream);
-
- for (level=0; level<buf->scales-1; level++) {
- uint32_t w, h, f, w1, h1, f1;
-
- w = buf->w [level];
- h = buf->h [level];
- f = buf->f [level];
- w1 = buf->w [level+1] - w;
- h1 = buf->h [level+1] - h;
- f1 = buf->f [level+1] - f;
-
- if (w1 > 0) decode_quadrant(buf,level,1,w1,h,f,s_stream,i_stream);
- if (h1 > 0) decode_quadrant(buf,level,2,w,h1,f,s_stream,i_stream);
- if (f1 > 0) decode_quadrant(buf,level,3,w,h,f1,s_stream,i_stream);
- if (w1 > 0 && h1 > 0) decode_quadrant(buf,level,4,w1,h1,f,s_stream,i_stream);
- if (w1 > 0 && f1 > 0) decode_quadrant(buf,level,5,w1,h,f1,s_stream,i_stream);
- if (h1 > 0 && f1 > 0) decode_quadrant(buf,level,6,w,h1,f1,s_stream,i_stream);
- if (h1 > 0 && f1 > 0 && f1 > 0)
- decode_quadrant (buf,level,7,w1,h1,f1,s_stream,i_stream);
- }
+ int level;
+
+ buf->data[0] = decode_coeff (s_stream, i_stream);
+
+ for (level = 0; level < buf->scales - 1; level++) {
+ uint32_t w, h, f, w1, h1, f1;
+
+ w = buf->w[level];
+ h = buf->h[level];
+ f = buf->f[level];
+ w1 = buf->w[level + 1] - w;
+ h1 = buf->h[level + 1] - h;
+ f1 = buf->f[level + 1] - f;
+
+ if (w1 > 0)
+ decode_quadrant (buf, level, 1, w1, h, f, s_stream, i_stream);
+ if (h1 > 0)
+ decode_quadrant (buf, level, 2, w, h1, f, s_stream, i_stream);
+ if (f1 > 0)
+ decode_quadrant (buf, level, 3, w, h, f1, s_stream, i_stream);
+ if (w1 > 0 && h1 > 0)
+ decode_quadrant (buf, level, 4, w1, h1, f, s_stream, i_stream);
+ if (w1 > 0 && f1 > 0)
+ decode_quadrant (buf, level, 5, w1, h, f1, s_stream, i_stream);
+ if (h1 > 0 && f1 > 0)
+ decode_quadrant (buf, level, 6, w, h1, f1, s_stream, i_stream);
+ if (h1 > 0 && f1 > 0 && f1 > 0)
+ decode_quadrant (buf, level, 7, w1, h1, f1, s_stream, i_stream);
+ }
}
#else
-static
-void encode_coefficients (const Wavelet3DBuf* buf,
- ENTROPY_CODER s_stream [],
- ENTROPY_CODER i_stream [])
+static void
+encode_coefficients (const Wavelet3DBuf * buf,
+ ENTROPY_CODER s_stream[], ENTROPY_CODER i_stream[])
{
- uint32_t i;
+ uint32_t i;
- for (i=0; i<buf->width*buf->height*buf->frames; i++)
- encode_coeff(s_stream, i_stream, buf->data[i]);
+ for (i = 0; i < buf->width * buf->height * buf->frames; i++)
+ encode_coeff (s_stream, i_stream, buf->data[i]);
}
-static
-void decode_coefficients (Wavelet3DBuf* buf,
- ENTROPY_CODER s_stream [],
- ENTROPY_CODER i_stream [])
+static void
+decode_coefficients (Wavelet3DBuf * buf,
+ ENTROPY_CODER s_stream[], ENTROPY_CODER i_stream[])
{
- uint32_t i;
+ uint32_t i;
- for (i=0; i<buf->width*buf->height*buf->frames; i++) {
- uint32_t skip;
+ for (i = 0; i < buf->width * buf->height * buf->frames; i++) {
+ uint32_t skip;
- buf->data[i] = decode_coeff(s_stream, i_stream);
+ buf->data[i] = decode_coeff (s_stream, i_stream);
- skip = skip_0coeffs (buf, s_stream, i_stream,
- buf->width*buf->height*buf->frames - i);
- i += skip;
- }
+ skip = skip_0coeffs (buf, s_stream, i_stream,
+ buf->width * buf->height * buf->frames - i);
+ i += skip;
+ }
}
#endif
-static
-uint32_t setup_limittabs (ENTROPY_CODER significand_bitstream [],
- ENTROPY_CODER insignificand_bitstream [],
- uint32_t significand_limittab [],
- uint32_t insignificand_limittab [],
- uint32_t limit)
+static uint32_t
+setup_limittabs (ENTROPY_CODER significand_bitstream[],
+ ENTROPY_CODER insignificand_bitstream[],
+ uint32_t significand_limittab[],
+ uint32_t insignificand_limittab[], uint32_t limit)
{
- uint32_t significand_limit;
- uint32_t insignificand_limit;
- uint32_t byte_count;
- int i;
-
- assert (limit > 2 * TYPE_BITS * sizeof(uint32_t)); /* limit too small */
-
- printf ("%s: limit == %u\n", __FUNCTION__, limit);
- byte_count = 2 * TYPE_BITS * sizeof(uint32_t); /* 2 binary coded limittabs */
- limit -= byte_count;
- printf ("%s: rem. limit == %u\n", __FUNCTION__, limit);
-
- significand_limit = limit * 7 / 8;
- insignificand_limit = limit - significand_limit;
-
- printf ("%s: limit == %u\n", __FUNCTION__, limit);
- printf ("significand limit == %u\n", significand_limit);
- printf ("insignificand limit == %u\n", insignificand_limit);
-
- for (i=TYPE_BITS-1; i>=0; i--) {
- uint32_t s_bytes, i_bytes;
-
- if (i > 0) {
- significand_limittab[i] = (significand_limit + 1) / 2;
- insignificand_limittab[i] = (insignificand_limit + 1) / 2;
- } else {
- significand_limittab[0] = significand_limit;
- insignificand_limittab[0] = insignificand_limit;
- }
+ uint32_t significand_limit;
+ uint32_t insignificand_limit;
+ uint32_t byte_count;
+ int i;
+
+ assert (limit > 2 * TYPE_BITS * sizeof (uint32_t)); /* limit too small */
+
+ printf ("%s: limit == %u\n", __FUNCTION__, limit);
+ byte_count = 2 * TYPE_BITS * sizeof (uint32_t); /* 2 binary coded limittabs */
+ limit -= byte_count;
+ printf ("%s: rem. limit == %u\n", __FUNCTION__, limit);
+
+ significand_limit = limit * 7 / 8;
+ insignificand_limit = limit - significand_limit;
- s_bytes = ENTROPY_ENCODER_FLUSH(&significand_bitstream[i]);
- i_bytes = ENTROPY_ENCODER_FLUSH(&insignificand_bitstream[i]);
+ printf ("%s: limit == %u\n", __FUNCTION__, limit);
+ printf ("significand limit == %u\n", significand_limit);
+ printf ("insignificand limit == %u\n", insignificand_limit);
- if (s_bytes < significand_limittab[i])
- significand_limittab[i] = s_bytes;
+ for (i = TYPE_BITS - 1; i >= 0; i--) {
+ uint32_t s_bytes, i_bytes;
- if (i_bytes < insignificand_limittab[i])
- insignificand_limittab[i] = i_bytes;
+ if (i > 0) {
+ significand_limittab[i] = (significand_limit + 1) / 2;
+ insignificand_limittab[i] = (insignificand_limit + 1) / 2;
+ } else {
+ significand_limittab[0] = significand_limit;
+ insignificand_limittab[0] = insignificand_limit;
+ }
- byte_count += significand_limittab[i];
- byte_count += insignificand_limittab[i];
+ s_bytes = ENTROPY_ENCODER_FLUSH (&significand_bitstream[i]);
+ i_bytes = ENTROPY_ENCODER_FLUSH (&insignificand_bitstream[i]);
- printf ("insignificand_limittab[%i] == %u / %u\n",
- i, insignificand_limittab[i], i_bytes);
- printf (" significand_limittab[%i] == %u / %u\n",
- i, significand_limittab[i], s_bytes);
+ if (s_bytes < significand_limittab[i])
+ significand_limittab[i] = s_bytes;
- significand_limit -= significand_limittab[i];
- insignificand_limit -= insignificand_limittab[i];
- }
+ if (i_bytes < insignificand_limittab[i])
+ insignificand_limittab[i] = i_bytes;
- printf ("byte_count == %u\n", byte_count);
+ byte_count += significand_limittab[i];
+ byte_count += insignificand_limittab[i];
- return byte_count;
+ printf ("insignificand_limittab[%i] == %u / %u\n",
+ i, insignificand_limittab[i], i_bytes);
+ printf (" significand_limittab[%i] == %u / %u\n",
+ i, significand_limittab[i], s_bytes);
+
+ significand_limit -= significand_limittab[i];
+ insignificand_limit -= insignificand_limittab[i];
+ }
+
+ printf ("byte_count == %u\n", byte_count);
+
+ return byte_count;
}
/**
* write 'em binary for now, should be easy to compress ...
*/
-static
-uint8_t* write_limittabs (uint8_t *bitstream,
- uint32_t significand_limittab [],
- uint32_t insignificand_limittab [])
+static uint8_t *
+write_limittabs (uint8_t * bitstream,
+ uint32_t significand_limittab[], uint32_t insignificand_limittab[])
{
- int i;
+ int i;
- for (i=0; i<TYPE_BITS; i++) {
- *(uint32_t*) bitstream = significand_limittab[i];
- bitstream += 4;
- }
+ for (i = 0; i < TYPE_BITS; i++) {
+ *(uint32_t *) bitstream = significand_limittab[i];
+ bitstream += 4;
+ }
- for (i=0; i<TYPE_BITS; i++) {
- *(uint32_t*) bitstream = insignificand_limittab[i];
- bitstream += 4;
- }
+ for (i = 0; i < TYPE_BITS; i++) {
+ *(uint32_t *) bitstream = insignificand_limittab[i];
+ bitstream += 4;
+ }
- return bitstream;
+ return bitstream;
}
-static
-uint8_t* read_limittabs (uint8_t *bitstream,
- uint32_t significand_limittab [],
- uint32_t insignificand_limittab [])
+static uint8_t *
+read_limittabs (uint8_t * bitstream,
+ uint32_t significand_limittab[], uint32_t insignificand_limittab[])
{
- int i;
-
- for (i=0; i<TYPE_BITS; i++) {
- significand_limittab[i] = *(uint32_t*) bitstream;
- printf ("significand_limittab[%i] == %u\n", i, significand_limittab[i]);
- bitstream += 4;
- }
-
- for (i=0; i<TYPE_BITS; i++) {
- insignificand_limittab[i] = *(uint32_t*) bitstream;
- printf ("insignificand_limittab[%i] == %u\n", i, insignificand_limittab[i]);
- bitstream += 4;
- }
-
- return bitstream;
+ int i;
+
+ for (i = 0; i < TYPE_BITS; i++) {
+ significand_limittab[i] = *(uint32_t *) bitstream;
+ printf ("significand_limittab[%i] == %u\n", i, significand_limittab[i]);
+ bitstream += 4;
+ }
+
+ for (i = 0; i < TYPE_BITS; i++) {
+ insignificand_limittab[i] = *(uint32_t *) bitstream;
+ printf ("insignificand_limittab[%i] == %u\n", i,
+ insignificand_limittab[i]);
+ bitstream += 4;
+ }
+
+ return bitstream;
}
/**
* concatenate entropy coder bitstreams
*/
-static
-void merge_bitstreams (uint8_t *bitstream,
- ENTROPY_CODER significand_bitstream [],
- ENTROPY_CODER insignificand_bitstream [],
- uint32_t significand_limittab [],
- uint32_t insignificand_limittab [])
+static void
+merge_bitstreams (uint8_t * bitstream,
+ ENTROPY_CODER significand_bitstream[],
+ ENTROPY_CODER insignificand_bitstream[],
+ uint32_t significand_limittab[], uint32_t insignificand_limittab[])
{
- int i;
+ int i;
- for (i=TYPE_BITS-1; i>=0; i--) {
- memcpy (bitstream,
- ENTROPY_CODER_BITSTREAM(&significand_bitstream[i]),
- significand_limittab[i]);
+ for (i = TYPE_BITS - 1; i >= 0; i--) {
+ memcpy (bitstream,
+ ENTROPY_CODER_BITSTREAM (&significand_bitstream[i]),
+ significand_limittab[i]);
- bitstream += significand_limittab[i];
- }
+ bitstream += significand_limittab[i];
+ }
- for (i=TYPE_BITS-1; i>=0; i--) {
- memcpy (bitstream,
- ENTROPY_CODER_BITSTREAM(&insignificand_bitstream[i]),
- insignificand_limittab[i]);
+ for (i = TYPE_BITS - 1; i >= 0; i--) {
+ memcpy (bitstream,
+ ENTROPY_CODER_BITSTREAM (&insignificand_bitstream[i]),
+ insignificand_limittab[i]);
- bitstream += insignificand_limittab[i];
- }
+ bitstream += insignificand_limittab[i];
+ }
}
-static
-void split_bitstreams (uint8_t *bitstream,
- ENTROPY_CODER significand_bitstream [],
- ENTROPY_CODER insignificand_bitstream [],
- uint32_t significand_limittab [],
- uint32_t insignificand_limittab [])
+static void
+split_bitstreams (uint8_t * bitstream,
+ ENTROPY_CODER significand_bitstream[],
+ ENTROPY_CODER insignificand_bitstream[],
+ uint32_t significand_limittab[], uint32_t insignificand_limittab[])
{
- uint32_t byte_count;
- int i;
-
- for (i=TYPE_BITS-1; i>=0; i--) {
- byte_count = significand_limittab[i];
- ENTROPY_DECODER_INIT(&significand_bitstream[i], bitstream, byte_count);
- bitstream += byte_count;
- }
-
- for (i=TYPE_BITS-1; i>=0; i--) {
- byte_count = insignificand_limittab[i];
- ENTROPY_DECODER_INIT(&insignificand_bitstream[i], bitstream, byte_count);
- bitstream += byte_count;
- }
+ uint32_t byte_count;
+ int i;
+
+ for (i = TYPE_BITS - 1; i >= 0; i--) {
+ byte_count = significand_limittab[i];
+ ENTROPY_DECODER_INIT (&significand_bitstream[i], bitstream, byte_count);
+ bitstream += byte_count;
+ }
+
+ for (i = TYPE_BITS - 1; i >= 0; i--) {
+ byte_count = insignificand_limittab[i];
+ ENTROPY_DECODER_INIT (&insignificand_bitstream[i], bitstream, byte_count);
+ bitstream += byte_count;
+ }
}
-int wavelet_3d_buf_encode_coeff (const Wavelet3DBuf* buf,
- uint8_t *bitstream,
- uint32_t limit)
+int
+wavelet_3d_buf_encode_coeff (const Wavelet3DBuf * buf,
+ uint8_t * bitstream, uint32_t limit)
{
- ENTROPY_CODER significand_bitstream [TYPE_BITS];
- ENTROPY_CODER insignificand_bitstream [TYPE_BITS];
- uint32_t significand_limittab [TYPE_BITS];
- uint32_t insignificand_limittab [TYPE_BITS];
- uint32_t byte_count;
- int i;
+ ENTROPY_CODER significand_bitstream[TYPE_BITS];
+ ENTROPY_CODER insignificand_bitstream[TYPE_BITS];
+ uint32_t significand_limittab[TYPE_BITS];
+ uint32_t insignificand_limittab[TYPE_BITS];
+ uint32_t byte_count;
+ int i;
- for (i=0; i<TYPE_BITS; i++)
- ENTROPY_ENCODER_INIT(&significand_bitstream[i], limit);
- for (i=0; i<TYPE_BITS; i++)
- ENTROPY_ENCODER_INIT(&insignificand_bitstream[i], limit);
+ for (i = 0; i < TYPE_BITS; i++)
+ ENTROPY_ENCODER_INIT (&significand_bitstream[i], limit);
+ for (i = 0; i < TYPE_BITS; i++)
+ ENTROPY_ENCODER_INIT (&insignificand_bitstream[i], limit);
- encode_coefficients (buf, significand_bitstream, insignificand_bitstream);
+ encode_coefficients (buf, significand_bitstream, insignificand_bitstream);
- byte_count = setup_limittabs (significand_bitstream, insignificand_bitstream,
- significand_limittab, insignificand_limittab,
- limit);
+ byte_count = setup_limittabs (significand_bitstream, insignificand_bitstream,
+ significand_limittab, insignificand_limittab, limit);
- bitstream = write_limittabs (bitstream,
- significand_limittab, insignificand_limittab);
+ bitstream = write_limittabs (bitstream,
+ significand_limittab, insignificand_limittab);
- merge_bitstreams (bitstream, significand_bitstream, insignificand_bitstream,
- significand_limittab, insignificand_limittab);
+ merge_bitstreams (bitstream, significand_bitstream, insignificand_bitstream,
+ significand_limittab, insignificand_limittab);
- for (i=0; i<TYPE_BITS; i++) {
- ENTROPY_ENCODER_DONE(&significand_bitstream[i]);
- ENTROPY_ENCODER_DONE(&insignificand_bitstream[i]);
- }
+ for (i = 0; i < TYPE_BITS; i++) {
+ ENTROPY_ENCODER_DONE (&significand_bitstream[i]);
+ ENTROPY_ENCODER_DONE (&insignificand_bitstream[i]);
+ }
- return byte_count;
+ return byte_count;
}
-void wavelet_3d_buf_decode_coeff (Wavelet3DBuf* buf,
- uint8_t *bitstream,
- uint32_t byte_count)
+void
+wavelet_3d_buf_decode_coeff (Wavelet3DBuf * buf,
+ uint8_t * bitstream, uint32_t byte_count)
{
- ENTROPY_CODER significand_bitstream [TYPE_BITS];
- ENTROPY_CODER insignificand_bitstream [TYPE_BITS];
- uint32_t significand_limittab [TYPE_BITS];
- uint32_t insignificand_limittab [TYPE_BITS];
- int i;
+ ENTROPY_CODER significand_bitstream[TYPE_BITS];
+ ENTROPY_CODER insignificand_bitstream[TYPE_BITS];
+ uint32_t significand_limittab[TYPE_BITS];
+ uint32_t insignificand_limittab[TYPE_BITS];
+ int i;
- memset (buf->data, 0,
- buf->width * buf->height * buf->frames * sizeof(TYPE));
+ memset (buf->data, 0, buf->width * buf->height * buf->frames * sizeof (TYPE));
- bitstream = read_limittabs (bitstream,
- significand_limittab, insignificand_limittab);
+ bitstream = read_limittabs (bitstream,
+ significand_limittab, insignificand_limittab);
- split_bitstreams (bitstream, significand_bitstream, insignificand_bitstream,
- significand_limittab, insignificand_limittab);
+ split_bitstreams (bitstream, significand_bitstream, insignificand_bitstream,
+ significand_limittab, insignificand_limittab);
- decode_coefficients (buf, significand_bitstream, insignificand_bitstream);
+ decode_coefficients (buf, significand_bitstream, insignificand_bitstream);
- for (i=0; i<TYPE_BITS; i++) {
- ENTROPY_DECODER_DONE(&significand_bitstream[i]);
- ENTROPY_DECODER_DONE(&insignificand_bitstream[i]);
- }
+ for (i = 0; i < TYPE_BITS; i++) {
+ ENTROPY_DECODER_DONE (&significand_bitstream[i]);
+ ENTROPY_DECODER_DONE (&insignificand_bitstream[i]);
+ }
}
-
-
diff --git a/ext/tarkin/wavelet_xform.c b/ext/tarkin/wavelet_xform.c
index f052f003..fda5f59d 100644
--- a/ext/tarkin/wavelet_xform.c
+++ b/ext/tarkin/wavelet_xform.c
@@ -8,388 +8,414 @@
-static
-void fwd_analyze_1 (const TYPE *x, TYPE *d, int stride, int n)
+static void
+fwd_analyze_1 (const TYPE * x, TYPE * d, int stride, int n)
{
- int i, k=n/2;
+ int i, k = n / 2;
- for (i=0; i<k; i++)
- d[i] = x[(2*i+1)*stride] - x[2*i*stride];
+ for (i = 0; i < k; i++)
+ d[i] = x[(2 * i + 1) * stride] - x[2 * i * stride];
}
-static
-void fwd_synthesize_1 (const TYPE *x, TYPE *s, const TYPE *d, int stride, int n)
+static void
+fwd_synthesize_1 (const TYPE * x, TYPE * s, const TYPE * d, int stride, int n)
{
- int i, k=n/2;
+ int i, k = n / 2;
- for (i=0; i<k; i++)
- s[i*stride] = x[2*i*stride] + d[i] / 2;
- if (n & 1)
- s[k*stride] = x[2*k*stride] + d[k-1] / 2;
+ for (i = 0; i < k; i++)
+ s[i * stride] = x[2 * i * stride] + d[i] / 2;
+ if (n & 1)
+ s[k * stride] = x[2 * k * stride] + d[k - 1] / 2;
}
-static
-void inv_analyze_1 (TYPE *x, const TYPE *d, int stride, int n)
+static void
+inv_analyze_1 (TYPE * x, const TYPE * d, int stride, int n)
{
- int i, k=n/2;
+ int i, k = n / 2;
- for (i=0; i<k; i++)
- x[(2*i+1)*stride] = d[i] + x[2*i*stride];
+ for (i = 0; i < k; i++)
+ x[(2 * i + 1) * stride] = d[i] + x[2 * i * stride];
}
-static
-void inv_synthesize_1 (TYPE *x, const TYPE *s, const TYPE *d, int stride, int n)
+static void
+inv_synthesize_1 (TYPE * x, const TYPE * s, const TYPE * d, int stride, int n)
{
- int i, k=n/2;
+ int i, k = n / 2;
- for (i=0; i<k; i++)
- x[2*i*stride] = s[i] - d[i] / 2;
- if (n & 1)
- x[2*k*stride] = s[k] - d[k-1] / 2;
+ for (i = 0; i < k; i++)
+ x[2 * i * stride] = s[i] - d[i] / 2;
+ if (n & 1)
+ x[2 * k * stride] = s[k] - d[k - 1] / 2;
}
-static
-void fwd_analyze_2 (const TYPE *x, TYPE *d, int stride, int n)
+static void
+fwd_analyze_2 (const TYPE * x, TYPE * d, int stride, int n)
{
- int i, k=n/2;
-
- if (n & 1) {
- for (i=0; i<k; i++)
- d[i] = x[(2*i+1)*stride] - (x[2*i*stride] + x[(2*i+2)*stride]) / 2;
- } else {
- for (i=0; i<k-1; i++)
- d[i] = x[(2*i+1)*stride] - (x[2*i*stride] + x[(2*i+2)*stride]) / 2;
- d[k-1] = x[(n-1)*stride] - x[(n-2)*stride];
- }
+ int i, k = n / 2;
+
+ if (n & 1) {
+ for (i = 0; i < k; i++)
+ d[i] =
+ x[(2 * i + 1) * stride] - (x[2 * i * stride] + x[(2 * i +
+ 2) * stride]) / 2;
+ } else {
+ for (i = 0; i < k - 1; i++)
+ d[i] =
+ x[(2 * i + 1) * stride] - (x[2 * i * stride] + x[(2 * i +
+ 2) * stride]) / 2;
+ d[k - 1] = x[(n - 1) * stride] - x[(n - 2) * stride];
+ }
}
-static
-void fwd_synthesize_2 (const TYPE *x, TYPE *s, const TYPE *d, int stride, int n)
+static void
+fwd_synthesize_2 (const TYPE * x, TYPE * s, const TYPE * d, int stride, int n)
{
- int i, k=n/2;
+ int i, k = n / 2;
- s[0] = x[0] + d[1] / 2;
- for (i=1; i<k; i++)
- s[i*stride] = x[2*i*stride] + (d[i-1] + d[i]) / 4;
- if (n & 1)
- s[k*stride] = x[2*k*stride] + d[k-1] / 2;
+ s[0] = x[0] + d[1] / 2;
+ for (i = 1; i < k; i++)
+ s[i * stride] = x[2 * i * stride] + (d[i - 1] + d[i]) / 4;
+ if (n & 1)
+ s[k * stride] = x[2 * k * stride] + d[k - 1] / 2;
}
-static inline
-void inv_analyze_2 (TYPE *x, const TYPE *d, int stride, int n)
+static inline void
+inv_analyze_2 (TYPE * x, const TYPE * d, int stride, int n)
{
- int i, k=n/2;
-
- if (n & 1) {
- for (i=0; i<k; i++)
- x[(2*i+1)*stride] = d[i] + (x[2*i*stride] + x[(2*i+2)*stride]) / 2;
- } else {
- for (i=0; i<k-1; i++)
- x[(2*i+1)*stride] = d[i] + (x[2*i*stride] + x[(2*i+2)*stride]) / 2;
- x[(n-1)*stride] = d[k-1] + x[(n-2)*stride];
- }
+ int i, k = n / 2;
+
+ if (n & 1) {
+ for (i = 0; i < k; i++)
+ x[(2 * i + 1) * stride] =
+ d[i] + (x[2 * i * stride] + x[(2 * i + 2) * stride]) / 2;
+ } else {
+ for (i = 0; i < k - 1; i++)
+ x[(2 * i + 1) * stride] =
+ d[i] + (x[2 * i * stride] + x[(2 * i + 2) * stride]) / 2;
+ x[(n - 1) * stride] = d[k - 1] + x[(n - 2) * stride];
+ }
}
-static inline
-void inv_synthesize_2 (TYPE *x, const TYPE *s, const TYPE *d, int stride, int n)
+static inline void
+inv_synthesize_2 (TYPE * x, const TYPE * s, const TYPE * d, int stride, int n)
{
- int i, k=n/2;
+ int i, k = n / 2;
- x[0] = s[0] - d[1] / 2;
- for (i=1; i<k; i++)
- x[2*i*stride] = s[i] - (d[i-1] + d[i]) / 4;
- if (n & 1)
- x[2*k*stride] = s[k] - d[k-1] / 2;
+ x[0] = s[0] - d[1] / 2;
+ for (i = 1; i < k; i++)
+ x[2 * i * stride] = s[i] - (d[i - 1] + d[i]) / 4;
+ if (n & 1)
+ x[2 * k * stride] = s[k] - d[k - 1] / 2;
}
-static
-void fwd_analyze_4 (const TYPE *x, TYPE *d, int stride, int n)
+static void
+fwd_analyze_4 (const TYPE * x, TYPE * d, int stride, int n)
{
- int i, k=n/2;
-
- d[0] = x[stride] - (x[0] + x[2*stride]) / 2;
-
- if (n & 1) {
- for (i=1; i<k-1; i++)
- d[i] = x[(2*i+1)*stride]
- - ((uint32_t) 9 * (x[2*i*stride] + x[(2*i+2)*stride])
- - (x[(2*i-2)*stride] + x[(2*i+4)*stride])) / 16;
- if (k > 1)
- d[k-1] = x[(2*k-1)*stride] - (x[(2*k-2)*stride] + x[2*k*stride]) / 2;
- } else {
- for (i=1; i<k-2; i++)
- d[i] = x[(2*i+1)*stride]
- - ((uint32_t) 9 * (x[2*i*stride] + x[(2*i+2)*stride])
- - (x[(2*i-2)*stride] + x[(2*i+4)*stride])) / 16;
- if (k > 2)
- d[k-2] = x[(2*k-3)*stride] - (x[(2*k-4)*stride]
- + x[(2*k-2)*stride]) / 2;
- if (k > 1)
- d[k-1] = x[(n-1)*stride] - x[(n-2)*stride];
- }
+ int i, k = n / 2;
+
+ d[0] = x[stride] - (x[0] + x[2 * stride]) / 2;
+
+ if (n & 1) {
+ for (i = 1; i < k - 1; i++)
+ d[i] = x[(2 * i + 1) * stride]
+ - ((uint32_t) 9 * (x[2 * i * stride] + x[(2 * i + 2) * stride])
+ - (x[(2 * i - 2) * stride] + x[(2 * i + 4) * stride])) / 16;
+ if (k > 1)
+ d[k - 1] =
+ x[(2 * k - 1) * stride] - (x[(2 * k - 2) * stride] +
+ x[2 * k * stride]) / 2;
+ } else {
+ for (i = 1; i < k - 2; i++)
+ d[i] = x[(2 * i + 1) * stride]
+ - ((uint32_t) 9 * (x[2 * i * stride] + x[(2 * i + 2) * stride])
+ - (x[(2 * i - 2) * stride] + x[(2 * i + 4) * stride])) / 16;
+ if (k > 2)
+ d[k - 2] = x[(2 * k - 3) * stride] - (x[(2 * k - 4) * stride]
+ + x[(2 * k - 2) * stride]) / 2;
+ if (k > 1)
+ d[k - 1] = x[(n - 1) * stride] - x[(n - 2) * stride];
+ }
}
-static
-void fwd_synthesize_4 (const TYPE *x, TYPE *s, const TYPE *d, int stride, int n)
+static void
+fwd_synthesize_4 (const TYPE * x, TYPE * s, const TYPE * d, int stride, int n)
{
- int i, k=n/2;
-
- s[0] = x[0] + d[1] / 2;
- if (k > 1)
- s[stride] = x[2*stride] + (d[0] + d[1]) / 4;
- for (i=2; i<k-1; i++)
- s[i*stride] = x[2*i*stride]
- + ((uint32_t) 9 * (d[i-1] + d[i]) - (d[i-2] + d[i+1])) / 32;
- if (k > 2)
- s[(k-1)*stride] = x[(2*k-2)*stride] + (d[k-2] + d[k-1]) / 4;
- if (n & 1)
- s[k*stride] = x[2*k*stride] + d[k-1] / 2;
+ int i, k = n / 2;
+
+ s[0] = x[0] + d[1] / 2;
+ if (k > 1)
+ s[stride] = x[2 * stride] + (d[0] + d[1]) / 4;
+ for (i = 2; i < k - 1; i++)
+ s[i * stride] = x[2 * i * stride]
+ + ((uint32_t) 9 * (d[i - 1] + d[i]) - (d[i - 2] + d[i + 1])) / 32;
+ if (k > 2)
+ s[(k - 1) * stride] = x[(2 * k - 2) * stride] + (d[k - 2] + d[k - 1]) / 4;
+ if (n & 1)
+ s[k * stride] = x[2 * k * stride] + d[k - 1] / 2;
}
-static
-void inv_analyze_4 (TYPE *x, const TYPE *d, int stride, int n)
+static void
+inv_analyze_4 (TYPE * x, const TYPE * d, int stride, int n)
{
- int i, k=n/2;
-
- x[stride] = d[0] + (x[0] + x[2*stride]) / 2;
-
- if (n & 1) {
- for (i=1; i<k-1; i++)
- x[(2*i+1)*stride] = d[i]
- + ((uint32_t) 9 * (x[2*i*stride] + x[(2*i+2)*stride])
- - (x[(2*i-2)*stride] + x[(2*i+4)*stride])) / 16;
- if (k > 1)
- x[(2*k-1)*stride] = d[k-1] + (x[(2*k-2)*stride] + x[2*k*stride]) / 2;
- } else {
- for (i=1; i<k-2; i++)
- x[(2*i+1)*stride] = d[i]
- + (9 * (x[2*i*stride] + x[(2*i+2)*stride])
- - (x[(2*i-2)*stride] + x[(2*i+4)*stride])) / 16;
- if (k > 2)
- x[(2*k-3)*stride] = d[k-2] + (x[(2*k-4)*stride]
- + x[(2*k-2)*stride]) / 2;
- if (k > 1)
- x[(n-1)*stride] = d[k-1] + x[(n-2)*stride];
- }
+ int i, k = n / 2;
+
+ x[stride] = d[0] + (x[0] + x[2 * stride]) / 2;
+
+ if (n & 1) {
+ for (i = 1; i < k - 1; i++)
+ x[(2 * i + 1) * stride] = d[i]
+ + ((uint32_t) 9 * (x[2 * i * stride] + x[(2 * i + 2) * stride])
+ - (x[(2 * i - 2) * stride] + x[(2 * i + 4) * stride])) / 16;
+ if (k > 1)
+ x[(2 * k - 1) * stride] =
+ d[k - 1] + (x[(2 * k - 2) * stride] + x[2 * k * stride]) / 2;
+ } else {
+ for (i = 1; i < k - 2; i++)
+ x[(2 * i + 1) * stride] = d[i]
+ + (9 * (x[2 * i * stride] + x[(2 * i + 2) * stride])
+ - (x[(2 * i - 2) * stride] + x[(2 * i + 4) * stride])) / 16;
+ if (k > 2)
+ x[(2 * k - 3) * stride] = d[k - 2] + (x[(2 * k - 4) * stride]
+ + x[(2 * k - 2) * stride]) / 2;
+ if (k > 1)
+ x[(n - 1) * stride] = d[k - 1] + x[(n - 2) * stride];
+ }
}
-static
-void inv_synthesize_4 (TYPE *x, const TYPE *s, const TYPE *d, int stride, int n)
+static void
+inv_synthesize_4 (TYPE * x, const TYPE * s, const TYPE * d, int stride, int n)
{
- int i, k=n/2;
-
- x[0] = s[0] - d[1] / 2;
- if (k > 1)
- x[2*stride] = s[1] - (d[0] + d[1]) / 4;
- for (i=2; i<k-1; i++)
- x[2*i*stride] = s[i] - ((uint32_t) 9 * (d[i-1] + d[i])
- - (d[i-2] + d[i+1])) / 32;
- if (k > 2)
- x[(2*k-2)*stride] = s[k-1] - (d[k-2] + d[k-1]) / 4;
- if (n & 1)
- x[2*k*stride] = s[k] - d[k-1] / 2;
+ int i, k = n / 2;
+
+ x[0] = s[0] - d[1] / 2;
+ if (k > 1)
+ x[2 * stride] = s[1] - (d[0] + d[1]) / 4;
+ for (i = 2; i < k - 1; i++)
+ x[2 * i * stride] = s[i] - ((uint32_t) 9 * (d[i - 1] + d[i])
+ - (d[i - 2] + d[i + 1])) / 32;
+ if (k > 2)
+ x[(2 * k - 2) * stride] = s[k - 1] - (d[k - 2] + d[k - 1]) / 4;
+ if (n & 1)
+ x[2 * k * stride] = s[k] - d[k - 1] / 2;
}
-static inline
-void copyback_d (TYPE *x, const TYPE *d, int stride, int n)
+static inline void
+copyback_d (TYPE * x, const TYPE * d, int stride, int n)
{
- int i, j, k=n/2;
+ int i, j, k = n / 2;
- for (i=n-k, j=0; i<n; i++, j++)
- x [i*stride] = d[j];
+ for (i = n - k, j = 0; i < n; i++, j++)
+ x[i * stride] = d[j];
}
-static inline
-void copy_s_d (const TYPE *x, TYPE *s_d, int stride, int n)
+static inline void
+copy_s_d (const TYPE * x, TYPE * s_d, int stride, int n)
{
- int i;
+ int i;
- for (i=0; i<n; i++)
- s_d[i] = x [i*stride];
+ for (i = 0; i < n; i++)
+ s_d[i] = x[i * stride];
}
typedef
-void (*FwdSFnc) (const TYPE *x, TYPE *s, const TYPE *d, int stride, int n);
+ void (*FwdSFnc) (const TYPE * x, TYPE * s, const TYPE * d, int stride,
+ int n);
-typedef
-void (*FwdAFnc) (const TYPE *x, TYPE *d, int stride, int n);
+typedef void (*FwdAFnc) (const TYPE * x, TYPE * d, int stride, int n);
typedef
-void (*InvSFnc) (TYPE *x, const TYPE *s, const TYPE *d, int stride, int n);
+ void (*InvSFnc) (TYPE * x, const TYPE * s, const TYPE * d, int stride,
+ int n);
-typedef
-void (*InvAFnc) (TYPE *x, const TYPE *d, int stride, int n);
+typedef void (*InvAFnc) (TYPE * x, const TYPE * d, int stride, int n);
-static FwdSFnc fwd_synthesize [] = { NULL, fwd_synthesize_1, fwd_synthesize_2,
- NULL, fwd_synthesize_4 };
+static FwdSFnc fwd_synthesize[] = { NULL, fwd_synthesize_1, fwd_synthesize_2,
+ NULL, fwd_synthesize_4
+};
-static FwdAFnc fwd_analyze [] = { NULL, fwd_analyze_1, fwd_analyze_2,
- NULL, fwd_analyze_4 };
+static FwdAFnc fwd_analyze[] = { NULL, fwd_analyze_1, fwd_analyze_2,
+ NULL, fwd_analyze_4
+};
-static InvSFnc inv_synthesize [] = { NULL, inv_synthesize_1, inv_synthesize_2,
- NULL, inv_synthesize_4 };
+static InvSFnc inv_synthesize[] = { NULL, inv_synthesize_1, inv_synthesize_2,
+ NULL, inv_synthesize_4
+};
-static InvAFnc inv_analyze [] = { NULL, inv_analyze_1, inv_analyze_2,
- NULL, inv_analyze_4 };
+static InvAFnc inv_analyze[] = { NULL, inv_analyze_1, inv_analyze_2,
+ NULL, inv_analyze_4
+};
-static inline
-void fwd_xform (TYPE *scratchbuf, TYPE *data, int stride, int n,
- int a_moments, int s_moments)
+static inline void
+fwd_xform (TYPE * scratchbuf, TYPE * data, int stride, int n,
+ int a_moments, int s_moments)
{
- TYPE *x = data;
- TYPE *d = scratchbuf;
- TYPE *s = data;
-
- assert (a_moments == 1 || a_moments == 2 || a_moments == 4);
- assert (s_moments == 1 || s_moments == 2 || s_moments == 4);
-
- /* XXX FIXME: Ugly hack to work around */
- /* the short-row bug in high */
- /* order xform functions */
- if (n < 9)
- a_moments = s_moments = 2;
- if (n < 5)
- a_moments = s_moments = 1;
-
- fwd_analyze [a_moments] (x, d, stride, n);
- fwd_synthesize [s_moments] (x, s, d, stride, n);
- copyback_d (x, d, stride, n);
+ TYPE *x = data;
+ TYPE *d = scratchbuf;
+ TYPE *s = data;
+
+ assert (a_moments == 1 || a_moments == 2 || a_moments == 4);
+ assert (s_moments == 1 || s_moments == 2 || s_moments == 4);
+
+ /* XXX FIXME: Ugly hack to work around */
+ /* the short-row bug in high */
+ /* order xform functions */
+ if (n < 9)
+ a_moments = s_moments = 2;
+ if (n < 5)
+ a_moments = s_moments = 1;
+
+ fwd_analyze[a_moments] (x, d, stride, n);
+ fwd_synthesize[s_moments] (x, s, d, stride, n);
+ copyback_d (x, d, stride, n);
}
-static inline
-void inv_xform (TYPE *scratchbuf, TYPE *data, int stride, int n,
- int a_moments, int s_moments)
+static inline void
+inv_xform (TYPE * scratchbuf, TYPE * data, int stride, int n,
+ int a_moments, int s_moments)
{
- int k=n/2;
- TYPE *x = data;
- TYPE *s = scratchbuf;
- TYPE *d = scratchbuf + n - k;
-
- assert (a_moments == 1 || a_moments == 2 || a_moments == 4);
- assert (s_moments == 1 || s_moments == 2 || s_moments == 4);
-
- /* XXX FIXME: Ugly hack to work around */
- /* the short-row bug in high */
- /* order xform functions */
- if (n < 9)
- a_moments = s_moments = 2;
- if (n < 5)
- a_moments = s_moments = 1;
-
- copy_s_d (data, scratchbuf, stride, n);
- inv_synthesize [s_moments] (x, s, d, stride, n);
- inv_analyze [a_moments] (x, d, stride, n);
+ int k = n / 2;
+ TYPE *x = data;
+ TYPE *s = scratchbuf;
+ TYPE *d = scratchbuf + n - k;
+
+ assert (a_moments == 1 || a_moments == 2 || a_moments == 4);
+ assert (s_moments == 1 || s_moments == 2 || s_moments == 4);
+
+ /* XXX FIXME: Ugly hack to work around */
+ /* the short-row bug in high */
+ /* order xform functions */
+ if (n < 9)
+ a_moments = s_moments = 2;
+ if (n < 5)
+ a_moments = s_moments = 1;
+
+ copy_s_d (data, scratchbuf, stride, n);
+ inv_synthesize[s_moments] (x, s, d, stride, n);
+ inv_analyze[a_moments] (x, d, stride, n);
}
-void wavelet_3d_buf_fwd_xform (Wavelet3DBuf* buf, int a_moments, int s_moments)
+void
+wavelet_3d_buf_fwd_xform (Wavelet3DBuf * buf, int a_moments, int s_moments)
{
- int level;
-
- for (level=buf->scales-1; level>0; level--) {
- uint32_t w = buf->w[level];
- uint32_t h = buf->h[level];
- uint32_t f = buf->f[level];
-
- if (w > 1) {
- int row, frame;
- for (frame=0; frame<f; frame++) {
- for (row=0; row<h; row++) {
- TYPE *data = buf->data + (frame * buf->height + row) * buf->width;
- fwd_xform (buf->scratchbuf, data, 1, w, a_moments, s_moments);
- }
- }
+ int level;
+
+ for (level = buf->scales - 1; level > 0; level--) {
+ uint32_t w = buf->w[level];
+ uint32_t h = buf->h[level];
+ uint32_t f = buf->f[level];
+
+ if (w > 1) {
+ int row, frame;
+
+ for (frame = 0; frame < f; frame++) {
+ for (row = 0; row < h; row++) {
+ TYPE *data = buf->data + (frame * buf->height + row) * buf->width;
+
+ fwd_xform (buf->scratchbuf, data, 1, w, a_moments, s_moments);
+ }
}
+ }
+
+ if (h > 1) {
+ int col, frame;
+
+ for (frame = 0; frame < f; frame++) {
+ for (col = 0; col < w; col++) {
+ TYPE *data = buf->data + frame * buf->width * buf->height + col;
- if (h > 1) {
- int col, frame;
- for (frame=0; frame<f; frame++) {
- for (col=0; col<w; col++) {
- TYPE *data = buf->data + frame * buf->width * buf->height + col;
- fwd_xform (buf->scratchbuf, data, buf->width, h,
- a_moments, s_moments);
- }
- }
+ fwd_xform (buf->scratchbuf, data, buf->width, h,
+ a_moments, s_moments);
+ }
}
+ }
+
+ if (f > 1) {
+ int i, j;
+
+ for (j = 0; j < h; j++) {
+ for (i = 0; i < w; i++) {
+ TYPE *data = buf->data + j * buf->width + i;
- if (f > 1) {
- int i, j;
- for (j=0; j<h; j++) {
- for (i=0; i<w; i++) {
- TYPE *data = buf->data + j*buf->width + i;
- fwd_xform (buf->scratchbuf, data, buf->width * buf->height, f,
- a_moments, s_moments);
- }
- }
+ fwd_xform (buf->scratchbuf, data, buf->width * buf->height, f,
+ a_moments, s_moments);
+ }
}
- }
+ }
+ }
}
-void wavelet_3d_buf_inv_xform (Wavelet3DBuf* buf, int a_moments, int s_moments)
+void
+wavelet_3d_buf_inv_xform (Wavelet3DBuf * buf, int a_moments, int s_moments)
{
- int level;
-
- for (level=1; level<buf->scales; level++) {
- uint32_t w = buf->w[level];
- uint32_t h = buf->h[level];
- uint32_t f = buf->f[level];
-
- if (f > 1) {
- int i, j;
- for (j=0; j<h; j++) {
- for (i=0; i<w; i++) {
- TYPE *data = buf->data + j*buf->width + i;
- inv_xform (buf->scratchbuf, data, buf->width * buf->height, f,
- a_moments, s_moments);
- }
- }
+ int level;
+
+ for (level = 1; level < buf->scales; level++) {
+ uint32_t w = buf->w[level];
+ uint32_t h = buf->h[level];
+ uint32_t f = buf->f[level];
+
+ if (f > 1) {
+ int i, j;
+
+ for (j = 0; j < h; j++) {
+ for (i = 0; i < w; i++) {
+ TYPE *data = buf->data + j * buf->width + i;
+
+ inv_xform (buf->scratchbuf, data, buf->width * buf->height, f,
+ a_moments, s_moments);
+ }
}
+ }
+
+ if (h > 1) {
+ int col, frame;
- if (h > 1) {
- int col, frame;
- for (frame=0; frame<f; frame++) {
- for (col=0; col<w; col++) {
- TYPE *data = buf->data + frame * buf->width * buf->height + col;
- inv_xform (buf->scratchbuf, data, buf->width, h,
- a_moments, s_moments);
- }
- }
+ for (frame = 0; frame < f; frame++) {
+ for (col = 0; col < w; col++) {
+ TYPE *data = buf->data + frame * buf->width * buf->height + col;
+
+ inv_xform (buf->scratchbuf, data, buf->width, h,
+ a_moments, s_moments);
+ }
}
+ }
+
+ if (w > 1) {
+ int row, frame;
- if (w > 1) {
- int row, frame;
- for (frame=0; frame<f; frame++) {
- for (row=0; row<h; row++) {
- TYPE *data = buf->data + (frame * buf->height + row) * buf->width;
- inv_xform (buf->scratchbuf, data, 1, w, a_moments, s_moments);
- }
- }
+ for (frame = 0; frame < f; frame++) {
+ for (row = 0; row < h; row++) {
+ TYPE *data = buf->data + (frame * buf->height + row) * buf->width;
+
+ inv_xform (buf->scratchbuf, data, 1, w, a_moments, s_moments);
+ }
}
- }
+ }
+ }
}
-
diff --git a/ext/tarkin/yuv.c b/ext/tarkin/yuv.c
index 32c563f4..d781a3c8 100644
--- a/ext/tarkin/yuv.c
+++ b/ext/tarkin/yuv.c
@@ -8,221 +8,227 @@
/*#define TARKIN_YUV_LXY*/
-static inline
-uint8_t CLAMP(int16_t x)
+static inline uint8_t
+CLAMP (int16_t x)
{
- return ((x > 255) ? 255 : (x < 0) ? 0 : x);
+ return ((x > 255) ? 255 : (x < 0) ? 0 : x);
}
-void rgb24_to_yuv (uint8_t *rgb, Wavelet3DBuf *yuv [], uint32_t frame)
+void
+rgb24_to_yuv (uint8_t * rgb, Wavelet3DBuf * yuv[], uint32_t frame)
{
- int count = yuv[0]->width * yuv[0]->height;
- int16_t *y = yuv[0]->data + frame * count;
- int16_t *u = yuv[1]->data + frame * count;
- int16_t *v = yuv[2]->data + frame * count;
- int i;
+ int count = yuv[0]->width * yuv[0]->height;
+ int16_t *y = yuv[0]->data + frame * count;
+ int16_t *u = yuv[1]->data + frame * count;
+ int16_t *v = yuv[2]->data + frame * count;
+ int i;
#if defined(TARKIN_YUV_EXACT)
- for (i=0; i<count; i++, rgb+=3) {
- y [i] = ((int16_t) 77 * rgb [0] + 150 * rgb [1] + 29 * rgb [2]) / 256;
- u [i] = ((int16_t) -44 * rgb [0] - 87 * rgb [1] + 131 * rgb [2]) / 256;
- v [i] = ((int16_t) 131 * rgb [0] - 110 * rgb [1] - 21 * rgb [2]) / 256;
- }
+ for (i = 0; i < count; i++, rgb += 3) {
+ y[i] = ((int16_t) 77 * rgb[0] + 150 * rgb[1] + 29 * rgb[2]) / 256;
+ u[i] = ((int16_t) - 44 * rgb[0] - 87 * rgb[1] + 131 * rgb[2]) / 256;
+ v[i] = ((int16_t) 131 * rgb[0] - 110 * rgb[1] - 21 * rgb[2]) / 256;
+ }
#elif defined(TARKIN_YUV_LXY)
- for (i=0; i<count; i++, rgb+=3) {
- y [i] = ((int16_t) 54 * rgb [0] + 182 * rgb [1] + 18 * rgb [2]) / 256;
- u [i] = rgb [0] - y [i];
- v [i] = rgb [2] - y [i];
- }
+ for (i = 0; i < count; i++, rgb += 3) {
+ y[i] = ((int16_t) 54 * rgb[0] + 182 * rgb[1] + 18 * rgb[2]) / 256;
+ u[i] = rgb[0] - y[i];
+ v[i] = rgb[2] - y[i];
+ }
#else
- for (i=0; i<count; i++, rgb+=3) {
- v [i] = rgb [0] - rgb [1];
- u [i] = rgb [2] - rgb [1];
- y [i] = rgb [1] + (u [i] + v [i]) / 4;
- }
+ for (i = 0; i < count; i++, rgb += 3) {
+ v[i] = rgb[0] - rgb[1];
+ u[i] = rgb[2] - rgb[1];
+ y[i] = rgb[1] + (u[i] + v[i]) / 4;
+ }
#endif
}
-void yuv_to_rgb24 (Wavelet3DBuf *yuv [], uint8_t *rgb, uint32_t frame)
+void
+yuv_to_rgb24 (Wavelet3DBuf * yuv[], uint8_t * rgb, uint32_t frame)
{
- int count = yuv[0]->width * yuv[0]->height;
- int16_t *y = yuv[0]->data + frame * count;
- int16_t *u = yuv[1]->data + frame * count;
- int16_t *v = yuv[2]->data + frame * count;
- int i;
+ int count = yuv[0]->width * yuv[0]->height;
+ int16_t *y = yuv[0]->data + frame * count;
+ int16_t *u = yuv[1]->data + frame * count;
+ int16_t *v = yuv[2]->data + frame * count;
+ int i;
#if defined(TARKIN_YUV_EXACT)
- for (i=0; i<count; i++, rgb+=3) {
- rgb [0] = CLAMP(y [i] + 1.371 * v [i]);
- rgb [1] = CLAMP(y [i] - 0.698 * v [i] - 0.336 * u [i]);
- rgb [2] = CLAMP(y [i] + 1.732 * u [i]);
- }
+ for (i = 0; i < count; i++, rgb += 3) {
+ rgb[0] = CLAMP (y[i] + 1.371 * v[i]);
+ rgb[1] = CLAMP (y[i] - 0.698 * v[i] - 0.336 * u[i]);
+ rgb[2] = CLAMP (y[i] + 1.732 * u[i]);
+ }
#elif defined(TARKIN_YUV_LXY)
- for (i=0; i<count; i++, rgb+=3) {
- rgb [1] = CLAMP(y [i] - (76 * u [i] - 26 * v [i]) / 256);
- rgb [0] = CLAMP(y [i] + u [i]);
- rgb [2] = CLAMP(y [i] + v [i]);
- }
+ for (i = 0; i < count; i++, rgb += 3) {
+ rgb[1] = CLAMP (y[i] - (76 * u[i] - 26 * v[i]) / 256);
+ rgb[0] = CLAMP (y[i] + u[i]);
+ rgb[2] = CLAMP (y[i] + v[i]);
+ }
#else
- for (i=0; i<count; i++, rgb+=3) {
- rgb [1] = CLAMP(y [i] - (u [i] + v [i]) / 4);
- rgb [2] = CLAMP(u [i] + rgb [1]);
- rgb [0] = CLAMP(v [i] + rgb [1]);
- }
+ for (i = 0; i < count; i++, rgb += 3) {
+ rgb[1] = CLAMP (y[i] - (u[i] + v[i]) / 4);
+ rgb[2] = CLAMP (u[i] + rgb[1]);
+ rgb[0] = CLAMP (v[i] + rgb[1]);
+ }
#endif
}
-void rgb32_to_yuv (uint8_t *rgb, Wavelet3DBuf *yuv [], uint32_t frame)
+void
+rgb32_to_yuv (uint8_t * rgb, Wavelet3DBuf * yuv[], uint32_t frame)
{
- int count = yuv[0]->width * yuv[0]->height;
- int16_t *y = yuv[0]->data + frame * count;
- int16_t *u = yuv[1]->data + frame * count;
- int16_t *v = yuv[2]->data + frame * count;
- int i;
+ int count = yuv[0]->width * yuv[0]->height;
+ int16_t *y = yuv[0]->data + frame * count;
+ int16_t *u = yuv[1]->data + frame * count;
+ int16_t *v = yuv[2]->data + frame * count;
+ int i;
#if defined(TARKIN_YUV_EXACT)
- for (i=0; i<count; i++, rgb+=4) {
- y [i] = ((int16_t) 77 * rgb [0] + 150 * rgb [1] + 29 * rgb [2]) / 256;
- u [i] = ((int16_t) -44 * rgb [0] - 87 * rgb [1] + 131 * rgb [2]) / 256;
- v [i] = ((int16_t) 131 * rgb [0] - 110 * rgb [1] - 21 * rgb [2]) / 256;
- }
+ for (i = 0; i < count; i++, rgb += 4) {
+ y[i] = ((int16_t) 77 * rgb[0] + 150 * rgb[1] + 29 * rgb[2]) / 256;
+ u[i] = ((int16_t) - 44 * rgb[0] - 87 * rgb[1] + 131 * rgb[2]) / 256;
+ v[i] = ((int16_t) 131 * rgb[0] - 110 * rgb[1] - 21 * rgb[2]) / 256;
+ }
#elif defined(TARKIN_YUV_LXY)
- for (i=0; i<count; i++, rgb+=4) {
- y [i] = ((int16_t) 54 * rgb [0] + 182 * rgb [1] + 18 * rgb [2]) / 256;
- u [i] = rgb [0] - y [i];
- v [i] = rgb [2] - y [i];
- }
+ for (i = 0; i < count; i++, rgb += 4) {
+ y[i] = ((int16_t) 54 * rgb[0] + 182 * rgb[1] + 18 * rgb[2]) / 256;
+ u[i] = rgb[0] - y[i];
+ v[i] = rgb[2] - y[i];
+ }
#else
- for (i=0; i<count; i++, rgb+=4) {
- v [i] = rgb [0] - rgb [1];
- u [i] = rgb [2] - rgb [1];
- y [i] = rgb [1] + (u [i] + v [i]) / 4;
- }
+ for (i = 0; i < count; i++, rgb += 4) {
+ v[i] = rgb[0] - rgb[1];
+ u[i] = rgb[2] - rgb[1];
+ y[i] = rgb[1] + (u[i] + v[i]) / 4;
+ }
#endif
}
-void yuv_to_rgb32 (Wavelet3DBuf *yuv [], uint8_t *rgb, uint32_t frame)
+void
+yuv_to_rgb32 (Wavelet3DBuf * yuv[], uint8_t * rgb, uint32_t frame)
{
- int count = yuv[0]->width * yuv[0]->height;
- int16_t *y = yuv[0]->data + frame * count;
- int16_t *u = yuv[1]->data + frame * count;
- int16_t *v = yuv[2]->data + frame * count;
- int i;
+ int count = yuv[0]->width * yuv[0]->height;
+ int16_t *y = yuv[0]->data + frame * count;
+ int16_t *u = yuv[1]->data + frame * count;
+ int16_t *v = yuv[2]->data + frame * count;
+ int i;
#if defined(TARKIN_YUV_EXACT)
- for (i=0; i<count; i++, rgb+=4) {
- rgb [0] = CLAMP(y [i] + 1.371 * v [i]);
- rgb [1] = CLAMP(y [i] - 0.698 * v [i] - 0.336 * u [i]);
- rgb [2] = CLAMP(y [i] + 1.732 * u [i]);
- }
+ for (i = 0; i < count; i++, rgb += 4) {
+ rgb[0] = CLAMP (y[i] + 1.371 * v[i]);
+ rgb[1] = CLAMP (y[i] - 0.698 * v[i] - 0.336 * u[i]);
+ rgb[2] = CLAMP (y[i] + 1.732 * u[i]);
+ }
#elif defined(TARKIN_YUV_LXY)
- for (i=0; i<count; i++, rgb+=4) {
- rgb [1] = CLAMP(y [i] - (76 * u [i] - 26 * v [i]) / 256);
- rgb [0] = CLAMP(y [i] + u [i]);
- rgb [2] = CLAMP(y [i] + v [i]);
- }
+ for (i = 0; i < count; i++, rgb += 4) {
+ rgb[1] = CLAMP (y[i] - (76 * u[i] - 26 * v[i]) / 256);
+ rgb[0] = CLAMP (y[i] + u[i]);
+ rgb[2] = CLAMP (y[i] + v[i]);
+ }
#else
- for (i=0; i<count; i++, rgb+=4) {
- rgb [1] = CLAMP(y [i] - (u [i] + v [i]) / 4);
- rgb [2] = CLAMP(u [i] + rgb [1]);
- rgb [0] = CLAMP(v [i] + rgb [1]);
- }
+ for (i = 0; i < count; i++, rgb += 4) {
+ rgb[1] = CLAMP (y[i] - (u[i] + v[i]) / 4);
+ rgb[2] = CLAMP (u[i] + rgb[1]);
+ rgb[0] = CLAMP (v[i] + rgb[1]);
+ }
#endif
}
-void rgba_to_yuv (uint8_t *rgba, Wavelet3DBuf *yuva [], uint32_t frame)
+void
+rgba_to_yuv (uint8_t * rgba, Wavelet3DBuf * yuva[], uint32_t frame)
{
- int count = yuva[0]->width * yuva[0]->height;
- int16_t *y = yuva[0]->data + frame * count;
- int16_t *u = yuva[1]->data + frame * count;
- int16_t *v = yuva[2]->data + frame * count;
- int16_t *a = yuva[3]->data + frame * count;
- int i;
+ int count = yuva[0]->width * yuva[0]->height;
+ int16_t *y = yuva[0]->data + frame * count;
+ int16_t *u = yuva[1]->data + frame * count;
+ int16_t *v = yuva[2]->data + frame * count;
+ int16_t *a = yuva[3]->data + frame * count;
+ int i;
#if defined(TARKIN_YUV_EXACT)
- for (i=0; i<count; i++, rgba+=4) {
- y [i] = ((int16_t) 77 * rgba [0] + 150 * rgba [1] + 29 * rgba [2]) / 256;
- u [i] = ((int16_t) -44 * rgba [0] - 87 * rgba [1] + 131 * rgba [2]) / 256;
- v [i] = ((int16_t) 131 * rgba [0] - 110 * rgba [1] - 21 * rgba [2]) / 256;
- a [i] = rgba [3];
- }
+ for (i = 0; i < count; i++, rgba += 4) {
+ y[i] = ((int16_t) 77 * rgba[0] + 150 * rgba[1] + 29 * rgba[2]) / 256;
+ u[i] = ((int16_t) - 44 * rgba[0] - 87 * rgba[1] + 131 * rgba[2]) / 256;
+ v[i] = ((int16_t) 131 * rgba[0] - 110 * rgba[1] - 21 * rgba[2]) / 256;
+ a[i] = rgba[3];
+ }
#elif defined(TARKIN_YUV_LXY)
- for (i=0; i<count; i++, rgba+=4) {
- y [i] = ((int16_t) 54 * rgba [0] + 182 * rgba [1] + 18 * rgba [2]) / 256;
- u [i] = rgba [0] - y [i];
- v [i] = rgba [2] - y [i];
- a [i] = rgba [3];
- }
+ for (i = 0; i < count; i++, rgba += 4) {
+ y[i] = ((int16_t) 54 * rgba[0] + 182 * rgba[1] + 18 * rgba[2]) / 256;
+ u[i] = rgba[0] - y[i];
+ v[i] = rgba[2] - y[i];
+ a[i] = rgba[3];
+ }
#else
- for (i=0; i<count; i++, rgba+=4) {
- v [i] = rgba [0] - rgba [1];
- u [i] = rgba [2] - rgba [1];
- y [i] = rgba [1] + (u [i] + v [i]) / 4;
- a [i] = rgba [3];
- }
+ for (i = 0; i < count; i++, rgba += 4) {
+ v[i] = rgba[0] - rgba[1];
+ u[i] = rgba[2] - rgba[1];
+ y[i] = rgba[1] + (u[i] + v[i]) / 4;
+ a[i] = rgba[3];
+ }
#endif
}
-void yuv_to_rgba (Wavelet3DBuf *yuva [], uint8_t *rgba, uint32_t frame)
+void
+yuv_to_rgba (Wavelet3DBuf * yuva[], uint8_t * rgba, uint32_t frame)
{
- int count = yuva[0]->width * yuva[0]->height;
- int16_t *y = yuva[0]->data + frame * count;
- int16_t *u = yuva[1]->data + frame * count;
- int16_t *v = yuva[2]->data + frame * count;
- int16_t *a = yuva[3]->data + frame * count;
- int i;
+ int count = yuva[0]->width * yuva[0]->height;
+ int16_t *y = yuva[0]->data + frame * count;
+ int16_t *u = yuva[1]->data + frame * count;
+ int16_t *v = yuva[2]->data + frame * count;
+ int16_t *a = yuva[3]->data + frame * count;
+ int i;
#if defined(TARKIN_YUV_EXACT)
- for (i=0; i<count; i++, rgba+=4) {
- rgba [0] = CLAMP(y [i] + 1.371 * v [i]);
- rgba [1] = CLAMP(y [i] - 0.698 * v [i] - 0.336 * u [i]);
- rgba [2] = CLAMP(y [i] + 1.732 * u [i]);
- rgba [3] = a [i];
- }
+ for (i = 0; i < count; i++, rgba += 4) {
+ rgba[0] = CLAMP (y[i] + 1.371 * v[i]);
+ rgba[1] = CLAMP (y[i] - 0.698 * v[i] - 0.336 * u[i]);
+ rgba[2] = CLAMP (y[i] + 1.732 * u[i]);
+ rgba[3] = a[i];
+ }
#elif defined(TARKIN_YUV_LXY)
- for (i=0; i<count; i++, rgba+=4) {
- rgba [1] = CLAMP(y [i] - (76 * u [i] - 26 * v [i]) / 256);
- rgba [0] = CLAMP(y [i] + u [i]);
- rgba [2] = CLAMP(y [i] + v [i]);
- rgba [3] = a [i];
- }
+ for (i = 0; i < count; i++, rgba += 4) {
+ rgba[1] = CLAMP (y[i] - (76 * u[i] - 26 * v[i]) / 256);
+ rgba[0] = CLAMP (y[i] + u[i]);
+ rgba[2] = CLAMP (y[i] + v[i]);
+ rgba[3] = a[i];
+ }
#else
- for (i=0; i<count; i++, rgba+=4) {
- rgba [1] = CLAMP(y [i] - (u [i] + v [i]) / 4);
- rgba [2] = CLAMP(u [i] + rgba [1]);
- rgba [0] = CLAMP(v [i] + rgba [1]);
- rgba [3] = a [i];
- }
+ for (i = 0; i < count; i++, rgba += 4) {
+ rgba[1] = CLAMP (y[i] - (u[i] + v[i]) / 4);
+ rgba[2] = CLAMP (u[i] + rgba[1]);
+ rgba[0] = CLAMP (v[i] + rgba[1]);
+ rgba[3] = a[i];
+ }
#endif
}
-void grayscale_to_y (uint8_t *rgba, Wavelet3DBuf *y [], uint32_t frame)
+void
+grayscale_to_y (uint8_t * rgba, Wavelet3DBuf * y[], uint32_t frame)
{
- int count = y[0]->width * y[0]->height;
- int16_t *_y = y[0]->data + frame * count;
- int i;
+ int count = y[0]->width * y[0]->height;
+ int16_t *_y = y[0]->data + frame * count;
+ int i;
- for (i=0; i<count; i++)
- _y [i] = rgba [i];
+ for (i = 0; i < count; i++)
+ _y[i] = rgba[i];
}
-void y_to_grayscale (Wavelet3DBuf *y [], uint8_t *rgba, uint32_t frame)
+void
+y_to_grayscale (Wavelet3DBuf * y[], uint8_t * rgba, uint32_t frame)
{
- int count = y[0]->width * y[0]->height;
- int16_t *_y = y[0]->data + frame * count;
- int i;
+ int count = y[0]->width * y[0]->height;
+ int16_t *_y = y[0]->data + frame * count;
+ int i;
- for (i=0; i<count; i++)
- rgba [i] = CLAMP(_y[i]);
+ for (i = 0; i < count; i++)
+ rgba[i] = CLAMP (_y[i]);
}
-
-
diff --git a/ext/tarkin/yuv.h b/ext/tarkin/yuv.h
index 42ceb072..31711bc6 100644
--- a/ext/tarkin/yuv.h
+++ b/ext/tarkin/yuv.h
@@ -5,17 +5,16 @@
#include <stdint.h>
#include "wavelet.h"
-extern void rgb24_to_yuv (uint8_t *rgb, Wavelet3DBuf *yuv [], uint32_t frame);
-extern void yuv_to_rgb24 (Wavelet3DBuf *yuv [], uint8_t *rgb, uint32_t frame);
+extern void rgb24_to_yuv (uint8_t * rgb, Wavelet3DBuf * yuv[], uint32_t frame);
+extern void yuv_to_rgb24 (Wavelet3DBuf * yuv[], uint8_t * rgb, uint32_t frame);
-extern void rgb32_to_yuv (uint8_t *rgb, Wavelet3DBuf *yuv [], uint32_t frame);
-extern void yuv_to_rgb32 (Wavelet3DBuf *yuv [], uint8_t *rgb, uint32_t frame);
+extern void rgb32_to_yuv (uint8_t * rgb, Wavelet3DBuf * yuv[], uint32_t frame);
+extern void yuv_to_rgb32 (Wavelet3DBuf * yuv[], uint8_t * rgb, uint32_t frame);
-extern void rgba_to_yuv (uint8_t *rgba, Wavelet3DBuf *yuva [], uint32_t frame);
-extern void yuv_to_rgba (Wavelet3DBuf *yuva [], uint8_t *rgba, uint32_t frame);
+extern void rgba_to_yuv (uint8_t * rgba, Wavelet3DBuf * yuva[], uint32_t frame);
+extern void yuv_to_rgba (Wavelet3DBuf * yuva[], uint8_t * rgba, uint32_t frame);
-extern void grayscale_to_y (uint8_t *rgba, Wavelet3DBuf *y [], uint32_t frame);
-extern void y_to_grayscale (Wavelet3DBuf *y [], uint8_t *rgba, uint32_t frame);
+extern void grayscale_to_y (uint8_t * rgba, Wavelet3DBuf * y[], uint32_t frame);
+extern void y_to_grayscale (Wavelet3DBuf * y[], uint8_t * rgba, uint32_t frame);
#endif
-
diff --git a/ext/xine/gstxine.h b/ext/xine/gstxine.h
index 61ab50ef..53d40a23 100644
--- a/ext/xine/gstxine.h
+++ b/ext/xine/gstxine.h
@@ -25,7 +25,6 @@
#include <xine/buffer.h>
G_BEGIN_DECLS
-
#define GST_TYPE_XINE \
(gst_xine_get_type())
#define GST_XINE(obj) \
@@ -38,47 +37,45 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_XINE))
#define GST_IS_XINE_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_XINE))
-
-typedef struct _GstXine GstXine;
+typedef struct _GstXine GstXine;
typedef struct _GstXineClass GstXineClass;
struct _GstXine
{
- GstElement element;
+ GstElement element;
- xine_stream_t * stream;
- xine_ao_driver_t * audio_driver;
- xine_vo_driver_t * video_driver;
+ xine_stream_t *stream;
+ xine_ao_driver_t *audio_driver;
+ xine_vo_driver_t *video_driver;
};
-struct _GstXineClass
+struct _GstXineClass
{
- GstElementClass parent_class;
+ GstElementClass parent_class;
- xine_t * xine;
+ xine_t *xine;
- xine_ao_driver_t * (* create_audio_driver) (GstXine * xine);
- xine_vo_driver_t * (* create_video_driver) (GstXine * xine);
+ xine_ao_driver_t *(*create_audio_driver) (GstXine * xine);
+ xine_vo_driver_t *(*create_video_driver) (GstXine * xine);
};
-GType gst_xine_get_type (void);
+GType gst_xine_get_type (void);
-xine_stream_t * gst_xine_get_stream (GstXine *xine);
-void gst_xine_free_stream (GstXine *xine);
+xine_stream_t *gst_xine_get_stream (GstXine * xine);
+void gst_xine_free_stream (GstXine * xine);
-void gst_buffer_to_xine_buffer (buf_element_t *element, GstBuffer *buffer);
+void gst_buffer_to_xine_buffer (buf_element_t * element, GstBuffer * buffer);
/* conversion functions from xinecaps.c */
-const gchar * gst_xine_get_caps_for_format (guint32 format);
-guint32 gst_xine_get_format_for_caps (const GstCaps *caps);
+const gchar *gst_xine_get_caps_for_format (guint32 format);
+guint32 gst_xine_get_format_for_caps (const GstCaps * caps);
/* init functions for the plugins */
-gboolean gst_xine_audio_sink_init_plugin (GstPlugin *plugin);
-gboolean gst_xine_audio_dec_init_plugin (GstPlugin *plugin);
-gboolean gst_xine_input_init_plugin (GstPlugin *plugin);
-
-G_END_DECLS
+gboolean gst_xine_audio_sink_init_plugin (GstPlugin * plugin);
+gboolean gst_xine_audio_dec_init_plugin (GstPlugin * plugin);
+gboolean gst_xine_input_init_plugin (GstPlugin * plugin);
+G_END_DECLS
#endif /* __GST_XINE_H__ */
diff --git a/ext/xine/xine.c b/ext/xine/xine.c
index e7736bf4..f1dbb399 100644
--- a/ext/xine/xine.c
+++ b/ext/xine/xine.c
@@ -25,22 +25,21 @@
GST_BOILERPLATE (GstXine, gst_xine, GstElement, GST_TYPE_ELEMENT)
-static GstElementStateReturn gst_xine_change_state (GstElement * element);
-
-static xine_ao_driver_t * _xine_create_audio_driver (GstXine * xine);
-static xine_vo_driver_t * _xine_create_video_driver (GstXine * xine);
+ static GstElementStateReturn gst_xine_change_state (GstElement * element);
+ static xine_ao_driver_t *_xine_create_audio_driver (GstXine * xine);
+ static xine_vo_driver_t *_xine_create_video_driver (GstXine * xine);
-static void
-gst_xine_base_init (gpointer klass)
+
+ static void gst_xine_base_init (gpointer klass)
{
}
static void
-gst_xine_class_init (GstXineClass *klass)
+gst_xine_class_init (GstXineClass * klass)
{
GstElementClass *element = GST_ELEMENT_CLASS (klass);
-
+
klass->xine = xine_new ();
xine_init (klass->xine);
@@ -51,15 +50,15 @@ gst_xine_class_init (GstXineClass *klass)
}
static void
-gst_xine_init (GstXine *filter)
+gst_xine_init (GstXine * filter)
{
}
static GstElementStateReturn
-gst_xine_change_state (GstElement *element)
+gst_xine_change_state (GstElement * element)
{
GstXine *xine = GST_XINE (element);
-
+
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
break;
@@ -79,32 +78,36 @@ gst_xine_change_state (GstElement *element)
GST_ERROR_OBJECT (element, "invalid state change");
break;
}
-
- return GST_CALL_PARENT_WITH_DEFAULT (GST_ELEMENT_CLASS, change_state, (element), GST_STATE_SUCCESS);
+
+ return GST_CALL_PARENT_WITH_DEFAULT (GST_ELEMENT_CLASS, change_state,
+ (element), GST_STATE_SUCCESS);
}
static xine_ao_driver_t *
-_xine_create_audio_driver (GstXine *xine)
+_xine_create_audio_driver (GstXine * xine)
{
return xine_open_audio_driver (GST_XINE_GET_CLASS (xine)->xine, "none", NULL);
}
static xine_vo_driver_t *
-_xine_create_video_driver (GstXine *xine)
+_xine_create_video_driver (GstXine * xine)
{
- return xine_open_video_driver (GST_XINE_GET_CLASS (xine)->xine, "none", XINE_VISUAL_TYPE_NONE, NULL);
+ return xine_open_video_driver (GST_XINE_GET_CLASS (xine)->xine, "none",
+ XINE_VISUAL_TYPE_NONE, NULL);
}
xine_stream_t *
-gst_xine_get_stream (GstXine *xine)
+gst_xine_get_stream (GstXine * xine)
{
if (!xine->stream) {
GstXineClass *klass = GST_XINE_GET_CLASS (xine);
+
g_assert (xine->video_driver == NULL);
g_assert (xine->audio_driver == NULL);
xine->audio_driver = klass->create_audio_driver (xine);
xine->video_driver = klass->create_video_driver (xine);
- xine->stream = xine_stream_new (klass->xine, xine->audio_driver, xine->video_driver);
+ xine->stream =
+ xine_stream_new (klass->xine, xine->audio_driver, xine->video_driver);
/* FIXME: fail gracefully */
g_assert (xine->stream);
@@ -114,7 +117,7 @@ gst_xine_get_stream (GstXine *xine)
}
void
-gst_xine_free_stream (GstXine *xine)
+gst_xine_free_stream (GstXine * xine)
{
g_return_if_fail (xine->stream != NULL);
g_assert (xine->video_driver != NULL);
@@ -129,17 +132,17 @@ gst_xine_free_stream (GstXine *xine)
}
static void
-_free_xine_buf_element (buf_element_t *buffer)
+_free_xine_buf_element (buf_element_t * buffer)
{
gst_buffer_unref (GST_BUFFER (buffer->source));
}
void
-gst_buffer_to_xine_buffer (buf_element_t *ret, GstBuffer *buffer)
+gst_buffer_to_xine_buffer (buf_element_t * ret, GstBuffer * buffer)
{
g_return_if_fail (ret != NULL);
g_return_if_fail (buffer != NULL);
-
+
/* FIXME: what's the difference? */
ret->mem = GST_BUFFER_DATA (buffer);
ret->content = GST_BUFFER_DATA (buffer);
@@ -151,7 +154,7 @@ gst_buffer_to_xine_buffer (buf_element_t *ret, GstBuffer *buffer)
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
if (!gst_xine_input_init_plugin (plugin) ||
!gst_xine_audio_dec_init_plugin (plugin) ||
@@ -161,14 +164,8 @@ plugin_init (GstPlugin *plugin)
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "xine",
- "wrapper for libxine (version "XINE_VERSION") plugins",
- plugin_init,
- VERSION,
- "GPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "xine",
+ "wrapper for libxine (version " XINE_VERSION ") plugins",
+ plugin_init, VERSION, "GPL", GST_PACKAGE, GST_ORIGIN)
diff --git a/ext/xine/xineaudiodec.c b/ext/xine/xineaudiodec.c
index 93f3984a..869c3b4d 100644
--- a/ext/xine/xineaudiodec.c
+++ b/ext/xine/xineaudiodec.c
@@ -37,46 +37,47 @@
GType gst_xine_audio_dec_get_type (void);
-typedef struct _GstXineAudioDec GstXineAudioDec;
+typedef struct _GstXineAudioDec GstXineAudioDec;
typedef struct _GstXineAudioDecClass GstXineAudioDecClass;
struct _GstXineAudioDec
{
- GstXine parent;
+ GstXine parent;
- GstPad * sinkpad;
- GstPad * srcpad;
+ GstPad *sinkpad;
+ GstPad *srcpad;
- audio_decoder_t * decoder;
- guint32 format;
- xine_waveformatex wave;
- gboolean setup;
+ audio_decoder_t *decoder;
+ guint32 format;
+ xine_waveformatex wave;
+ gboolean setup;
};
-struct _GstXineAudioDecClass
+struct _GstXineAudioDecClass
{
- GstXineClass parent_class;
+ GstXineClass parent_class;
- plugin_node_t * plugin_node;
+ plugin_node_t *plugin_node;
};
/*** xine audio driver wrapper ************************************************/
-
-typedef struct {
- xine_ao_driver_t driver;
- GstXineAudioDec * xine;
- gboolean open;
+
+typedef struct
+{
+ xine_ao_driver_t driver;
+ GstXineAudioDec *xine;
+ gboolean open;
} GstXineAudioDriver;
static guint32
-_driver_get_capabilities (xine_ao_driver_t *driver)
+_driver_get_capabilities (xine_ao_driver_t * driver)
{
/* FIXME: add more when gst handles more than 2 channels */
return AO_CAP_MODE_MONO | AO_CAP_MODE_STEREO | AO_CAP_8BITS;
}
static gint
-_driver_get_property (xine_ao_driver_t *driver, int property)
+_driver_get_property (xine_ao_driver_t * driver, int property)
{
return 0;
}
@@ -88,80 +89,82 @@ _driver_set_property (xine_ao_driver_t * driver, int property, int value)
}
static gint
-_driver_open (xine_ao_driver_t *driver, xine_stream_t *stream, guint32 bits, guint32 rate, int mode)
+_driver_open (xine_ao_driver_t * driver, xine_stream_t * stream, guint32 bits,
+ guint32 rate, int mode)
{
GstCaps *caps;
GstXineAudioDriver *xine = ((GstXineAudioDriver *) driver);
-
+
caps = gst_caps_new_simple ("audio/x-raw-int",
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "width", G_TYPE_INT, (gint) bits,
- "depth", G_TYPE_INT, (gint) bits,
- "signed", G_TYPE_BOOLEAN, (bits == 8) ? FALSE : TRUE,
- "channels", G_TYPE_INT, (mode | AO_CAP_MODE_STEREO) ? 2 : 1,
- "rate", G_TYPE_INT, rate,
- NULL);
-
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "width", G_TYPE_INT, (gint) bits,
+ "depth", G_TYPE_INT, (gint) bits,
+ "signed", G_TYPE_BOOLEAN, (bits == 8) ? FALSE : TRUE,
+ "channels", G_TYPE_INT, (mode | AO_CAP_MODE_STEREO) ? 2 : 1,
+ "rate", G_TYPE_INT, rate, NULL);
+
if (!gst_pad_set_explicit_caps (xine->xine->srcpad, caps)) {
gst_caps_free (caps);
driver->open = FALSE;
return -1;
}
-
+
xine->open = TRUE;
gst_caps_free (caps);
return rate;
}
static void
-_driver_close (xine_ao_driver_t *driver, xine_stream_t *stream)
+_driver_close (xine_ao_driver_t * driver, xine_stream_t * stream)
{
/* FIXME: unset explicit caps here? And how? */
driver->open = FALSE;
}
static void
-_driver_exit (xine_ao_driver_t *driver)
+_driver_exit (xine_ao_driver_t * driver)
{
g_free (driver);
}
static int
-_driver_control (xine_ao_driver_t *driver, int cmd, ...)
+_driver_control (xine_ao_driver_t * driver, int cmd, ...)
{
return 0;
}
static void
-_driver_flush (xine_ao_driver_t *driver)
+_driver_flush (xine_ao_driver_t * driver)
{
}
static int
-_driver_status (xine_ao_driver_t *driver, xine_stream_t *stream, uint32_t *bits, uint32_t *rate, int *mode)
+_driver_status (xine_ao_driver_t * driver, xine_stream_t * stream,
+ uint32_t * bits, uint32_t * rate, int *mode)
{
const GstCaps *caps;
GstStructure *structure;
gint temp;
GstXineAudioDriver *xine = (GstXineAudioDriver *) driver;
-
- if (xine->open == FALSE || !(caps = gst_pad_get_negotiated_caps (xine->xine->srcpad)))
+
+ if (xine->open == FALSE
+ || !(caps = gst_pad_get_negotiated_caps (xine->xine->srcpad)))
return 0;
structure = gst_caps_get_structure (caps, 0);
- *bits = 0; /* FIXME */
+ *bits = 0; /* FIXME */
if (!gst_structure_get_int (structure, "rate", &temp)) {
- g_assert_not_reached (); /* may never happen with negotiated caps */
+ g_assert_not_reached (); /* may never happen with negotiated caps */
return 0;
}
*rate = temp;
if (!gst_structure_get_int (structure, "channels", &temp)) {
- g_assert_not_reached (); /* may never happen with negotiated caps */
+ g_assert_not_reached (); /* may never happen with negotiated caps */
return 0;
}
*mode = (temp == 2) ? AO_CAP_MODE_STEREO : AO_CAP_MODE_MONO;
if (!gst_structure_get_int (structure, "width", &temp)) {
- g_assert_not_reached (); /* may never happen with negotiated caps */
+ g_assert_not_reached (); /* may never happen with negotiated caps */
return 0;
}
if (temp == 8)
@@ -172,25 +175,26 @@ _driver_status (xine_ao_driver_t *driver, xine_stream_t *stream, uint32_t *bits,
#define _DRIVER_BUFFER_SIZE 4096
static audio_buffer_t *
-_driver_get_buffer (xine_ao_driver_t *driver)
+_driver_get_buffer (xine_ao_driver_t * driver)
{
GstXineAudioDriver *xine = (GstXineAudioDriver *) driver;
- audio_buffer_t *audio = g_new0 (audio_buffer_t, 1);
+ audio_buffer_t *audio = g_new0 (audio_buffer_t, 1);
audio->mem = g_malloc (_DRIVER_BUFFER_SIZE);
audio->mem_size = _DRIVER_BUFFER_SIZE;
audio->stream = gst_xine_get_stream (GST_XINE (xine->xine));
/* FIXME: fill more fields */
-
+
return audio;
}
-static void
-_driver_put_buffer (xine_ao_driver_t *driver, audio_buffer_t *audio, xine_stream_t *stream)
+static void
+_driver_put_buffer (xine_ao_driver_t * driver, audio_buffer_t * audio,
+ xine_stream_t * stream)
{
GstXineAudioDriver *xine = (GstXineAudioDriver *) driver;
GstBuffer *buffer;
-
+
buffer = gst_buffer_new ();
GST_BUFFER_DATA (buffer) = (guint8 *) audio->mem;
GST_BUFFER_SIZE (buffer) = audio->mem_size;
@@ -199,27 +203,27 @@ _driver_put_buffer (xine_ao_driver_t *driver, audio_buffer_t *audio, xine_stream
g_free (audio);
gst_pad_push (xine->xine->srcpad, GST_DATA (buffer));
}
-
+
static xine_ao_driver_t *
-_gst_xine_audio_dec_create_audio_driver (GstXine *xine)
+_gst_xine_audio_dec_create_audio_driver (GstXine * xine)
{
GstXineAudioDriver *driver = g_new (GstXineAudioDriver, 1);
driver->xine = GST_XINE_AUDIO_DEC (xine);
driver->open = FALSE;
-
- driver->driver.get_buffer = _driver_get_buffer;
- driver->driver.put_buffer = _driver_put_buffer;
- driver->driver.get_capabilities = _driver_get_capabilities;
- driver->driver.get_property = _driver_get_property;
- driver->driver.set_property = _driver_set_property;
- driver->driver.open = _driver_open;
- driver->driver.close = _driver_close;
- driver->driver.exit = _driver_exit;
- driver->driver.control = _driver_control;
- driver->driver.flush = _driver_flush;
- driver->driver.status = _driver_status;
-
+
+ driver->driver.get_buffer = _driver_get_buffer;
+ driver->driver.put_buffer = _driver_put_buffer;
+ driver->driver.get_capabilities = _driver_get_capabilities;
+ driver->driver.get_property = _driver_get_property;
+ driver->driver.set_property = _driver_set_property;
+ driver->driver.open = _driver_open;
+ driver->driver.close = _driver_close;
+ driver->driver.exit = _driver_exit;
+ driver->driver.control = _driver_control;
+ driver->driver.flush = _driver_flush;
+ driver->driver.status = _driver_status;
+
return (xine_ao_driver_t *) driver;
}
@@ -227,20 +231,22 @@ _gst_xine_audio_dec_create_audio_driver (GstXine *xine)
GST_BOILERPLATE (GstXineAudioDec, gst_xine_audio_dec, GstXine, GST_TYPE_XINE)
-static void gst_xine_audio_dec_chain (GstPad *pad, GstData *in);
-static GstElementStateReturn
- gst_xine_audio_dec_change_state (GstElement *element);
+ static void gst_xine_audio_dec_chain (GstPad * pad, GstData * in);
+ static GstElementStateReturn
+ gst_xine_audio_dec_change_state (GstElement * element);
/* this function handles the link with other plug-ins */
-static GstPadLinkReturn
-gst_xine_audio_dec_sink_link (GstPad *pad, const GstCaps *caps)
+ static GstPadLinkReturn
+ gst_xine_audio_dec_sink_link (GstPad * pad, const GstCaps * caps)
{
guint temp;
GstStructure *structure;
- GstXineAudioDec *xine = GST_XINE_AUDIO_DEC (gst_object_get_parent (GST_OBJECT (pad)));
+ GstXineAudioDec *xine =
+ GST_XINE_AUDIO_DEC (gst_object_get_parent (GST_OBJECT (pad)));
xine->format = gst_xine_get_format_for_caps (caps);
- if (xine->format == 0) return GST_PAD_LINK_REFUSED;
+ if (xine->format == 0)
+ return GST_PAD_LINK_REFUSED;
/* get setup data */
xine->setup = FALSE;
@@ -249,7 +255,7 @@ gst_xine_audio_dec_sink_link (GstPad *pad, const GstCaps *caps)
xine->wave.nChannels = temp;
if (gst_structure_get_int (structure, "rate", &temp))
xine->wave.nSamplesPerSec = temp;
- xine->wave.wBitsPerSample = 16; /* FIXME: how do we figure this thing out? */
+ xine->wave.wBitsPerSample = 16; /* FIXME: how do we figure this thing out? */
/* FIXME: fill wave header better */
return GST_PAD_LINK_OK;
@@ -261,7 +267,7 @@ gst_xine_audio_dec_base_init (gpointer g_class)
}
static void
-gst_xine_audio_dec_class_init (GstXineAudioDecClass *klass)
+gst_xine_audio_dec_class_init (GstXineAudioDecClass * klass)
{
GstXineClass *xine = GST_XINE_CLASS (klass);
GstElementClass *element = GST_ELEMENT_CLASS (klass);
@@ -272,22 +278,23 @@ gst_xine_audio_dec_class_init (GstXineAudioDecClass *klass)
}
static void
-gst_xine_audio_dec_init (GstXineAudioDec *xine)
+gst_xine_audio_dec_init (GstXineAudioDec * xine)
{
xine->setup = FALSE;
}
static void
-gst_xine_audio_dec_event (GstXineAudioDec *xine, GstEvent *event)
+gst_xine_audio_dec_event (GstXineAudioDec * xine, GstEvent * event)
{
gst_pad_event_default (xine->sinkpad, event);
}
static void
-gst_xine_audio_dec_chain (GstPad *pad, GstData *in)
+gst_xine_audio_dec_chain (GstPad * pad, GstData * in)
{
buf_element_t buffer = { 0, };
- GstXineAudioDec *xine = GST_XINE_AUDIO_DEC (gst_object_get_parent (GST_OBJECT (pad)));
+ GstXineAudioDec *xine =
+ GST_XINE_AUDIO_DEC (gst_object_get_parent (GST_OBJECT (pad)));
if (GST_IS_EVENT (in)) {
gst_xine_audio_dec_event (xine, GST_EVENT (in));
@@ -296,7 +303,8 @@ gst_xine_audio_dec_chain (GstPad *pad, GstData *in)
if (xine->format == 0) {
/* no caps yet */
- GST_ELEMENT_ERROR (xine, CORE, NEGOTIATION, (NULL), ("buffer sent before doing caps nego"));
+ GST_ELEMENT_ERROR (xine, CORE, NEGOTIATION, (NULL),
+ ("buffer sent before doing caps nego"));
gst_data_unref (in);
return;
}
@@ -306,6 +314,7 @@ gst_xine_audio_dec_chain (GstPad *pad, GstData *in)
guint8 stsd[150] = { 0, };
guint temp;
GstStructure *structure;
+
/* sent setup header */
element.type = xine->format;
element.decoder_flags = BUF_FLAG_HEADER;
@@ -313,45 +322,46 @@ gst_xine_audio_dec_chain (GstPad *pad, GstData *in)
element.decoder_info[1] = xine->wave.nSamplesPerSec;
element.decoder_info[2] = xine->wave.wBitsPerSample;
element.decoder_info[3] = xine->wave.nChannels;
- element.content = (guchar *) &xine->wave;
+ element.content = (guchar *) & xine->wave;
element.size = sizeof (xine_waveformatex);
xine->decoder->decode_data (xine->decoder, &element);
/* send stsd emulation to the decoder */
/* FIXME: qdm2 only right now */
g_assert (gst_pad_get_negotiated_caps (xine->sinkpad));
- structure = gst_caps_get_structure (gst_pad_get_negotiated_caps (xine->sinkpad), 0);
- *((guint32 *) &stsd[56]) = GUINT32_TO_BE (12);
+ structure =
+ gst_caps_get_structure (gst_pad_get_negotiated_caps (xine->sinkpad), 0);
+ *((guint32 *) & stsd[56]) = GUINT32_TO_BE (12);
memcpy (&stsd[60], "frmaQDM2", 8);
- *((guint32 *) &stsd[68]) = GUINT32_TO_BE (36);
+ *((guint32 *) & stsd[68]) = GUINT32_TO_BE (36);
memcpy (&stsd[72], "QDCA", 4);
- *((guint32 *) &stsd[76]) = GUINT32_TO_BE (1);
+ *((guint32 *) & stsd[76]) = GUINT32_TO_BE (1);
if (!gst_structure_get_int (structure, "channels", &temp))
temp = 0;
- *((guint32 *) &stsd[80]) = GUINT32_TO_BE (temp);
+ *((guint32 *) & stsd[80]) = GUINT32_TO_BE (temp);
if (!gst_structure_get_int (structure, "rate", &temp))
temp = 0;
- *((guint32 *) &stsd[84]) = GUINT32_TO_BE (temp);
+ *((guint32 *) & stsd[84]) = GUINT32_TO_BE (temp);
if (!gst_structure_get_int (structure, "bitrate", &temp))
temp = 0;
- *((guint32 *) &stsd[88]) = GUINT32_TO_BE (temp);
+ *((guint32 *) & stsd[88]) = GUINT32_TO_BE (temp);
if (!gst_structure_get_int (structure, "blocksize", &temp))
temp = 0;
- *((guint32 *) &stsd[92]) = GUINT32_TO_BE (temp);
- *((guint32 *) &stsd[96]) = GUINT32_TO_BE (256);
+ *((guint32 *) & stsd[92]) = GUINT32_TO_BE (temp);
+ *((guint32 *) & stsd[96]) = GUINT32_TO_BE (256);
if (!gst_structure_get_int (structure, "framesize", &temp))
temp = 0;
- *((guint32 *) &stsd[100]) = GUINT32_TO_BE (temp);
- *((guint32 *) &stsd[104]) = GUINT32_TO_BE (28);
+ *((guint32 *) & stsd[100]) = GUINT32_TO_BE (temp);
+ *((guint32 *) & stsd[104]) = GUINT32_TO_BE (28);
memcpy (&stsd[108], "QDCP", 4);
- *((guint32 *) &stsd[112]) = GUINT32_TO_BE (1065353216);
- *((guint32 *) &stsd[116]) = GUINT32_TO_BE (0);
- *((guint32 *) &stsd[120]) = GUINT32_TO_BE (1065353216);
- *((guint32 *) &stsd[124]) = GUINT32_TO_BE (1065353216);
- *((guint32 *) &stsd[128]) = GUINT32_TO_BE (27);
- *((guint32 *) &stsd[132]) = GUINT32_TO_BE (8);
- *((guint32 *) &stsd[136]) = GUINT32_TO_BE (0);
- *((guint32 *) &stsd[140]) = GUINT32_TO_BE (24);
- gst_util_dump_mem (stsd, 144);
+ *((guint32 *) & stsd[112]) = GUINT32_TO_BE (1065353216);
+ *((guint32 *) & stsd[116]) = GUINT32_TO_BE (0);
+ *((guint32 *) & stsd[120]) = GUINT32_TO_BE (1065353216);
+ *((guint32 *) & stsd[124]) = GUINT32_TO_BE (1065353216);
+ *((guint32 *) & stsd[128]) = GUINT32_TO_BE (27);
+ *((guint32 *) & stsd[132]) = GUINT32_TO_BE (8);
+ *((guint32 *) & stsd[136]) = GUINT32_TO_BE (0);
+ *((guint32 *) & stsd[140]) = GUINT32_TO_BE (24);
+ gst_util_dump_mem (stsd, 144);
element.decoder_flags = BUF_FLAG_SPECIAL;
element.decoder_info[1] = BUF_SPECIAL_STSD_ATOM;
element.decoder_info[2] = 144;
@@ -360,10 +370,10 @@ gst_xine_audio_dec_chain (GstPad *pad, GstData *in)
element.size = 0;
element.content = 0;
xine->decoder->decode_data (xine->decoder, &element);
-
+
xine->setup = TRUE;
}
-
+
gst_buffer_to_xine_buffer (&buffer, GST_BUFFER (in));
buffer.type = xine->format;
xine->decoder->decode_data (xine->decoder, &buffer);
@@ -371,13 +381,13 @@ gst_xine_audio_dec_chain (GstPad *pad, GstData *in)
}
static audio_decoder_t *
-_load_decoder (GstXineAudioDec* dec)
+_load_decoder (GstXineAudioDec * dec)
{
xine_stream_t *stream = gst_xine_get_stream (GST_XINE (dec));
plugin_catalog_t *catalog = stream->xine->plugin_catalog;
plugin_node_t *node = GST_XINE_AUDIO_DEC_GET_CLASS (dec)->plugin_node;
audio_decoder_t *ret;
-
+
/* FIXME: this is really hacky, but how to force xine to load a plugin? */
/* how it works: xine can load a plugin for a particular stream type.
* We just take one type, which should not have plugins attached to it,
@@ -391,10 +401,10 @@ _load_decoder (GstXineAudioDec* dec)
}
static GstElementStateReturn
-gst_xine_audio_dec_change_state (GstElement *element)
+gst_xine_audio_dec_change_state (GstElement * element)
{
GstXineAudioDec *xine = GST_XINE_AUDIO_DEC (element);
-
+
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
xine->decoder = _load_decoder (xine);
@@ -411,68 +421,69 @@ gst_xine_audio_dec_change_state (GstElement *element)
break;
case GST_STATE_READY_TO_NULL:
xine->setup = FALSE;
- _x_free_audio_decoder (gst_xine_get_stream (GST_XINE (xine)), xine->decoder);
+ _x_free_audio_decoder (gst_xine_get_stream (GST_XINE (xine)),
+ xine->decoder);
break;
default:
GST_ERROR_OBJECT (element, "invalid state change");
break;
}
-
- return GST_CALL_PARENT_WITH_DEFAULT (GST_ELEMENT_CLASS, change_state, (element), GST_STATE_SUCCESS);
+
+ return GST_CALL_PARENT_WITH_DEFAULT (GST_ELEMENT_CLASS, change_state,
+ (element), GST_STATE_SUCCESS);
}
/** GstXineAudioDec subclasses ************************************************/
-static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "audio/x-raw-int, "
- "endianness = (int) BYTE_ORDER, "
- "signed = (boolean) TRUE, "
- "width = (int) 16, "
- "depth = (int) 16, "
- "rate = (int) [ 1, MAX ], "
- "channels = (int) [ 1, 2 ]; "
- "audio/x-raw-int, "
- "signed = (boolean) FALSE, "
- "width = (int) 8, "
- "depth = (int) 8, "
- "rate = (int) [ 1, MAX ], "
- "channels = (int) [ 1, 2 ]"
- )
-);
+static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "endianness = (int) BYTE_ORDER, "
+ "signed = (boolean) TRUE, "
+ "width = (int) 16, "
+ "depth = (int) 16, "
+ "rate = (int) [ 1, MAX ], "
+ "channels = (int) [ 1, 2 ]; "
+ "audio/x-raw-int, "
+ "signed = (boolean) FALSE, "
+ "width = (int) 8, "
+ "depth = (int) 8, "
+ "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2 ]")
+ );
static void
gst_xine_audio_dec_subclass_init (gpointer g_class, gpointer class_data)
{
GstXineAudioDecClass *xine_class = GST_XINE_AUDIO_DEC_CLASS (g_class);
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- GstElementDetails details = GST_ELEMENT_DETAILS (
- NULL,
- "Filter/Decoder/Audio",
- NULL,
- "Benjamin Otte <otte@gnome.org>"
- );
+ GstElementDetails details = GST_ELEMENT_DETAILS (NULL,
+ "Filter/Decoder/Audio",
+ NULL,
+ "Benjamin Otte <otte@gnome.org>");
GstPadTemplate *template;
guint i = 0;
GstCaps *caps = gst_caps_new_empty ();
decoder_info_t *dec;
-
+
xine_class->plugin_node = class_data;
dec = xine_class->plugin_node->info->special_info;
- details.longname = g_strdup_printf ("%s xine audio decoder", xine_class->plugin_node->info->id);
- details.description = g_strdup_printf ("decodes audio using the xine '%s' plugin", xine_class->plugin_node->info->id);
+ details.longname =
+ g_strdup_printf ("%s xine audio decoder",
+ xine_class->plugin_node->info->id);
+ details.description =
+ g_strdup_printf ("decodes audio using the xine '%s' plugin",
+ xine_class->plugin_node->info->id);
gst_element_class_set_details (element_class, &details);
g_free (details.longname);
g_free (details.description);
-
- gst_element_class_add_pad_template (element_class,
+
+ gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&src_template));
-
+
while (dec->supported_types[i] != 0) {
- const gchar *type_str = gst_xine_get_caps_for_format (dec->supported_types[i]);
+ const gchar *type_str =
+ gst_xine_get_caps_for_format (dec->supported_types[i]);
if (type_str) {
gst_caps_append (caps, gst_caps_from_string (type_str));
}
@@ -483,28 +494,29 @@ gst_xine_audio_dec_subclass_init (gpointer g_class, gpointer class_data)
}
static void
-gst_xine_audio_dec_sub_init (GTypeInstance *instance, gpointer g_class)
+gst_xine_audio_dec_sub_init (GTypeInstance * instance, gpointer g_class)
{
GstElementClass *klass = GST_ELEMENT_GET_CLASS (instance);
GstXineAudioDec *xine = GST_XINE_AUDIO_DEC (instance);
- xine->sinkpad = gst_pad_new_from_template (
- gst_element_class_get_pad_template (klass, "sink"), "sink");
+ xine->sinkpad =
+ gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
+ "sink"), "sink");
gst_pad_set_link_function (xine->sinkpad, gst_xine_audio_dec_sink_link);
gst_pad_set_chain_function (xine->sinkpad, gst_xine_audio_dec_chain);
gst_element_add_pad (GST_ELEMENT (xine), xine->sinkpad);
- xine->srcpad = gst_pad_new_from_template (
- gst_element_class_get_pad_template (klass, "src"), "src");
+ xine->srcpad =
+ gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
+ "src"), "src");
gst_pad_use_explicit_caps (xine->srcpad);
gst_element_add_pad (GST_ELEMENT (xine), xine->srcpad);
}
gboolean
-gst_xine_audio_dec_init_plugin (GstPlugin *plugin)
+gst_xine_audio_dec_init_plugin (GstPlugin * plugin)
{
- GTypeInfo plugin_info =
- {
+ GTypeInfo plugin_info = {
sizeof (GstXineAudioDecClass),
NULL,
NULL,
@@ -517,9 +529,9 @@ gst_xine_audio_dec_init_plugin (GstPlugin *plugin)
};
xine_node_t *list;
GstXineClass *klass;
-
+
klass = g_type_class_ref (GST_TYPE_XINE);
-
+
list = klass->xine->plugin_catalog->audio->first;
while (list) {
plugin_node_t *node = list->content;
@@ -527,20 +539,28 @@ gst_xine_audio_dec_init_plugin (GstPlugin *plugin)
guint format = 0;
list = list->next;
- if (!node) continue;
-
+ if (!node)
+ continue;
+
dec = node->info->special_info;
while (dec->supported_types[format] != 0) {
- const gchar *caps = gst_xine_get_caps_for_format (dec->supported_types[format]);
+ const gchar *caps =
+ gst_xine_get_caps_for_format (dec->supported_types[format]);
if (caps) {
- gchar *plugin_name = g_strdup_printf ("xineaudiodec_%s", node->info->id);
- gchar *type_name = g_strdup_printf ("GstXineAudioDec%s", node->info->id);
+ gchar *plugin_name =
+ g_strdup_printf ("xineaudiodec_%s", node->info->id);
+ gchar *type_name =
+ g_strdup_printf ("GstXineAudioDec%s", node->info->id);
GType type;
+
plugin_info.class_data = node;
- type = g_type_register_static (GST_TYPE_XINE_AUDIO_DEC, type_name, &plugin_info, 0);
+ type =
+ g_type_register_static (GST_TYPE_XINE_AUDIO_DEC, type_name,
+ &plugin_info, 0);
g_free (type_name);
- if (!gst_element_register (plugin, plugin_name,
- MAX (GST_RANK_MARGINAL, GST_RANK_MARGINAL * dec->priority / 10 + 1), type)) {
+ if (!gst_element_register (plugin, plugin_name,
+ MAX (GST_RANK_MARGINAL,
+ GST_RANK_MARGINAL * dec->priority / 10 + 1), type)) {
g_free (plugin_name);
return FALSE;
}
@@ -550,7 +570,6 @@ gst_xine_audio_dec_init_plugin (GstPlugin *plugin)
}
}
- g_type_class_unref (klass);
+ g_type_class_unref (klass);
return TRUE;
}
-
diff --git a/ext/xine/xineaudiosink.c b/ext/xine/xineaudiosink.c
index bdb947ca..4638526d 100644
--- a/ext/xine/xineaudiosink.c
+++ b/ext/xine/xineaudiosink.c
@@ -38,40 +38,39 @@
GType gst_xine_audio_sink_get_type (void);
-typedef struct _GstXineAudioSink GstXineAudioSink;
+typedef struct _GstXineAudioSink GstXineAudioSink;
typedef struct _GstXineAudioSinkClass GstXineAudioSinkClass;
struct _GstXineAudioSink
{
- GstXine parent;
+ GstXine parent;
- GstPad * sinkpad;
+ GstPad *sinkpad;
- ao_driver_t * driver;
- guint open; /* number of bytes per sample or 0 if driver not open */
+ ao_driver_t *driver;
+ guint open; /* number of bytes per sample or 0 if driver not open */
};
-struct _GstXineAudioSinkClass
+struct _GstXineAudioSinkClass
{
- GstXineClass parent_class;
+ GstXineClass parent_class;
- plugin_node_t * plugin_node;
+ plugin_node_t *plugin_node;
};
/** GstXineAudioSink ***********************************************************/
GST_BOILERPLATE (GstXineAudioSink, gst_xine_audio_sink, GstXine, GST_TYPE_XINE)
-static GstElementStateReturn
- gst_xine_audio_sink_change_state (GstElement *element);
+ static GstElementStateReturn
+ gst_xine_audio_sink_change_state (GstElement * element);
-static void
-gst_xine_audio_sink_base_init (gpointer g_class)
+ static void gst_xine_audio_sink_base_init (gpointer g_class)
{
}
static void
-gst_xine_audio_sink_class_init (GstXineAudioSinkClass *klass)
+gst_xine_audio_sink_class_init (GstXineAudioSinkClass * klass)
{
GstElementClass *element = GST_ELEMENT_CLASS (klass);
@@ -79,35 +78,43 @@ gst_xine_audio_sink_class_init (GstXineAudioSinkClass *klass)
}
static void
-gst_xine_audio_sink_init (GstXineAudioSink *xine)
+gst_xine_audio_sink_init (GstXineAudioSink * xine)
{
}
static void
-gst_xine_audio_sink_chain (GstPad *pad, GstData *data)
+gst_xine_audio_sink_chain (GstPad * pad, GstData * data)
{
- GstXineAudioSink *xine = GST_XINE_AUDIO_SINK (gst_object_get_parent (GST_OBJECT (pad)));
+ GstXineAudioSink *xine =
+ GST_XINE_AUDIO_SINK (gst_object_get_parent (GST_OBJECT (pad)));
- while (xine->driver->write (xine->driver, (guint16 *) GST_BUFFER_DATA (data), GST_BUFFER_SIZE (data) / xine->open) == 0);
+ while (xine->driver->write (xine->driver, (guint16 *) GST_BUFFER_DATA (data),
+ GST_BUFFER_SIZE (data) / xine->open) == 0);
gst_data_unref (GST_DATA (data));
}
static GstElementStateReturn
-gst_xine_audio_sink_change_state (GstElement *element)
+gst_xine_audio_sink_change_state (GstElement * element)
{
GstXineAudioSink *xine = GST_XINE_AUDIO_SINK (element);
- audio_driver_class_t *driver = (audio_driver_class_t *) GST_XINE_AUDIO_SINK_GET_CLASS (xine)->plugin_node->plugin_class;
+ audio_driver_class_t *driver =
+ (audio_driver_class_t *) GST_XINE_AUDIO_SINK_GET_CLASS (xine)->
+ plugin_node->plugin_class;
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
if (driver == NULL) {
- xine_audio_port_t *port = xine_open_audio_driver (GST_XINE_GET_CLASS (xine)->xine,
+ xine_audio_port_t *port =
+ xine_open_audio_driver (GST_XINE_GET_CLASS (xine)->xine,
GST_XINE_AUDIO_SINK_GET_CLASS (xine)->plugin_node->info->id, NULL);
+
if (!port)
return GST_STATE_FAILURE;
port->exit (port);
- driver = (audio_driver_class_t *) GST_XINE_AUDIO_SINK_GET_CLASS (xine)->plugin_node->plugin_class;
- if (driver == NULL)
+ driver =
+ (audio_driver_class_t *) GST_XINE_AUDIO_SINK_GET_CLASS (xine)->
+ plugin_node->plugin_class;
+ if (driver == NULL)
return GST_STATE_FAILURE;
}
xine->driver = driver->open_plugin (driver, NULL);
@@ -133,23 +140,25 @@ gst_xine_audio_sink_change_state (GstElement *element)
GST_ERROR_OBJECT (element, "invalid state change");
break;
}
-
- return GST_CALL_PARENT_WITH_DEFAULT (GST_ELEMENT_CLASS, change_state, (element), GST_STATE_SUCCESS);
+
+ return GST_CALL_PARENT_WITH_DEFAULT (GST_ELEMENT_CLASS, change_state,
+ (element), GST_STATE_SUCCESS);
}
static GstCaps *
-_xine_audio_sink_get_caps (GstPad *pad)
+_xine_audio_sink_get_caps (GstPad * pad)
{
- GstXineAudioSink *xine = GST_XINE_AUDIO_SINK (gst_object_get_parent (GST_OBJECT (pad)));
+ GstXineAudioSink *xine =
+ GST_XINE_AUDIO_SINK (gst_object_get_parent (GST_OBJECT (pad)));
GstCaps *caps, *ret = gst_caps_new_empty ();
guint32 capa, channels;
-
+
if (!xine->driver)
return gst_caps_copy (gst_pad_get_pad_template_caps (pad));
capa = xine->driver->get_capabilities (xine->driver);
channels = capa & (AO_CAP_MODE_MONO | AO_CAP_MODE_STEREO);
-
+
if (channels == 0) {
/* neither mono nor stereo supported, die */
return ret;
@@ -162,16 +171,14 @@ _xine_audio_sink_get_caps (GstPad *pad)
caps = gst_caps_from_string ("audio/x-raw-int, "
"signed = (boolean) FALSE, "
"width = (int) 8, "
- "depth = (int) 8, "
- "rate = (int) [ 8000, 192000 ]");
+ "depth = (int) 8, " "rate = (int) [ 8000, 192000 ]");
capa &= ~AO_CAP_8BITS;
} else {
caps = gst_caps_from_string ("audio/x-raw-int, "
"endianness = (int) BYTE_ORDER, "
"signed = (boolean) TRUE, "
"width = (int) 16, "
- "depth = (int) 16, "
- "rate = (int) [ 8000, 192000 ]");
+ "depth = (int) 16, " "rate = (int) [ 8000, 192000 ]");
capa = -1;
}
switch (channels) {
@@ -190,18 +197,19 @@ _xine_audio_sink_get_caps (GstPad *pad)
}
gst_caps_append (ret, caps);
} while (capa != -1);
-
+
return ret;
}
static GstPadLinkReturn
-_xine_audio_sink_link (GstPad *pad, const GstCaps *caps)
+_xine_audio_sink_link (GstPad * pad, const GstCaps * caps)
{
GstStructure *structure = gst_caps_get_structure (caps, 0);
- GstXineAudioSink *xine = GST_XINE_AUDIO_SINK (gst_object_get_parent (GST_OBJECT (pad)));
+ GstXineAudioSink *xine =
+ GST_XINE_AUDIO_SINK (gst_object_get_parent (GST_OBJECT (pad)));
guint channels, temp, rate, width;
int mode;
-
+
if (!gst_structure_get_int (structure, "channels", &channels))
return GST_PAD_LINK_REFUSED;
mode = (channels == 1) ? AO_CAP_MODE_MONO : AO_CAP_MODE_STEREO;
@@ -209,77 +217,76 @@ _xine_audio_sink_link (GstPad *pad, const GstCaps *caps)
return GST_PAD_LINK_REFUSED;
if (!gst_structure_get_int (structure, "width", &width))
return GST_PAD_LINK_REFUSED;
-
+
if (xine->open != 0)
xine->driver->close (xine->driver);
xine->open = 0;
temp = xine->driver->open (xine->driver, width, rate, mode);
if (temp == 0)
return GST_PAD_LINK_REFUSED;
-
+
xine->open = channels * width / 8;
if (temp != rate) {
/* FIXME? */
- GST_WARNING_OBJECT (xine, "rates don't match (requested: %u, got %u)", rate, temp);
+ GST_WARNING_OBJECT (xine, "rates don't match (requested: %u, got %u)", rate,
+ temp);
}
-
+
return GST_PAD_LINK_OK;
}
/** GstXineAudioSink subclasses ************************************************/
-static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "audio/x-raw-int, "
- "signed = (boolean) FALSE, "
- "width = (int) 8, "
- "depth = (int) 8, "
- "rate = (int) [ 8000, 192000 ], "
- "channels = (int) [1, 2]; "
- "audio/x-raw-int, "
- "endianness = (int) BYTE_ORDER, "
- "signed = (boolean) TRUE, "
- "width = (int) 16, "
- "depth = (int) 16, "
- "rate = (int) [ 8000, 192000 ], "
- "channels = (int) [1, 2]"
- )
-);
+static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "signed = (boolean) FALSE, "
+ "width = (int) 8, "
+ "depth = (int) 8, "
+ "rate = (int) [ 8000, 192000 ], "
+ "channels = (int) [1, 2]; "
+ "audio/x-raw-int, "
+ "endianness = (int) BYTE_ORDER, "
+ "signed = (boolean) TRUE, "
+ "width = (int) 16, "
+ "depth = (int) 16, "
+ "rate = (int) [ 8000, 192000 ], " "channels = (int) [1, 2]")
+ );
static void
gst_xine_audio_sink_subclass_init (gpointer g_class, gpointer class_data)
{
GstXineAudioSinkClass *xine_class = GST_XINE_AUDIO_SINK_CLASS (g_class);
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- GstElementDetails details = GST_ELEMENT_DETAILS (
- NULL,
- "Source",
- NULL,
- "Benjamin Otte <otte@gnome.org>"
- );
-
+ GstElementDetails details = GST_ELEMENT_DETAILS (NULL,
+ "Source",
+ NULL,
+ "Benjamin Otte <otte@gnome.org>");
+
xine_class->plugin_node = class_data;
- details.longname = g_strdup_printf ("%s xine audio sink", xine_class->plugin_node->info->id);
- details.description = g_strdup_printf ("%s audio output using Xine", xine_class->plugin_node->info->id);
+ details.longname =
+ g_strdup_printf ("%s xine audio sink", xine_class->plugin_node->info->id);
+ details.description =
+ g_strdup_printf ("%s audio output using Xine",
+ xine_class->plugin_node->info->id);
gst_element_class_set_details (element_class, &details);
g_free (details.longname);
g_free (details.description);
-
- gst_element_class_add_pad_template (element_class,
+
+ gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sink_template));
}
static void
-gst_xine_audio_sink_sub_init (GTypeInstance *instance, gpointer g_class)
+gst_xine_audio_sink_sub_init (GTypeInstance * instance, gpointer g_class)
{
GstElementClass *klass = GST_ELEMENT_GET_CLASS (instance);
GstXineAudioSink *xine = GST_XINE_AUDIO_SINK (instance);
- xine->sinkpad = gst_pad_new_from_template (
- gst_element_class_get_pad_template (klass, "sink"), "sink");
+ xine->sinkpad =
+ gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
+ "sink"), "sink");
gst_pad_set_chain_function (xine->sinkpad, gst_xine_audio_sink_chain);
gst_pad_set_getcaps_function (xine->sinkpad, _xine_audio_sink_get_caps);
gst_pad_set_link_function (xine->sinkpad, _xine_audio_sink_link);
@@ -287,10 +294,9 @@ gst_xine_audio_sink_sub_init (GTypeInstance *instance, gpointer g_class)
}
gboolean
-gst_xine_audio_sink_init_plugin (GstPlugin *plugin)
+gst_xine_audio_sink_init_plugin (GstPlugin * plugin)
{
- GTypeInfo plugin_info =
- {
+ GTypeInfo plugin_info = {
sizeof (GstXineAudioSinkClass),
NULL,
NULL,
@@ -303,19 +309,21 @@ gst_xine_audio_sink_init_plugin (GstPlugin *plugin)
};
plugin_node_t *node;
GstXineClass *klass;
-
+
klass = g_type_class_ref (GST_TYPE_XINE);
-
+
node = xine_list_first_content (klass->xine->plugin_catalog->aout);
while (node) {
gchar *plugin_name = g_strdup_printf ("xineaudiosink_%s", node->info->id);
gchar *type_name = g_strdup_printf ("GstXineAudioSink%s", node->info->id);
GType type;
+
plugin_info.class_data = node;
- type = g_type_register_static (GST_TYPE_XINE_AUDIO_SINK, type_name, &plugin_info, 0);
+ type =
+ g_type_register_static (GST_TYPE_XINE_AUDIO_SINK, type_name,
+ &plugin_info, 0);
g_free (type_name);
- if (!gst_element_register (plugin, plugin_name,
- GST_RANK_MARGINAL, type)) {
+ if (!gst_element_register (plugin, plugin_name, GST_RANK_MARGINAL, type)) {
g_free (plugin_name);
return FALSE;
}
@@ -324,7 +332,6 @@ gst_xine_audio_sink_init_plugin (GstPlugin *plugin)
node = xine_list_next_content (klass->xine->plugin_catalog->aout);
}
- g_type_class_unref (klass);
+ g_type_class_unref (klass);
return TRUE;
}
-
diff --git a/ext/xine/xinecaps.c b/ext/xine/xinecaps.c
index d243f72f..1df3ab97 100644
--- a/ext/xine/xinecaps.c
+++ b/ext/xine/xinecaps.c
@@ -20,13 +20,14 @@
#include "gstxine.h"
#include <xine/buffer.h>
-typedef struct {
- guint32 xine;
- gchar * caps;
+typedef struct
+{
+ guint32 xine;
+ gchar *caps;
} GstXineCapsMap;
static GstXineCapsMap _gst_xine_caps_map[] = {
- { BUF_AUDIO_QDESIGN2, "audio/x-qdm2" },
+ {BUF_AUDIO_QDESIGN2, "audio/x-qdm2"},
/* FIXME:
#define BUF_AUDIO_A52 0x03000000
#define BUF_AUDIO_MPEG 0x03010000
@@ -79,29 +80,29 @@ static GstXineCapsMap _gst_xine_caps_map[] = {
#define BUF_AUDIO_RAWPCM 0x03300000
#define BUF_AUDIO_4X_ADPCM 0x03310000
*/
- { 0, NULL }
+ {0, NULL}
};
const gchar *
gst_xine_get_caps_for_format (guint32 format)
{
guint i = 0;
-
+
while (_gst_xine_caps_map[i].xine != 0) {
if (_gst_xine_caps_map[i].xine == format)
return _gst_xine_caps_map[i].caps;
i++;
}
-
+
return NULL;
}
guint32
-gst_xine_get_format_for_caps (const GstCaps *caps)
+gst_xine_get_format_for_caps (const GstCaps * caps)
{
guint i = 0;
GstCaps *compare, *intersect;
-
+
while (_gst_xine_caps_map[i].xine != 0) {
compare = gst_caps_from_string (_gst_xine_caps_map[i].caps);
intersect = gst_caps_intersect (caps, compare);
@@ -113,7 +114,6 @@ gst_xine_get_format_for_caps (const GstCaps *caps)
gst_caps_free (intersect);
i++;
}
-
- return 0;
-}
+ return 0;
+}
diff --git a/ext/xine/xineinput.c b/ext/xine/xineinput.c
index a44f8c16..19a4bbbe 100644
--- a/ext/xine/xineinput.c
+++ b/ext/xine/xineinput.c
@@ -38,51 +38,51 @@
GType gst_xine_input_get_type (void);
-typedef struct _GstXineInput GstXineInput;
+typedef struct _GstXineInput GstXineInput;
typedef struct _GstXineInputClass GstXineInputClass;
struct _GstXineInput
{
- GstXine parent;
+ GstXine parent;
- GstPad * srcpad;
+ GstPad *srcpad;
- input_plugin_t * input;
- gchar * location;
- guint blocksize;
+ input_plugin_t *input;
+ gchar *location;
+ guint blocksize;
};
-struct _GstXineInputClass
+struct _GstXineInputClass
{
- GstXineClass parent_class;
+ GstXineClass parent_class;
- plugin_node_t * plugin_node;
+ plugin_node_t *plugin_node;
};
/** GstXineInput ***********************************************************/
-enum {
+enum
+{
ARG_0,
ARG_LOCATION
};
GST_BOILERPLATE (GstXineInput, gst_xine_input, GstXine, GST_TYPE_XINE)
-static void gst_xine_input_dispose (GObject *object);
-static void gst_xine_input_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_xine_input_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
-static GstElementStateReturn
- gst_xine_input_change_state (GstElement *element);
+ static void gst_xine_input_dispose (GObject * object);
+ static void gst_xine_input_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+ static void gst_xine_input_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+ static GstElementStateReturn
+ gst_xine_input_change_state (GstElement * element);
-static void
-gst_xine_input_base_init (gpointer g_class)
+ static void gst_xine_input_base_init (gpointer g_class)
{
}
static void
-gst_xine_input_class_init (GstXineInputClass *klass)
+gst_xine_input_class_init (GstXineInputClass * klass)
{
GstElementClass *element = GST_ELEMENT_CLASS (klass);
GObjectClass *object = G_OBJECT_CLASS (klass);
@@ -92,19 +92,19 @@ gst_xine_input_class_init (GstXineInputClass *klass)
object->set_property = gst_xine_input_set_property;
object->get_property = gst_xine_input_get_property;
object->dispose = gst_xine_input_dispose;
-
- g_object_class_install_property (object, ARG_LOCATION,
- g_param_spec_string ("location", "location", "location",
- NULL, G_PARAM_READWRITE));
+
+ g_object_class_install_property (object, ARG_LOCATION,
+ g_param_spec_string ("location", "location", "location",
+ NULL, G_PARAM_READWRITE));
}
static void
-gst_xine_input_init (GstXineInput *xine)
+gst_xine_input_init (GstXineInput * xine)
{
}
static void
-gst_xine_input_dispose (GObject *object)
+gst_xine_input_dispose (GObject * object)
{
GstXineInput *xine = GST_XINE_INPUT (object);
@@ -115,7 +115,8 @@ gst_xine_input_dispose (GObject *object)
}
static void
-gst_xine_input_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_xine_input_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstXineInput *xine = GST_XINE_INPUT (object);
@@ -127,14 +128,15 @@ gst_xine_input_set_property (GObject *object, guint prop_id, const GValue *value
g_free (xine->location);
xine->location = g_strdup (g_value_get_string (value));
break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- return;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ return;
}
}
static void
-gst_xine_input_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_xine_input_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstXineInput *xine = GST_XINE_INPUT (object);
@@ -142,43 +144,52 @@ gst_xine_input_get_property (GObject *object, guint prop_id, GValue *value, GPar
case ARG_LOCATION:
g_value_set_string (value, xine->location);
break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- return;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ return;
}
}
-#define BUFFER_SIZE 4096 /* FIXME: what size? */
+#define BUFFER_SIZE 4096 /* FIXME: what size? */
static GstData *
-gst_xine_input_get (GstPad *pad)
+gst_xine_input_get (GstPad * pad)
{
- GstXineInput *xine = GST_XINE_INPUT (gst_object_get_parent (GST_OBJECT (pad)));
+ GstXineInput *xine =
+ GST_XINE_INPUT (gst_object_get_parent (GST_OBJECT (pad)));
GstBuffer *buf;
gint real_size, position;
-
+
/* FIXME: how does xine figure out EOS? */
position = xine->input->get_current_pos (xine->input);
if (position > 0 && position == xine->input->get_length (xine->input)) {
gst_element_set_eos (GST_ELEMENT (xine));
return GST_DATA (gst_event_new (GST_EVENT_EOS));
}
-
- buf = gst_pad_alloc_buffer (xine->srcpad, GST_BUFFER_OFFSET_NONE, xine->blocksize);
+
+ buf =
+ gst_pad_alloc_buffer (xine->srcpad, GST_BUFFER_OFFSET_NONE,
+ xine->blocksize);
GST_BUFFER_OFFSET (buf) = position;
- real_size = xine->input->read (xine->input, GST_BUFFER_DATA (buf), GST_BUFFER_MAXSIZE (buf));
+ real_size =
+ xine->input->read (xine->input, GST_BUFFER_DATA (buf),
+ GST_BUFFER_MAXSIZE (buf));
GST_BUFFER_SIZE (buf) = real_size;
if (real_size < 0) {
- GST_ELEMENT_ERROR (xine, RESOURCE, READ, (NULL), ("error %d reading data", real_size));
+ GST_ELEMENT_ERROR (xine, RESOURCE, READ, (NULL), ("error %d reading data",
+ real_size));
gst_data_unref (GST_DATA (buf));
return NULL;
} else if (real_size == 0) {
buf_element_t *element;
+
if (xine->input->get_capabilities (xine->input) & INPUT_CAP_BLOCK)
- element = xine->input->read_block (xine->input, gst_xine_get_stream (GST_XINE (xine))->audio_fifo, xine->blocksize);
+ element =
+ xine->input->read_block (xine->input,
+ gst_xine_get_stream (GST_XINE (xine))->audio_fifo, xine->blocksize);
if (element == NULL) {
/* FIXME: is this EOS? */
gst_element_set_eos (GST_ELEMENT (xine));
- return GST_DATA (gst_event_new (GST_EVENT_EOS));
+ return GST_DATA (gst_event_new (GST_EVENT_EOS));
} else {
GST_BUFFER_SIZE (buf) = element->size;
/* FIXME: put buf_element_t data in buffer */
@@ -187,19 +198,23 @@ gst_xine_input_get (GstPad *pad)
}
}
GST_BUFFER_OFFSET_END (buf) = xine->input->get_current_pos (xine->input);
-
+
return GST_DATA (buf);
}
static GstElementStateReturn
-gst_xine_input_change_state (GstElement *element)
+gst_xine_input_change_state (GstElement * element)
{
GstXineInput *xine = GST_XINE_INPUT (element);
- input_class_t *input = (input_class_t *) GST_XINE_INPUT_GET_CLASS (xine)->plugin_node->plugin_class;
-
+ input_class_t *input =
+ (input_class_t *) GST_XINE_INPUT_GET_CLASS (xine)->plugin_node->
+ plugin_class;
+
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
- xine->input = input->get_instance (input, gst_xine_get_stream (GST_XINE (xine)), xine->location);
+ xine->input =
+ input->get_instance (input, gst_xine_get_stream (GST_XINE (xine)),
+ xine->location);
if (!xine->input)
return GST_STATE_FAILURE;
if (xine->input->open (xine->input) == 0)
@@ -225,82 +240,75 @@ gst_xine_input_change_state (GstElement *element)
GST_ERROR_OBJECT (element, "invalid state change");
break;
}
-
- return GST_CALL_PARENT_WITH_DEFAULT (GST_ELEMENT_CLASS, change_state, (element), GST_STATE_SUCCESS);
+
+ return GST_CALL_PARENT_WITH_DEFAULT (GST_ELEMENT_CLASS, change_state,
+ (element), GST_STATE_SUCCESS);
}
/** GstXineInput subclasses ************************************************/
-static GstStaticPadTemplate any_template = GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS_ANY
-);
-
-static GstStaticPadTemplate cdda_template = GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "audio/x-raw-int, "
- "endianness = (int) LITTLE_ENDIAN, "
- "signed = (boolean) true, "
- "width = (int) 16, "
- "depth = (int) 16, "
- "rate = (int) 44100, "
- "channels = (int) 2"
- )
-);
+static GstStaticPadTemplate any_template = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS_ANY);
+
+static GstStaticPadTemplate cdda_template = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "endianness = (int) LITTLE_ENDIAN, "
+ "signed = (boolean) true, "
+ "width = (int) 16, "
+ "depth = (int) 16, " "rate = (int) 44100, " "channels = (int) 2")
+ );
static void
gst_xine_input_subclass_init (gpointer g_class, gpointer class_data)
{
GstXineInputClass *xine_class = GST_XINE_INPUT_CLASS (g_class);
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- GstElementDetails details = GST_ELEMENT_DETAILS (
- NULL,
- "Source",
- NULL,
- "Benjamin Otte <otte@gnome.org>"
- );
+ GstElementDetails details = GST_ELEMENT_DETAILS (NULL,
+ "Source",
+ NULL,
+ "Benjamin Otte <otte@gnome.org>");
input_class_t *input;
-
+
xine_class->plugin_node = class_data;
input = (input_class_t *) xine_class->plugin_node->plugin_class;
- details.longname = g_strdup_printf ("%s xine input", input->get_identifier (input));
+ details.longname =
+ g_strdup_printf ("%s xine input", input->get_identifier (input));
details.description = g_strdup_printf ("%s", input->get_description (input));
gst_element_class_set_details (element_class, &details);
g_free (details.longname);
g_free (details.description);
-
+
/* FIXME: this is pretty hackish, anyone knows a better idea (xine doesn't) */
if (strcmp (input->get_identifier (input), "cdda") == 0) {
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&cdda_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&cdda_template));
} else {
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&any_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&any_template));
}
}
static void
-gst_xine_input_sub_init (GTypeInstance *instance, gpointer g_class)
+gst_xine_input_sub_init (GTypeInstance * instance, gpointer g_class)
{
GstElementClass *klass = GST_ELEMENT_GET_CLASS (instance);
GstXineInput *xine = GST_XINE_INPUT (instance);
- xine->srcpad = gst_pad_new_from_template (
- gst_element_class_get_pad_template (klass, "src"), "src");
+ xine->srcpad =
+ gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
+ "src"), "src");
gst_pad_set_get_function (xine->srcpad, gst_xine_input_get);
gst_element_add_pad (GST_ELEMENT (xine), xine->srcpad);
}
gboolean
-gst_xine_input_init_plugin (GstPlugin *plugin)
+gst_xine_input_init_plugin (GstPlugin * plugin)
{
- GTypeInfo plugin_info =
- {
+ GTypeInfo plugin_info = {
sizeof (GstXineInputClass),
NULL,
NULL,
@@ -313,19 +321,21 @@ gst_xine_input_init_plugin (GstPlugin *plugin)
};
plugin_node_t *node;
GstXineClass *klass;
-
+
klass = g_type_class_ref (GST_TYPE_XINE);
-
+
node = xine_list_first_content (klass->xine->plugin_catalog->input);
while (node) {
gchar *plugin_name = g_strdup_printf ("xinesrc_%s", node->info->id);
gchar *type_name = g_strdup_printf ("GstXineInput%s", node->info->id);
GType type;
+
plugin_info.class_data = node;
- type = g_type_register_static (GST_TYPE_XINE_INPUT, type_name, &plugin_info, 0);
+ type =
+ g_type_register_static (GST_TYPE_XINE_INPUT, type_name, &plugin_info,
+ 0);
g_free (type_name);
- if (!gst_element_register (plugin, plugin_name,
- GST_RANK_MARGINAL, type)) {
+ if (!gst_element_register (plugin, plugin_name, GST_RANK_MARGINAL, type)) {
g_free (plugin_name);
return FALSE;
}
@@ -334,7 +344,6 @@ gst_xine_input_init_plugin (GstPlugin *plugin)
node = xine_list_next_content (klass->xine->plugin_catalog->input);
}
- g_type_class_unref (klass);
+ g_type_class_unref (klass);
return TRUE;
}
-
diff --git a/ext/xvid/gstxvid.c b/ext/xvid/gstxvid.c
index 4b8826d5..1e22dbfd 100644
--- a/ext/xvid/gstxvid.c
+++ b/ext/xvid/gstxvid.c
@@ -42,17 +42,16 @@ gst_xvid_init (void)
/* set up xvid initially (function pointers, CPU flags) */
gst_xvid_init_struct (xinit);
- if ((ret = xvid_global(NULL, XVID_GBL_INIT, &xinit, NULL)) < 0) {
- g_warning("Failed to initialize XviD: %s (%d)",
- gst_xvid_error(ret), ret);
+ if ((ret = xvid_global (NULL, XVID_GBL_INIT, &xinit, NULL)) < 0) {
+ g_warning ("Failed to initialize XviD: %s (%d)", gst_xvid_error (ret), ret);
return FALSE;
}
GST_LOG ("Initted XviD version %d.%d.%d (API %d.%d)",
- XVID_VERSION_MAJOR (XVID_VERSION),
- XVID_VERSION_MINOR (XVID_VERSION),
- XVID_VERSION_PATCH (XVID_VERSION),
- XVID_API_MAJOR (XVID_API), XVID_API_MINOR (XVID_API));
+ XVID_VERSION_MAJOR (XVID_VERSION),
+ XVID_VERSION_MINOR (XVID_VERSION),
+ XVID_VERSION_PATCH (XVID_VERSION),
+ XVID_API_MAJOR (XVID_API), XVID_API_MINOR (XVID_API));
is_init = TRUE;
return TRUE;
@@ -88,8 +87,8 @@ gst_xvid_error (int errorcode)
}
gint
-gst_xvid_structure_to_csp (GstStructure *structure,
- gint w, gint *_stride, gint *_bpp)
+gst_xvid_structure_to_csp (GstStructure * structure,
+ gint w, gint * _stride, gint * _bpp)
{
const gchar *mime = gst_structure_get_name (structure);
gint xvid_cs = -1, stride = -1, bpp = -1;
@@ -99,70 +98,70 @@ gst_xvid_structure_to_csp (GstStructure *structure,
gst_structure_get_fourcc (structure, "format", &fourcc);
switch (fourcc) {
- case GST_MAKE_FOURCC('I','4','2','0'):
- xvid_cs = XVID_CSP_I420;
- stride = w;
- bpp = 12;
- break;
- case GST_MAKE_FOURCC('Y','U','Y','2'):
- xvid_cs = XVID_CSP_YUY2;
- stride = w * 2;
- bpp = 16;
- break;
- case GST_MAKE_FOURCC('Y','V','1','2'):
- xvid_cs = XVID_CSP_YV12;
- stride = w;
- bpp = 12;
- break;
- case GST_MAKE_FOURCC('U','Y','V','Y'):
- xvid_cs = XVID_CSP_UYVY;
- stride = w * 2;
- bpp = 16;
- break;
- case GST_MAKE_FOURCC('Y','V','Y','U'):
- xvid_cs = XVID_CSP_YVYU;
- stride = w * 2;
- bpp = 16;
- break;
+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):
+ xvid_cs = XVID_CSP_I420;
+ stride = w;
+ bpp = 12;
+ break;
+ case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
+ xvid_cs = XVID_CSP_YUY2;
+ stride = w * 2;
+ bpp = 16;
+ break;
+ case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
+ xvid_cs = XVID_CSP_YV12;
+ stride = w;
+ bpp = 12;
+ break;
+ case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
+ xvid_cs = XVID_CSP_UYVY;
+ stride = w * 2;
+ bpp = 16;
+ break;
+ case GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U'):
+ xvid_cs = XVID_CSP_YVYU;
+ stride = w * 2;
+ bpp = 16;
+ break;
}
} else {
gint depth, r_mask;
- gst_structure_get_int(structure, "depth", &depth);
- gst_structure_get_int(structure, "bpp", &bpp);
- gst_structure_get_int(structure, "red_mask", &r_mask);
+ gst_structure_get_int (structure, "depth", &depth);
+ gst_structure_get_int (structure, "bpp", &bpp);
+ gst_structure_get_int (structure, "red_mask", &r_mask);
switch (depth) {
case 15:
- xvid_cs = XVID_CSP_RGB555;
- break;
+ xvid_cs = XVID_CSP_RGB555;
+ break;
case 16:
- xvid_cs = XVID_CSP_RGB565;
- break;
+ xvid_cs = XVID_CSP_RGB565;
+ break;
case 24:
- if (bpp == 24) {
- xvid_cs = XVID_CSP_BGR;
- } else {
- switch (r_mask) {
- case 0xff000000:
- xvid_cs = XVID_CSP_RGBA;
- break;
+ if (bpp == 24) {
+ xvid_cs = XVID_CSP_BGR;
+ } else {
+ switch (r_mask) {
+ case 0xff000000:
+ xvid_cs = XVID_CSP_RGBA;
+ break;
#ifdef XVID_CSP_ARGB
- case 0x00ff0000:
- xvid_cs = XVID_CSP_ARGB;
- break;
+ case 0x00ff0000:
+ xvid_cs = XVID_CSP_ARGB;
+ break;
#endif
- case 0x0000ff00:
- xvid_cs = XVID_CSP_BGRA;
- break;
- case 0x000000ff:
- xvid_cs = XVID_CSP_ABGR;
- break;
- }
- }
- break;
+ case 0x0000ff00:
+ xvid_cs = XVID_CSP_BGRA;
+ break;
+ case 0x000000ff:
+ xvid_cs = XVID_CSP_ABGR;
+ break;
+ }
+ }
+ break;
default:
- break;
+ break;
}
stride = w * bpp / 8;
@@ -190,58 +189,81 @@ gst_xvid_csp_to_caps (gint csp, gint w, gint h, gdouble fps)
#ifdef XVID_CSP_ARGB
case XVID_CSP_ARGB:
#endif
- case XVID_CSP_RGBA: {
+ case XVID_CSP_RGBA:{
gint r_mask = 0, b_mask = 0, g_mask = 0,
- endianness = 0, bpp = 0, depth = 0;
+ endianness = 0, bpp = 0, depth = 0;
switch (csp) {
- case XVID_CSP_RGB555:
- r_mask = GST_VIDEO_RED_MASK_15_INT;
- g_mask = GST_VIDEO_GREEN_MASK_15_INT;
- b_mask = GST_VIDEO_BLUE_MASK_15_INT;
- endianness = G_BYTE_ORDER; depth = 15; bpp = 16;
- break;
- case XVID_CSP_RGB565:
- r_mask = GST_VIDEO_RED_MASK_16_INT;
- g_mask = GST_VIDEO_GREEN_MASK_16_INT;
- b_mask = GST_VIDEO_BLUE_MASK_16_INT;
- endianness = G_BYTE_ORDER; depth = 16; bpp = 16;
- break;
- case XVID_CSP_BGR:
- r_mask = 0x0000ff; g_mask = 0x00ff00; b_mask = 0xff0000;
- endianness = G_BIG_ENDIAN; depth = 24; bpp = 24;
- break;
- case XVID_CSP_ABGR:
- r_mask = 0x000000ff; g_mask = 0x0000ff00; b_mask = 0x00ff0000;
- endianness = G_BIG_ENDIAN; depth = 24; bpp = 32;
- break;
- case XVID_CSP_BGRA:
- r_mask = 0x0000ff00; g_mask = 0x00ff0000; b_mask = 0xff000000;
- endianness = G_BIG_ENDIAN; depth = 24; bpp = 32;
- break;
+ case XVID_CSP_RGB555:
+ r_mask = GST_VIDEO_RED_MASK_15_INT;
+ g_mask = GST_VIDEO_GREEN_MASK_15_INT;
+ b_mask = GST_VIDEO_BLUE_MASK_15_INT;
+ endianness = G_BYTE_ORDER;
+ depth = 15;
+ bpp = 16;
+ break;
+ case XVID_CSP_RGB565:
+ r_mask = GST_VIDEO_RED_MASK_16_INT;
+ g_mask = GST_VIDEO_GREEN_MASK_16_INT;
+ b_mask = GST_VIDEO_BLUE_MASK_16_INT;
+ endianness = G_BYTE_ORDER;
+ depth = 16;
+ bpp = 16;
+ break;
+ case XVID_CSP_BGR:
+ r_mask = 0x0000ff;
+ g_mask = 0x00ff00;
+ b_mask = 0xff0000;
+ endianness = G_BIG_ENDIAN;
+ depth = 24;
+ bpp = 24;
+ break;
+ case XVID_CSP_ABGR:
+ r_mask = 0x000000ff;
+ g_mask = 0x0000ff00;
+ b_mask = 0x00ff0000;
+ endianness = G_BIG_ENDIAN;
+ depth = 24;
+ bpp = 32;
+ break;
+ case XVID_CSP_BGRA:
+ r_mask = 0x0000ff00;
+ g_mask = 0x00ff0000;
+ b_mask = 0xff000000;
+ endianness = G_BIG_ENDIAN;
+ depth = 24;
+ bpp = 32;
+ break;
#ifdef XVID_CSP_ARGB
- case XVID_CSP_ARGB:
- r_mask = 0x00ff0000; g_mask = 0x0000ff00; b_mask = 0x000000ff;
- endianness = G_BIG_ENDIAN; depth = 24; bpp = 32;
- break;
+ case XVID_CSP_ARGB:
+ r_mask = 0x00ff0000;
+ g_mask = 0x0000ff00;
+ b_mask = 0x000000ff;
+ endianness = G_BIG_ENDIAN;
+ depth = 24;
+ bpp = 32;
+ break;
#endif
- case XVID_CSP_RGBA:
- r_mask = 0xff000000; g_mask = 0x00ff0000; b_mask = 0x0000ff00;
- endianness = G_BIG_ENDIAN; depth = 24; bpp = 32;
- break;
+ case XVID_CSP_RGBA:
+ r_mask = 0xff000000;
+ g_mask = 0x00ff0000;
+ b_mask = 0x0000ff00;
+ endianness = G_BIG_ENDIAN;
+ depth = 24;
+ bpp = 32;
+ break;
}
caps = gst_caps_new_simple ("video/x-raw-rgb",
- "width", G_TYPE_INT, w,
- "height", G_TYPE_INT, h,
- "depth", G_TYPE_INT, depth,
- "bpp", G_TYPE_INT, bpp,
- "endianness", G_TYPE_INT, endianness,
- "red_mask", G_TYPE_INT, r_mask,
- "green_mask", G_TYPE_INT, g_mask,
- "blue_mask", G_TYPE_INT, b_mask,
- "framerate", G_TYPE_DOUBLE, fps,
- NULL);
+ "width", G_TYPE_INT, w,
+ "height", G_TYPE_INT, h,
+ "depth", G_TYPE_INT, depth,
+ "bpp", G_TYPE_INT, bpp,
+ "endianness", G_TYPE_INT, endianness,
+ "red_mask", G_TYPE_INT, r_mask,
+ "green_mask", G_TYPE_INT, g_mask,
+ "blue_mask", G_TYPE_INT, b_mask,
+ "framerate", G_TYPE_DOUBLE, fps, NULL);
break;
}
@@ -249,33 +271,32 @@ gst_xvid_csp_to_caps (gint csp, gint w, gint h, gdouble fps)
case XVID_CSP_YVYU:
case XVID_CSP_UYVY:
case XVID_CSP_I420:
- case XVID_CSP_YV12: {
+ case XVID_CSP_YV12:{
guint32 fourcc = 0;
switch (csp) {
- case XVID_CSP_YUY2:
- fourcc = GST_MAKE_FOURCC ('Y','U','Y','2');
- break;
- case XVID_CSP_YVYU:
- fourcc = GST_MAKE_FOURCC ('Y','V','Y','U');
- break;
- case XVID_CSP_UYVY:
- fourcc = GST_MAKE_FOURCC ('U','Y','V','Y');
- break;
- case XVID_CSP_I420:
- fourcc = GST_MAKE_FOURCC ('I','4','2','0');
- break;
- case XVID_CSP_YV12:
- fourcc = GST_MAKE_FOURCC ('Y','V','1','2');
- break;
+ case XVID_CSP_YUY2:
+ fourcc = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2');
+ break;
+ case XVID_CSP_YVYU:
+ fourcc = GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U');
+ break;
+ case XVID_CSP_UYVY:
+ fourcc = GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y');
+ break;
+ case XVID_CSP_I420:
+ fourcc = GST_MAKE_FOURCC ('I', '4', '2', '0');
+ break;
+ case XVID_CSP_YV12:
+ fourcc = GST_MAKE_FOURCC ('Y', 'V', '1', '2');
+ break;
}
caps = gst_caps_new_simple ("video/x-raw-yuv",
- "width", G_TYPE_INT, w,
- "height", G_TYPE_INT, h,
- "format", GST_TYPE_FOURCC, fourcc,
- "framerate", G_TYPE_DOUBLE, fps,
- NULL);
+ "width", G_TYPE_INT, w,
+ "height", G_TYPE_INT, h,
+ "format", GST_TYPE_FOURCC, fourcc,
+ "framerate", G_TYPE_DOUBLE, fps, NULL);
break;
}
}
@@ -285,22 +306,15 @@ gst_xvid_csp_to_caps (gint csp, gint w, gint h, gdouble fps)
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return (gst_element_register (plugin, "xvidenc",
- GST_RANK_NONE, GST_TYPE_XVIDENC) &&
- gst_element_register (plugin, "xviddec",
- GST_RANK_SECONDARY, GST_TYPE_XVIDDEC));
+ GST_RANK_NONE, GST_TYPE_XVIDENC) &&
+ gst_element_register (plugin, "xviddec",
+ GST_RANK_SECONDARY, GST_TYPE_XVIDDEC));
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "xvid",
- "XviD plugin library",
- plugin_init,
- VERSION,
- "GPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "xvid",
+ "XviD plugin library", plugin_init, VERSION, "GPL", GST_PACKAGE, GST_ORIGIN)
diff --git a/ext/xvid/gstxvid.h b/ext/xvid/gstxvid.h
index 100f93b8..e204ae4a 100644
--- a/ext/xvid/gstxvid.h
+++ b/ext/xvid/gstxvid.h
@@ -23,13 +23,11 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define gst_xvid_init_struct(s) \
do { \
memset (&s, 0, sizeof(s)); \
s.version = XVID_VERSION; \
} while (0);
-
#define RGB_24_32_STATIC_CAPS(bpp, r_mask,g_mask,b_mask) \
"video/x-raw-rgb, " \
"width = (int) [ 0, MAX ], " \
@@ -41,14 +39,12 @@ G_BEGIN_DECLS
"red_mask = (int) " G_STRINGIFY (r_mask) ", " \
"green_mask = (int) " G_STRINGIFY (g_mask) ", " \
"blue_mask = (int) " G_STRINGIFY (b_mask)
+extern gchar *gst_xvid_error (int errorcode);
+extern gboolean gst_xvid_init (void);
-extern gchar * gst_xvid_error (int errorcode);
-extern gboolean gst_xvid_init (void);
-
-extern gint gst_xvid_structure_to_csp (GstStructure *structure,
- gint w, gint *stride, gint *bpp);
-extern GstCaps *gst_xvid_csp_to_caps (gint csp, gint w, gint h, gdouble fps);
+extern gint gst_xvid_structure_to_csp (GstStructure * structure,
+ gint w, gint * stride, gint * bpp);
+extern GstCaps *gst_xvid_csp_to_caps (gint csp, gint w, gint h, gdouble fps);
G_END_DECLS
-
#endif /* __GST_XVID_H__ */
diff --git a/ext/xvid/gstxviddec.c b/ext/xvid/gstxviddec.c
index 1266bcdb..cab1a027 100644
--- a/ext/xvid/gstxviddec.c
+++ b/ext/xvid/gstxviddec.c
@@ -35,90 +35,76 @@ GstElementDetails gst_xviddec_details = {
"Ronald Bultje <rbultje@ronald.bitfreak.net>",
};
-static GstStaticPadTemplate sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "video/x-xvid, "
- "width = (int) [ 0, MAX ], "
- "height = (int) [ 0, MAX ], "
- "framerate = (double) [ 0, MAX ]"
- )
-);
-
-static GstStaticPadTemplate src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- GST_VIDEO_CAPS_YUV ("{ I420, YUY2, YV12, YVYU, UYVY }") "; "
- RGB_24_32_STATIC_CAPS (32, 0x00ff0000, 0x0000ff00, 0x000000ff) "; "
- RGB_24_32_STATIC_CAPS (32, 0xff000000, 0x00ff0000, 0x0000ff00) "; "
- RGB_24_32_STATIC_CAPS (32, 0x0000ff00, 0x00ff0000, 0xff000000) "; "
- RGB_24_32_STATIC_CAPS (32, 0x000000ff, 0x0000ff00, 0x00ff0000) "; "
- RGB_24_32_STATIC_CAPS (24, 0x0000ff, 0x00ff00, 0xff0000) "; "
- GST_VIDEO_CAPS_RGB_15 "; "
- GST_VIDEO_CAPS_RGB_16
- )
-);
+static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-xvid, "
+ "width = (int) [ 0, MAX ], "
+ "height = (int) [ 0, MAX ], " "framerate = (double) [ 0, MAX ]")
+ );
+
+static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("{ I420, YUY2, YV12, YVYU, UYVY }")
+ "; " RGB_24_32_STATIC_CAPS (32, 0x00ff0000, 0x0000ff00,
+ 0x000000ff) "; " RGB_24_32_STATIC_CAPS (32, 0xff000000, 0x00ff0000,
+ 0x0000ff00) "; " RGB_24_32_STATIC_CAPS (32, 0x0000ff00, 0x00ff0000,
+ 0xff000000) "; " RGB_24_32_STATIC_CAPS (32, 0x000000ff, 0x0000ff00,
+ 0x00ff0000) "; " RGB_24_32_STATIC_CAPS (24, 0x0000ff, 0x00ff00,
+ 0xff0000) "; " GST_VIDEO_CAPS_RGB_15 "; " GST_VIDEO_CAPS_RGB_16)
+ );
/* XvidDec signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0
- /* FILL ME */
+ /* FILL ME */
};
-static void gst_xviddec_base_init (gpointer g_class);
-static void gst_xviddec_class_init (GstXvidDecClass *klass);
-static void gst_xviddec_init (GstXvidDec *xviddec);
-static void gst_xviddec_chain (GstPad *pad,
- GstData *data);
+static void gst_xviddec_base_init (gpointer g_class);
+static void gst_xviddec_class_init (GstXvidDecClass * klass);
+static void gst_xviddec_init (GstXvidDec * xviddec);
+static void gst_xviddec_chain (GstPad * pad, GstData * data);
static GstPadLinkReturn
- gst_xviddec_sink_link (GstPad *pad,
- const GstCaps *vscapslist);
+gst_xviddec_sink_link (GstPad * pad, const GstCaps * vscapslist);
static GstPadLinkReturn
- gst_xviddec_src_link (GstPad *pad,
- const GstCaps *vscapslist);
-static GstCaps *
- gst_xviddec_src_getcaps (GstPad *pad);
-static GstElementStateReturn
- gst_xviddec_change_state (GstElement *element);
+gst_xviddec_src_link (GstPad * pad, const GstCaps * vscapslist);
+static GstCaps *gst_xviddec_src_getcaps (GstPad * pad);
+static GstElementStateReturn gst_xviddec_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
+
/* static guint gst_xviddec_signals[LAST_SIGNAL] = { 0 }; */
GType
-gst_xviddec_get_type(void)
+gst_xviddec_get_type (void)
{
static GType xviddec_type = 0;
- if (!xviddec_type)
- {
+ if (!xviddec_type) {
static const GTypeInfo xviddec_info = {
- sizeof(GstXvidDecClass),
+ sizeof (GstXvidDecClass),
gst_xviddec_base_init,
NULL,
(GClassInitFunc) gst_xviddec_class_init,
NULL,
NULL,
- sizeof(GstXvidDec),
+ sizeof (GstXvidDec),
0,
(GInstanceInitFunc) gst_xviddec_init,
};
- xviddec_type = g_type_register_static(GST_TYPE_ELEMENT,
- "GstXvidDec",
- &xviddec_info, 0);
+ xviddec_type = g_type_register_static (GST_TYPE_ELEMENT,
+ "GstXvidDec", &xviddec_info, 0);
}
return xviddec_type;
}
@@ -128,47 +114,47 @@ gst_xviddec_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&sink_template));
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&src_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&sink_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&src_template));
gst_element_class_set_details (element_class, &gst_xviddec_details);
}
static void
-gst_xviddec_class_init (GstXvidDecClass *klass)
+gst_xviddec_class_init (GstXvidDecClass * klass)
{
GstElementClass *gstelement_class = (GstElementClass *) klass;
- parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
+ parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gstelement_class->change_state = gst_xviddec_change_state;
}
static void
-gst_xviddec_init (GstXvidDec *xviddec)
+gst_xviddec_init (GstXvidDec * xviddec)
{
- gst_xvid_init();
+ gst_xvid_init ();
/* create the sink pad */
- xviddec->sinkpad = gst_pad_new_from_template(
- gst_static_pad_template_get (&sink_template),
- "sink");
- gst_element_add_pad(GST_ELEMENT(xviddec), xviddec->sinkpad);
+ xviddec->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&sink_template),
+ "sink");
+ gst_element_add_pad (GST_ELEMENT (xviddec), xviddec->sinkpad);
- gst_pad_set_chain_function(xviddec->sinkpad, gst_xviddec_chain);
- gst_pad_set_link_function(xviddec->sinkpad, gst_xviddec_sink_link);
+ gst_pad_set_chain_function (xviddec->sinkpad, gst_xviddec_chain);
+ gst_pad_set_link_function (xviddec->sinkpad, gst_xviddec_sink_link);
/* create the src pad */
- xviddec->srcpad = gst_pad_new_from_template(
- gst_static_pad_template_get (&src_template),
- "src");
- gst_element_add_pad(GST_ELEMENT(xviddec), xviddec->srcpad);
+ xviddec->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&src_template),
+ "src");
+ gst_element_add_pad (GST_ELEMENT (xviddec), xviddec->srcpad);
gst_pad_set_getcaps_function (xviddec->srcpad, gst_xviddec_src_getcaps);
- gst_pad_set_link_function(xviddec->srcpad, gst_xviddec_src_link);
+ gst_pad_set_link_function (xviddec->srcpad, gst_xviddec_src_link);
/* size, etc. */
xviddec->width = xviddec->height = xviddec->csp = -1;
@@ -179,16 +165,16 @@ gst_xviddec_init (GstXvidDec *xviddec)
static void
-gst_xviddec_unset (GstXvidDec *xviddec)
+gst_xviddec_unset (GstXvidDec * xviddec)
{
/* unref this instance */
- xvid_decore(xviddec->handle, XVID_DEC_DESTROY, NULL, NULL);
+ xvid_decore (xviddec->handle, XVID_DEC_DESTROY, NULL, NULL);
xviddec->handle = NULL;
}
static gboolean
-gst_xviddec_setup (GstXvidDec *xviddec)
+gst_xviddec_setup (GstXvidDec * xviddec)
{
xvid_dec_create_t xdec;
int ret;
@@ -199,12 +185,11 @@ gst_xviddec_setup (GstXvidDec *xviddec)
xdec.height = xviddec->height;
xdec.handle = NULL;
- if ((ret = xvid_decore(NULL, XVID_DEC_CREATE,
- &xdec, NULL)) < 0) {
+ if ((ret = xvid_decore (NULL, XVID_DEC_CREATE, &xdec, NULL)) < 0) {
GST_ELEMENT_ERROR (xviddec, LIBRARY, SETTINGS, (NULL),
- ("Setting parameters %dx%d@%d failed: %s (%d)",
- xviddec->width, xviddec->height, xviddec->csp,
- gst_xvid_error(ret), ret));
+ ("Setting parameters %dx%d@%d failed: %s (%d)",
+ xviddec->width, xviddec->height, xviddec->csp,
+ gst_xvid_error (ret), ret));
return FALSE;
}
@@ -215,68 +200,65 @@ gst_xviddec_setup (GstXvidDec *xviddec)
static void
-gst_xviddec_chain (GstPad *pad,
- GstData *_data)
+gst_xviddec_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
- GstXvidDec *xviddec = GST_XVIDDEC(GST_OBJECT_PARENT(pad));
+ GstXvidDec *xviddec = GST_XVIDDEC (GST_OBJECT_PARENT (pad));
GstBuffer *outbuf;
xvid_dec_frame_t xframe;
int ret;
- g_return_if_fail(pad != NULL);
- g_return_if_fail(GST_IS_PAD(pad));
+ g_return_if_fail (pad != NULL);
+ g_return_if_fail (GST_IS_PAD (pad));
if (!xviddec->handle) {
GST_ELEMENT_ERROR (xviddec, CORE, NEGOTIATION, (NULL),
- ("format wasn't negotiated before chain function"));
- gst_buffer_unref(buf);
+ ("format wasn't negotiated before chain function"));
+ gst_buffer_unref (buf);
return;
}
- outbuf = gst_buffer_new_and_alloc(xviddec->width *
- xviddec->height *
- xviddec->bpp / 8);
- GST_BUFFER_TIMESTAMP(outbuf) = GST_BUFFER_TIMESTAMP(buf);
- GST_BUFFER_DURATION(outbuf) = GST_BUFFER_DURATION(buf);
- GST_BUFFER_SIZE(outbuf) = xviddec->width *
- xviddec->height *
- xviddec->bpp / 8;
+ outbuf = gst_buffer_new_and_alloc (xviddec->width *
+ xviddec->height * xviddec->bpp / 8);
+ GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
+ GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buf);
+ GST_BUFFER_SIZE (outbuf) = xviddec->width *
+ xviddec->height * xviddec->bpp / 8;
/* decode and so ... */
gst_xvid_init_struct (xframe);
xframe.general = 0;
- xframe.bitstream = (void *) GST_BUFFER_DATA(buf);
- xframe.length = GST_BUFFER_SIZE(buf);
+ xframe.bitstream = (void *) GST_BUFFER_DATA (buf);
+ xframe.length = GST_BUFFER_SIZE (buf);
xframe.output.csp = xviddec->csp;
if (xviddec->width == xviddec->stride) {
- xframe.output.plane[0] = GST_BUFFER_DATA(outbuf);
- xframe.output.plane[1] = xframe.output.plane[0] + (xviddec->width * xviddec->height);
- xframe.output.plane[2] = xframe.output.plane[1] + (xviddec->width * xviddec->height / 4);
+ xframe.output.plane[0] = GST_BUFFER_DATA (outbuf);
+ xframe.output.plane[1] =
+ xframe.output.plane[0] + (xviddec->width * xviddec->height);
+ xframe.output.plane[2] =
+ xframe.output.plane[1] + (xviddec->width * xviddec->height / 4);
xframe.output.stride[0] = xviddec->width;
xframe.output.stride[1] = xviddec->width / 2;
xframe.output.stride[2] = xviddec->width / 2;
} else {
- xframe.output.plane[0] = GST_BUFFER_DATA(outbuf);
+ xframe.output.plane[0] = GST_BUFFER_DATA (outbuf);
xframe.output.stride[0] = xviddec->stride;
}
- if ((ret = xvid_decore(xviddec->handle, XVID_DEC_DECODE,
- &xframe, NULL)) < 0) {
+ if ((ret = xvid_decore (xviddec->handle, XVID_DEC_DECODE, &xframe, NULL)) < 0) {
GST_ELEMENT_ERROR (xviddec, STREAM, DECODE, (NULL),
- ("Error decoding xvid frame: %s (%d)\n",
- gst_xvid_error(ret), ret));
- gst_buffer_unref(buf);
- gst_buffer_unref(outbuf);
+ ("Error decoding xvid frame: %s (%d)\n", gst_xvid_error (ret), ret));
+ gst_buffer_unref (buf);
+ gst_buffer_unref (outbuf);
return;
}
- gst_pad_push(xviddec->srcpad, GST_DATA (outbuf));
- gst_buffer_unref(buf);
+ gst_pad_push (xviddec->srcpad, GST_DATA (outbuf));
+ gst_buffer_unref (buf);
}
static GstCaps *
-gst_xviddec_src_getcaps (GstPad *pad)
+gst_xviddec_src_getcaps (GstPad * pad)
{
GstXvidDec *xviddec = GST_XVIDDEC (gst_pad_get_parent (pad));
GstCaps *caps;
@@ -300,13 +282,15 @@ gst_xviddec_src_getcaps (GstPad *pad)
if (!GST_PAD_CAPS (xviddec->sinkpad)) {
GstPadTemplate *templ = gst_static_pad_template_get (&src_template);
+
return gst_caps_copy (gst_pad_template_get_caps (templ));
}
caps = gst_caps_new_empty ();
for (i = 0; csp[i] != 0; i++) {
GstCaps *one = gst_xvid_csp_to_caps (csp[i], xviddec->width,
- xviddec->height, xviddec->fps);
+ xviddec->height, xviddec->fps);
+
gst_caps_append (caps, one);
}
@@ -314,10 +298,9 @@ gst_xviddec_src_getcaps (GstPad *pad)
}
static GstPadLinkReturn
-gst_xviddec_src_link (GstPad *pad,
- const GstCaps *vscaps)
+gst_xviddec_src_link (GstPad * pad, const GstCaps * vscaps)
{
- GstXvidDec *xviddec = GST_XVIDDEC(gst_pad_get_parent (pad));
+ GstXvidDec *xviddec = GST_XVIDDEC (gst_pad_get_parent (pad));
GstStructure *structure = gst_caps_get_structure (vscaps, 0);
if (!GST_PAD_CAPS (xviddec->sinkpad))
@@ -325,55 +308,55 @@ gst_xviddec_src_link (GstPad *pad,
/* if there's something old around, remove it */
if (xviddec->handle) {
- gst_xviddec_unset(xviddec);
+ gst_xviddec_unset (xviddec);
}
-g_print ("out: %s\n", gst_caps_to_string (vscaps));
+ g_print ("out: %s\n", gst_caps_to_string (vscaps));
xviddec->csp = gst_xvid_structure_to_csp (structure, xviddec->width,
- &xviddec->stride,
- &xviddec->bpp);
+ &xviddec->stride, &xviddec->bpp);
if (xviddec->csp < 0)
return GST_PAD_LINK_REFUSED;
- if (!gst_xviddec_setup(xviddec))
+ if (!gst_xviddec_setup (xviddec))
return GST_PAD_LINK_REFUSED;
return GST_PAD_LINK_OK;
}
static GstPadLinkReturn
-gst_xviddec_sink_link (GstPad *pad,
- const GstCaps *vscaps)
+gst_xviddec_sink_link (GstPad * pad, const GstCaps * vscaps)
{
- GstXvidDec *xviddec = GST_XVIDDEC(gst_pad_get_parent (pad));
+ GstXvidDec *xviddec = GST_XVIDDEC (gst_pad_get_parent (pad));
GstStructure *structure;
/* if there's something old around, remove it */
if (xviddec->handle) {
- gst_xviddec_unset(xviddec);
+ gst_xviddec_unset (xviddec);
}
/* if we get here, we know the input is xvid. we
* only need to bother with the output colorspace,
* which the src_link function takes care of. */
structure = gst_caps_get_structure (vscaps, 0);
- gst_structure_get_int(structure, "width", &xviddec->width);
- gst_structure_get_int(structure, "height", &xviddec->height);
- gst_structure_get_double(structure, "framerate", &xviddec->fps);
-g_print ("in: %dx%d\n", xviddec->width, xviddec->height);
+ gst_structure_get_int (structure, "width", &xviddec->width);
+ gst_structure_get_int (structure, "height", &xviddec->height);
+ gst_structure_get_double (structure, "framerate", &xviddec->fps);
+ g_print ("in: %dx%d\n", xviddec->width, xviddec->height);
/* re-nego? or just await src nego? */
- if (GST_PAD_CAPS(xviddec->srcpad)) {
+ if (GST_PAD_CAPS (xviddec->srcpad)) {
GstPadLinkReturn ret;
GstCaps *vscaps = gst_pad_get_allowed_caps (xviddec->srcpad), *new;
gint i, csp;
for (i = 0; i < gst_caps_get_size (vscaps); i++) {
csp = gst_xvid_structure_to_csp (gst_caps_get_structure (vscaps, i),
- 0, NULL, NULL);
- new = gst_xvid_csp_to_caps (csp, xviddec->width, xviddec->height, xviddec->fps);
- ret = gst_pad_try_set_caps(xviddec->srcpad, new);
+ 0, NULL, NULL);
+ new =
+ gst_xvid_csp_to_caps (csp, xviddec->width, xviddec->height,
+ xviddec->fps);
+ ret = gst_pad_try_set_caps (xviddec->srcpad, new);
if (ret != GST_PAD_LINK_REFUSED)
- return ret;
+ return ret;
}
return GST_PAD_LINK_REFUSED;
@@ -383,14 +366,14 @@ g_print ("in: %dx%d\n", xviddec->width, xviddec->height);
}
static GstElementStateReturn
-gst_xviddec_change_state (GstElement *element)
+gst_xviddec_change_state (GstElement * element)
{
GstXvidDec *xviddec = GST_XVIDDEC (element);
switch (GST_STATE_PENDING (element)) {
case GST_STATE_PAUSED_TO_READY:
if (xviddec->handle) {
- gst_xviddec_unset (xviddec);
+ gst_xviddec_unset (xviddec);
}
break;
default:
diff --git a/ext/xvid/gstxviddec.h b/ext/xvid/gstxviddec.h
index fa90d06a..10538175 100644
--- a/ext/xvid/gstxviddec.h
+++ b/ext/xvid/gstxviddec.h
@@ -24,8 +24,9 @@
#include "gstxvid.h"
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_XVIDDEC \
@@ -39,32 +40,34 @@ extern "C" {
#define GST_IS_XVIDDEC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_XVIDDEC))
-typedef struct _GstXvidDec GstXvidDec;
-typedef struct _GstXvidDecClass GstXvidDecClass;
+ typedef struct _GstXvidDec GstXvidDec;
+ typedef struct _GstXvidDecClass GstXvidDecClass;
-struct _GstXvidDec {
- GstElement element;
+ struct _GstXvidDec
+ {
+ GstElement element;
- /* pads */
- GstPad *sinkpad, *srcpad;
+ /* pads */
+ GstPad *sinkpad, *srcpad;
- /* xvid handle */
- void *handle;
+ /* xvid handle */
+ void *handle;
- /* video (output) settings */
- gint csp, bpp, stride;
- gint width, height;
- double fps;
-};
+ /* video (output) settings */
+ gint csp, bpp, stride;
+ gint width, height;
+ double fps;
+ };
-struct _GstXvidDecClass {
- GstElementClass parent_class;
-};
+ struct _GstXvidDecClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_xviddec_get_type(void);
+ GType gst_xviddec_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_XVIDDEC_H__ */
+#endif /* __GST_XVIDDEC_H__ */
diff --git a/ext/xvid/gstxvidenc.c b/ext/xvid/gstxvidenc.c
index a98d31cf..5a9b34ba 100644
--- a/ext/xvid/gstxvidenc.c
+++ b/ext/xvid/gstxvidenc.c
@@ -36,78 +36,63 @@ GstElementDetails gst_xvidenc_details = {
"Ronald Bultje <rbultje@ronald.bitfreak.net>",
};
-static GstStaticPadTemplate sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- GST_VIDEO_CAPS_YUV ("{ I420, YUY2, YV12, YVYU, UYVY }") "; "
- RGB_24_32_STATIC_CAPS (32, 0x00ff0000, 0x0000ff00, 0x000000ff) "; "
- RGB_24_32_STATIC_CAPS (32, 0xff000000, 0x00ff0000, 0x0000ff00) "; "
- RGB_24_32_STATIC_CAPS (32, 0x0000ff00, 0x00ff0000, 0xff000000) "; "
- RGB_24_32_STATIC_CAPS (32, 0x000000ff, 0x0000ff00, 0x00ff0000) "; "
- RGB_24_32_STATIC_CAPS (24, 0x0000ff, 0x00ff00, 0xff0000) "; "
- GST_VIDEO_CAPS_RGB_15 "; "
- GST_VIDEO_CAPS_RGB_16
- )
-);
-
-static GstStaticPadTemplate src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "video/x-xvid, "
- "width = (int) [ 0, MAX ], "
- "height = (int) [ 0, MAX ], "
- "framerate = (double) [ 0.0, MAX ]"
- )
-);
+static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("{ I420, YUY2, YV12, YVYU, UYVY }")
+ "; " RGB_24_32_STATIC_CAPS (32, 0x00ff0000, 0x0000ff00,
+ 0x000000ff) "; " RGB_24_32_STATIC_CAPS (32, 0xff000000, 0x00ff0000,
+ 0x0000ff00) "; " RGB_24_32_STATIC_CAPS (32, 0x0000ff00, 0x00ff0000,
+ 0xff000000) "; " RGB_24_32_STATIC_CAPS (32, 0x000000ff, 0x0000ff00,
+ 0x00ff0000) "; " RGB_24_32_STATIC_CAPS (24, 0x0000ff, 0x00ff00,
+ 0xff0000) "; " GST_VIDEO_CAPS_RGB_15 "; " GST_VIDEO_CAPS_RGB_16)
+ );
+
+static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-xvid, "
+ "width = (int) [ 0, MAX ], "
+ "height = (int) [ 0, MAX ], " "framerate = (double) [ 0.0, MAX ]")
+ );
/* XvidEnc signals and args */
-enum {
+enum
+{
FRAME_ENCODED,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_PROFILE,
ARG_BITRATE,
ARG_MAXKEYINTERVAL,
ARG_BUFSIZE
- /* FILL ME:
- * - ME
- * - VOP
- * - VOL
- * - PAR
- * - max b frames
- */
+ /* FILL ME:
+ * - ME
+ * - VOP
+ * - VOL
+ * - PAR
+ * - max b frames
+ */
};
-static void gst_xvidenc_base_init (gpointer g_class);
-static void gst_xvidenc_class_init (GstXvidEncClass *klass);
-static void gst_xvidenc_init (GstXvidEnc *xvidenc);
-static void gst_xvidenc_chain (GstPad *pad,
- GstData *data);
+static void gst_xvidenc_base_init (gpointer g_class);
+static void gst_xvidenc_class_init (GstXvidEncClass * klass);
+static void gst_xvidenc_init (GstXvidEnc * xvidenc);
+static void gst_xvidenc_chain (GstPad * pad, GstData * data);
static GstPadLinkReturn
- gst_xvidenc_link (GstPad *pad,
- const GstCaps *vscapslist);
+gst_xvidenc_link (GstPad * pad, const GstCaps * vscapslist);
/* properties */
-static void gst_xvidenc_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gst_xvidenc_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static GstElementStateReturn
- gst_xvidenc_change_state (GstElement *element);
+static void gst_xvidenc_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_xvidenc_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
+static GstElementStateReturn gst_xvidenc_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
static guint gst_xvidenc_signals[LAST_SIGNAL] = { 0 };
@@ -121,51 +106,52 @@ gst_xvidenc_profile_get_type (void)
if (!xvidenc_profile_type) {
static const GEnumValue xvidenc_profiles[] = {
- { XVID_PROFILE_S_L0, "S_L0", "Simple profile, L0" },
- { XVID_PROFILE_S_L1, "S_L1", "Simple profile, L1" },
- { XVID_PROFILE_S_L2, "S_L2", "Simple profile, L2" },
- { XVID_PROFILE_S_L3, "S_L3", "Simple profile, L3" },
- { XVID_PROFILE_ARTS_L1, "ARTS_L1", "Advanced real-time simple profile, L1" },
- { XVID_PROFILE_ARTS_L2, "ARTS_L2", "Advanced real-time simple profile, L2" },
- { XVID_PROFILE_ARTS_L3, "ARTS_L3", "Advanced real-time simple profile, L3" },
- { XVID_PROFILE_ARTS_L4, "ARTS_L4", "Advanced real-time simple profile, L4" },
- { XVID_PROFILE_AS_L0, "AS_L0", "Advanced simple profile, L0" },
- { XVID_PROFILE_AS_L1, "AS_L1", "Advanced simple profile, L1" },
- { XVID_PROFILE_AS_L2, "AS_L2", "Advanced simple profile, L2" },
- { XVID_PROFILE_AS_L3, "AS_L3", "Advanced simple profile, L3" },
- { XVID_PROFILE_AS_L4, "AS_L4", "Advanced simple profile, L4" },
- { 0, NULL, NULL },
+ {XVID_PROFILE_S_L0, "S_L0", "Simple profile, L0"},
+ {XVID_PROFILE_S_L1, "S_L1", "Simple profile, L1"},
+ {XVID_PROFILE_S_L2, "S_L2", "Simple profile, L2"},
+ {XVID_PROFILE_S_L3, "S_L3", "Simple profile, L3"},
+ {XVID_PROFILE_ARTS_L1, "ARTS_L1",
+ "Advanced real-time simple profile, L1"},
+ {XVID_PROFILE_ARTS_L2, "ARTS_L2",
+ "Advanced real-time simple profile, L2"},
+ {XVID_PROFILE_ARTS_L3, "ARTS_L3",
+ "Advanced real-time simple profile, L3"},
+ {XVID_PROFILE_ARTS_L4, "ARTS_L4",
+ "Advanced real-time simple profile, L4"},
+ {XVID_PROFILE_AS_L0, "AS_L0", "Advanced simple profile, L0"},
+ {XVID_PROFILE_AS_L1, "AS_L1", "Advanced simple profile, L1"},
+ {XVID_PROFILE_AS_L2, "AS_L2", "Advanced simple profile, L2"},
+ {XVID_PROFILE_AS_L3, "AS_L3", "Advanced simple profile, L3"},
+ {XVID_PROFILE_AS_L4, "AS_L4", "Advanced simple profile, L4"},
+ {0, NULL, NULL},
};
xvidenc_profile_type =
- g_enum_register_static ("GstXvidEncProfiles",
- xvidenc_profiles);
+ g_enum_register_static ("GstXvidEncProfiles", xvidenc_profiles);
}
return xvidenc_profile_type;
}
GType
-gst_xvidenc_get_type(void)
+gst_xvidenc_get_type (void)
{
static GType xvidenc_type = 0;
- if (!xvidenc_type)
- {
+ if (!xvidenc_type) {
static const GTypeInfo xvidenc_info = {
- sizeof(GstXvidEncClass),
+ sizeof (GstXvidEncClass),
gst_xvidenc_base_init,
NULL,
(GClassInitFunc) gst_xvidenc_class_init,
NULL,
NULL,
- sizeof(GstXvidEnc),
+ sizeof (GstXvidEnc),
0,
(GInstanceInitFunc) gst_xvidenc_init,
};
- xvidenc_type = g_type_register_static(GST_TYPE_ELEMENT,
- "GstXvidEnc",
- &xvidenc_info, 0);
+ xvidenc_type = g_type_register_static (GST_TYPE_ELEMENT,
+ "GstXvidEnc", &xvidenc_info, 0);
}
return xvidenc_type;
}
@@ -176,14 +162,14 @@ gst_xvidenc_base_init (gpointer g_class)
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&sink_template));
+ gst_static_pad_template_get (&sink_template));
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&src_template));
+ gst_static_pad_template_get (&src_template));
gst_element_class_set_details (element_class, &gst_xvidenc_details);
}
static void
-gst_xvidenc_class_init (GstXvidEncClass *klass)
+gst_xvidenc_class_init (GstXvidEncClass * klass)
{
GstElementClass *gstelement_class;
GObjectClass *gobject_class;
@@ -191,70 +177,66 @@ gst_xvidenc_class_init (GstXvidEncClass *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);
/* encoding profile */
- g_object_class_install_property(gobject_class, ARG_PROFILE,
- g_param_spec_enum("profile", "Profile", "XviD/MPEG-4 encoding profile",
- GST_TYPE_XVIDENC_PROFILE, XVID_PROFILE_S_L0,
- G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_PROFILE,
+ g_param_spec_enum ("profile", "Profile", "XviD/MPEG-4 encoding profile",
+ GST_TYPE_XVIDENC_PROFILE, XVID_PROFILE_S_L0, G_PARAM_READWRITE));
/* bitrate */
- g_object_class_install_property(gobject_class, ARG_BITRATE,
- g_param_spec_int("bitrate","Bitrate",
- "Target video bitrate (kbps)",
- 0,G_MAXINT,512,G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_BITRATE,
+ g_param_spec_int ("bitrate", "Bitrate",
+ "Target video bitrate (kbps)", 0, G_MAXINT, 512, G_PARAM_READWRITE));
/* keyframe interval */
- g_object_class_install_property(gobject_class, ARG_MAXKEYINTERVAL,
- g_param_spec_int("max_key_interval","Max. Key Interval",
- "Maximum number of frames between two keyframes",
- 0,G_MAXINT,0,G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_MAXKEYINTERVAL,
+ g_param_spec_int ("max_key_interval", "Max. Key Interval",
+ "Maximum number of frames between two keyframes",
+ 0, G_MAXINT, 0, G_PARAM_READWRITE));
- g_object_class_install_property(gobject_class, ARG_BUFSIZE,
- g_param_spec_ulong("buffer_size", "Buffer Size",
- "Size of the video buffers",
- 0,G_MAXULONG,0,G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_BUFSIZE,
+ g_param_spec_ulong ("buffer_size", "Buffer Size",
+ "Size of the video buffers", 0, G_MAXULONG, 0, G_PARAM_READWRITE));
gobject_class->set_property = gst_xvidenc_set_property;
gobject_class->get_property = gst_xvidenc_get_property;
gstelement_class->change_state = gst_xvidenc_change_state;
gst_xvidenc_signals[FRAME_ENCODED] =
- g_signal_new ("frame-encoded", G_TYPE_FROM_CLASS(klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstXvidEncClass, frame_encoded),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("frame-encoded", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstXvidEncClass, frame_encoded),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}
static void
-gst_xvidenc_init (GstXvidEnc *xvidenc)
+gst_xvidenc_init (GstXvidEnc * xvidenc)
{
- gst_xvid_init();
+ gst_xvid_init ();
/* create the sink pad */
- xvidenc->sinkpad = gst_pad_new_from_template(
- gst_static_pad_template_get (&sink_template),
- "sink");
- gst_element_add_pad(GST_ELEMENT(xvidenc), xvidenc->sinkpad);
+ xvidenc->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&sink_template),
+ "sink");
+ gst_element_add_pad (GST_ELEMENT (xvidenc), xvidenc->sinkpad);
- gst_pad_set_chain_function(xvidenc->sinkpad, gst_xvidenc_chain);
- gst_pad_set_link_function(xvidenc->sinkpad, gst_xvidenc_link);
+ gst_pad_set_chain_function (xvidenc->sinkpad, gst_xvidenc_chain);
+ gst_pad_set_link_function (xvidenc->sinkpad, gst_xvidenc_link);
/* create the src pad */
- xvidenc->srcpad = gst_pad_new_from_template(
- gst_static_pad_template_get (&src_template),
- "src");
- gst_element_add_pad(GST_ELEMENT(xvidenc), xvidenc->srcpad);
+ xvidenc->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&src_template),
+ "src");
+ gst_element_add_pad (GST_ELEMENT (xvidenc), xvidenc->srcpad);
/* bitrate, etc. */
xvidenc->width = xvidenc->height = xvidenc->csp = xvidenc->stride = -1;
xvidenc->profile = XVID_PROFILE_S_L0;
xvidenc->bitrate = 512;
xvidenc->max_b_frames = 2;
- xvidenc->max_key_interval = -1; /* default - 2*fps */
+ xvidenc->max_key_interval = -1; /* default - 2*fps */
xvidenc->buffer_size = 512;
/* set xvid handle to NULL */
@@ -263,7 +245,7 @@ gst_xvidenc_init (GstXvidEnc *xvidenc)
static gboolean
-gst_xvidenc_setup (GstXvidEnc *xvidenc)
+gst_xvidenc_setup (GstXvidEnc * xvidenc)
{
xvid_enc_create_t xenc;
xvid_enc_plugin_t xplugin;
@@ -277,11 +259,11 @@ gst_xvidenc_setup (GstXvidEnc *xvidenc)
xenc.height = xvidenc->height;
xenc.max_bframes = xvidenc->max_b_frames;
xenc.global = XVID_GLOBAL_PACKED;
+
xenc.fbase = 1000000;
- xenc.fincr = (int)(xenc.fbase / xvidenc->fps);
+ xenc.fincr = (int) (xenc.fbase / xvidenc->fps);
xenc.max_key_interval = (xvidenc->max_key_interval == -1) ?
- (2 * xenc.fbase / xenc.fincr) :
- xvidenc->max_key_interval;
+ (2 * xenc.fbase / xenc.fincr) : xvidenc->max_key_interval;
xenc.handle = NULL;
/* CBR bitrate/quant for now */
@@ -297,11 +279,9 @@ gst_xvidenc_setup (GstXvidEnc *xvidenc)
xenc.plugins[0].func = xvid_plugin_single;
xenc.plugins[0].param = &xsingle;
- if ((ret = xvid_encore(NULL, XVID_ENC_CREATE,
- &xenc, NULL)) < 0) {
+ if ((ret = xvid_encore (NULL, XVID_ENC_CREATE, &xenc, NULL)) < 0) {
GST_ELEMENT_ERROR (xvidenc, LIBRARY, INIT, (NULL),
- ("Error setting up xvid encoder: %s (%d)",
- gst_xvid_error(ret), ret));
+ ("Error setting up xvid encoder: %s (%d)", gst_xvid_error (ret), ret));
return FALSE;
}
@@ -312,75 +292,73 @@ gst_xvidenc_setup (GstXvidEnc *xvidenc)
static void
-gst_xvidenc_chain (GstPad *pad,
- GstData *_data)
+gst_xvidenc_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
- GstXvidEnc *xvidenc = GST_XVIDENC(GST_OBJECT_PARENT(pad));
+ GstXvidEnc *xvidenc = GST_XVIDENC (GST_OBJECT_PARENT (pad));
GstBuffer *outbuf;
xvid_enc_frame_t xframe;
xvid_enc_stats_t xstats;
gint ret;
- g_return_if_fail(pad != NULL);
- g_return_if_fail(GST_IS_PAD(pad));
+ g_return_if_fail (pad != NULL);
+ g_return_if_fail (GST_IS_PAD (pad));
- outbuf = gst_buffer_new_and_alloc(xvidenc->buffer_size << 10);
- GST_BUFFER_TIMESTAMP(outbuf) = GST_BUFFER_TIMESTAMP(buf);
- GST_BUFFER_DURATION(outbuf) = GST_BUFFER_DURATION(buf);
+ outbuf = gst_buffer_new_and_alloc (xvidenc->buffer_size << 10);
+ GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
+ GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buf);
/* encode and so ... */
gst_xvid_init_struct (xframe);
- xframe.vol_flags = XVID_VOL_MPEGQUANT |
- XVID_VOL_GMC;
+ xframe.vol_flags = XVID_VOL_MPEGQUANT | XVID_VOL_GMC;
xframe.par = XVID_PAR_11_VGA;
xframe.vop_flags = XVID_VOP_TRELLISQUANT;
xframe.motion = 0;
xframe.input.csp = xvidenc->csp;
if (xvidenc->width == xvidenc->stride) {
- xframe.input.plane[0] = GST_BUFFER_DATA(buf);
- xframe.input.plane[1] = xframe.input.plane[0] + (xvidenc->width * xvidenc->height);
- xframe.input.plane[2] = xframe.input.plane[1] + (xvidenc->width * xvidenc->height / 4);
+ xframe.input.plane[0] = GST_BUFFER_DATA (buf);
+ xframe.input.plane[1] =
+ xframe.input.plane[0] + (xvidenc->width * xvidenc->height);
+ xframe.input.plane[2] =
+ xframe.input.plane[1] + (xvidenc->width * xvidenc->height / 4);
xframe.input.stride[0] = xvidenc->width;
xframe.input.stride[1] = xvidenc->width / 2;
xframe.input.stride[2] = xvidenc->width / 2;
} else {
- xframe.input.plane[0] = GST_BUFFER_DATA(buf);
+ xframe.input.plane[0] = GST_BUFFER_DATA (buf);
xframe.input.stride[0] = xvidenc->stride;
}
xframe.type = XVID_TYPE_AUTO;
- xframe.bitstream = (void *) GST_BUFFER_DATA(outbuf);
- xframe.length = GST_BUFFER_MAXSIZE(outbuf);
+ xframe.bitstream = (void *) GST_BUFFER_DATA (outbuf);
+ xframe.length = GST_BUFFER_MAXSIZE (outbuf);
gst_xvid_init_struct (xstats);
- if ((ret = xvid_encore(xvidenc->handle, XVID_ENC_ENCODE,
- &xframe, &xstats)) < 0) {
+ if ((ret = xvid_encore (xvidenc->handle, XVID_ENC_ENCODE,
+ &xframe, &xstats)) < 0) {
GST_ELEMENT_ERROR (xvidenc, LIBRARY, ENCODE, (NULL),
- ("Error encoding xvid frame: %s (%d)",
- gst_xvid_error(ret), ret));
- gst_buffer_unref(buf);
- gst_buffer_unref(outbuf);
+ ("Error encoding xvid frame: %s (%d)", gst_xvid_error (ret), ret));
+ gst_buffer_unref (buf);
+ gst_buffer_unref (outbuf);
return;
}
- GST_BUFFER_SIZE(outbuf) = xstats.length;
+ GST_BUFFER_SIZE (outbuf) = xstats.length;
if (xframe.out_flags & XVID_KEYFRAME)
- GST_BUFFER_FLAG_SET(outbuf, GST_BUFFER_KEY_UNIT);
+ GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_KEY_UNIT);
/* go out, multiply! */
- gst_pad_push(xvidenc->srcpad, GST_DATA (outbuf));
+ gst_pad_push (xvidenc->srcpad, GST_DATA (outbuf));
/* proclaim destiny */
- g_signal_emit(G_OBJECT(xvidenc),gst_xvidenc_signals[FRAME_ENCODED], 0);
+ g_signal_emit (G_OBJECT (xvidenc), gst_xvidenc_signals[FRAME_ENCODED], 0);
/* until the final judgement */
- gst_buffer_unref(buf);
+ gst_buffer_unref (buf);
}
static GstPadLinkReturn
-gst_xvidenc_link (GstPad *pad,
- const GstCaps *vscaps)
+gst_xvidenc_link (GstPad * pad, const GstCaps * vscaps)
{
GstXvidEnc *xvidenc;
GstStructure *structure;
@@ -389,11 +367,11 @@ gst_xvidenc_link (GstPad *pad,
double fps;
gint xvid_cs = -1, stride = -1;
- xvidenc = GST_XVIDENC(gst_pad_get_parent (pad));
+ xvidenc = GST_XVIDENC (gst_pad_get_parent (pad));
/* if there's something old around, remove it */
if (xvidenc->handle) {
- xvid_encore(xvidenc->handle, XVID_ENC_DESTROY, NULL, NULL);
+ xvid_encore (xvidenc->handle, XVID_ENC_DESTROY, NULL, NULL);
xvidenc->handle = NULL;
}
@@ -414,19 +392,18 @@ gst_xvidenc_link (GstPad *pad,
xvidenc->stride = stride;
xvidenc->fps = fps;
- if (gst_xvidenc_setup(xvidenc)) {
+ if (gst_xvidenc_setup (xvidenc)) {
GstPadLinkReturn ret;
GstCaps *new_caps;
- new_caps = gst_caps_new_simple("video/x-xvid",
- "width", G_TYPE_INT, w,
- "height", G_TYPE_INT, h,
- "framerate", G_TYPE_DOUBLE, fps, NULL);
- ret = gst_pad_try_set_caps(xvidenc->srcpad, new_caps);
+ new_caps = gst_caps_new_simple ("video/x-xvid",
+ "width", G_TYPE_INT, w,
+ "height", G_TYPE_INT, h, "framerate", G_TYPE_DOUBLE, fps, NULL);
+ ret = gst_pad_try_set_caps (xvidenc->srcpad, new_caps);
if (GST_PAD_LINK_FAILED (ret)) {
if (xvidenc->handle) {
- xvid_encore(xvidenc->handle, XVID_ENC_DESTROY, NULL, NULL);
- xvidenc->handle = NULL;
+ xvid_encore (xvidenc->handle, XVID_ENC_DESTROY, NULL, NULL);
+ xvidenc->handle = NULL;
}
}
@@ -439,30 +416,27 @@ gst_xvidenc_link (GstPad *pad,
static void
-gst_xvidenc_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gst_xvidenc_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstXvidEnc *xvidenc;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_XVIDENC (object));
- xvidenc = GST_XVIDENC(object);
+ xvidenc = GST_XVIDENC (object);
- switch (prop_id)
- {
+ switch (prop_id) {
case ARG_PROFILE:
- xvidenc->profile = g_value_get_enum(value);
+ xvidenc->profile = g_value_get_enum (value);
break;
case ARG_BITRATE:
- xvidenc->bitrate = g_value_get_int(value);
+ xvidenc->bitrate = g_value_get_int (value);
break;
case ARG_BUFSIZE:
- xvidenc->buffer_size = g_value_get_int(value);
+ xvidenc->buffer_size = g_value_get_int (value);
break;
case ARG_MAXKEYINTERVAL:
- xvidenc->max_key_interval = g_value_get_int(value);
+ xvidenc->max_key_interval = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -472,29 +446,27 @@ gst_xvidenc_set_property (GObject *object,
static void
-gst_xvidenc_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gst_xvidenc_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
{
GstXvidEnc *xvidenc;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_XVIDENC (object));
- xvidenc = GST_XVIDENC(object);
+ xvidenc = GST_XVIDENC (object);
switch (prop_id) {
case ARG_PROFILE:
- g_value_set_enum(value, xvidenc->profile);
+ g_value_set_enum (value, xvidenc->profile);
break;
case ARG_BITRATE:
- g_value_set_int(value, xvidenc->bitrate);
+ g_value_set_int (value, xvidenc->bitrate);
break;
case ARG_BUFSIZE:
- g_value_set_int(value, xvidenc->buffer_size);
+ g_value_set_int (value, xvidenc->buffer_size);
break;
case ARG_MAXKEYINTERVAL:
- g_value_set_int(value, xvidenc->max_key_interval);
+ g_value_set_int (value, xvidenc->max_key_interval);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -503,15 +475,15 @@ gst_xvidenc_get_property (GObject *object,
}
static GstElementStateReturn
-gst_xvidenc_change_state (GstElement *element)
+gst_xvidenc_change_state (GstElement * element)
{
GstXvidEnc *xvidenc = GST_XVIDENC (element);
switch (GST_STATE_PENDING (element)) {
case GST_STATE_PAUSED_TO_READY:
if (xvidenc->handle) {
- xvid_encore(xvidenc->handle, XVID_ENC_DESTROY, NULL, NULL);
- xvidenc->handle = NULL;
+ xvid_encore (xvidenc->handle, XVID_ENC_DESTROY, NULL, NULL);
+ xvidenc->handle = NULL;
}
break;
default:
diff --git a/ext/xvid/gstxvidenc.h b/ext/xvid/gstxvidenc.h
index 356ce53f..fa786617 100644
--- a/ext/xvid/gstxvidenc.h
+++ b/ext/xvid/gstxvidenc.h
@@ -24,8 +24,9 @@
#include "gstxvid.h"
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_XVIDENC \
@@ -39,46 +40,48 @@ extern "C" {
#define GST_IS_XVIDENC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_XVIDENC))
-typedef struct _GstXvidEnc GstXvidEnc;
-typedef struct _GstXvidEncClass GstXvidEncClass;
+ typedef struct _GstXvidEnc GstXvidEnc;
+ typedef struct _GstXvidEncClass GstXvidEncClass;
-struct _GstXvidEnc {
- GstElement element;
+ struct _GstXvidEnc
+ {
+ GstElement element;
- /* pads */
- GstPad *sinkpad, *srcpad;
+ /* pads */
+ GstPad *sinkpad, *srcpad;
- /* encoding profile */
- gint profile;
+ /* encoding profile */
+ gint profile;
- /* quality of encoded image */
- gint bitrate;
- gint buffer_size;
+ /* quality of encoded image */
+ gint bitrate;
+ gint buffer_size;
- /* max number of B frames between I/P */
- gint max_b_frames;
+ /* max number of B frames between I/P */
+ gint max_b_frames;
- /* max key interval */
- gint max_key_interval;
+ /* max key interval */
+ gint max_key_interval;
- /* xvid handle */
- void *handle;
- gint csp;
- gint width, height, stride;
- gdouble fps;
-};
+ /* xvid handle */
+ void *handle;
+ gint csp;
+ gint width, height, stride;
+ gdouble fps;
+ };
-struct _GstXvidEncClass {
- GstElementClass parent_class;
+ struct _GstXvidEncClass
+ {
+ GstElementClass parent_class;
- /* signals */
- void (*frame_encoded) (GstElement *element);
-};
+ /* signals */
+ void (*frame_encoded) (GstElement * element);
+ };
-GType gst_xvidenc_get_type(void);
+ GType gst_xvidenc_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_XVIDENC_H__ */
+#endif /* __GST_XVIDENC_H__ */