  
      f_par_n = gst_value_get_fraction_numerator (from_pix_ar);
      f_par_d = gst_value_get_fraction_denominator (from_pix_ar);
--- 
-2.27.0
-

-
-  othercaps = gst_caps_truncate (othercaps);
-  othercaps = gst_caps_make_writable (othercaps);
+  GST_DEBUG_OBJECT (btrans, "%s: othercaps size = %u\n", __func__, gst_caps_get_size (othercaps));
+  if (!gst_caps_is_writable(othercaps))
+    othercaps = gst_caps_make_writable (othercaps);
+  filter_context.found_nvfeature = FALSE;
+  filter_context.ift = ift;
+  gst_caps_filter_and_map_in_place (othercaps, nvmm_filter, &filter_context);
+  GST_DEBUG_OBJECT (btrans, "%s: after filtering othercaps size = %u (found=%d)\n",
+                    __func__, gst_caps_get_size (othercaps), filter_context.found_nvfeature);
+  gst_object_unref(ift);
+  if (filter_context.found_nvfeature)
+    othercaps = gst_caps_truncate (othercaps);
 
   GST_DEBUG_OBJECT (space, "trying to fixate othercaps %" GST_PTR_FORMAT
       " based on caps %" GST_PTR_FORMAT, othercaps, caps);
@@ -2215,7 +2225,10 @@ gst_nvvconv_fixate_caps (GstBaseTransform * btrans,
     gint numerator, denominator;
 
     /* from_pix_ar should be fixed */

From a0fd3692ff010976135091c5cfc718106212e5c5 Mon Sep 17 00:00:00 2001
From: Matt Madison <matt@madison.systems>
Date: Sun, 31 Jan 2021 09:51:46 -0800
Subject: [PATCH] Use filter function for fixating caps

To fix SIGSEGVs during caps negotiation.

---
 gstnvvconv.c | 51 ++++++++++++++++++++++++++++-----------------------
 1 file changed, 28 insertions(+), 23 deletions(-)

diff --git a/gstnvvconv.c b/gstnvvconv.c
index 2019c11..d5774b4 100644
--- a/gstnvvconv.c
+++ b/gstnvvconv.c
@@ -2094,6 +2094,23 @@ gst_nvvconv_get_unit_size (GstBaseTransform * btrans, GstCaps * caps,
   return ret;
 }
 
+static gboolean nvmm_filter (GstCapsFeatures *features,
+                             GstStructure *structure,
+                             gpointer user_data)
+{
+  return gst_caps_features_contains(features, GST_CAPS_FEATURE_MEMORY_NVMM);
+}
+
+static gboolean nvmm_find (GstCapsFeatures *features,
+                           GstStructure *structure,
+                           gpointer user_data)
+{
+  gboolean *have_nvmm = (gboolean *) user_data;
+  if (features && gst_caps_features_contains(features, GST_CAPS_FEATURE_MEMORY_NVMM))
+    *have_nvmm = TRUE;
+  return TRUE;
+}
+
 /**
   * Given the pad in direction and the given caps,
   * fixate the caps on the other pad.
@@ -2121,28 +2138,13 @@ gst_nvvconv_fixate_caps (GstBaseTransform * btrans,
   gboolean have_nvfeature = FALSE;
 
   space = GST_NVVCONV (btrans);
-  GstCapsFeatures *ift = NULL;
