capsfilter: allow NULL filters and fix refcounting
authorWim Taymans <wim.taymans@collabora.co.uk>
Mon, 16 May 2011 16:29:29 +0000 (18:29 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Mon, 16 May 2011 16:29:29 +0000 (18:29 +0200)
plugins/elements/gstcapsfilter.c

index 192939e..b70b93b 100644 (file)
@@ -258,8 +258,14 @@ gst_capsfilter_transform_caps (GstBaseTransform * base,
   filter_caps = gst_caps_ref (capsfilter->filter_caps);
   GST_OBJECT_UNLOCK (capsfilter);
 
-  tmp = gst_caps_intersect_full (filter, filter_caps, GST_CAPS_INTERSECT_FIRST);
-  ret = gst_caps_intersect_full (tmp, caps, GST_CAPS_INTERSECT_FIRST);
+  if (filter) {
+    tmp =
+        gst_caps_intersect_full (filter, filter_caps, GST_CAPS_INTERSECT_FIRST);
+    gst_caps_unref (filter_caps);
+    filter_caps = tmp;
+  }
+
+  ret = gst_caps_intersect_full (filter_caps, caps, GST_CAPS_INTERSECT_FIRST);
 
   GST_DEBUG_OBJECT (capsfilter, "input:     %" GST_PTR_FORMAT, caps);
   GST_DEBUG_OBJECT (capsfilter, "filter:    %" GST_PTR_FORMAT, filter);