gaudieffects: port solarize to GstVideoFilter

This commit is contained in:
Luis de Bethencourt 2012-05-09 17:21:30 +01:00
parent ee60c2cf98
commit bc3afe0ac2
2 changed files with 25 additions and 47 deletions

View file

@ -115,17 +115,17 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_STATIC_CAPS (CAPS_STR)
);
#define gst_solarize_parent_class parent_class
G_DEFINE_TYPE (GstSolarize, gst_solarize, GST_TYPE_VIDEO_FILTER);
static void gst_solarize_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_solarize_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static void gst_solarize_finalize (GObject * object);
static gboolean gst_solarize_set_caps (GstBaseTransform * btrans,
GstCaps * incaps, GstCaps * outcaps);
static GstFlowReturn gst_solarize_transform (GstBaseTransform * btrans,
GstBuffer * in_buf, GstBuffer * out_buf);
static GstFlowReturn gst_solarize_transform_frame (GstVideoFilter * vfilter,
GstVideoFrame * in_frame, GstVideoFrame * out_frame);
/* GObject vmethod implementations */
@ -135,7 +135,7 @@ gst_solarize_class_init (GstSolarizeClass * klass)
{
GObjectClass *gobject_class = (GObjectClass *) klass;
GstElementClass *gstelement_class = (GstElementClass *) klass;
GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
GstVideoFilterClass *vfilter_class = (GstVideoFilterClass *) klass;
gst_element_class_set_details_simple (gstelement_class,
"Solarize",
@ -150,6 +150,7 @@ gst_solarize_class_init (GstSolarizeClass * klass)
gobject_class->set_property = gst_solarize_set_property;
gobject_class->get_property = gst_solarize_get_property;
gobject_class->finalize = gst_solarize_finalize;
g_object_class_install_property (gobject_class, PROP_THRESHOLD,
g_param_spec_uint ("threshold", "Threshold",
@ -170,8 +171,8 @@ gst_solarize_class_init (GstSolarizeClass * klass)
g_param_spec_boolean ("silent", "Silent", "Produce verbose output ?",
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_solarize_set_caps);
trans_class->transform = GST_DEBUG_FUNCPTR (gst_solarize_transform);
vfilter_class->transform_frame =
GST_DEBUG_FUNCPTR (gst_solarize_transform_frame);
}
/* Initialize the element,
@ -240,56 +241,36 @@ gst_solarize_get_property (GObject * object, guint prop_id,
GST_OBJECT_UNLOCK (filter);
}
static void
gst_solarize_finalize (GObject * object)
{
G_OBJECT_CLASS (parent_class)->finalize (object);
}
/* GstElement vmethod implementations */
/* Handle the link with other elements. */
static gboolean
gst_solarize_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
GstCaps * outcaps)
{
GstSolarize *solarize = GST_SOLARIZE (btrans);
GstVideoInfo info;
if (!gst_video_info_from_caps (&info, incaps))
goto invalid_caps;
solarize->info = info;
solarize->width = GST_VIDEO_INFO_WIDTH (&info);
solarize->height = GST_VIDEO_INFO_HEIGHT (&info);
return TRUE;
/* ERRORS */
invalid_caps:
{
GST_DEBUG_OBJECT (btrans, "could not parse caps");
return FALSE;
}
}
/* Actual processing. */
static GstFlowReturn
gst_solarize_transform (GstBaseTransform * btrans,
GstBuffer * in_buf, GstBuffer * out_buf)
gst_solarize_transform_frame (GstVideoFilter * vfilter,
GstVideoFrame * in_frame, GstVideoFrame * out_frame)
{
GstSolarize *filter = GST_SOLARIZE (btrans);
gint video_size, threshold, start, end;
GstSolarize *filter = GST_SOLARIZE (vfilter);
gint video_size, threshold, start, end, width, height;
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);
src = GST_VIDEO_FRAME_PLANE_DATA (&in_frame, 0);
dest = GST_VIDEO_FRAME_PLANE_DATA (&out_frame, 0);
width = GST_VIDEO_FRAME_WIDTH (in_frame);
height = GST_VIDEO_FRAME_HEIGHT (in_frame);
/* GstController: update the properties */
timestamp = GST_BUFFER_TIMESTAMP (in_buf);
timestamp = GST_BUFFER_TIMESTAMP (in_frame->buffer);
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_TIME_ARGS (timestamp));
@ -303,7 +284,7 @@ gst_solarize_transform (GstBaseTransform * btrans,
end = filter->end;
GST_OBJECT_UNLOCK (filter);
video_size = filter->width * filter->height;
video_size = width * height;
transform (src, dest, video_size, threshold, start, end);
return GST_FLOW_OK;

View file

@ -74,9 +74,6 @@ struct _GstSolarize
/* < private > */
GstVideoInfo info;
gint width, height;
gint threshold, start, end;
gboolean silent;
};