From e78f5817e59f6eab61551dc70ce885f2909d00b8 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Tue, 8 May 2012 17:38:22 +0100 Subject: [PATCH] gaudieffects: port dodge to 0.11 --- gst/gaudieffects/gstdodge.c | 80 +++++++++++++++++++------------------ gst/gaudieffects/gstdodge.h | 6 ++- 2 files changed, 46 insertions(+), 40 deletions(-) diff --git a/gst/gaudieffects/gstdodge.c b/gst/gaudieffects/gstdodge.c index 5e9231cbd5..ff941fa6db 100644 --- a/gst/gaudieffects/gstdodge.c +++ b/gst/gaudieffects/gstdodge.c @@ -1,7 +1,7 @@ /* * GStreamer - * Copyright (C) 2010 Luis de Bethencourt - * + * Copyright (C) <2010-2012> Luis de Bethencourt + * * Dodge - saturation video effect. * Based on Pete Warden's FreeFrame plugin with the same name. * @@ -67,15 +67,13 @@ #include "gstplugin.h" #include "gstdodge.h" -#include - GST_DEBUG_CATEGORY_STATIC (gst_dodge_debug); #define GST_CAT_DEFAULT gst_dodge_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 /* Filter signals and args. */ @@ -109,7 +107,7 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src", GST_STATIC_CAPS (CAPS_STR) ); -GST_BOILERPLATE (GstDodge, gst_dodge, GstVideoFilter, GST_TYPE_VIDEO_FILTER); +G_DEFINE_TYPE (GstDodge, gst_dodge, GST_TYPE_VIDEO_FILTER); static void gst_dodge_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); @@ -123,30 +121,25 @@ static GstFlowReturn gst_dodge_transform (GstBaseTransform * btrans, /* GObject vmethod implementations */ -static void -gst_dodge_base_init (gpointer gclass) -{ - GstElementClass *element_class = GST_ELEMENT_CLASS (gclass); - - gst_element_class_set_details_simple (element_class, - "Dodge", - "Filter/Effect/Video", - "Dodge saturates the colors in the video signal.", - "Luis de Bethencourt "); - - gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&src_factory)); - gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&sink_factory)); -} - /* Initialize the dodge's class. */ static void gst_dodge_class_init (GstDodgeClass * klass) { GObjectClass *gobject_class = (GObjectClass *) klass; + GstElementClass *gstelement_class = (GstElementClass *) klass; GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass; + gst_element_class_set_details_simple (gstelement_class, + "Dodge", + "Filter/Effect/Video", + "Dodge saturates the colors in the video signal.", + "Luis de Bethencourt "); + + gst_element_class_add_pad_template (gstelement_class, + gst_static_pad_template_get (&src_factory)); + gst_element_class_add_pad_template (gstelement_class, + gst_static_pad_template_get (&sink_factory)); + gobject_class->set_property = gst_dodge_set_property; gobject_class->get_property = gst_dodge_get_property; @@ -164,7 +157,7 @@ gst_dodge_class_init (GstDodgeClass * klass) * initialize instance structure. */ static void -gst_dodge_init (GstDodge * filter, GstDodgeClass * gclass) +gst_dodge_init (GstDodge * filter) { filter->silent = FALSE; } @@ -210,20 +203,25 @@ static gboolean gst_dodge_set_caps (GstBaseTransform * btrans, GstCaps * incaps, GstCaps * outcaps) { - GstDodge *filter = GST_DODGE (btrans); - GstStructure *structure; - gboolean ret = TRUE; + GstDodge *dodge = GST_DODGE (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; + dodge->info = info; + + dodge->width = GST_VIDEO_INFO_WIDTH (&info); + dodge->height = GST_VIDEO_INFO_HEIGHT (&info); + + return TRUE; + + /* ERRORS */ +invalid_caps: + { + GST_DEBUG_OBJECT (btrans, "could not parse caps"); + return FALSE; } - GST_OBJECT_UNLOCK (filter); - - return ret; } /* Actual processing. */ @@ -232,9 +230,15 @@ gst_dodge_transform (GstBaseTransform * btrans, GstBuffer * in_buf, GstBuffer * out_buf) { GstDodge *filter = GST_DODGE (btrans); - guint32 *src = (guint32 *) GST_BUFFER_DATA (in_buf); - guint32 *dest = (guint32 *) GST_BUFFER_DATA (out_buf); + guint32 *src, *dest; gint video_size; + 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); video_size = filter->width * filter->height; diff --git a/gst/gaudieffects/gstdodge.h b/gst/gaudieffects/gstdodge.h index 4119131243..a8bee870c7 100644 --- a/gst/gaudieffects/gstdodge.h +++ b/gst/gaudieffects/gstdodge.h @@ -1,7 +1,7 @@ /* * GStreamer - * Copyright (C) 2010 Luis de Bethencourt > - * + * Copyright (C) <2010-2012> Luis de Bethencourt > + * * Dodge - saturation video effect. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -48,6 +48,7 @@ #include +#include #include G_BEGIN_DECLS @@ -73,6 +74,7 @@ struct _GstDodge /* < private > */ + GstVideoInfo info; gint width, height; gboolean silent;