summaryrefslogtreecommitdiff
path: root/gst/videofilter
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2011-12-21 23:51:03 +0100
committerWim Taymans <wim.taymans@collabora.co.uk>2011-12-21 23:51:03 +0100
commit2214657113a68430bdc5aaf186d4162d4b69f242 (patch)
tree8e0876f96ceaf080d6a98bd744fc259a9a849f6b /gst/videofilter
parent4b8975f86704fe0e731bf84f5c60cd2f814bf7b4 (diff)
downloadgstreamer-plugins-good-2214657113a68430bdc5aaf186d4162d4b69f242.tar.gz
update for videofilter changes.
Diffstat (limited to 'gst/videofilter')
-rw-r--r--gst/videofilter/gstgamma.c51
-rw-r--r--gst/videofilter/gstgamma.h4
-rw-r--r--gst/videofilter/gstvideobalance.c50
-rw-r--r--gst/videofilter/gstvideobalance.h3
-rw-r--r--gst/videofilter/gstvideoflip.c110
-rw-r--r--gst/videofilter/gstvideoflip.h5
6 files changed, 66 insertions, 157 deletions
diff --git a/gst/videofilter/gstgamma.c b/gst/videofilter/gstgamma.c
index 401aced45..a654f2b78 100644
--- a/gst/videofilter/gstgamma.c
+++ b/gst/videofilter/gstgamma.c
@@ -94,10 +94,10 @@ static void gst_gamma_set_property (GObject * object, guint prop_id,
static void gst_gamma_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
-static gboolean gst_gamma_set_caps (GstBaseTransform * base, GstCaps * incaps,
- GstCaps * outcaps);
-static GstFlowReturn gst_gamma_transform_ip (GstBaseTransform * transform,
- GstBuffer * buf);
+static gboolean gst_gamma_set_info (GstVideoFilter * vfilter, GstCaps * incaps,
+ GstVideoInfo * in_info, GstCaps * outcaps, GstVideoInfo * out_info);
+static GstFlowReturn gst_gamma_transform_frame_ip (GstVideoFilter * vfilter,
+ GstVideoFrame * frame);
static void gst_gamma_before_transform (GstBaseTransform * transform,
GstBuffer * buf);
@@ -111,6 +111,7 @@ gst_gamma_class_init (GstGammaClass * g_class)
GObjectClass *gobject_class = (GObjectClass *) g_class;
GstElementClass *gstelement_class = (GstElementClass *) g_class;
GstBaseTransformClass *trans_class = (GstBaseTransformClass *) g_class;
+ GstVideoFilterClass *vfilter_class = (GstVideoFilterClass *) g_class;
GST_DEBUG_CATEGORY_INIT (gamma_debug, "gamma", 0, "gamma");
@@ -131,10 +132,12 @@ gst_gamma_class_init (GstGammaClass * g_class)
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_gamma_src_template));
- trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_gamma_set_caps);
- trans_class->transform_ip = GST_DEBUG_FUNCPTR (gst_gamma_transform_ip);
trans_class->before_transform =
GST_DEBUG_FUNCPTR (gst_gamma_before_transform);
+
+ vfilter_class->set_info = GST_DEBUG_FUNCPTR (gst_gamma_set_info);
+ vfilter_class->transform_frame_ip =
+ GST_DEBUG_FUNCPTR (gst_gamma_transform_frame_ip);
}
static void
@@ -318,22 +321,16 @@ gst_gamma_packed_rgb_ip (GstGamma * gamma, GstVideoFrame * frame)
}
static gboolean
-gst_gamma_set_caps (GstBaseTransform * base, GstCaps * incaps,
- GstCaps * outcaps)
+gst_gamma_set_info (GstVideoFilter * vfilter, GstCaps * incaps,
+ GstVideoInfo * in_info, GstCaps * outcaps, GstVideoInfo * out_info)
{
- GstGamma *gamma = GST_GAMMA (base);
- GstVideoInfo info;
+ GstGamma *gamma = GST_GAMMA (vfilter);
GST_DEBUG_OBJECT (gamma,
"setting caps: in %" GST_PTR_FORMAT " out %" GST_PTR_FORMAT, incaps,
outcaps);
- if (!gst_video_info_from_caps (&info, incaps))
- goto invalid_caps;
-
- gamma->info = info;
-
- switch (GST_VIDEO_INFO_FORMAT (&info)) {
+ switch (GST_VIDEO_INFO_FORMAT (in_info)) {
case GST_VIDEO_FORMAT_I420:
case GST_VIDEO_FORMAT_YV12:
case GST_VIDEO_FORMAT_Y41B:
@@ -365,9 +362,9 @@ gst_gamma_set_caps (GstBaseTransform * base, GstCaps * incaps,
goto invalid_caps;
break;
}
-
return TRUE;
+ /* ERRORS */
invalid_caps:
{
GST_ERROR_OBJECT (gamma, "Invalid caps: %" GST_PTR_FORMAT, incaps);
@@ -393,36 +390,24 @@ gst_gamma_before_transform (GstBaseTransform * base, GstBuffer * outbuf)
}
static GstFlowReturn
-gst_gamma_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
+gst_gamma_transform_frame_ip (GstVideoFilter * vfilter, GstVideoFrame * frame)
{
- GstGamma *gamma = GST_GAMMA (base);
- GstVideoFrame frame;
+ GstGamma *gamma = GST_GAMMA (vfilter);
if (!gamma->process)
goto not_negotiated;
- if (base->passthrough)
+ if (GST_BASE_TRANSFORM (vfilter)->passthrough)
goto done;
- if (!gst_video_frame_map (&frame, &gamma->info, outbuf, GST_MAP_READWRITE))
- goto wrong_buffer;
-
GST_OBJECT_LOCK (gamma);
- gamma->process (gamma, &frame);
+ gamma->process (gamma, frame);
GST_OBJECT_UNLOCK (gamma);
- gst_video_frame_unmap (&frame);
-
done:
return GST_FLOW_OK;
/* ERRORS */
-wrong_buffer:
- {
- GST_ELEMENT_ERROR (gamma, STREAM, FORMAT,
- (NULL), ("Invalid buffer received"));
- return GST_FLOW_ERROR;
- }
not_negotiated:
{
GST_ERROR_OBJECT (gamma, "Not negotiated yet");
diff --git a/gst/videofilter/gstgamma.h b/gst/videofilter/gstgamma.h
index b76dd973e..6a1b886d2 100644
--- a/gst/videofilter/gstgamma.h
+++ b/gst/videofilter/gstgamma.h
@@ -54,10 +54,6 @@ struct _GstGamma
GstVideoFilter videofilter;
/* < private > */
-
- /* format */
- GstVideoInfo info;
-
/* properties */
gdouble gamma;
diff --git a/gst/videofilter/gstvideobalance.c b/gst/videofilter/gstvideobalance.c
index 3c5a31e83..33080965a 100644
--- a/gst/videofilter/gstvideobalance.c
+++ b/gst/videofilter/gstvideobalance.c
@@ -354,21 +354,17 @@ gst_video_balance_packed_rgb (GstVideoBalance * videobalance,
/* get notified of caps and plug in the correct process function */
static gboolean
-gst_video_balance_set_caps (GstBaseTransform * base, GstCaps * incaps,
- GstCaps * outcaps)
+gst_video_balance_set_info (GstVideoFilter * vfilter, GstCaps * incaps,
+ GstVideoInfo * in_info, GstCaps * outcaps, GstVideoInfo * out_info)
{
- GstVideoBalance *videobalance = GST_VIDEO_BALANCE (base);
- GstVideoInfo info;
+ GstVideoBalance *videobalance = GST_VIDEO_BALANCE (vfilter);
GST_DEBUG_OBJECT (videobalance,
"in %" GST_PTR_FORMAT " out %" GST_PTR_FORMAT, incaps, outcaps);
videobalance->process = NULL;
- if (!gst_video_info_from_caps (&info, incaps))
- goto invalid_caps;
-
- switch (GST_VIDEO_INFO_FORMAT (&info)) {
+ switch (GST_VIDEO_INFO_FORMAT (in_info)) {
case GST_VIDEO_FORMAT_I420:
case GST_VIDEO_FORMAT_YV12:
case GST_VIDEO_FORMAT_Y41B:
@@ -399,15 +395,9 @@ gst_video_balance_set_caps (GstBaseTransform * base, GstCaps * incaps,
break;
}
- videobalance->info = info;
-
return TRUE;
-invalid_caps:
- {
- GST_ERROR_OBJECT (videobalance, "Invalid caps: %" GST_PTR_FORMAT, incaps);
- return FALSE;
- }
+ /* ERRORS */
unknown_format:
{
GST_ERROR_OBJECT (videobalance, "unknown format %" GST_PTR_FORMAT, incaps);
@@ -433,38 +423,26 @@ gst_video_balance_before_transform (GstBaseTransform * base, GstBuffer * buf)
}
static GstFlowReturn
-gst_video_balance_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
+gst_video_balance_transform_frame_ip (GstVideoFilter * vfilter,
+ GstVideoFrame * frame)
{
- GstVideoBalance *videobalance = GST_VIDEO_BALANCE (base);
- GstVideoFrame frame;
+ GstVideoBalance *videobalance = GST_VIDEO_BALANCE (vfilter);
if (!videobalance->process)
goto not_negotiated;
/* if no change is needed, we are done */
- if (base->passthrough)
+ if (GST_BASE_TRANSFORM (vfilter)->passthrough)
goto done;
- if (!gst_video_frame_map (&frame, &videobalance->info, outbuf,
- GST_MAP_READWRITE))
- goto wrong_frame;
-
GST_OBJECT_LOCK (videobalance);
- videobalance->process (videobalance, &frame);
+ videobalance->process (videobalance, frame);
GST_OBJECT_UNLOCK (videobalance);
- gst_video_frame_unmap (&frame);
-
done:
return GST_FLOW_OK;
/* ERRORS */
-wrong_frame:
- {
- GST_ELEMENT_ERROR (videobalance, STREAM, FORMAT,
- (NULL), ("Invalid buffer received"));
- return GST_FLOW_ERROR;
- }
not_negotiated:
{
GST_ERROR_OBJECT (videobalance, "Not negotiated yet");
@@ -501,6 +479,7 @@ gst_video_balance_class_init (GstVideoBalanceClass * klass)
GObjectClass *gobject_class = (GObjectClass *) klass;
GstElementClass *gstelement_class = (GstElementClass *) klass;
GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
+ GstVideoFilterClass *vfilter_class = (GstVideoFilterClass *) klass;
GST_DEBUG_CATEGORY_INIT (videobalance_debug, "videobalance", 0,
"videobalance");
@@ -535,11 +514,12 @@ gst_video_balance_class_init (GstVideoBalanceClass * klass)
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_video_balance_src_template));
- trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_video_balance_set_caps);
- trans_class->transform_ip =
- GST_DEBUG_FUNCPTR (gst_video_balance_transform_ip);
trans_class->before_transform =
GST_DEBUG_FUNCPTR (gst_video_balance_before_transform);
+
+ vfilter_class->set_info = GST_DEBUG_FUNCPTR (gst_video_balance_set_info);
+ vfilter_class->transform_frame_ip =
+ GST_DEBUG_FUNCPTR (gst_video_balance_transform_frame_ip);
}
static void
diff --git a/gst/videofilter/gstvideobalance.h b/gst/videofilter/gstvideobalance.h
index 1d3375a45..194144bb3 100644
--- a/gst/videofilter/gstvideobalance.h
+++ b/gst/videofilter/gstvideobalance.h
@@ -60,9 +60,6 @@ struct _GstVideoBalance {
gdouble hue;
gdouble saturation;
- /* format */
- GstVideoInfo info;
-
/* tables */
guint8 tabley[256];
guint8 *tableu[256];
diff --git a/gst/videofilter/gstvideoflip.c b/gst/videofilter/gstvideoflip.c
index f9bad9aaa..9075a36e5 100644
--- a/gst/videofilter/gstvideoflip.c
+++ b/gst/videofilter/gstvideoflip.c
@@ -180,24 +180,6 @@ gst_video_flip_transform_caps (GstBaseTransform * trans,
return ret;
}
-static gboolean
-gst_video_flip_get_unit_size (GstBaseTransform * btrans, GstCaps * caps,
- gsize * size)
-{
- GstVideoInfo info;
-
- if (!gst_video_info_from_caps (&info, caps))
- return FALSE;
-
- *size = info.size;
-
- GST_DEBUG_OBJECT (btrans,
- "our frame size is %" G_GSIZE_FORMAT " bytes (%dx%d)", *size, info.width,
- info.height);
-
- return TRUE;
-}
-
static void
gst_video_flip_planar_yuv (GstVideoFlip * videoflip, GstVideoFrame * dest,
const GstVideoFrame * src)
@@ -765,20 +747,15 @@ gst_video_flip_y422 (GstVideoFlip * videoflip, GstVideoFrame * dest,
static gboolean
-gst_video_flip_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
- GstCaps * outcaps)
+gst_video_flip_set_info (GstVideoFilter * vfilter, GstCaps * incaps,
+ GstVideoInfo * in_info, GstCaps * outcaps, GstVideoInfo * out_info)
{
- GstVideoFlip *vf = GST_VIDEO_FLIP (btrans);
- GstVideoInfo in_info, out_info;
+ GstVideoFlip *vf = GST_VIDEO_FLIP (vfilter);
gboolean ret = FALSE;
vf->process = NULL;
- if (!gst_video_info_from_caps (&in_info, incaps)
- || !gst_video_info_from_caps (&out_info, outcaps))
- goto invalid_caps;
-
- if (GST_VIDEO_INFO_FORMAT (&in_info) != GST_VIDEO_INFO_FORMAT (&out_info))
+ if (GST_VIDEO_INFO_FORMAT (in_info) != GST_VIDEO_INFO_FORMAT (out_info))
goto invalid_caps;
/* Check that they are correct */
@@ -787,11 +764,11 @@ gst_video_flip_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
case GST_VIDEO_FLIP_METHOD_90L:
case GST_VIDEO_FLIP_METHOD_TRANS:
case GST_VIDEO_FLIP_METHOD_OTHER:
- if ((in_info.width != out_info.height) ||
- (in_info.height != out_info.width)) {
+ if ((in_info->width != out_info->height) ||
+ (in_info->height != out_info->width)) {
GST_ERROR_OBJECT (vf, "we are inverting width and height but caps "
- "are not correct : %dx%d to %dx%d", in_info.width,
- in_info.height, out_info.width, out_info.height);
+ "are not correct : %dx%d to %dx%d", in_info->width,
+ in_info->height, out_info->width, out_info->height);
goto beach;
}
break;
@@ -801,11 +778,11 @@ gst_video_flip_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
case GST_VIDEO_FLIP_METHOD_180:
case GST_VIDEO_FLIP_METHOD_HORIZ:
case GST_VIDEO_FLIP_METHOD_VERT:
- if ((in_info.width != out_info.width) ||
- (in_info.height != out_info.height)) {
+ if ((in_info->width != out_info->width) ||
+ (in_info->height != out_info->height)) {
GST_ERROR_OBJECT (vf, "we are keeping width and height but caps "
- "are not correct : %dx%d to %dx%d", in_info.width,
- in_info.height, out_info.width, out_info.height);
+ "are not correct : %dx%d to %dx%d", in_info->width,
+ in_info->height, out_info->width, out_info->height);
goto beach;
}
break;
@@ -815,10 +792,8 @@ gst_video_flip_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
}
ret = TRUE;
- vf->in_info = in_info;
- vf->out_info = out_info;
- switch (GST_VIDEO_INFO_FORMAT (&in_info)) {
+ switch (GST_VIDEO_INFO_FORMAT (in_info)) {
case GST_VIDEO_FORMAT_I420:
case GST_VIDEO_FORMAT_YV12:
case GST_VIDEO_FORMAT_Y444:
@@ -873,34 +848,21 @@ gst_video_flip_before_transform (GstBaseTransform * trans, GstBuffer * in)
}
static GstFlowReturn
-gst_video_flip_transform (GstBaseTransform * trans, GstBuffer * in,
- GstBuffer * out)
+gst_video_flip_transform_frame (GstVideoFilter * vfilter,
+ GstVideoFrame * in_frame, GstVideoFrame * out_frame)
{
- GstVideoFlip *videoflip = GST_VIDEO_FLIP (trans);
- GstVideoFrame dest;
- GstVideoFrame src;
+ GstVideoFlip *videoflip = GST_VIDEO_FLIP (vfilter);
if (G_UNLIKELY (videoflip->process == NULL))
goto not_negotiated;
- if (!gst_video_frame_map (&src, &videoflip->in_info, in, GST_MAP_READ))
- goto invalid_in;
-
- if (!gst_video_frame_map (&dest, &videoflip->out_info, out, GST_MAP_WRITE))
- goto invalid_out;
-
- GST_LOG_OBJECT (videoflip, "videoflip: flipping %dx%d to %dx%d (%s)",
- videoflip->in_info.width, videoflip->in_info.height,
- videoflip->out_info.width, videoflip->out_info.height,
+ GST_LOG_OBJECT (videoflip, "videoflip: flipping (%s)",
video_flip_methods[videoflip->method].value_nick);
GST_OBJECT_LOCK (videoflip);
- videoflip->process (videoflip, &dest, &src);
+ videoflip->process (videoflip, out_frame, in_frame);
GST_OBJECT_UNLOCK (videoflip);
- gst_video_frame_unmap (&src);
- gst_video_frame_unmap (&dest);
-
return GST_FLOW_OK;
not_negotiated:
@@ -908,17 +870,6 @@ not_negotiated:
GST_ERROR_OBJECT (videoflip, "Not negotiated yet");
return GST_FLOW_NOT_NEGOTIATED;
}
-invalid_in:
- {
- GST_ERROR_OBJECT (videoflip, "invalid input frame");
- return GST_FLOW_OK;
- }
-invalid_out:
- {
- GST_ERROR_OBJECT (videoflip, "invalid output frame");
- gst_video_frame_unmap (&src);
- return GST_FLOW_OK;
- }
}
static gboolean
@@ -928,6 +879,7 @@ gst_video_flip_src_event (GstBaseTransform * trans, GstEvent * event)
gdouble new_x, new_y, x, y;
GstStructure *structure;
gboolean ret;
+ GstVideoInfo *out_info = &GST_VIDEO_FILTER (trans)->out_info;
GST_DEBUG_OBJECT (vf, "handling %s event", GST_EVENT_TYPE_NAME (event));
@@ -943,31 +895,31 @@ gst_video_flip_src_event (GstBaseTransform * trans, GstEvent * event)
switch (vf->method) {
case GST_VIDEO_FLIP_METHOD_90R:
new_x = y;
- new_y = vf->out_info.width - x;
+ new_y = out_info->width - x;
break;
case GST_VIDEO_FLIP_METHOD_90L:
- new_x = vf->out_info.height - y;
+ new_x = out_info->height - y;
new_y = x;
break;
case GST_VIDEO_FLIP_METHOD_OTHER:
- new_x = vf->out_info.height - y;
- new_y = vf->out_info.width - x;
+ new_x = out_info->height - y;
+ new_y = out_info->width - x;
break;
case GST_VIDEO_FLIP_METHOD_TRANS:
new_x = y;
new_y = x;
break;
case GST_VIDEO_FLIP_METHOD_180:
- new_x = vf->out_info.width - x;
- new_y = vf->out_info.height - y;
+ new_x = out_info->width - x;
+ new_y = out_info->height - y;
break;
case GST_VIDEO_FLIP_METHOD_HORIZ:
- new_x = vf->out_info.width - x;
+ new_x = out_info->width - x;
new_y = y;
break;
case GST_VIDEO_FLIP_METHOD_VERT:
new_x = x;
- new_y = vf->out_info.height - y;
+ new_y = out_info->height - y;
break;
default:
new_x = x;
@@ -1047,6 +999,7 @@ gst_video_flip_class_init (GstVideoFlipClass * klass)
GObjectClass *gobject_class = (GObjectClass *) klass;
GstElementClass *gstelement_class = (GstElementClass *) klass;
GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
+ GstVideoFilterClass *vfilter_class = (GstVideoFilterClass *) klass;
GST_DEBUG_CATEGORY_INIT (video_flip_debug, "videoflip", 0, "videoflip");
@@ -1069,12 +1022,13 @@ gst_video_flip_class_init (GstVideoFlipClass * klass)
trans_class->transform_caps =
GST_DEBUG_FUNCPTR (gst_video_flip_transform_caps);
- trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_video_flip_set_caps);
- trans_class->get_unit_size = GST_DEBUG_FUNCPTR (gst_video_flip_get_unit_size);
- trans_class->transform = GST_DEBUG_FUNCPTR (gst_video_flip_transform);
trans_class->before_transform =
GST_DEBUG_FUNCPTR (gst_video_flip_before_transform);
trans_class->src_event = GST_DEBUG_FUNCPTR (gst_video_flip_src_event);
+
+ vfilter_class->set_info = GST_DEBUG_FUNCPTR (gst_video_flip_set_info);
+ vfilter_class->transform_frame =
+ GST_DEBUG_FUNCPTR (gst_video_flip_transform_frame);
}
static void
diff --git a/gst/videofilter/gstvideoflip.h b/gst/videofilter/gstvideoflip.h
index d520b03a3..dac4bdb5c 100644
--- a/gst/videofilter/gstvideoflip.h
+++ b/gst/videofilter/gstvideoflip.h
@@ -71,11 +71,8 @@ typedef struct _GstVideoFlipClass GstVideoFlipClass;
*/
struct _GstVideoFlip {
GstVideoFilter videofilter;
-
+
/* < private > */
- GstVideoInfo in_info;
- GstVideoInfo out_info;
-
GstVideoFlipMethod method;
void (*process) (GstVideoFlip *videoflip, GstVideoFrame *dest, const GstVideoFrame *src);
};