cudaupload,cudadownload: Don't simplify caps in transform_caps
authorSeungha Yang <seungha@centricular.com>
Sun, 14 Aug 2022 12:18:24 +0000 (21:18 +0900)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 15 Aug 2022 18:44:14 +0000 (18:44 +0000)
The simplified caps might not be a subset of filter caps
and basetransform will complain about it.

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

subprojects/gst-plugins-bad/sys/nvcodec/gstcudamemorycopy.c

index dbcfe4c..b766ec3 100644 (file)
@@ -206,33 +206,27 @@ static GstCaps *
 create_transform_caps (GstCaps * caps, gboolean to_cuda)
 {
   GstCaps *ret = NULL;
+  GstCaps *new_caps = NULL;
 
   if (to_cuda) {
-    GstCaps *sys_caps = gst_caps_simplify (_set_caps_features (caps,
-            GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY));
-    GstCaps *new_caps;
-
-    ret = gst_caps_copy (sys_caps);
+    /* SRC -> SINK of cudadownload or SINK -> SRC of cudaupload */
+    ret = gst_caps_copy (caps);
 
 #ifdef HAVE_NVCODEC_NVMM
     if (gst_cuda_nvmm_init_once ()) {
-      new_caps = _set_caps_features (sys_caps,
+      new_caps = _set_caps_features (caps,
           GST_CAPS_FEATURE_MEMORY_CUDA_NVMM_MEMORY);
       ret = gst_caps_merge (ret, new_caps);
     }
 #endif
 
-    new_caps = _set_caps_features (sys_caps,
-        GST_CAPS_FEATURE_MEMORY_CUDA_MEMORY);
+    new_caps = _set_caps_features (caps, GST_CAPS_FEATURE_MEMORY_CUDA_MEMORY);
     ret = gst_caps_merge (ret, new_caps);
 
     ret = gst_caps_make_writable (ret);
     _remove_field (ret, "texture-target");
-
-    gst_caps_unref (sys_caps);
   } else {
-    GstCaps *new_caps;
-
+    /* SINK -> SRC of cudadownload or SRC -> SINK of cudaupload */
     ret = gst_caps_ref (caps);
 
 #ifdef HAVE_NVCODEC_NVMM
@@ -253,8 +247,8 @@ create_transform_caps (GstCaps * caps, gboolean to_cuda)
 #endif
 
     new_caps = _set_caps_features (caps, GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY);
-
     ret = gst_caps_merge (ret, new_caps);
+
     ret = gst_caps_make_writable (ret);
     _remove_field (ret, "texture-target");
   }