mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
gaudieffects: port dilate to GstVideoFilter
This commit is contained in:
parent
2eba32aef3
commit
e9ec32fee7
2 changed files with 26 additions and 50 deletions
|
@ -76,6 +76,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_dilate_debug);
|
||||||
#define CAPS_STR GST_VIDEO_CAPS_MAKE ("{ xBGR, xRGB }")
|
#define CAPS_STR GST_VIDEO_CAPS_MAKE ("{ xBGR, xRGB }")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define gst_dilate_parent_class parent_class
|
||||||
G_DEFINE_TYPE (GstDilate, gst_dilate, GST_TYPE_VIDEO_FILTER);
|
G_DEFINE_TYPE (GstDilate, gst_dilate, GST_TYPE_VIDEO_FILTER);
|
||||||
|
|
||||||
/* Filter signals and args. */
|
/* Filter signals and args. */
|
||||||
|
@ -117,11 +118,10 @@ static void gst_dilate_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec);
|
const GValue * value, GParamSpec * pspec);
|
||||||
static void gst_dilate_get_property (GObject * object, guint prop_id,
|
static void gst_dilate_get_property (GObject * object, guint prop_id,
|
||||||
GValue * value, GParamSpec * pspec);
|
GValue * value, GParamSpec * pspec);
|
||||||
|
static void gst_dilate_finalize (GObject * object);
|
||||||
|
|
||||||
static gboolean gst_dilate_set_caps (GstBaseTransform * btrans,
|
static GstFlowReturn gst_dilate_transform_frame (GstVideoFilter * vfilter,
|
||||||
GstCaps * incaps, GstCaps * outcaps);
|
GstVideoFrame * in_frame, GstVideoFrame * out_frame);
|
||||||
static GstFlowReturn gst_dilate_transform (GstBaseTransform * btrans,
|
|
||||||
GstBuffer * in_buf, GstBuffer * out_buf);
|
|
||||||
|
|
||||||
/* GObject vmethod implementations */
|
/* GObject vmethod implementations */
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ gst_dilate_class_init (GstDilateClass * 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,
|
gst_element_class_set_details_simple (gstelement_class,
|
||||||
"Dilate",
|
"Dilate",
|
||||||
|
@ -146,6 +146,7 @@ gst_dilate_class_init (GstDilateClass * klass)
|
||||||
|
|
||||||
gobject_class->set_property = gst_dilate_set_property;
|
gobject_class->set_property = gst_dilate_set_property;
|
||||||
gobject_class->get_property = gst_dilate_get_property;
|
gobject_class->get_property = gst_dilate_get_property;
|
||||||
|
gobject_class->finalize = gst_dilate_finalize;
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class, PROP_ERODE,
|
g_object_class_install_property (gobject_class, PROP_ERODE,
|
||||||
g_param_spec_boolean ("erode", "Erode", "Erode parameter", FALSE,
|
g_param_spec_boolean ("erode", "Erode", "Erode parameter", FALSE,
|
||||||
|
@ -155,8 +156,8 @@ gst_dilate_class_init (GstDilateClass * 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_dilate_set_caps);
|
vfilter_class->transform_frame =
|
||||||
trans_class->transform = GST_DEBUG_FUNCPTR (gst_dilate_transform);
|
GST_DEBUG_FUNCPTR (gst_dilate_transform_frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the element,
|
/* Initialize the element,
|
||||||
|
@ -211,59 +212,37 @@ gst_dilate_get_property (GObject * object, guint prop_id,
|
||||||
GST_OBJECT_UNLOCK (filter);
|
GST_OBJECT_UNLOCK (filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* GstElement vmethod implementations */
|
static void
|
||||||
|
gst_dilate_finalize (GObject * object)
|
||||||
/* Handle the link with other elements. */
|
|
||||||
static gboolean
|
|
||||||
gst_dilate_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
|
|
||||||
GstCaps * outcaps)
|
|
||||||
{
|
{
|
||||||
GstDilate *dilate = GST_DILATE (btrans);
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
GstVideoInfo info;
|
|
||||||
|
|
||||||
if (!gst_video_info_from_caps (&info, incaps))
|
|
||||||
goto invalid_caps;
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* GstElement vmethod implementations */
|
||||||
|
|
||||||
/* Actual processing. */
|
/* Actual processing. */
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_dilate_transform (GstBaseTransform * btrans,
|
gst_dilate_transform_frame (GstVideoFilter * vfilter,
|
||||||
GstBuffer * in_buf, GstBuffer * out_buf)
|
GstVideoFrame * in_frame, GstVideoFrame * out_frame)
|
||||||
{
|
{
|
||||||
GstDilate *filter = GST_DILATE (btrans);
|
GstDilate *filter = GST_DILATE (vfilter);
|
||||||
gint video_size;
|
gint video_size, width, height;
|
||||||
gboolean erode;
|
gboolean erode;
|
||||||
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);
|
||||||
|
|
||||||
video_size = filter->width * filter->height;
|
|
||||||
|
|
||||||
/* 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));
|
||||||
|
@ -275,7 +254,8 @@ gst_dilate_transform (GstBaseTransform * btrans,
|
||||||
erode = filter->erode;
|
erode = filter->erode;
|
||||||
GST_OBJECT_UNLOCK (filter);
|
GST_OBJECT_UNLOCK (filter);
|
||||||
|
|
||||||
transform (src, dest, video_size, filter->width, filter->height, erode);
|
video_size = width * height;
|
||||||
|
transform (src, dest, video_size, width, height, erode);
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,10 +73,6 @@ struct _GstDilate
|
||||||
GstVideoFilter videofilter;
|
GstVideoFilter videofilter;
|
||||||
|
|
||||||
/* < private > */
|
/* < private > */
|
||||||
|
|
||||||
GstVideoInfo info;
|
|
||||||
gint width, height;
|
|
||||||
|
|
||||||
gboolean silent;
|
gboolean silent;
|
||||||
gboolean erode;
|
gboolean erode;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue