Blame SOURCES/0004-camerabin-Set-src_filter-and-zoom_src_filter-caps-wh.patch

56b13a
From 9ea00bf5e7043cab7da93abcb345b2f5c65285de Mon Sep 17 00:00:00 2001
56b13a
From: Hans de Goede <hdegoede@redhat.com>
56b13a
Date: Fri, 8 Jun 2012 13:39:37 +0200
56b13a
Subject: [PATCH 4/4] camerabin: Set src_filter and zoom_src_filter caps while
56b13a
 creating the pipeline
56b13a
56b13a
We (Fedora) have been receiving bug reports for cheese, about cheese
56b13a
taking 30-60 seconds before showing video, and pausing the same amount of
56b13a
time when changing the resolution for example.
56b13a
56b13a
I've managed to reproduce this with a Logitech Webcam Pro 9000, which
56b13a
supports a large list of resolutions at about 5 different framerates /
56b13a
resolution, in my case with an unmodified gst-plugins-bad-0.10.23, the
56b13a
camerabin_create_src_elements function takes approx 7 seconds.
56b13a
56b13a
Running under gdb and interrupting the execution during these 7 seconds
56b13a
consistenly points to gst_caps_intersect_full.
56b13a
56b13a
Part of the problem is cheese setting the
56b13a
GST_CAMERABIN_FLAG_SOURCE_COLOR_CONVERSION flag, which means that after
56b13a
the first ffmpegcsp element in the pipe the total number of caps is
56b13a
x resolutions * y framerates * z formats, where both x (due to the camera)
56b13a
and z (due to ffmpegcsp) being large. intersecting this with the capabilities
56b13a
of other parts of the pipeline simply leads to an explosion of combinations
56b13a
which pegs my core i5 CPU @3.1GHz for 7 seconds!
56b13a
56b13a
This patch fixes this issue by setting up the capsfilter elements in the pipe
56b13a
with an initial filter, greatly reducing the number of combinations when doing
56b13a
cap intersecting.
56b13a
56b13a
This reduces the time spend in camerabin_create_src_elements from approx 7
56b13a
to 0.2 seconds. And when patching cheese to use the default camerabin flags,
56b13a
(so removing the first ffmpegcsp element) from approx 0.7 to 0.04 seconds
56b13a
56b13a
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
56b13a
---
56b13a
 gst/camerabin/gstcamerabin.c |    7 +++++++
56b13a
 1 file changed, 7 insertions(+)
56b13a
56b13a
diff --git a/gst/camerabin/gstcamerabin.c b/gst/camerabin/gstcamerabin.c
56b13a
index a36d5b5..6d7d30f 100644
56b13a
--- a/gst/camerabin/gstcamerabin.c
56b13a
+++ b/gst/camerabin/gstcamerabin.c
56b13a
@@ -606,6 +606,7 @@ camerabin_create_src_elements (GstCameraBin * camera)
56b13a
   gboolean ret = FALSE;
56b13a
   GstBin *cbin = GST_BIN (camera);
56b13a
   gchar *driver_name = NULL;
56b13a
+  GstCaps *filter_caps;
56b13a
 
56b13a
   /* Add application set or default video src element */
56b13a
   if (!(camera->src_vid_src = gst_camerabin_setup_default_element (cbin,
56b13a
@@ -625,6 +626,10 @@ camerabin_create_src_elements (GstCameraBin * camera)
56b13a
           gst_camerabin_create_and_add_element (cbin, "capsfilter",
56b13a
               "src-capsfilter")))
56b13a
     goto done;
56b13a
+
56b13a
+  filter_caps = camerabin_create_view_finder_caps (camera);
56b13a
+  g_object_set (G_OBJECT (camera->src_filter), "caps", filter_caps, NULL);
56b13a
+
56b13a
   if (camera->flags & GST_CAMERABIN_FLAG_SOURCE_RESIZE) {
56b13a
     if (!(camera->src_zoom_crop =
56b13a
             gst_camerabin_create_and_add_element (cbin, "videocrop",
56b13a
@@ -638,6 +643,8 @@ camerabin_create_src_elements (GstCameraBin * camera)
56b13a
             gst_camerabin_create_and_add_element (cbin, "capsfilter",
56b13a
                 "src-resize-capsfilter")))
56b13a
       goto done;
56b13a
+    g_object_set (G_OBJECT (camera->src_zoom_filter), "caps", filter_caps,
56b13a
+                  NULL);
56b13a
   }
56b13a
   if (camera->app_video_filter) {
56b13a
     if (!gst_camerabin_add_element (cbin, camera->app_video_filter)) {
56b13a
-- 
56b13a
1.7.10.2
56b13a