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

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