gaudieffects: port dilate to 0.11

This commit is contained in:
Luis de Bethencourt 2012-05-08 17:17:16 +01:00
parent 6b5d5c6f24
commit 1471e804d8
2 changed files with 46 additions and 40 deletions

View file

@ -1,7 +1,7 @@
/*
* GStreamer
* Copyright (C) 2010 Luis de Bethencourt <luis@debethencourt.com>
*
* Copyright (C) <2010-2012> Luis de Bethencourt <luis@debethencourt.com>
*
* Dilate - dilated eye video effect.
* Based on Pete Warden's FreeFrame plugin with the same name.
*
@ -67,17 +67,17 @@
#include "gstplugin.h"
#include "gstdilate.h"
#include <gst/video/video.h>
GST_DEBUG_CATEGORY_STATIC (gst_dilate_debug);
#define GST_CAT_DEFAULT gst_dilate_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 (GstDilate, gst_dilate, GST_TYPE_VIDEO_FILTER);
/* Filter signals and args. */
enum
{
@ -113,8 +113,6 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_STATIC_CAPS (CAPS_STR)
);
GST_BOILERPLATE (GstDilate, gst_dilate, GstVideoFilter, GST_TYPE_VIDEO_FILTER);
static void gst_dilate_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_dilate_get_property (GObject * object, guint prop_id,
@ -127,30 +125,25 @@ static GstFlowReturn gst_dilate_transform (GstBaseTransform * btrans,
/* GObject vmethod implementations */
static void
gst_dilate_base_init (gpointer gclass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
gst_element_class_set_details_simple (element_class,
"Dilate",
"Filter/Effect/Video",
"Dilate copies the brightest pixel around.",
"Luis de Bethencourt <luis@debethencourt.com>");
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 dilate's class. */
static void
gst_dilate_class_init (GstDilateClass * klass)
{
GObjectClass *gobject_class = (GObjectClass *) klass;
GstElementClass *gstelement_class = (GstElementClass *) klass;
GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
gst_element_class_set_details_simple (gstelement_class,
"Dilate",
"Filter/Effect/Video",
"Dilate copies the brightest pixel around.",
"Luis de Bethencourt <luis@debethencourt.com>");
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_dilate_set_property;
gobject_class->get_property = gst_dilate_get_property;
@ -172,7 +165,7 @@ gst_dilate_class_init (GstDilateClass * klass)
* initialize instance structure.
*/
static void
gst_dilate_init (GstDilate * filter, GstDilateClass * gclass)
gst_dilate_init (GstDilate * filter)
{
filter->erode = DEFAULT_ERODE;
filter->silent = FALSE;
@ -225,20 +218,25 @@ static gboolean
gst_dilate_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
GstCaps * outcaps)
{
GstDilate *filter = GST_DILATE (btrans);
GstStructure *structure;
gboolean ret = TRUE;
GstDilate *dilate = GST_DILATE (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;
dilate->info = info;
dilate->width = GST_VIDEO_INFO_WIDTH (&info);
dilate->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. */
@ -249,10 +247,16 @@ gst_dilate_transform (GstBaseTransform * btrans,
GstDilate *filter = GST_DILATE (btrans);
gint video_size;
gboolean erode;
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);
video_size = filter->width * filter->height;

View file

@ -1,7 +1,7 @@
/*
* GStreamer
* Copyright (C) 2010 Luis de Bethencourt <luis@debethencourt.com>
*
*
* Dilate - curve adjustment film video effect.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@ -48,6 +48,7 @@
#include <gst/gst.h>
#include <gst/video/video.h>
#include <gst/video/gstvideofilter.h>
G_BEGIN_DECLS
@ -73,6 +74,7 @@ struct _GstDilate
/* < private > */
GstVideoInfo info;
gint width, height;
gboolean silent;