[cogl] cogl-gst: More pedantic style fixes
- From: Neil Roberts <nroberts src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl] cogl-gst: More pedantic style fixes
- Date: Thu, 21 Mar 2013 19:00:52 +0000 (UTC)
commit 3ffe8979da4d4dc7deb221e5653b6f24f41b412c
Author: Neil Roberts <neil linux intel com>
Date: Tue Mar 19 19:37:19 2013 +0000
cogl-gst: More pedantic style fixes
• Fixes some overly long lines, hugging asterisks in the pointer type
declarations and indentation issues.
• Tidies up the GLSL source so that it will look nicer in the
debug output.
• Removes the backwards ‘parent_class’ define which hacks the
implementation of the G_DEFINE_TYPE macro and just uses the full
type name instead.
Reviewed-by: Robert Bragg <robert linux intel com>
cogl-gst/cogl-gst-plugin.c | 28 +++++-----
cogl-gst/cogl-gst-shader.c | 20 ++++--
cogl-gst/cogl-gst-video-sink.c | 120 +++++++++++++++++++++-------------------
3 files changed, 90 insertions(+), 78 deletions(-)
---
diff --git a/cogl-gst/cogl-gst-plugin.c b/cogl-gst/cogl-gst-plugin.c
index 9588146..c710074 100644
--- a/cogl-gst/cogl-gst-plugin.c
+++ b/cogl-gst/cogl-gst-plugin.c
@@ -43,20 +43,20 @@
#define VERSION "0.0"
static CoglBool
-_plugin_init (GstPlugin * coglgstvideosink)
+_plugin_init (GstPlugin *coglgstvideosink)
{
- return gst_element_register (coglgstvideosink, "coglsink", GST_RANK_PRIMARY,
- COGL_GST_TYPE_VIDEO_SINK);
+ return gst_element_register (coglgstvideosink,
+ "coglsink",
+ GST_RANK_PRIMARY,
+ COGL_GST_TYPE_VIDEO_SINK);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- cogl,
- "Sends video data from GStreamer to a Cogl pipeline",
- _plugin_init,
- VERSION,
- "LGPL",
- "CoglGst",
- "http://gstreamer.net/"
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ cogl,
+ "Sends video data from GStreamer to a Cogl pipeline",
+ _plugin_init,
+ VERSION,
+ "LGPL",
+ "CoglGst",
+ "http://gstreamer.net/")
diff --git a/cogl-gst/cogl-gst-shader.c b/cogl-gst/cogl-gst-shader.c
index bd765bc..bc11f18 100644
--- a/cogl-gst/cogl-gst-shader.c
+++ b/cogl-gst/cogl-gst-shader.c
@@ -38,13 +38,17 @@
const char
_cogl_gst_shader_rgba_to_rgba_decl[] =
- "vec4 cogl_gst_sample_video (vec2 UV) {\n"
+ "vec4\n"
+ "cogl_gst_sample_video (vec2 UV)\n"
+ "{\n"
" return texture2D (cogl_sampler0, UV);\n"
- "}";
+ "}\n";
const char
_cogl_gst_shader_yv12_to_rgba_decl[] =
- "vec4 cogl_gst_sample_video (vec2 UV) {\n"
+ "vec4\n"
+ "cogl_gst_sample_video (vec2 UV)\n"
+ "{\n"
" float y = 1.1640625 * (texture2D (cogl_sampler0, UV).g - 0.0625);\n"
" float u = texture2D (cogl_sampler1, UV).g - 0.5;\n"
" float v = texture2D (cogl_sampler2, UV).g - 0.5;\n"
@@ -54,11 +58,13 @@ _cogl_gst_shader_yv12_to_rgba_decl[] =
" color.b = y + 2.015625 * u;\n"
" color.a = 1.0;\n"
" return color;\n"
- "}";
+ "}\n";
const char
_cogl_gst_shader_ayuv_to_rgba_decl[] =
- "vec4 cogl_gst_sample_video (vec2 UV) {\n"
+ "vec4\n"
+ "cogl_gst_sample_video (vec2 UV)\n"
+ "{\n"
" vec4 color = texture2D (cogl_sampler0, UV);\n"
" float y = 1.1640625 * (color.g - 0.0625);\n"
" float u = color.b - 0.5;\n"
@@ -68,8 +74,8 @@ _cogl_gst_shader_ayuv_to_rgba_decl[] =
" color.g = y - 0.390625 * u - 0.8125 * v;\n"
" color.b = y + 2.015625 * u;\n"
" return color;\n"
- "}";
+ "}\n";
const char
_cogl_gst_shader_default_sample[] =
- "cogl_layer = cogl_gst_sample_video (cogl_tex_coord0_in.st);";
+ " cogl_layer = cogl_gst_sample_video (cogl_tex_coord0_in.st);\n";
diff --git a/cogl-gst/cogl-gst-video-sink.c b/cogl-gst/cogl-gst-video-sink.c
index cae04dd..414cc06 100644
--- a/cogl-gst/cogl-gst-video-sink.c
+++ b/cogl-gst/cogl-gst-video-sink.c
@@ -47,7 +47,7 @@
#define COGL_GST_TEXTURE_FLAGS \
(COGL_TEXTURE_NO_SLICING | COGL_TEXTURE_NO_ATLAS)
-#define COGL_GST_DEFAULT_PRIORITY (G_PRIORITY_HIGH_IDLE)
+#define COGL_GST_DEFAULT_PRIORITY G_PRIORITY_HIGH_IDLE
#define BASE_SINK_CAPS "{ AYUV," \
"YV12," \
@@ -57,15 +57,14 @@
"RGB," \
"BGR }"
+#define SINK_CAPS GST_VIDEO_CAPS_MAKE (BASE_SINK_CAPS)
-#define SINK_CAPS GST_VIDEO_CAPS_MAKE(BASE_SINK_CAPS)
+static GstStaticPadTemplate sinktemplate_all =
+ GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (SINK_CAPS));
-static GstStaticPadTemplate sinktemplate_all = GST_STATIC_PAD_TEMPLATE ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (SINK_CAPS));
-
-#define cogl_gst_video_sink_parent_class parent_class
G_DEFINE_TYPE (CoglGstVideoSink, cogl_gst_video_sink, GST_TYPE_BASE_SINK);
enum
@@ -93,7 +92,7 @@ typedef enum
COGL_GST_YV12,
COGL_GST_SURFACE,
COGL_GST_I420
-}CoglGstVideoFormat;
+} CoglGstVideoFormat;
typedef enum
{
@@ -107,10 +106,10 @@ typedef struct _CoglGstSource
GMutex buffer_lock;
GstBuffer *buffer;
CoglBool has_new_caps;
-}CoglGstSource;
+} CoglGstSource;
-typedef void (CoglGstRendererPaint) (CoglGstVideoSink*);
-typedef void (CoglGstRendererPostPaint) (CoglGstVideoSink*);
+typedef void (CoglGstRendererPaint) (CoglGstVideoSink *);
+typedef void (CoglGstRendererPostPaint) (CoglGstVideoSink *);
typedef struct _CoglGstRenderer
{
@@ -118,11 +117,11 @@ typedef struct _CoglGstRenderer
CoglGstVideoFormat format;
int flags;
GstStaticCaps caps;
- void (*init) (CoglGstVideoSink *sink);
- void (*deinit) (CoglGstVideoSink *sink);
+ void (*init) (CoglGstVideoSink *sink);
+ void (*deinit) (CoglGstVideoSink *sink);
CoglBool (*upload) (CoglGstVideoSink *sink,
GstBuffer *buffer);
-}CoglGstRenderer;
+} CoglGstRenderer;
struct _CoglGstVideoSinkPrivate
{
@@ -144,7 +143,7 @@ struct _CoglGstVideoSinkPrivate
static void
cogl_gst_source_finalize (GSource *source)
{
- CoglGstSource *gst_source = (CoglGstSource*) source;
+ CoglGstSource *gst_source = (CoglGstSource *) source;
g_mutex_lock (&gst_source->buffer_lock);
if (gst_source->buffer)
@@ -155,7 +154,7 @@ cogl_gst_source_finalize (GSource *source)
}
int
-cogl_gst_video_sink_get_free_layer (CoglGstVideoSink* sink)
+cogl_gst_video_sink_get_free_layer (CoglGstVideoSink *sink)
{
return sink->priv->free_layer;
}
@@ -178,7 +177,7 @@ static CoglBool
cogl_gst_source_prepare (GSource *source,
int *timeout)
{
- CoglGstSource *gst_source = (CoglGstSource*) source;
+ CoglGstSource *gst_source = (CoglGstSource *) source;
*timeout = -1;
@@ -188,7 +187,7 @@ cogl_gst_source_prepare (GSource *source,
static CoglBool
cogl_gst_source_check (GSource *source)
{
- CoglGstSource *gst_source = (CoglGstSource*) source;
+ CoglGstSource *gst_source = (CoglGstSource *) source;
return gst_source->buffer != NULL;
}
@@ -198,7 +197,7 @@ cogl_gst_video_sink_set_priority (CoglGstVideoSink *sink,
int priority)
{
if (sink->priv->source)
- g_source_set_priority ((GSource*) sink->priv->source, priority);
+ g_source_set_priority ((GSource *) sink->priv->source, priority);
}
/* We want to cache the snippets instead of recreating a new one every
@@ -268,7 +267,7 @@ create_template_pipeline (CoglGstVideoSink *sink,
g_signal_emit (sink, video_sink_signals[PIPELINE_READY_SIGNAL], 0, NULL);
}
-CoglPipeline*
+CoglPipeline *
cogl_gst_video_sink_get_pipeline (CoglGstVideoSink *vt)
{
CoglGstVideoSinkPrivate *priv = vt->priv;
@@ -365,7 +364,6 @@ map_fail:
}
}
-
static CoglGstRenderer rgb24_renderer =
{
"RGB 24",
@@ -595,15 +593,15 @@ static void
append_cap (gpointer data,
gpointer user_data)
{
- CoglGstRenderer *renderer = (CoglGstRenderer*) data;
- GstCaps *caps = (GstCaps*) user_data;
+ CoglGstRenderer *renderer = (CoglGstRenderer *) data;
+ GstCaps *caps = (GstCaps *) user_data;
GstCaps *writable_caps;
writable_caps =
gst_caps_make_writable (gst_static_caps_get (&renderer->caps));
gst_caps_append (caps, writable_caps);
}
-static GstCaps*
+static GstCaps *
cogl_gst_build_caps (GSList *renderers)
{
GstCaps *caps;
@@ -616,7 +614,8 @@ cogl_gst_build_caps (GSList *renderers)
}
void
-cogl_gst_video_sink_set_context (CoglGstVideoSink *vt, CoglContext *ctx)
+cogl_gst_video_sink_set_context (CoglGstVideoSink *vt,
+ CoglContext *ctx)
{
CoglGstVideoSinkPrivate *priv = vt->priv;
@@ -643,7 +642,7 @@ cogl_gst_video_sink_set_context (CoglGstVideoSink *vt, CoglContext *ctx)
}
}
-static CoglGstRenderer*
+static CoglGstRenderer *
cogl_gst_find_renderer_by_format (CoglGstVideoSink *sink,
CoglGstVideoFormat format)
{
@@ -653,7 +652,7 @@ cogl_gst_find_renderer_by_format (CoglGstVideoSink *sink,
for (element = priv->renderers; element; element = g_slist_next (element))
{
- CoglGstRenderer *candidate = (CoglGstRenderer*) element->data;
+ CoglGstRenderer *candidate = (CoglGstRenderer *) element->data;
if (candidate->format == format)
{
renderer = candidate;
@@ -664,7 +663,7 @@ cogl_gst_find_renderer_by_format (CoglGstVideoSink *sink,
return renderer;
}
-static GstCaps*
+static GstCaps *
cogl_gst_video_sink_get_caps (GstBaseSink *bsink,
GstCaps *filter)
{
@@ -683,7 +682,7 @@ cogl_gst_video_sink_parse_caps (GstCaps *caps,
GstVideoInfo vinfo;
CoglGstVideoFormat format;
CoglBool bgr = FALSE;
- CoglGstRenderer* renderer;
+ CoglGstRenderer *renderer;
intersection = gst_caps_intersect (priv->caps, caps);
if (gst_caps_is_empty (intersection))
@@ -694,7 +693,8 @@ cogl_gst_video_sink_parse_caps (GstCaps *caps,
if (!gst_video_info_from_caps (&vinfo, caps))
goto unknown_format;
- switch (vinfo.finfo->format) {
+ switch (vinfo.finfo->format)
+ {
case GST_VIDEO_FORMAT_YV12:
format = COGL_GST_YV12;
break;
@@ -723,7 +723,7 @@ cogl_gst_video_sink_parse_caps (GstCaps *caps,
break;
default:
goto unhandled_format;
- }
+ }
renderer = cogl_gst_find_renderer_by_format (sink, format);
@@ -732,14 +732,15 @@ cogl_gst_video_sink_parse_caps (GstCaps *caps,
GST_INFO_OBJECT (sink, "found the %s renderer", renderer->name);
- if (save) {
- priv->info = vinfo;
+ if (save)
+ {
+ priv->info = vinfo;
- priv->format = format;
- priv->bgr = bgr;
+ priv->format = format;
+ priv->bgr = bgr;
- priv->renderer = renderer;
- }
+ priv->renderer = renderer;
+ }
return TRUE;
@@ -793,7 +794,7 @@ cogl_gst_video_sink_set_caps (GstBaseSink *bsink,
static CoglBool
cogl_gst_source_dispatch (GSource *source,
GSourceFunc callback,
- void* user_data)
+ void *user_data)
{
CoglGstSource *gst_source= (CoglGstSource*) source;
CoglGstVideoSinkPrivate *priv = gst_source->sink->priv;
@@ -865,14 +866,14 @@ static GSourceFuncs gst_source_funcs =
cogl_gst_source_finalize
};
-static CoglGstSource*
+static CoglGstSource *
cogl_gst_source_new (CoglGstVideoSink *sink)
{
GSource *source;
CoglGstSource *gst_source;
source = g_source_new (&gst_source_funcs, sizeof (CoglGstSource));
- gst_source = (CoglGstSource*) source;
+ gst_source = (CoglGstSource *) source;
g_source_set_can_recurse (source, TRUE);
g_source_set_priority (source, COGL_GST_DEFAULT_PRIORITY);
@@ -887,7 +888,7 @@ cogl_gst_source_new (CoglGstVideoSink *sink)
static void
cogl_gst_video_sink_init (CoglGstVideoSink *sink)
{
- CoglGstVideoSinkPrivate* priv;
+ CoglGstVideoSinkPrivate *priv;
sink->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (sink,
COGL_GST_TYPE_VIDEO_SINK,
@@ -953,7 +954,7 @@ cogl_gst_video_sink_dispose (GObject *object)
priv->caps = NULL;
}
- G_OBJECT_CLASS(parent_class)->dispose (object);
+ G_OBJECT_CLASS (cogl_gst_video_sink_parent_class)->dispose (object);
}
static void
@@ -963,7 +964,7 @@ cogl_gst_video_sink_finalize (GObject *object)
cogl_gst_video_sink_set_context (self, NULL);
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (cogl_gst_video_sink_parent_class)->finalize (object);
}
static CoglBool
@@ -973,7 +974,7 @@ cogl_gst_video_sink_start (GstBaseSink *base_sink)
CoglGstVideoSinkPrivate *priv = sink->priv;
priv->source = cogl_gst_source_new (sink);
- g_source_attach ((GSource*) priv->source, NULL);
+ g_source_attach ((GSource *) priv->source, NULL);
priv->flow_return = GST_FLOW_OK;
return TRUE;
}
@@ -1009,7 +1010,7 @@ cogl_gst_video_sink_get_property (GObject *object,
switch (prop_id)
{
case PROP_UPDATE_PRIORITY:
- g_value_set_int (value, g_source_get_priority ((GSource*) priv->source));
+ g_value_set_int (value, g_source_get_priority ((GSource *) priv->source));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -1025,7 +1026,7 @@ cogl_gst_video_sink_stop (GstBaseSink *base_sink)
if (priv->source)
{
- GSource *source = (GSource*) priv->source;
+ GSource *source = (GSource *) priv->source;
g_source_destroy (source);
g_source_unref (source);
priv->source = NULL;
@@ -1040,6 +1041,7 @@ cogl_gst_video_sink_class_init (CoglGstVideoSinkClass *klass)
GObjectClass *go_class = G_OBJECT_CLASS (klass);
GstBaseSinkClass *gb_class = GST_BASE_SINK_CLASS (klass);
GstElementClass *ge_class = GST_ELEMENT_CLASS (klass);
+ GstPadTemplate *pad_template;
GParamSpec *pspec;
g_type_class_add_private (klass, sizeof (CoglGstVideoSinkPrivate));
@@ -1048,14 +1050,18 @@ cogl_gst_video_sink_class_init (CoglGstVideoSinkClass *klass)
go_class->dispose = cogl_gst_video_sink_dispose;
go_class->finalize = cogl_gst_video_sink_finalize;
- gst_element_class_add_pad_template (ge_class,
- gst_static_pad_template_get (&sinktemplate_all));
- gst_element_class_set_metadata (ge_class, "Cogl video sink", "Sink/Video",
- "Sends video data from GStreamer to a Cogl pipeline",
- "Jonathan Matthew <jonathan kaolin wh9 net>, "
- "Matthew Allum <mallum o-hand com, "
- "Chris Lord <chris o-hand com>, "
- "Plamena Manolova <plamena n manolova intel com>");
+ pad_template = gst_static_pad_template_get (&sinktemplate_all);
+ gst_element_class_add_pad_template (ge_class, pad_template);
+
+ gst_element_class_set_metadata (ge_class,
+ "Cogl video sink", "Sink/Video",
+ "Sends video data from GStreamer to a "
+ "Cogl pipeline",
+ "Jonathan Matthew <jonathan kaolin wh9 net>, "
+ "Matthew Allum <mallum o-hand com, "
+ "Chris Lord <chris o-hand com>, "
+ "Plamena Manolova "
+ "<plamena n manolova intel com>");
gb_class->render = _cogl_gst_video_sink_render;
gb_class->preroll = _cogl_gst_video_sink_render;
@@ -1096,10 +1102,10 @@ cogl_gst_video_sink_class_init (CoglGstVideoSinkClass *klass)
0 /* n_params */);
}
-CoglGstVideoSink*
+CoglGstVideoSink *
cogl_gst_video_sink_new (CoglContext *ctx)
{
- CoglGstVideoSink* sink = g_object_new (COGL_GST_TYPE_VIDEO_SINK, NULL);
+ CoglGstVideoSink *sink = g_object_new (COGL_GST_TYPE_VIDEO_SINK, NULL);
cogl_gst_video_sink_set_context (sink, ctx);
return sink;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]