v4l2: Optimize negotiation by removing the query filter
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>
Wed, 19 Jun 2013 10:37:31 +0000 (12:37 +0200)
committerSjoerd Simons <sjoerd@luon.net>
Wed, 19 Jun 2013 13:05:25 +0000 (15:05 +0200)
As cameras tend to have a quite specific set of capabilities (specific
framerates for each resolution), getting the peer caps filtered by our
probed caps can cause a big increase in the caps size which slows down
things quire a bit.

As for negotiation v4l2 iterates through the caps of the peer to find the
first intersection with the probed caps, getting the fully expanded
intersection of capabilities is not useful.

Using the same testcase as for bug #702632, adding this patch on top of
the patches suggested there speeds up getting the inital frame from
around ~14-15 seconds to around ~3-4 seconds.

https://bugzilla.gnome.org/show_bug.cgi?id=702638

sys/v4l2/gstv4l2src.c

index 9f5c92e..107ea21 100644 (file)
@@ -330,8 +330,8 @@ gst_v4l2src_negotiate (GstBaseSrc * basesrc)
   if (thiscaps == NULL || gst_caps_is_any (thiscaps))
     goto no_nego_needed;
 
-  /* get the peer caps */
-  peercaps = gst_pad_peer_query_caps (GST_BASE_SRC_PAD (basesrc), thiscaps);
+  /* get the peer caps without a filter as we'll filter ourselves later on */
+  peercaps = gst_pad_peer_query_caps (GST_BASE_SRC_PAD (basesrc), NULL);
   GST_DEBUG_OBJECT (basesrc, "caps of peer: %" GST_PTR_FORMAT, peercaps);
   LOG_CAPS (basesrc, peercaps);
   if (peercaps && !gst_caps_is_any (peercaps)) {