mfvideoenc: Allow only even resolution numbers
authorSeungha Yang <seungha@centricular.com>
Wed, 3 May 2023 19:44:31 +0000 (04:44 +0900)
committerTim-Philipp Müller <tim@centricular.com>
Fri, 5 May 2023 08:57:37 +0000 (09:57 +0100)
Some H/W vendors support odd resolution if D3D11 texture is used
or via IMF2DBuffer, but not all vendors support it.
Also software MFT does not allow odd resolution.

Fixes: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1165
Fixes: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/2537
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4548>

subprojects/gst-plugins-bad/sys/mediafoundation/gstmfvideoencoder.cpp

index 1c62740..34e510c 100644 (file)
@@ -1697,12 +1697,17 @@ gst_mf_video_encoder_enum_internal (GstMFTransform * transform, GUID & subtype,
   sink_caps = gst_caps_new_empty_simple ("video/x-raw");
   /* FIXME: don't hardcode max resolution, but MF doesn't provide
    * API for querying supported max resolution... */
-  gst_caps_set_simple (sink_caps,
-      "width", GST_TYPE_INT_RANGE, 64, 8192,
-      "height", GST_TYPE_INT_RANGE, 64, 8192, nullptr);
-  gst_caps_set_simple (src_caps,
-      "width", GST_TYPE_INT_RANGE, 64, 8192,
-      "height", GST_TYPE_INT_RANGE, 64, 8192, nullptr);
+
+  GValue res_val = G_VALUE_INIT;
+  g_value_init (&res_val, GST_TYPE_INT_RANGE);
+  gst_value_set_int_range_step (&res_val, 64, 8192, 2);
+
+  gst_caps_set_value (sink_caps, "width", &res_val);
+  gst_caps_set_value (sink_caps, "heigh", &res_val);
+  gst_caps_set_value (src_caps, "width", &res_val);
+  gst_caps_set_value (src_caps, "heigh", &res_val);
+
+  g_value_unset (&res_val);
 
 #if GST_MF_HAVE_D3D11
   /* Check whether this MFT can support D3D11 */