gaudieffects: port exclusion to GstVideoFilter

This commit is contained in:
Luis de Bethencourt 2012-05-09 17:06:20 +01:00
parent 2e1aa96113
commit ee60c2cf98
2 changed files with 25 additions and 46 deletions

View file

@ -113,17 +113,17 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_STATIC_CAPS (CAPS_STR) GST_STATIC_CAPS (CAPS_STR)
); );
#define gst_exclusion_parent_class parent_class
G_DEFINE_TYPE (GstExclusion, gst_exclusion, GST_TYPE_VIDEO_FILTER); G_DEFINE_TYPE (GstExclusion, gst_exclusion, 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);
static void gst_exclusion_get_property (GObject * object, guint prop_id, static void gst_exclusion_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec); GValue * value, GParamSpec * pspec);
static void gst_exclusion_finalize (GObject * object);
static gboolean gst_exclusion_set_caps (GstBaseTransform * btrans, static GstFlowReturn gst_exclusion_transform_frame (GstVideoFilter * vfilter,
GstCaps * incaps, GstCaps * outcaps); GstVideoFrame * in_frame, GstVideoFrame * out_frame);
static GstFlowReturn gst_exclusion_transform (GstBaseTransform * btrans,
GstBuffer * in_buf, GstBuffer * out_buf);
/* GObject vmethod implementations */ /* GObject vmethod implementations */
@ -133,7 +133,7 @@ gst_exclusion_class_init (GstExclusionClass * klass)
{ {
GObjectClass *gobject_class = (GObjectClass *) klass; GObjectClass *gobject_class = (GObjectClass *) klass;
GstElementClass *gstelement_class = (GstElementClass *) klass; GstElementClass *gstelement_class = (GstElementClass *) klass;
GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass; GstVideoFilterClass *vfilter_class = (GstVideoFilterClass *) klass;
gst_element_class_set_details_simple (gstelement_class, "Exclusion", gst_element_class_set_details_simple (gstelement_class, "Exclusion",
"Filter/Effect/Video", "Filter/Effect/Video",
@ -147,6 +147,7 @@ gst_exclusion_class_init (GstExclusionClass * klass)
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;
gobject_class->finalize = gst_exclusion_finalize;
g_object_class_install_property (gobject_class, PROP_FACTOR, g_object_class_install_property (gobject_class, PROP_FACTOR,
g_param_spec_uint ("factor", "Factor", g_param_spec_uint ("factor", "Factor",
@ -157,8 +158,8 @@ gst_exclusion_class_init (GstExclusionClass * klass)
g_param_spec_boolean ("silent", "Silent", "Produce verbose output ?", g_param_spec_boolean ("silent", "Silent", "Produce verbose output ?",
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_exclusion_set_caps); vfilter_class->transform_frame =
trans_class->transform = GST_DEBUG_FUNCPTR (gst_exclusion_transform); GST_DEBUG_FUNCPTR (gst_exclusion_transform_frame);
} }
/* Initialize the element, /* Initialize the element,
@ -213,55 +214,36 @@ gst_exclusion_get_property (GObject * object, guint prop_id,
GST_OBJECT_UNLOCK (filter); GST_OBJECT_UNLOCK (filter);
} }
/* GstElement vmethod implementations */ static void
/* Handle the link with other elements. */ gst_exclusion_finalize (GObject * object)
static gboolean
gst_exclusion_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
GstCaps * outcaps)
{ {
GstExclusion *exclusion = GST_EXCLUSION (btrans); G_OBJECT_CLASS (parent_class)->finalize (object);
GstVideoInfo info;
if (!gst_video_info_from_caps (&info, incaps))
goto invalid_caps;
exclusion->info = info;
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;
}
} }
/* GstElement vmethod implementations */
/* Actual processing. */ /* Actual processing. */
static GstFlowReturn static GstFlowReturn
gst_exclusion_transform (GstBaseTransform * btrans, gst_exclusion_transform_frame (GstVideoFilter * vfilter,
GstBuffer * in_buf, GstBuffer * out_buf) GstVideoFrame * in_frame, GstVideoFrame * out_frame)
{ {
GstExclusion *filter = GST_EXCLUSION (btrans); GstExclusion *filter = GST_EXCLUSION (vfilter);
gint video_size, factor; gint video_size, factor, width, height;
guint32 *src, *dest; guint32 *src, *dest;
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); src = GST_VIDEO_FRAME_PLANE_DATA (in_frame, 0);
gst_video_frame_map (&out_frame, &filter->info, out_buf, GST_MAP_WRITE); dest = GST_VIDEO_FRAME_PLANE_DATA (out_frame, 0);
src = GST_VIDEO_FRAME_PLANE_DATA (&in_frame, 0); width = GST_VIDEO_FRAME_WIDTH (in_frame);
dest = GST_VIDEO_FRAME_PLANE_DATA (&out_frame, 0); height = GST_VIDEO_FRAME_HEIGHT (in_frame);
/* GstController: update the properties */ /* GstController: update the properties */
timestamp = GST_BUFFER_TIMESTAMP (in_buf); timestamp = GST_BUFFER_TIMESTAMP (in_frame->buffer);
stream_time = stream_time =
gst_segment_to_stream_time (&btrans->segment, GST_FORMAT_TIME, timestamp); gst_segment_to_stream_time (&GST_BASE_TRANSFORM (filter)->segment,
GST_FORMAT_TIME, timestamp);
GST_DEBUG_OBJECT (filter, "sync to %" GST_TIME_FORMAT, GST_DEBUG_OBJECT (filter, "sync to %" GST_TIME_FORMAT,
GST_TIME_ARGS (timestamp)); GST_TIME_ARGS (timestamp));
@ -273,7 +255,7 @@ gst_exclusion_transform (GstBaseTransform * btrans,
factor = filter->factor; factor = filter->factor;
GST_OBJECT_UNLOCK (filter); GST_OBJECT_UNLOCK (filter);
video_size = filter->width * filter->height; video_size = width * height;
transform (src, dest, video_size, factor); transform (src, dest, video_size, factor);
return GST_FLOW_OK; return GST_FLOW_OK;

View file

@ -74,9 +74,6 @@ struct _GstExclusion
/* < private > */ /* < private > */
GstVideoInfo info;
gint width, height;
gint factor; gint factor;
gboolean silent; gboolean silent;
}; };