[cheese/f17] Reduce camerabin pipeline creation time (rhbz#797188, gnome#677731)
Hans de Goede
jwrdegoede at fedoraproject.org
Tue Jun 19 21:31:14 UTC 2012
commit e9fed6766de3c04725a14c778040f81beffe30c6
Author: Hans de Goede <hdegoede at redhat.com>
Date: Tue Jun 19 23:35:52 2012 +0200
Reduce camerabin pipeline creation time (rhbz#797188, gnome#677731)
- Don't add 0 byte sized files to the thumb-view (rhbz#830166, gnome#677735)
- Fix sizing of horizontal thumbnail list (rhbz#829957)
- Optimize encoding parameters (rhbz#572169)
...ra-Don-t-overwrite-camerabin-s-default-fl.patch | 61 ++++++++++
...b-view-Don-t-add-0-sized-files-to-the-thu.patch | 48 ++++++++
...b-view-Don-t-set-columns-to-5000-in-horiz.patch | 126 ++++++++++++++++++++
0008-cheese-optimize-encoding.patch | 58 +++++++++
cheese.spec | 19 +++-
5 files changed, 311 insertions(+), 1 deletions(-)
---
diff --git a/0005-cheese-camera-Don-t-overwrite-camerabin-s-default-fl.patch b/0005-cheese-camera-Don-t-overwrite-camerabin-s-default-fl.patch
new file mode 100644
index 0000000..26a5ab1
--- /dev/null
+++ b/0005-cheese-camera-Don-t-overwrite-camerabin-s-default-fl.patch
@@ -0,0 +1,61 @@
+From 90d318aadb255be77c7e27764716df6cd5a1fe0e Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede at redhat.com>
+Date: Fri, 8 Jun 2012 23:18:32 +0200
+Subject: [PATCH] cheese-camera: Don't overwrite camerabin's default flags
+
+The comment above this code said: "Set flags to enable conversions", but
+camerabin has conversion enabled in the necessary places by default, all
+the code does is add an extra, unneeded ffmpegcsp element at the beginning
+of the pipeline.
+
+This results in a huge number of reported caps on pads further down the
+pipeline, which when intersected with input caps of later ffmpegcsp elements
+leads to an explosion of possible combinations and gst_caps_intersect_full
+starts consuming the cpu for 100% for seconds (various Fedora users have
+reported startup delays of upto a minute).
+
+On my test system, with a Logitech webcam 9000 pro, the time to create
+the camerabin pipeline (not start, not configure, just create!) drops
+from 7 seconds to 0.7 seconds by elimenating the unnecessary ffmpegcsp
+element at the beginning of the pipe.
+
+The only reason the ffmpegcsp element this patch removes could be useful
+would be for cameras producing only jpeg data, but since cheese always uses
+v4l2src, and that should always be compiled with libv4l2 support (otherwise
+a lot of camera specific video formats will not be understood), libv4l2 will
+take care of jpeg decompression, so there really is no reason for having
+this extra element, and thus no reason to override the default camerabin
+flags.
+
+Signed-off-by: Hans de Goede <hdegoede at redhat.com>
+---
+ libcheese/cheese-camera.c | 12 ------------
+ 1 file changed, 12 deletions(-)
+
+diff --git a/libcheese/cheese-camera.c b/libcheese/cheese-camera.c
+index 7b8eb70..73cda1a 100644
+--- a/libcheese/cheese-camera.c
++++ b/libcheese/cheese-camera.c
+@@ -1494,19 +1494,7 @@ cheese_camera_setup (CheeseCamera *camera, const gchar *uuid, GError **error)
+ g_object_set (G_OBJECT (video_sink), "async", FALSE, NULL);
+ g_object_set (G_OBJECT (priv->camerabin), "viewfinder-sink", video_sink, NULL);
+
+- /* Set flags to enable conversions*/
+-
+- g_object_set (G_OBJECT (priv->camerabin), "flags",
+- GST_CAMERABIN_FLAG_SOURCE_RESIZE |
+- GST_CAMERABIN_FLAG_SOURCE_COLOR_CONVERSION |
+- GST_CAMERABIN_FLAG_VIEWFINDER_SCALE |
+- GST_CAMERABIN_FLAG_AUDIO_CONVERSION |
+- GST_CAMERABIN_FLAG_IMAGE_COLOR_CONVERSION |
+- GST_CAMERABIN_FLAG_VIDEO_COLOR_CONVERSION,
+- NULL);
+-
+ /* Set caps to filter, so it doesn't defaults to I420 format*/
+-
+ caps = gst_caps_from_string ("video/x-raw-yuv; video/x-raw-rgb");
+ g_object_set (G_OBJECT (priv->camerabin), "filter-caps", caps, NULL);
+ gst_caps_unref (caps);
+--
+1.7.10.2
+
diff --git a/0006-cheese-thumb-view-Don-t-add-0-sized-files-to-the-thu.patch b/0006-cheese-thumb-view-Don-t-add-0-sized-files-to-the-thu.patch
new file mode 100644
index 0000000..41d763f
--- /dev/null
+++ b/0006-cheese-thumb-view-Don-t-add-0-sized-files-to-the-thu.patch
@@ -0,0 +1,48 @@
+From 176a3f264f6a8eb08ca5ec9dc300198f591ac1b7 Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede at redhat.com>
+Date: Sat, 9 Jun 2012 00:06:20 +0200
+Subject: [PATCH] cheese-thumb-view: Don't add 0 sized files to the thumb view
+
+Sometimes, ie when cheese crashes when starting to record, something which
+we need to fix, 0 bytes large files are created under ~/Videos/Webcam.
+
+totem-video-thumbnailer does not like these, getting stuck for approx a minute
+on them, I've filed a bug for this here:
+https://bugzilla.gnome.org/show_bug.cgi?id=677734
+
+But even with this bug fixed, trying to add 0 byte sized files to the
+thumb view makes no sense, and in the mean time it also neatly works
+around this totem-video-thumbnailer bug.
+
+Signed-off-by: Hans de Goede <hdegoede at redhat.com>
+---
+ src/thumbview/cheese-thumb-view.c | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+diff --git a/src/thumbview/cheese-thumb-view.c b/src/thumbview/cheese-thumb-view.c
+index 5c06ff3..49bc31a 100644
+--- a/src/thumbview/cheese-thumb-view.c
++++ b/src/thumbview/cheese-thumb-view.c
+@@ -197,9 +197,19 @@ cheese_thumb_view_append_item (CheeseThumbView *thumb_view, GFile *file)
+ char *filename, *basename, *col_filename;
+ GError *error = NULL;
+ gboolean skip = FALSE;
++ GFileInfo *info;
++ goffset size;
+
+ CheeseThumbViewIdleData *data;
+
++ info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_SIZE, 0, NULL,
++ NULL);
++ size = g_file_info_get_size(info);
++ g_object_unref (info);
++
++ if (size == 0)
++ return;
++
+ filename = g_file_get_path (file);
+
+ if (!(g_str_has_suffix (filename, CHEESE_PHOTO_NAME_SUFFIX))
+--
+1.7.10.2
+
diff --git a/0007-cheese-thumb-view-Don-t-set-columns-to-5000-in-horiz.patch b/0007-cheese-thumb-view-Don-t-set-columns-to-5000-in-horiz.patch
new file mode 100644
index 0000000..5b81351
--- /dev/null
+++ b/0007-cheese-thumb-view-Don-t-set-columns-to-5000-in-horiz.patch
@@ -0,0 +1,126 @@
+From 4f6953de531316e0385aaace9ae5f2400e4451c8 Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede at redhat.com>
+Date: Sun, 10 Jun 2012 14:50:54 +0200
+Subject: [PATCH] cheese-thumb-view: Don't set columns to 5000 in horizontal
+ mode
+
+Rather then assuming 5000 will be enough, just set the number of columns to
+the number of thumbnails we have.
+
+Signed-off-by: Hans de Goede <hdegoede at redhat.com>
+---
+ src/cheese-window.vala | 4 ++--
+ src/thumbview/cheese-thumb-view.c | 21 ++++++++++++++++++++-
+ src/thumbview/cheese-thumb-view.h | 1 +
+ src/vapi/cheese-thumbview.vapi | 1 +
+ 4 files changed, 24 insertions(+), 3 deletions(-)
+
+diff --git a/src/cheese-window.vala b/src/cheese-window.vala
+index 12ef2e0..0ab0d2d 100644
+--- a/src/cheese-window.vala
++++ b/src/cheese-window.vala
+@@ -837,7 +837,7 @@ public class Cheese.MainWindow : Gtk.Window
+
+ if (is_wide_mode)
+ {
+- thumb_view.set_columns (1);
++ thumb_view.set_vertical (true);
+ thumb_nav.set_vertical (true);
+ if (thumbnails_bottom.get_child () != null)
+ {
+@@ -850,7 +850,7 @@ public class Cheese.MainWindow : Gtk.Window
+ }
+ else
+ {
+- thumb_view.set_columns (5000);
++ thumb_view.set_vertical (false);
+ thumb_nav.set_vertical (false);
+ if (thumbnails_right.get_child () != null)
+ {
+diff --git a/src/thumbview/cheese-thumb-view.c b/src/thumbview/cheese-thumb-view.c
+index 49bc31a..243d325 100644
+--- a/src/thumbview/cheese-thumb-view.c
++++ b/src/thumbview/cheese-thumb-view.c
+@@ -51,6 +51,7 @@ typedef struct
+ GFileMonitor *video_file_monitor;
+ GnomeDesktopThumbnailFactory *factory;
+ gboolean multiplex_thumbnail_generator;
++ gboolean vertical;
+ guint n_items;
+ guint idle_id;
+ GQueue *thumbnails;
+@@ -601,7 +602,10 @@ cheese_thumb_view_row_inserted_cb (GtkTreeModel *tree_model,
+ CheeseThumbViewPrivate *priv = CHEESE_THUMB_VIEW_GET_PRIVATE (thumb_view);
+
+ priv->n_items++;
+- gtk_widget_set_size_request (GTK_WIDGET (thumb_view), -1, -1);
++ if (!priv->vertical)
++ gtk_icon_view_set_columns(GTK_ICON_VIEW (thumb_view), priv->n_items);
++ else
++ gtk_widget_set_size_request (GTK_WIDGET (thumb_view), -1, -1);
+ }
+
+ static void
+@@ -616,6 +620,8 @@ cheese_thumb_view_row_deleted_cb (GtkTreeModel *tree_model,
+ gtk_widget_set_size_request (GTK_WIDGET (thumb_view),
+ THUMB_VIEW_MINIMUM_WIDTH,
+ THUMB_VIEW_MINIMUM_HEIGHT);
++ else if (!priv->vertical)
++ gtk_icon_view_set_columns(GTK_ICON_VIEW (thumb_view), priv->n_items);
+ }
+
+ static void
+@@ -684,6 +690,7 @@ cheese_thumb_view_constructed (GObject *object)
+ THUMBNAIL_BASENAME_URL_COLUMN, GTK_SORT_ASCENDING);
+
+ cheese_thumb_view_fill (thumb_view);
++ cheese_thumb_view_set_vertical (thumb_view, FALSE);
+ }
+
+ GtkWidget *
+@@ -696,6 +703,18 @@ cheese_thumb_view_new ()
+ }
+
+ void
++cheese_thumb_view_set_vertical (CheeseThumbView *thumb_view, gboolean vertical)
++{
++ CheeseThumbViewPrivate *priv = CHEESE_THUMB_VIEW_GET_PRIVATE (thumb_view);
++
++ priv->vertical = vertical;
++ if (!priv->vertical && priv->n_items)
++ gtk_icon_view_set_columns(GTK_ICON_VIEW (thumb_view), priv->n_items);
++ else
++ gtk_icon_view_set_columns(GTK_ICON_VIEW (thumb_view), 1);
++}
++
++void
+ cheese_thumb_view_start_monitoring_photo_path (CheeseThumbView *thumb_view, const char *path_photos)
+ {
+ CheeseThumbViewPrivate *priv = CHEESE_THUMB_VIEW_GET_PRIVATE (thumb_view);
+diff --git a/src/thumbview/cheese-thumb-view.h b/src/thumbview/cheese-thumb-view.h
+index 140a283..b2ca2b3 100644
+--- a/src/thumbview/cheese-thumb-view.h
++++ b/src/thumbview/cheese-thumb-view.h
+@@ -54,6 +54,7 @@ GList *cheese_thumb_view_get_selected_images_list (CheeseThumbView *thumb_view);
+ char * cheese_thumb_view_get_selected_image (CheeseThumbView *thumb_view);
+ guint cheese_thumb_view_get_n_selected (CheeseThumbView *thumbview);
+ void cheese_thumb_view_remove_item (CheeseThumbView *thumb_view, GFile *file);
++void cheese_thumb_view_set_vertical (CheeseThumbView *thumb_view, gboolean vertical);
+ void cheese_thumb_view_start_monitoring_photo_path (CheeseThumbView *thumbview, const char *path_photos);
+ void cheese_thumb_view_start_monitoring_video_path (CheeseThumbView *thumbview, const char *path_videos);
+
+diff --git a/src/vapi/cheese-thumbview.vapi b/src/vapi/cheese-thumbview.vapi
+index 669b724..61b323e 100644
+--- a/src/vapi/cheese-thumbview.vapi
++++ b/src/vapi/cheese-thumbview.vapi
+@@ -9,6 +9,7 @@ namespace Cheese
+ public List<GLib.File> get_selected_images_list ();
+ public int get_n_selected ();
+ public void remove_item (GLib.File file);
++ public void set_vertical (bool vertical);
+ public void start_monitoring_photo_path (string path_photos);
+ public void start_monitoring_video_path (string path_videos);
+ }
+--
+1.7.10.2
+
diff --git a/0008-cheese-optimize-encoding.patch b/0008-cheese-optimize-encoding.patch
new file mode 100644
index 0000000..abeec14
--- /dev/null
+++ b/0008-cheese-optimize-encoding.patch
@@ -0,0 +1,58 @@
+--- cheese-3.4.2.orig/libcheese/cheese-camera.c 2012-06-19 23:03:38.976989128 +0200
++++ cheese-3.4.2/libcheese/cheese-camera.c 2012-06-19 23:04:22.697442542 +0200
+@@ -32,6 +32,7 @@
+ #include <clutter-gst/clutter-gst.h>
+ #include <gst/gst.h>
+ #include <X11/Xlib.h>
++#include <unistd.h>
+
+ #include "cheese-camera.h"
+ #include "cheese-camera-device.h"
+@@ -444,6 +445,7 @@
+ CheeseCameraPrivate *priv = camera->priv;
+ GstElement *video_enc;
+ GstElement *mux;
++ int n_threads;
+
+ g_return_if_fail (error == NULL || *error == NULL);
+
+@@ -453,7 +455,17 @@
+ return;
+ }
+ g_object_set (priv->camerabin, "video-encoder", video_enc, NULL);
+- g_object_set (G_OBJECT (video_enc), "speed", 2, NULL);
++
++ /* Since we do realtime encoding setup the encoder for speed without
++ sacrificing too much quality */
++ g_object_set (G_OBJECT (video_enc), "speed", 6, NULL);
++#ifdef _SC_NPROCESSORS_ONLN
++ n_threads = sysconf (_SC_NPROCESSORS_ONLN); /* includes hyper-threading */
++ n_threads = MIN (n_threads, 64);
++#else
++ n_threads = 3;
++#endif
++ g_object_set (G_OBJECT (video_enc), "threads", n_threads, NULL);
+
+ if ((mux = gst_element_factory_make ("webmmux", "webmmux")) == NULL)
+ {
+@@ -688,6 +702,7 @@
+ {
+ CheeseCameraPrivate *priv;
+ CheeseCameraDevice *device;
++ GObject *video_enc;
+ GstCaps *caps;
+
+ g_return_if_fail (CHEESE_IS_CAMERA (camera));
+@@ -710,6 +725,12 @@
+ g_signal_emit_by_name (priv->camerabin, "set-video-resolution-fps",
+ priv->current_format->width,
+ priv->current_format->height, 0, 1, 0);
++ if (priv->current_format->width >= 1280 &&
++ priv->current_format->height >= 720)
++ {
++ g_object_get (priv->camerabin, "video-encoder", &video_enc, NULL);
++ g_object_set (video_enc, "token-parts", 2, NULL);
++ }
+ }
+ gst_caps_unref (caps);
+
diff --git a/cheese.spec b/cheese.spec
index 798a22e..ec70872 100644
--- a/cheese.spec
+++ b/cheese.spec
@@ -1,7 +1,7 @@
Name: cheese
Epoch: 2
Version: 3.4.2
-Release: 2%{?dist}
+Release: 3%{?dist}
Summary: Application for taking pictures and movies from a webcam
Group: Amusements/Graphics
@@ -18,6 +18,13 @@ Patch2: 0002-Stop-warnings-caused-by-the-mode-buttons.patch
Patch3: 0003-main-window-ui-Fix-images-missing-from-effect-button.patch
# https://bugzilla.gnome.org/show_bug.cgi?id=677544
Patch4: 0004-camera-device-monitor-Don-t-add-NULL-devices-to-the-.patch
+# https://bugzilla.gnome.org/show_bug.cgi?id=677731
+Patch5: 0005-cheese-camera-Don-t-overwrite-camerabin-s-default-fl.patch
+# https://bugzilla.gnome.org/show_bug.cgi?id=677735
+Patch6: 0006-cheese-thumb-view-Don-t-add-0-sized-files-to-the-thu.patch
+# FIXME file upstream bugs for these 2 (gnome bz is down atm)
+Patch7: 0007-cheese-thumb-view-Don-t-set-columns-to-5000-in-horiz.patch
+Patch8: 0008-cheese-optimize-encoding.patch
BuildRequires: gtk3-devel >= 3.0.0
BuildRequires: gstreamer-devel >= 0.10.23
@@ -79,6 +86,10 @@ for writing applications that require a webcam display widget.
%patch2 -p1
%patch3 -p1
%patch4 -p1
+%patch5 -p1
+%patch6 -p1
+%patch7 -p1
+%patch8 -p1
%build
@@ -154,6 +165,12 @@ glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || :
%{_datadir}/gir-1.0/Cheese-3.0.gir
%changelog
+* Tue Jun 19 2012 Hans de Goede <hdegoede at redhat.com> - 2:3.4.2-3
+- Reduce camerabin pipeline creation time (rhbz#797188, gnome#677731)
+- Don't add 0 byte sized files to the thumb-view (rhbz#830166, gnome#677735)
+- Fix sizing of horizontal thumbnail list (rhbz#829957)
+- Optimize encoding parameters (rhbz#572169)
+
* Tue Jun 5 2012 Hans de Goede <hdegoede at redhat.com> - 2:3.4.2-2
- Fix missing images on buttons, also fixes the "Gtk-WARNING **: Attempting to
add a widget with type GtkImage to a GtkButton ..." warnings (gnome#677543)
More information about the scm-commits
mailing list