videoconvert,videoscale: Do conversion in videoconvert and scaling in videoscale
authorSeungha Yang <seungha@centricular.com>
Fri, 5 Aug 2022 11:52:19 +0000 (20:52 +0900)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 16 Aug 2022 12:08:36 +0000 (12:08 +0000)
Keep behaving the same as before videoconvertscale port

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2778>

subprojects/gst-plugins-base/docs/plugins/gst_plugins_cache.json
subprojects/gst-plugins-base/gst/videoconvertscale/gstvideoconvert.c
subprojects/gst-plugins-base/gst/videoconvertscale/gstvideoconvertscale.c
subprojects/gst-plugins-base/gst/videoconvertscale/gstvideoconvertscale.h
subprojects/gst-plugins-base/gst/videoconvertscale/gstvideoscale.c

index 97ac972..d666e2d 100644 (file)
                     "GInitiallyUnowned",
                     "GObject"
                 ],
-                "klass": "Filter/Converter/Video/Scaler/Colorspace",
-                "long-name": "Video colorspace converter and scaler",
+                "klass": "Filter/Converter/Video/Colorspace",
+                "long-name": "Video colorspace converter",
                 "pad-templates": {
                     "sink": {
                         "caps": "video/x-raw:\n         format: { ABGR64_LE, BGRA64_LE, AYUV64, ARGB64_LE, ARGB64, RGBA64_LE, ABGR64_BE, BGRA64_BE, ARGB64_BE, RGBA64_BE, GBRA_12LE, GBRA_12BE, Y412_LE, Y412_BE, A444_10LE, GBRA_10LE, A444_10BE, GBRA_10BE, A422_10LE, A422_10BE, A420_10LE, A420_10BE, RGB10A2_LE, BGR10A2_LE, Y410, GBRA, ABGR, VUYA, BGRA, AYUV, ARGB, RGBA, A420, AV12, Y444_16LE, Y444_16BE, v216, P016_LE, P016_BE, Y444_12LE, GBR_12LE, Y444_12BE, GBR_12BE, I422_12LE, I422_12BE, Y212_LE, Y212_BE, I420_12LE, I420_12BE, P012_LE, P012_BE, Y444_10LE, GBR_10LE, Y444_10BE, GBR_10BE, r210, I422_10LE, I422_10BE, NV16_10LE32, Y210, v210, UYVP, I420_10LE, I420_10BE, P010_10LE, NV12_10LE32, NV12_10LE40, P010_10BE, NV12_10BE_8L128, Y444, RGBP, GBR, BGRP, NV24, xBGR, BGRx, xRGB, RGBx, BGR, IYU2, v308, RGB, Y42B, NV61, NV16, VYUY, UYVY, YVYU, YUY2, I420, YV12, NV21, NV12, NV12_8L128, NV12_64Z32, NV12_4L4, NV12_32L32, NV12_16L32S, Y41B, IYU1, YVU9, YUV9, RGB16, BGR16, RGB15, BGR15, RGB8P, GRAY16_LE, GRAY16_BE, GRAY10_LE32, GRAY8 }\n          width: [ 1, 32767 ]\n         height: [ 1, 32767 ]\n      framerate: [ 0/1, 2147483647/1 ]\n\nvideo/x-raw(ANY):\n         format: { ABGR64_LE, BGRA64_LE, AYUV64, ARGB64_LE, ARGB64, RGBA64_LE, ABGR64_BE, BGRA64_BE, ARGB64_BE, RGBA64_BE, GBRA_12LE, GBRA_12BE, Y412_LE, Y412_BE, A444_10LE, GBRA_10LE, A444_10BE, GBRA_10BE, A422_10LE, A422_10BE, A420_10LE, A420_10BE, RGB10A2_LE, BGR10A2_LE, Y410, GBRA, ABGR, VUYA, BGRA, AYUV, ARGB, RGBA, A420, AV12, Y444_16LE, Y444_16BE, v216, P016_LE, P016_BE, Y444_12LE, GBR_12LE, Y444_12BE, GBR_12BE, I422_12LE, I422_12BE, Y212_LE, Y212_BE, I420_12LE, I420_12BE, P012_LE, P012_BE, Y444_10LE, GBR_10LE, Y444_10BE, GBR_10BE, r210, I422_10LE, I422_10BE, NV16_10LE32, Y210, v210, UYVP, I420_10LE, I420_10BE, P010_10LE, NV12_10LE32, NV12_10LE40, P010_10BE, NV12_10BE_8L128, Y444, RGBP, GBR, BGRP, NV24, xBGR, BGRx, xRGB, RGBx, BGR, IYU2, v308, RGB, Y42B, NV61, NV16, VYUY, UYVY, YVYU, YUY2, I420, YV12, NV21, NV12, NV12_8L128, NV12_64Z32, NV12_4L4, NV12_32L32, NV12_16L32S, Y41B, IYU1, YVU9, YUV9, RGB16, BGR16, RGB15, BGR15, RGB8P, GRAY16_LE, GRAY16_BE, GRAY10_LE32, GRAY8 }\n          width: [ 1, 32767 ]\n         height: [ 1, 32767 ]\n      framerate: [ 0/1, 2147483647/1 ]\n",
             },
             "videoconvertscale": {
                 "author": "Wim Taymans <wim.taymans@gmail.com>",
-                "description": "Resizes video and allow color conversion",
+                "description": "Converts video from one colorspace to another",
                 "hierarchy": [
                     "GstVideoConvertScale",
                     "GstVideoFilter",
             },
             "videoscale": {
                 "author": "Wim Taymans <wim.taymans@gmail.com>",
-                "description": "Resizes video and allow color conversion",
+                "description": "Resizes video",
                 "hierarchy": [
                     "GstVideoScale",
                     "GstVideoConvertScale",
                     "GInitiallyUnowned",
                     "GObject"
                 ],
-                "klass": "Filter/Converter/Video/Scaler/Colorspace",
-                "long-name": "Video colorspace converter and scaler",
+                "klass": "Filter/Converter/Video/Scaler",
+                "long-name": "Video scaler",
                 "pad-templates": {
                     "sink": {
                         "caps": "video/x-raw:\n         format: { ABGR64_LE, BGRA64_LE, AYUV64, ARGB64_LE, ARGB64, RGBA64_LE, ABGR64_BE, BGRA64_BE, ARGB64_BE, RGBA64_BE, GBRA_12LE, GBRA_12BE, Y412_LE, Y412_BE, A444_10LE, GBRA_10LE, A444_10BE, GBRA_10BE, A422_10LE, A422_10BE, A420_10LE, A420_10BE, RGB10A2_LE, BGR10A2_LE, Y410, GBRA, ABGR, VUYA, BGRA, AYUV, ARGB, RGBA, A420, AV12, Y444_16LE, Y444_16BE, v216, P016_LE, P016_BE, Y444_12LE, GBR_12LE, Y444_12BE, GBR_12BE, I422_12LE, I422_12BE, Y212_LE, Y212_BE, I420_12LE, I420_12BE, P012_LE, P012_BE, Y444_10LE, GBR_10LE, Y444_10BE, GBR_10BE, r210, I422_10LE, I422_10BE, NV16_10LE32, Y210, v210, UYVP, I420_10LE, I420_10BE, P010_10LE, NV12_10LE32, NV12_10LE40, P010_10BE, NV12_10BE_8L128, Y444, RGBP, GBR, BGRP, NV24, xBGR, BGRx, xRGB, RGBx, BGR, IYU2, v308, RGB, Y42B, NV61, NV16, VYUY, UYVY, YVYU, YUY2, I420, YV12, NV21, NV12, NV12_8L128, NV12_64Z32, NV12_4L4, NV12_32L32, NV12_16L32S, Y41B, IYU1, YVU9, YUV9, RGB16, BGR16, RGB15, BGR15, RGB8P, GRAY16_LE, GRAY16_BE, GRAY10_LE32, GRAY8 }\n          width: [ 1, 32767 ]\n         height: [ 1, 32767 ]\n      framerate: [ 0/1, 2147483647/1 ]\n\nvideo/x-raw(ANY):\n         format: { ABGR64_LE, BGRA64_LE, AYUV64, ARGB64_LE, ARGB64, RGBA64_LE, ABGR64_BE, BGRA64_BE, ARGB64_BE, RGBA64_BE, GBRA_12LE, GBRA_12BE, Y412_LE, Y412_BE, A444_10LE, GBRA_10LE, A444_10BE, GBRA_10BE, A422_10LE, A422_10BE, A420_10LE, A420_10BE, RGB10A2_LE, BGR10A2_LE, Y410, GBRA, ABGR, VUYA, BGRA, AYUV, ARGB, RGBA, A420, AV12, Y444_16LE, Y444_16BE, v216, P016_LE, P016_BE, Y444_12LE, GBR_12LE, Y444_12BE, GBR_12BE, I422_12LE, I422_12BE, Y212_LE, Y212_BE, I420_12LE, I420_12BE, P012_LE, P012_BE, Y444_10LE, GBR_10LE, Y444_10BE, GBR_10BE, r210, I422_10LE, I422_10BE, NV16_10LE32, Y210, v210, UYVP, I420_10LE, I420_10BE, P010_10LE, NV12_10LE32, NV12_10LE40, P010_10BE, NV12_10BE_8L128, Y444, RGBP, GBR, BGRP, NV24, xBGR, BGRx, xRGB, RGBx, BGR, IYU2, v308, RGB, Y42B, NV61, NV16, VYUY, UYVY, YVYU, YUY2, I420, YV12, NV21, NV12, NV12_8L128, NV12_64Z32, NV12_4L4, NV12_32L32, NV12_16L32S, Y41B, IYU1, YVU9, YUV9, RGB16, BGR16, RGB15, BGR15, RGB8P, GRAY16_LE, GRAY16_BE, GRAY10_LE32, GRAY8 }\n          width: [ 1, 32767 ]\n         height: [ 1, 32767 ]\n      framerate: [ 0/1, 2147483647/1 ]\n",
index ff8b4f1..88f3de0 100644 (file)
@@ -49,7 +49,19 @@ GST_ELEMENT_REGISTER_DEFINE (videoconvert, "videoconvert",
 static void
 gst_video_convert_class_init (GstVideoConvertClass * klass)
 {
-  ((GstVideoConvertScaleClass *) klass)->any_memory = TRUE;
+  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstVideoConvertScaleClass *convertscale_class =
+      GST_VIDEO_CONVERT_SCALE_CLASS (klass);
+
+  gst_element_class_set_static_metadata (element_class,
+      "Video colorspace converter",
+      "Filter/Converter/Video/Colorspace",
+      "Resizes video and allow color conversion",
+      "Wim Taymans <wim.taymans@gmail.com>");
+
+  convertscale_class->any_memory = TRUE;
+  convertscale_class->converts = TRUE;
+  convertscale_class->scales = FALSE;
 }
 
 static void
index ace06ab..f85ee5d 100644 (file)
@@ -378,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",
+      "Converts video from one colorspace to another",
       "Wim Taymans <wim.taymans@gmail.com>");
 
   gst_element_class_add_pad_template (element_class,
@@ -404,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
@@ -569,8 +573,10 @@ gst_video_convert_scale_get_property (GObject * object, guint prop_id,
 }
 
 static GstCaps *
-gst_video_convert_caps_remove_format_and_rangify_size_info (GstCaps * caps)
+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;
@@ -596,15 +602,20 @@ gst_video_convert_caps_remove_format_and_rangify_size_info (GstCaps * caps)
             || gst_caps_features_is_equal (features, features_format_interlaced)
             || gst_caps_features_is_equal (features,
                 features_format_interlaced_sysmem))) {
-      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 */
-      if (gst_structure_has_field (structure, "pixel-aspect-ratio")) {
-        gst_structure_set (structure, "pixel-aspect-ratio",
-            GST_TYPE_FRACTION_RANGE, 1, G_MAXINT, G_MAXINT, 1, NULL);
+      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 */
+        if (gst_structure_has_field (structure, "pixel-aspect-ratio")) {
+          gst_structure_set (structure, "pixel-aspect-ratio",
+              GST_TYPE_FRACTION_RANGE, 1, G_MAXINT, G_MAXINT, 1, NULL);
+        }
+      }
+
+      if (klass->converts) {
+        gst_structure_remove_fields (structure, "format", "colorimetry",
+            "chroma-site", NULL);
       }
-      gst_structure_remove_fields (structure, "format", "colorimetry",
-          "chroma-site", NULL);
     }
     gst_caps_append_structure_full (ret, structure,
         gst_caps_features_copy (features));
@@ -617,6 +628,7 @@ 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;
 
@@ -624,7 +636,7 @@ gst_video_convert_scale_transform_caps (GstBaseTransform * trans,
       "Transforming caps %" GST_PTR_FORMAT " in direction %s", caps,
       (direction == GST_PAD_SINK) ? "sink" : "src");
 
-  ret = gst_video_convert_caps_remove_format_and_rangify_size_info (caps);
+  ret = gst_video_convert_caps_remove_format_and_rangify_size_info (self, caps);
   if (filter) {
     GstCaps *intersection;
 
index 64be8b1..1b24add 100644 (file)
@@ -38,6 +38,8 @@ struct _GstVideoConvertScaleClass
   GstVideoFilterClass parent;
 
   gboolean any_memory;
+  gboolean scales;
+  gboolean converts;
 };
 
 /**
index e8e41f1..5e6cfbd 100644 (file)
@@ -107,17 +107,26 @@ gst_video_scale_set_property (GObject * object, guint prop_id,
 static void
 gst_video_scale_class_init (GstVideoScaleClass * klass)
 {
-  GObjectClass *gobject_class = (GObjectClass *) klass;
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstVideoConvertScaleClass *convertscale_class =
+      GST_VIDEO_CONVERT_SCALE_CLASS (klass);
 
   gobject_class->set_property = gst_video_scale_set_property;
   gobject_class->get_property = gst_video_scale_get_property;
 
-  ((GstVideoConvertScaleClass *) klass)->any_memory = TRUE;
-
   g_object_class_install_property (gobject_class, PROP_GAMMA_DECODE,
       g_param_spec_boolean ("gamma-decode", "Gamma Decode",
           "Decode gamma before scaling", DEFAULT_PROP_GAMMA_DECODE,
           G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  gst_element_class_set_static_metadata (element_class,
+      "Video scaler", "Filter/Converter/Video/Scaler",
+      "Resizes video", "Wim Taymans <wim.taymans@gmail.com>");
+
+  convertscale_class->any_memory = TRUE;
+  convertscale_class->converts = FALSE;
+  convertscale_class->scales = TRUE;
 }
 
 static void