From: Sebastian Dröge Date: Fri, 23 Apr 2010 13:14:56 +0000 (+0200) Subject: videoscale: Some random cleanup X-Git-Tag: RELEASE-0.10.30~269 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=838d76dc4b07797d3c119d7820b3bfb36561917d;p=platform%2Fupstream%2Fgst-plugins-base.git videoscale: Some random cleanup --- diff --git a/gst/videoscale/gstvideoscale.c b/gst/videoscale/gstvideoscale.c index c0f2f26..00479e1 100644 --- a/gst/videoscale/gstvideoscale.c +++ b/gst/videoscale/gstvideoscale.c @@ -166,16 +166,20 @@ gst_video_scale_method_get_type (void) static GstCaps * gst_video_scale_get_capslist (void) { - static GstCaps *caps; + static GstCaps *caps = NULL; + static volatile gsize inited = 0; - if (caps == NULL) { - int i; + if (g_once_init_enter (&inited)) { + gint i; + + g_assert (caps == NULL); caps = gst_caps_new_empty (); for (i = 0; i < G_N_ELEMENTS (gst_video_scale_format_caps); i++) gst_caps_append (caps, gst_caps_make_writable (gst_static_caps_get (&gst_video_scale_format_caps[i]))); + g_once_init_leave (&inited, 1); } return caps; @@ -196,9 +200,6 @@ gst_video_scale_sink_template_factory (void) } -static void gst_video_scale_base_init (gpointer g_class); -static void gst_video_scale_class_init (GstVideoScaleClass * klass); -static void gst_video_scale_init (GstVideoScale * videoscale); static void gst_video_scale_finalize (GstVideoScale * videoscale); static gboolean gst_video_scale_src_event (GstBaseTransform * trans, GstEvent * event); @@ -220,33 +221,8 @@ static void gst_video_scale_set_property (GObject * object, guint prop_id, static void gst_video_scale_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); -static GstElementClass *parent_class = NULL; - - -GType -gst_video_scale_get_type (void) -{ - static GType video_scale_type = 0; - - if (!video_scale_type) { - static const GTypeInfo video_scale_info = { - sizeof (GstVideoScaleClass), - gst_video_scale_base_init, - NULL, - (GClassInitFunc) gst_video_scale_class_init, - NULL, - NULL, - sizeof (GstVideoScale), - 0, - (GInstanceInitFunc) gst_video_scale_init, - }; - - video_scale_type = - g_type_register_static (GST_TYPE_BASE_TRANSFORM, "GstVideoScale", - &video_scale_info, 0); - } - return video_scale_type; -} +GST_BOILERPLATE (GstVideoScale, gst_video_scale, GstVideoFilter, + GST_TYPE_VIDEO_FILTER); static void gst_video_scale_base_init (gpointer g_class) @@ -266,11 +242,8 @@ gst_video_scale_base_init (gpointer g_class) static void gst_video_scale_class_init (GstVideoScaleClass * klass) { - GObjectClass *gobject_class; - GstBaseTransformClass *trans_class; - - gobject_class = (GObjectClass *) klass; - trans_class = (GstBaseTransformClass *) klass; + GObjectClass *gobject_class = (GObjectClass *) klass; + GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass; gobject_class->finalize = (GObjectFinalizeFunc) gst_video_scale_finalize; gobject_class->set_property = gst_video_scale_set_property; @@ -291,14 +264,11 @@ gst_video_scale_class_init (GstVideoScaleClass * klass) trans_class->src_event = GST_DEBUG_FUNCPTR (gst_video_scale_src_event); trans_class->passthrough_on_same_caps = TRUE; - - parent_class = g_type_class_peek_parent (klass); } static void -gst_video_scale_init (GstVideoScale * videoscale) +gst_video_scale_init (GstVideoScale * videoscale, GstVideoScaleClass * klass) { - gst_base_transform_set_qos_enabled (GST_BASE_TRANSFORM (videoscale), TRUE); videoscale->tmp_buf = NULL; videoscale->method = DEFAULT_PROP_METHOD; } @@ -352,15 +322,12 @@ static GstCaps * gst_video_scale_transform_caps (GstBaseTransform * trans, GstPadDirection direction, GstCaps * caps) { - GstVideoScale *videoscale; GstCaps *ret; GstStructure *structure; /* this function is always called with a simple caps */ g_return_val_if_fail (GST_CAPS_IS_SIMPLE (caps), NULL); - videoscale = GST_VIDEO_SCALE (trans); - ret = gst_caps_copy (caps); structure = gst_structure_copy (gst_caps_get_structure (ret, 0)); @@ -388,7 +355,7 @@ gst_video_scale_transform_caps (GstBaseTransform * trans, static int gst_video_scale_get_format (GstCaps * caps) { - int i; + gint i; GstCaps *icaps, *scaps; for (i = 0; i < G_N_ELEMENTS (gst_video_scale_format_caps); i++) { @@ -526,11 +493,9 @@ parse_caps (GstCaps * caps, gint * format, gint * width, gint * height, static gboolean gst_video_scale_set_caps (GstBaseTransform * trans, GstCaps * in, GstCaps * out) { - GstVideoScale *videoscale; + GstVideoScale *videoscale = GST_VIDEO_SCALE (trans); gboolean ret; - videoscale = GST_VIDEO_SCALE (trans); - ret = parse_caps (in, &videoscale->format, &videoscale->from_width, &videoscale->from_height, &videoscale->interlaced); ret &= @@ -570,14 +535,12 @@ static gboolean gst_video_scale_get_unit_size (GstBaseTransform * trans, GstCaps * caps, guint * size) { - GstVideoScale *videoscale; + GstVideoScale *videoscale = GST_VIDEO_SCALE (trans); gint format, width, height; VSImage img; g_assert (size); - videoscale = GST_VIDEO_SCALE (trans); - if (!parse_caps (caps, &format, &width, &height, NULL)) return FALSE; @@ -1071,13 +1034,11 @@ unknown_mode: static gboolean gst_video_scale_src_event (GstBaseTransform * trans, GstEvent * event) { - GstVideoScale *videoscale; + GstVideoScale *videoscale = GST_VIDEO_SCALE (trans); gboolean ret; - double a; + gdouble a; GstStructure *structure; - videoscale = GST_VIDEO_SCALE (trans); - GST_DEBUG_OBJECT (videoscale, "handling %s event", GST_EVENT_TYPE_NAME (event)); @@ -1096,8 +1057,6 @@ gst_video_scale_src_event (GstBaseTransform * trans, GstEvent * event) a * videoscale->from_height / videoscale->to_height, NULL); } break; - case GST_EVENT_QOS: - break; default: break; } diff --git a/gst/videoscale/gstvideoscale.h b/gst/videoscale/gstvideoscale.h index 9ccb575..6b2cbfe 100644 --- a/gst/videoscale/gstvideoscale.h +++ b/gst/videoscale/gstvideoscale.h @@ -22,6 +22,7 @@ #include #include +#include #include "vs_image.h" @@ -64,7 +65,7 @@ typedef struct _GstVideoScaleClass GstVideoScaleClass; * Opaque data structure */ struct _GstVideoScale { - GstBaseTransform element; + GstVideoFilter element; GstVideoScaleMethod method; @@ -85,7 +86,7 @@ struct _GstVideoScale { }; struct _GstVideoScaleClass { - GstBaseTransformClass parent_class; + GstVideoFilterClass parent_class; }; GType gst_video_scale_get_type(void);