From 3bbb0387c48689597720e5ff337ac6929d448a1c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 15 Mar 2012 18:08:09 +0000 Subject: [PATCH] faceoverlay: don't make rsvgoverlay reload the SVG for every single frame Only set location on rsvgoverlay if it has changed. --- gst/faceoverlay/gstfaceoverlay.c | 13 ++++++++++--- gst/faceoverlay/gstfaceoverlay.h | 2 ++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/gst/faceoverlay/gstfaceoverlay.c b/gst/faceoverlay/gstfaceoverlay.c index b3442b2..da3cb40 100644 --- a/gst/faceoverlay/gstfaceoverlay.c +++ b/gst/faceoverlay/gstfaceoverlay.c @@ -174,6 +174,7 @@ gst_face_overlay_change_state (GstElement * element, GstStateChange transition) "facedetect element or rsvgoverlay")); return GST_STATE_CHANGE_FAILURE; } + filter->update_svg = TRUE; break; default: break; @@ -237,11 +238,16 @@ gst_face_overlay_handle_faces (GstFaceOverlay * filter, GstStructure * s) svg_width = (int) width *filter->w; svg_height = (int) height *filter->h; - GST_LOG_OBJECT (filter, "setting overlay to %d x %d @ %d,%d (file: %s)", - svg_width, svg_height, svg_x, svg_y, GST_STR_NULL (filter->location)); + if (filter->update_svg) { + GST_DEBUG_OBJECT (filter, "set rsvgoverlay location=%s", filter->location); + g_object_set (filter->svg_overlay, "location", filter->location, NULL); + filter->update_svg = FALSE; + } + + GST_LOG_OBJECT (filter, "overlay dimensions: %d x %d @ %d,%d", + svg_width, svg_height, svg_x, svg_y); g_object_set (filter->svg_overlay, - "location", filter->location, "x", svg_x, "y", svg_y, "width", svg_width, "height", svg_height, NULL); } @@ -347,6 +353,7 @@ gst_face_overlay_set_property (GObject * object, guint prop_id, switch (prop_id) { case PROP_LOCATION: filter->location = g_value_dup_string (value); + filter->update_svg = TRUE; break; case PROP_X: filter->x = g_value_get_float (value); diff --git a/gst/faceoverlay/gstfaceoverlay.h b/gst/faceoverlay/gstfaceoverlay.h index 7f4427c..c21327b 100644 --- a/gst/faceoverlay/gstfaceoverlay.h +++ b/gst/faceoverlay/gstfaceoverlay.h @@ -73,6 +73,8 @@ struct _GstFaceOverlay gboolean process_message; + gboolean update_svg; + gchar *location; gfloat x; gfloat y; -- 2.7.4