mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-10 17:35:59 +00:00
gaudieffects: port exclusion to 0.11
This commit is contained in:
parent
e78f5817e5
commit
9602a3513b
2 changed files with 46 additions and 39 deletions
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* GStreamer
|
* GStreamer
|
||||||
* Copyright (C) 2010 Luis de Bethencourt <luis@debethencourt.com>
|
* Copyright (C) <2010-2012> Luis de Bethencourt <luis@debethencourt.com>
|
||||||
*
|
*
|
||||||
* Exclusion - color exclusion video effect.
|
* Exclusion - color exclusion video effect.
|
||||||
* Based on Pete Warden's FreeFrame plugin with the same name.
|
* Based on Pete Warden's FreeFrame plugin with the same name.
|
||||||
*
|
*
|
||||||
|
@ -73,9 +73,9 @@ GST_DEBUG_CATEGORY_STATIC (gst_exclusion_debug);
|
||||||
#define GST_CAT_DEFAULT gst_exclusion_debug
|
#define GST_CAT_DEFAULT gst_exclusion_debug
|
||||||
|
|
||||||
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
#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
|
#else
|
||||||
#define CAPS_STR GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_xBGR
|
#define CAPS_STR GST_VIDEO_CAPS_MAKE ("{ xBGR, xRGB }")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Filter signals and args. */
|
/* Filter signals and args. */
|
||||||
|
@ -113,8 +113,7 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_STATIC_CAPS (CAPS_STR)
|
GST_STATIC_CAPS (CAPS_STR)
|
||||||
);
|
);
|
||||||
|
|
||||||
GST_BOILERPLATE (GstExclusion, gst_exclusion, GstVideoFilter,
|
G_DEFINE_TYPE (GstExclusion, gst_exclusion, GST_TYPE_VIDEO_FILTER);
|
||||||
GST_TYPE_VIDEO_FILTER);
|
|
||||||
|
|
||||||
static void gst_exclusion_set_property (GObject * object, guint prop_id,
|
static void gst_exclusion_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec);
|
const GValue * value, GParamSpec * pspec);
|
||||||
|
@ -128,30 +127,24 @@ static GstFlowReturn gst_exclusion_transform (GstBaseTransform * btrans,
|
||||||
|
|
||||||
/* GObject vmethod implementations */
|
/* GObject vmethod implementations */
|
||||||
|
|
||||||
static void
|
|
||||||
gst_exclusion_base_init (gpointer gclass)
|
|
||||||
{
|
|
||||||
GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
|
|
||||||
|
|
||||||
gst_element_class_set_details_simple (element_class,
|
|
||||||
"Exclusion",
|
|
||||||
"Filter/Effect/Video",
|
|
||||||
"Exclusion exclodes the colors in the video signal.",
|
|
||||||
"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 exclusion's class. */
|
/* Initialize the exclusion's class. */
|
||||||
static void
|
static void
|
||||||
gst_exclusion_class_init (GstExclusionClass * klass)
|
gst_exclusion_class_init (GstExclusionClass * klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class = (GObjectClass *) klass;
|
GObjectClass *gobject_class = (GObjectClass *) klass;
|
||||||
|
GstElementClass *gstelement_class = (GstElementClass *) klass;
|
||||||
GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
|
GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
|
||||||
|
|
||||||
|
gst_element_class_set_details_simple (gstelement_class, "Exclusion",
|
||||||
|
"Filter/Effect/Video",
|
||||||
|
"Exclusion exclodes the colors in the video signal.",
|
||||||
|
"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_exclusion_set_property;
|
gobject_class->set_property = gst_exclusion_set_property;
|
||||||
gobject_class->get_property = gst_exclusion_get_property;
|
gobject_class->get_property = gst_exclusion_get_property;
|
||||||
|
|
||||||
|
@ -174,7 +167,7 @@ gst_exclusion_class_init (GstExclusionClass * klass)
|
||||||
* initialize instance structure.
|
* initialize instance structure.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
gst_exclusion_init (GstExclusion * filter, GstExclusionClass * gclass)
|
gst_exclusion_init (GstExclusion * filter)
|
||||||
{
|
{
|
||||||
filter->factor = DEFAULT_FACTOR;
|
filter->factor = DEFAULT_FACTOR;
|
||||||
filter->silent = FALSE;
|
filter->silent = FALSE;
|
||||||
|
@ -226,19 +219,25 @@ static gboolean
|
||||||
gst_exclusion_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
|
gst_exclusion_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
|
||||||
GstCaps * outcaps)
|
GstCaps * outcaps)
|
||||||
{
|
{
|
||||||
GstExclusion *filter = GST_EXCLUSION (btrans);
|
GstExclusion *exclusion = GST_EXCLUSION (btrans);
|
||||||
GstStructure *structure;
|
GstVideoInfo info;
|
||||||
gboolean ret = FALSE;
|
|
||||||
|
|
||||||
GST_OBJECT_LOCK (filter);
|
if (!gst_video_info_from_caps (&info, incaps))
|
||||||
structure = gst_caps_get_structure (incaps, 0);
|
goto invalid_caps;
|
||||||
if (gst_structure_get_int (structure, "width", &filter->width) &&
|
|
||||||
gst_structure_get_int (structure, "height", &filter->height)) {
|
exclusion->info = info;
|
||||||
ret = TRUE;
|
|
||||||
|
exclusion->width = GST_VIDEO_INFO_WIDTH (&info);
|
||||||
|
exclusion->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. */
|
/* Actual processing. */
|
||||||
|
@ -248,10 +247,16 @@ gst_exclusion_transform (GstBaseTransform * btrans,
|
||||||
{
|
{
|
||||||
GstExclusion *filter = GST_EXCLUSION (btrans);
|
GstExclusion *filter = GST_EXCLUSION (btrans);
|
||||||
gint video_size, factor;
|
gint video_size, factor;
|
||||||
guint32 *src = (guint32 *) GST_BUFFER_DATA (in_buf);
|
guint32 *src, *dest;
|
||||||
guint32 *dest = (guint32 *) GST_BUFFER_DATA (out_buf);
|
|
||||||
GstClockTime timestamp;
|
GstClockTime timestamp;
|
||||||
gint64 stream_time;
|
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 */
|
/* GstController: update the properties */
|
||||||
timestamp = GST_BUFFER_TIMESTAMP (in_buf);
|
timestamp = GST_BUFFER_TIMESTAMP (in_buf);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* GStreamer
|
* GStreamer
|
||||||
* Copyright (C) 2010 Luis de Bethencourt <luis@debethencourt.com>>
|
* Copyright (C) <2010-2012> Luis de Bethencourt <luis@debethencourt.com>>
|
||||||
*
|
*
|
||||||
* Exclusion - color exclusion video effect.
|
* Exclusion - color exclusion video effect.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
@ -49,6 +49,7 @@
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
|
||||||
#include <gst/video/gstvideofilter.h>
|
#include <gst/video/gstvideofilter.h>
|
||||||
|
#include <gst/video/video.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
@ -73,6 +74,7 @@ struct _GstExclusion
|
||||||
|
|
||||||
/* < private > */
|
/* < private > */
|
||||||
|
|
||||||
|
GstVideoInfo info;
|
||||||
gint width, height;
|
gint width, height;
|
||||||
|
|
||||||
gint factor;
|
gint factor;
|
||||||
|
|
Loading…
Reference in a new issue