From 1cef62ab7954c298a2ffb0cad3c160c15a6c1fac Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Tue, 2 Aug 2016 16:42:20 -0400 Subject: [PATCH] ges: Let the compositor do the scaling if mixing is enabled Differential Revision: https://phabricator.freedesktop.org/D1241 --- ges/ges-title-source.c | 1 + ges/ges-video-source.c | 2 ++ ges/ges-video-source.h | 7 ++++++- ges/gstframepositioner.c | 38 ++++++++++++++++++++------------------ ges/gstframepositioner.h | 1 + 5 files changed, 30 insertions(+), 19 deletions(-) diff --git a/ges/ges-title-source.c b/ges/ges-title-source.c index 3c8ce69..3515d3f 100644 --- a/ges/ges-title-source.c +++ b/ges/ges-title-source.c @@ -167,6 +167,7 @@ ges_title_source_class_init (GESTitleSourceClass * klass) timeline_element_class->set_inpoint = NULL; timeline_element_class->lookup_child = _lookup_child; + source_class->ABI.abi.disable_scale_in_compositor = TRUE; source_class->create_source = ges_title_source_create_source; } diff --git a/ges/ges-video-source.c b/ges/ges-video-source.c index b787262..fe41287 100644 --- a/ges/ges-video-source.c +++ b/ges/ges-video-source.c @@ -188,6 +188,8 @@ ges_video_source_create_element (GESTrackElement * trksrc) } self->priv->positioner = GST_FRAME_POSITIONNER (positioner); + self->priv->positioner->scale_in_compositor = + !GES_VIDEO_SOURCE_GET_CLASS (self)->ABI.abi.disable_scale_in_compositor; self->priv->capsfilter = capsfilter; return topbin; diff --git a/ges/ges-video-source.h b/ges/ges-video-source.h index 0e1bd44..6a731d5 100644 --- a/ges/ges-video-source.h +++ b/ges/ges-video-source.h @@ -80,7 +80,12 @@ struct _GESVideoSourceClass { /*< private >*/ /* Padding for API extension */ - gpointer _ges_reserved[GES_PADDING]; + union { + gpointer _ges_reserved[GES_PADDING]; + struct { + gboolean disable_scale_in_compositor; + } abi; + } ABI; }; GType ges_video_source_get_type (void); diff --git a/ges/gstframepositioner.c b/ges/gstframepositioner.c index fd1fc9e..34aaa3c 100644 --- a/ges/gstframepositioner.c +++ b/ges/gstframepositioner.c @@ -79,14 +79,15 @@ _weak_notify_cb (GstFramePositioner * pos, GObject * old) static void gst_frame_positioner_update_properties (GstFramePositioner * pos, - gint old_track_width, gint old_track_height) + gboolean track_mixing, gint old_track_width, gint old_track_height) { GstCaps *caps; if (pos->capsfilter == NULL) return; - if (pos->track_width && pos->track_height) { + if (pos->track_width && pos->track_height && + (!track_mixing || !pos->scale_in_compositor)) { caps = gst_caps_new_simple ("video/x-raw", "width", G_TYPE_INT, pos->track_width, "height", G_TYPE_INT, pos->track_height, NULL); @@ -117,10 +118,13 @@ gst_frame_positioner_update_properties (GstFramePositioner * pos, } static void -sync_properties_from_caps (GstFramePositioner * pos, GstCaps * caps) +sync_properties_from_track (GstFramePositioner * pos, GESTrack * track) { gint width, height; gint old_track_width, old_track_height; + GstCaps *caps; + + g_object_get (track, "restriction-caps", &caps, NULL); width = height = 0; @@ -146,24 +150,15 @@ sync_properties_from_caps (GstFramePositioner * pos, GstCaps * caps) GST_DEBUG_OBJECT (pos, "syncing framerate from caps : %d/%d", pos->fps_n, pos->fps_d); - gst_frame_positioner_update_properties (pos, old_track_width, - old_track_height); -} - -static void -sync_properties_with_track (GstFramePositioner * pos, GESTrack * track) -{ - GstCaps *caps; - - g_object_get (track, "restriction-caps", &caps, NULL); - sync_properties_from_caps (pos, caps); + gst_frame_positioner_update_properties (pos, ges_track_get_mixing (track), + old_track_width, old_track_height); } static void _track_restriction_changed_cb (GESTrack * track, GParamSpec * arg G_GNUC_UNUSED, GstFramePositioner * pos) { - sync_properties_with_track (pos, track); + sync_properties_from_track (pos, track); } static void @@ -187,7 +182,7 @@ set_track (GstFramePositioner * pos) g_signal_connect (pos->current_track, "notify::restriction-caps", (GCallback) _track_restriction_changed_cb, pos); - sync_properties_with_track (pos, pos->current_track); + sync_properties_from_track (pos, pos->current_track); } else { pos->current_track = NULL; } @@ -342,6 +337,7 @@ gst_frame_positioner_init (GstFramePositioner * framepositioner) framepositioner->capsfilter = NULL; framepositioner->track_source = NULL; framepositioner->current_track = NULL; + framepositioner->scale_in_compositor = TRUE; } void @@ -349,6 +345,10 @@ gst_frame_positioner_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) { GstFramePositioner *framepositioner = GST_FRAME_POSITIONNER (object); + gboolean track_mixing = TRUE; + + if (framepositioner->current_track) + track_mixing = ges_track_get_mixing (framepositioner->current_track); GST_OBJECT_LOCK (framepositioner); @@ -367,11 +367,13 @@ gst_frame_positioner_set_property (GObject * object, guint property_id, break; case PROP_WIDTH: framepositioner->width = g_value_get_int (value); - gst_frame_positioner_update_properties (framepositioner, 0, 0); + gst_frame_positioner_update_properties (framepositioner, track_mixing, + 0, 0); break; case PROP_HEIGHT: framepositioner->height = g_value_get_int (value); - gst_frame_positioner_update_properties (framepositioner, 0, 0); + gst_frame_positioner_update_properties (framepositioner, track_mixing, + 0, 0); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); diff --git a/ges/gstframepositioner.h b/ges/gstframepositioner.h index 7ca98ee..f08f730 100644 --- a/ges/gstframepositioner.h +++ b/ges/gstframepositioner.h @@ -45,6 +45,7 @@ struct _GstFramePositioner GESTrackElement *track_source; GESTrack *current_track; + gboolean scale_in_compositor; gdouble alpha; gint posx; gint posy; -- 2.7.4