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