diff options
author | Luis de Bethencourt <luis@debethencourt.com> | 2012-05-08 16:39:02 +0100 |
---|---|---|
committer | Luis de Bethencourt <luis@debethencourt.com> | 2012-05-09 13:18:53 +0100 |
commit | 3db482093d3bbd2585439f6f312d1252c6c6e83c (patch) | |
tree | cae021b6a4501ceff7db4862be31f81a52d77595 /gst/gaudieffects | |
parent | c123ac0735d5513dd37fda2f64d2e5f05a3ddf23 (diff) | |
download | gstreamer-plugins-bad-3db482093d3bbd2585439f6f312d1252c6c6e83c.tar.gz |
gaudieffects: port chromium to 0.11
Diffstat (limited to 'gst/gaudieffects')
-rw-r--r-- | gst/gaudieffects/gstchromium.c | 76 | ||||
-rw-r--r-- | gst/gaudieffects/gstchromium.h | 3 |
2 files changed, 41 insertions, 38 deletions
diff --git a/gst/gaudieffects/gstchromium.c b/gst/gaudieffects/gstchromium.c index b8870fc4c..8a6c433f1 100644 --- a/gst/gaudieffects/gstchromium.c +++ b/gst/gaudieffects/gstchromium.c @@ -1,7 +1,7 @@ /* * GStreamer - * Copyright (C) 2010 Luis de Bethencourt <luis@debethencourt.com> - * + * Copyright (C) <2010-2012> Luis de Bethencourt <luis@debethencourt.com> + * * Chromium - burning chrome video effect. * Based on Pete Warden's FreeFrame plugin with the same name. * @@ -67,17 +67,17 @@ #include "gstplugin.h" #include "gstchromium.h" -#include <gst/video/video.h> - GST_DEBUG_CATEGORY_STATIC (gst_chromium_debug); #define GST_CAT_DEFAULT gst_chromium_debug #if G_BYTE_ORDER == G_LITTLE_ENDIAN -#define CAPS_STR GST_VIDEO_CAPS_BGRx ";" GST_VIDEO_CAPS_RGBx +#define CAPS_STR GST_VIDEO_CAPS_MAKE ("{ BGRx, RGBx }") #else -#define CAPS_STR GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_xBGR +#define CAPS_STR GST_VIDEO_CAPS_MAKE ("{ xBGR, xRGB }") #endif +G_DEFINE_TYPE (GstChromium, gst_chromium, GST_TYPE_VIDEO_FILTER); + /* Filter signals and args. */ enum { @@ -127,9 +127,6 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src", GST_STATIC_CAPS (CAPS_STR) ); -GST_BOILERPLATE (GstChromium, gst_chromium, GstVideoFilter, - GST_TYPE_VIDEO_FILTER); - static void gst_chromium_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void gst_chromium_get_property (GObject * object, guint prop_id, @@ -142,29 +139,23 @@ static GstFlowReturn gst_chromium_transform (GstBaseTransform * btrans, /* GObject vmethod implementations */ +/* Initialize the chromium's class. */ static void -gst_chromium_base_init (gpointer gclass) +gst_chromium_class_init (GstChromiumClass * klass) { - GstElementClass *element_class = GST_ELEMENT_CLASS (gclass); + GObjectClass *gobject_class = (GObjectClass *) klass; + GstElementClass *gstelement_class = (GstElementClass *) klass; + GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass; - gst_element_class_set_details_simple (element_class, - "Chromium", + gst_element_class_set_details_simple (gstelement_class, "Chromium", "Filter/Effect/Video", "Chromium breaks the colors of the video signal.", "Luis de Bethencourt <luis@debethencourt.com>"); - gst_element_class_add_pad_template (element_class, + gst_element_class_add_pad_template (gstelement_class, gst_static_pad_template_get (&src_factory)); - gst_element_class_add_pad_template (element_class, + gst_element_class_add_pad_template (gstelement_class, gst_static_pad_template_get (&sink_factory)); -} - -/* Initialize the chromium's class. */ -static void -gst_chromium_class_init (GstChromiumClass * klass) -{ - GObjectClass *gobject_class = (GObjectClass *) klass; - GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass; gobject_class->set_property = gst_chromium_set_property; gobject_class->get_property = gst_chromium_get_property; @@ -193,7 +184,7 @@ gst_chromium_class_init (GstChromiumClass * klass) * initialize instance structure. */ static void -gst_chromium_init (GstChromium * filter, GstChromiumClass * gclass) +gst_chromium_init (GstChromium * filter) { filter->edge_a = DEFAULT_EDGE_A; filter->edge_b = DEFAULT_EDGE_B; @@ -256,20 +247,25 @@ static gboolean gst_chromium_set_caps (GstBaseTransform * btrans, GstCaps * incaps, GstCaps * outcaps) { - GstChromium *filter = GST_CHROMIUM (btrans); - GstStructure *structure; - gboolean ret = FALSE; + GstChromium *chromium = GST_CHROMIUM (btrans); + GstVideoInfo info; - structure = gst_caps_get_structure (incaps, 0); + if (!gst_video_info_from_caps (&info, incaps)) + goto invalid_caps; - GST_OBJECT_LOCK (filter); - if (gst_structure_get_int (structure, "width", &filter->width) && - gst_structure_get_int (structure, "height", &filter->height)) { - ret = TRUE; - } - GST_OBJECT_UNLOCK (filter); + chromium->info = info; + + chromium->width = GST_VIDEO_INFO_WIDTH (&info); + chromium->height = GST_VIDEO_INFO_HEIGHT (&info); + + return TRUE; - return ret; + /* ERRORS */ +invalid_caps: + { + GST_DEBUG_OBJECT (btrans, "could not parse caps"); + return FALSE; + } } /* Actual processing. */ @@ -279,10 +275,16 @@ gst_chromium_transform (GstBaseTransform * btrans, { GstChromium *filter = GST_CHROMIUM (btrans); gint video_size, edge_a, edge_b; - guint32 *src = (guint32 *) GST_BUFFER_DATA (in_buf); - guint32 *dest = (guint32 *) GST_BUFFER_DATA (out_buf); + guint32 *src, *dest; GstClockTime timestamp; gint64 stream_time; + GstVideoFrame in_frame, out_frame; + + gst_video_frame_map (&in_frame, &filter->info, in_buf, GST_MAP_READ); + gst_video_frame_map (&out_frame, &filter->info, out_buf, GST_MAP_WRITE); + + src = GST_VIDEO_FRAME_PLANE_DATA (&in_frame, 0); + dest = GST_VIDEO_FRAME_PLANE_DATA (&out_frame, 0); /* GstController: update the properties */ timestamp = GST_BUFFER_TIMESTAMP (in_buf); diff --git a/gst/gaudieffects/gstchromium.h b/gst/gaudieffects/gstchromium.h index 4f41f1d7a..e93b34f69 100644 --- a/gst/gaudieffects/gstchromium.h +++ b/gst/gaudieffects/gstchromium.h @@ -1,7 +1,7 @@ /* * GStreamer * Copyright (C) 2010 Luis de Bethencourt <luis@debethencourt.com>> - * + * * Chromium - burning chrome video effect. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -71,6 +71,7 @@ struct GstChromium gint width, height; /* < private > */ + GstVideoInfo info; gint edge_a, edge_b; gboolean silent; }; |