videoconvert, videoscaleconvert: fix element description
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-base / gst / videoconvertscale / gstvideoconvertscale.c
index 577a03c..b6c4f44 100644 (file)
@@ -107,9 +107,6 @@ typedef struct
 
   gint borders_h;
   gint borders_w;
-
-  gboolean scales;
-  gboolean converts;
 } GstVideoConvertScalePrivate;
 
 #define gst_video_convert_scale_parent_class parent_class
@@ -118,7 +115,7 @@ G_DEFINE_TYPE_WITH_PRIVATE (GstVideoConvertScale, gst_video_convert_scale,
 GST_ELEMENT_REGISTER_DEFINE (videoconvertscale, "videoconvertscale",
     GST_RANK_SECONDARY, GST_TYPE_VIDEO_CONVERT_SCALE);
 
-#define PRIV(self) ((GstVideoConvertScalePrivate*)gst_video_convert_scale_get_instance_private(((GstVideoConvertScale*) self)))
+#define PRIV(self) gst_video_convert_scale_get_instance_private(((GstVideoConvertScale*) self))
 
 #define GST_CAT_DEFAULT video_convertscale_debug
 GST_DEBUG_CATEGORY_STATIC (video_convertscale_debug);
@@ -381,7 +378,7 @@ gst_video_convert_scale_class_init (GstVideoConvertScaleClass * klass)
   gst_element_class_set_static_metadata (element_class,
       "Video colorspace converter and scaler",
       "Filter/Converter/Video/Scaler/Colorspace",
-      "Resizes video and allow color conversion",
+      "Resizes video and converts from one colorspace to another",
       "Wim Taymans <wim.taymans@gmail.com>");
 
   gst_element_class_add_pad_template (element_class,
@@ -407,6 +404,10 @@ gst_video_convert_scale_class_init (GstVideoConvertScaleClass * klass)
   filter_class->set_info = GST_DEBUG_FUNCPTR (gst_video_convert_scale_set_info);
   filter_class->transform_frame =
       GST_DEBUG_FUNCPTR (gst_video_convert_scale_transform_frame);
+
+  klass->any_memory = FALSE;
+  klass->converts = TRUE;
+  klass->scales = TRUE;
 }
 
 static void
@@ -429,8 +430,6 @@ gst_video_convert_scale_init (GstVideoConvertScale * self)
   priv->matrix_mode = DEFAULT_PROP_MATRIX_MODE;
   priv->gamma_mode = DEFAULT_PROP_GAMMA_MODE;
   priv->primaries_mode = DEFAULT_PROP_PRIMARIES_MODE;
-  priv->scales = TRUE;
-  priv->converts = TRUE;
 }
 
 static void
@@ -577,11 +576,11 @@ static GstCaps *
 gst_video_convert_caps_remove_format_and_rangify_size_info (GstVideoConvertScale
     * self, GstCaps * caps)
 {
+  GstVideoConvertScaleClass *klass = GST_VIDEO_CONVERT_SCALE_GET_CLASS (self);
   GstCaps *ret;
   GstStructure *structure;
   GstCapsFeatures *features;
   gint i, n;
-  GstVideoConvertScalePrivate *priv = PRIV (self);
 
   ret = gst_caps_new_empty ();
 
@@ -603,8 +602,7 @@ gst_video_convert_caps_remove_format_and_rangify_size_info (GstVideoConvertScale
             || gst_caps_features_is_equal (features, features_format_interlaced)
             || gst_caps_features_is_equal (features,
                 features_format_interlaced_sysmem))) {
-
-      if (priv->scales) {
+      if (klass->scales) {
         gst_structure_set (structure, "width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
             "height", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
         /* if pixel aspect ratio, make a range of it */
@@ -614,7 +612,7 @@ gst_video_convert_caps_remove_format_and_rangify_size_info (GstVideoConvertScale
         }
       }
 
-      if (priv->converts) {
+      if (klass->converts) {
         gst_structure_remove_fields (structure, "format", "colorimetry",
             "chroma-site", NULL);
       }
@@ -630,9 +628,9 @@ static GstCaps *
 gst_video_convert_scale_transform_caps (GstBaseTransform * trans,
     GstPadDirection direction, GstCaps * caps, GstCaps * filter)
 {
+  GstVideoConvertScale *self = GST_VIDEO_CONVERT_SCALE (trans);
   gint i;
   GstCaps *ret;
-  GstVideoConvertScale *self = GST_VIDEO_CONVERT_SCALE (trans);
 
   GST_DEBUG_OBJECT (trans,
       "Transforming caps %" GST_PTR_FORMAT " in direction %s", caps,
@@ -794,12 +792,11 @@ gst_video_convert_scale_set_info (GstVideoFilter * filter, GstCaps * in,
    * we're converting between equivalent transfer functions, do passthrough */
   tmp_info = *in_info;
   tmp_info.colorimetry.transfer = out_info->colorimetry.transfer;
-  if (gst_video_info_is_equal (&tmp_info, out_info)) {
-    if (gst_video_transfer_function_is_equivalent (in_info->
-            colorimetry.transfer, in_info->finfo->bits,
-            out_info->colorimetry.transfer, out_info->finfo->bits)) {
-      gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (filter), TRUE);
-    }
+  if (gst_video_info_is_equal (&tmp_info, out_info) &&
+      gst_video_transfer_function_is_equivalent (in_info->colorimetry.transfer,
+          in_info->finfo->bits, out_info->colorimetry.transfer,
+          out_info->finfo->bits)) {
+    gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (filter), TRUE);
   } else {
     GstStructure *options;
     GST_CAT_DEBUG_OBJECT (CAT_PERFORMANCE, filter, "setup videoscaling");
@@ -1164,17 +1161,34 @@ transfer_colorimetry_from_input (GstBaseTransform * trans, GstCaps * in_caps,
     GstVideoInfo in_info, out_info;
     const GValue *in_colorimetry =
         gst_structure_get_value (in_caps_s, "colorimetry");
+    GstCaps *tmp_caps = NULL;
+    GstStructure *tmp_caps_s;
 
     if (!gst_video_info_from_caps (&in_info, in_caps)) {
       GST_WARNING_OBJECT (trans,
           "Failed to convert sink pad caps to video info");
       return;
     }
-    if (!gst_video_info_from_caps (&out_info, out_caps)) {
+
+    /* We are before fixate_size(), the width and height of
+       the output caps may be absent or not fixed. */
+    tmp_caps = gst_caps_copy (out_caps);
+    tmp_caps = gst_caps_fixate (tmp_caps);
+    tmp_caps_s = gst_caps_get_structure (tmp_caps, 0);
+    if (!gst_structure_has_field (tmp_caps_s, "width"))
+      gst_structure_set_value (tmp_caps_s, "width",
+          gst_structure_get_value (in_caps_s, "width"));
+    if (!gst_structure_has_field (tmp_caps_s, "height"))
+      gst_structure_set_value (tmp_caps_s, "height",
+          gst_structure_get_value (in_caps_s, "height"));
+
+    if (!gst_video_info_from_caps (&out_info, tmp_caps)) {
+      gst_clear_caps (&tmp_caps);
       GST_WARNING_OBJECT (trans,
           "Failed to convert src pad caps to video info");
       return;
     }
+    gst_clear_caps (&tmp_caps);
 
     if (!have_colorimetry && in_colorimetry != NULL) {
       if ((GST_VIDEO_INFO_IS_YUV (&out_info)
@@ -1232,6 +1246,7 @@ gst_video_convert_scale_get_fixed_format (GstBaseTransform * trans,
     result = gst_caps_copy (othercaps);
   }
 
+  result = gst_caps_make_writable (result);
   gst_video_convert_scale_fixate_format (trans, caps, result);
 
   /* fixate remaining fields */
@@ -1783,39 +1798,3 @@ gst_video_convert_scale_src_event (GstBaseTransform * trans, GstEvent * event)
 
   return ret;
 }
-
-void
-gst_video_convert_scale_set_scales (GstVideoConvertScale * self,
-    gboolean scales)
-{
-  GstVideoConvertScalePrivate *priv = PRIV (self);
-
-  if (!scales)
-    g_assert (priv->converts);
-
-  priv->scales = scales;
-}
-
-void
-gst_video_convert_scale_set_converts (GstVideoConvertScale * self,
-    gboolean converts)
-{
-  GstVideoConvertScalePrivate *priv = PRIV (self);
-
-  if (!converts)
-    g_assert (priv->scales);
-
-  priv->converts = converts;
-}
-
-gboolean
-gst_video_convert_scale_get_scales (GstVideoConvertScale * self)
-{
-  return PRIV (self)->scales;
-}
-
-gboolean
-gst_video_convert_scale_get_converts (GstVideoConvertScale * self)
-{
-  return PRIV (self)->converts;
-}