vapostproc: Build classification dynamically.
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Tue, 29 Mar 2022 18:14:40 +0000 (20:14 +0200)
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Wed, 30 Mar 2022 04:24:35 +0000 (04:24 +0000)
By default, the classification is
"Converter/Filter/Colorspace/Scaler/Video/Hardware", but if VA
post-processor driver supports either color balance, skin tone
enhancement, sharpening or noise reduction, "Effect" is added.

Thus, if vapostproc ranking is raised, it can be chosen by
autovideosink.

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

subprojects/gst-plugins-bad/sys/va/gstvavpp.c

index a47b25c..4bf7dc9 100644 (file)
@@ -2021,6 +2021,7 @@ gst_va_vpp_class_init (gpointer g_class, gpointer class_data)
   GstVaFilter *filter;
   struct CData *cdata = class_data;
   gchar *long_name;
+  GString *klass;
 
   parent_class = g_type_class_peek_parent (g_class);
 
@@ -2033,10 +2034,7 @@ gst_va_vpp_class_init (gpointer g_class, gpointer class_data)
     long_name = g_strdup ("VA-API Video Postprocessor");
   }
 
-  gst_element_class_set_metadata (element_class, long_name,
-      "Filter/Converter/Video/Scaler/Hardware",
-      "VA-API based video postprocessor",
-      "Víctor Jáquez <vjaquez@igalia.com>");
+  klass = g_string_new ("Converter/Filter/Colorspace/Scaler/Video/Hardware");
 
   display = gst_va_display_drm_new_from_path (btrans_class->render_device_path);
   filter = gst_va_filter_new (display);
@@ -2050,10 +2048,32 @@ gst_va_vpp_class_init (gpointer g_class, gpointer class_data)
       gst_caps_set_features_simple (any_caps, gst_caps_features_new_any ());
       caps = gst_caps_merge (caps, any_caps);
     }
+
+    /* add converter klass */
+    {
+      int i;
+      VAProcFilterType types[] = { VAProcFilterColorBalance,
+        VAProcFilterSkinToneEnhancement, VAProcFilterSharpening,
+        VAProcFilterNoiseReduction
+      };
+
+      for (i = 0; i < G_N_ELEMENTS (types); i++) {
+        if (gst_va_filter_has_filter (filter, types[i])) {
+          g_string_prepend (klass, "Effect/");
+          break;
+        }
+      }
+    }
   } else {
     caps = gst_caps_from_string (caps_str);
   }
 
+  gst_element_class_set_metadata (element_class, long_name, klass->str,
+      "VA-API based video postprocessor",
+      "Víctor Jáquez <vjaquez@igalia.com>");
+
+  g_string_free (klass, TRUE);
+
   doc_caps = gst_caps_from_string (caps_str);
 
   sink_pad_templ = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,