docs: gst-launch -> gst-launch-1.0 and ffmpegcolorspace -> videoconvert
[platform/upstream/gstreamer.git] / gst / videofilter / gstvideobalance.c
index 0c3eeb6..4653b24 100644 (file)
@@ -32,7 +32,7 @@
  * <refsect2>
  * <title>Example launch line</title>
  * |[
- * gst-launch videotestsrc ! videobalance saturation=0.0 ! ffmpegcolorspace ! ximagesink
+ * gst-launch-1.0 videotestsrc ! videobalance saturation=0.0 ! videoconvert ! ximagesink
  * ]| This pipeline converts the image to black and white by setting the
  * saturation to 0.0.
  * </refsect2>
@@ -49,8 +49,7 @@
 #include "gstvideobalance.h"
 #include <string.h>
 
-#include <gst/controller/gstcontroller.h>
-#include <gst/interfaces/colorbalance.h>
+#include <gst/video/colorbalance.h>
 
 GST_DEBUG_CATEGORY_STATIC (videobalance_debug);
 #define GST_CAT_DEFAULT videobalance_debug
@@ -90,7 +89,8 @@ GST_STATIC_PAD_TEMPLATE ("sink",
             "I420, YV12, IYUV, Y41B }"))
     );
 
-static void gst_video_balance_colorbalance_init (GstColorBalanceClass * iface);
+static void gst_video_balance_colorbalance_init (GstColorBalanceInterface *
+    iface);
 
 static void gst_video_balance_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec);
@@ -156,13 +156,16 @@ gst_video_balance_is_passthrough (GstVideoBalance * videobalance)
 static void
 gst_video_balance_update_properties (GstVideoBalance * videobalance)
 {
-  gboolean passthrough = gst_video_balance_is_passthrough (videobalance);
+  gboolean passthrough;
   GstBaseTransform *base = GST_BASE_TRANSFORM (videobalance);
 
-  base->passthrough = passthrough;
-
+  GST_OBJECT_LOCK (videobalance);
+  passthrough = gst_video_balance_is_passthrough (videobalance);
   if (!passthrough)
     gst_video_balance_update_tables (videobalance);
+  GST_OBJECT_UNLOCK (videobalance);
+
+  gst_base_transform_set_passthrough (base, passthrough);
 }
 
 static void
@@ -354,21 +357,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 +398,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);
@@ -429,42 +422,25 @@ gst_video_balance_before_transform (GstBaseTransform * base, GstBuffer * buf)
       GST_TIME_ARGS (timestamp));
 
   if (GST_CLOCK_TIME_IS_VALID (stream_time))
-    gst_object_sync_values (G_OBJECT (balance), stream_time);
+    gst_object_sync_values (GST_OBJECT (balance), stream_time);
 }
 
 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)
-    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 +477,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");
@@ -525,7 +502,7 @@ gst_video_balance_class_init (GstVideoBalanceClass * klass)
           DEFAULT_PROP_SATURATION,
           GST_PARAM_CONTROLLABLE | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
-  gst_element_class_set_details_simple (gstelement_class, "Video balance",
+  gst_element_class_set_static_metadata (gstelement_class, "Video balance",
       "Filter/Effect/Video",
       "Adjusts brightness, contrast, hue, saturation on a video stream",
       "David Schleef <ds@schleef.org>");
@@ -535,11 +512,13 @@ 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);
+  trans_class->transform_ip_on_passthrough = FALSE;
+
+  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
@@ -604,7 +583,6 @@ gst_video_balance_colorbalance_set_value (GstColorBalance * balance,
   g_return_if_fail (GST_IS_VIDEO_FILTER (vb));
   g_return_if_fail (channel->label != NULL);
 
-  GST_BASE_TRANSFORM_LOCK (vb);
   GST_OBJECT_LOCK (vb);
   if (!g_ascii_strcasecmp (channel->label, "HUE")) {
     new_val = (value + 1000.0) * 2.0 / 2000.0 - 1.0;
@@ -627,7 +605,6 @@ gst_video_balance_colorbalance_set_value (GstColorBalance * balance,
   if (changed)
     gst_video_balance_update_properties (vb);
   GST_OBJECT_UNLOCK (vb);
-  GST_BASE_TRANSFORM_UNLOCK (vb);
 
   if (changed) {
     gst_color_balance_value_changed (balance, channel,
@@ -659,13 +636,19 @@ gst_video_balance_colorbalance_get_value (GstColorBalance * balance,
   return value;
 }
 
+static GstColorBalanceType
+gst_video_balance_colorbalance_get_balance_type (GstColorBalance * balance)
+{
+  return GST_COLOR_BALANCE_SOFTWARE;
+}
+
 static void
-gst_video_balance_colorbalance_init (GstColorBalanceClass * iface)
+gst_video_balance_colorbalance_init (GstColorBalanceInterface * iface)
 {
-  GST_COLOR_BALANCE_TYPE (iface) = GST_COLOR_BALANCE_SOFTWARE;
   iface->list_channels = gst_video_balance_colorbalance_list_channels;
   iface->set_value = gst_video_balance_colorbalance_set_value;
   iface->get_value = gst_video_balance_colorbalance_get_value;
+  iface->get_balance_type = gst_video_balance_colorbalance_get_balance_type;
 }
 
 static GstColorBalanceChannel *
@@ -690,7 +673,6 @@ gst_video_balance_set_property (GObject * object, guint prop_id,
   gdouble d;
   const gchar *label = NULL;
 
-  GST_BASE_TRANSFORM_LOCK (balance);
   GST_OBJECT_LOCK (balance);
   switch (prop_id) {
     case PROP_CONTRAST:
@@ -730,9 +712,8 @@ gst_video_balance_set_property (GObject * object, guint prop_id,
       break;
   }
 
-  gst_video_balance_update_properties (balance);
   GST_OBJECT_UNLOCK (balance);
-  GST_BASE_TRANSFORM_UNLOCK (balance);
+  gst_video_balance_update_properties (balance);
 
   if (label) {
     GstColorBalanceChannel *channel =