From 0680c3e47d496fecd62d6f20ee8bda76f947521c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 5 May 2018 16:14:14 +0200 Subject: [PATCH] videoaggregator: Move needs_alpha pad field to the private struct And also trigger renegotiation if the value has changed. https://bugzilla.gnome.org/show_bug.cgi?id=795836 --- gst-libs/gst/video/gstvideoaggregator.c | 32 ++++++++++++++++++++++++- gst-libs/gst/video/gstvideoaggregator.h | 7 +++--- gst/compositor/compositor.c | 3 ++- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/gst-libs/gst/video/gstvideoaggregator.c b/gst-libs/gst/video/gstvideoaggregator.c index cdbf260663..580e73713e 100644 --- a/gst-libs/gst/video/gstvideoaggregator.c +++ b/gst-libs/gst/video/gstvideoaggregator.c @@ -72,6 +72,10 @@ struct _GstVideoAggregatorPadPrivate guint zorder; gboolean repeat_after_eos; + /* Subclasses can force an alpha channel in the (input thus output) + * colorspace format */ + gboolean needs_alpha; + /* Converter, if NULL no conversion is done */ GstVideoConverter *convert; @@ -435,6 +439,32 @@ gst_video_aggregator_pad_get_prepared_frame (GstVideoAggregatorPad * pad) return pad->priv->prepared_frame.buffer ? &pad->priv->prepared_frame : NULL; } +/** + * gst_video_aggregator_pad_set_needs_alpha: + * @pad: a #GstVideoAggregatorPad + * @needs_alpha: %TRUE if this pad requires alpha output + * + * Allows selecting that this pad requires an output format with alpha + * + * Returns: (transfer none): The currently prepared video frame + */ +void +gst_video_aggregator_pad_set_needs_alpha (GstVideoAggregatorPad * pad, + gboolean needs_alpha) +{ + g_return_if_fail (GST_IS_VIDEO_AGGREGATOR_PAD (pad)); + + if (needs_alpha != pad->priv->needs_alpha) { + GstAggregator *agg = + GST_AGGREGATOR (gst_object_get_parent (GST_OBJECT (pad))); + pad->priv->needs_alpha = needs_alpha; + if (agg) { + gst_pad_mark_reconfigure (GST_AGGREGATOR_SRC_PAD (agg)); + gst_object_unref (agg); + } + } +} + /************************************** * GstVideoAggregator implementation * **************************************/ @@ -562,7 +592,7 @@ gst_video_aggregator_find_best_format (GstVideoAggregator * vagg, GINT_TO_POINTER (format_number)); /* If that pad is the first with alpha, set it as the new best format */ - if (!need_alpha && (pad->needs_alpha + if (!need_alpha && (pad->priv->needs_alpha && (!GST_VIDEO_FORMAT_INFO_HAS_ALPHA (pad->info.finfo)))) { need_alpha = TRUE; /* Just fallback to ARGB in case we require alpha but the input pad diff --git a/gst-libs/gst/video/gstvideoaggregator.h b/gst-libs/gst/video/gstvideoaggregator.h index af1e026828..70715ca1fa 100644 --- a/gst-libs/gst/video/gstvideoaggregator.h +++ b/gst-libs/gst/video/gstvideoaggregator.h @@ -71,10 +71,6 @@ struct _GstVideoAggregatorPad /* read-only, with OBJECT_LOCK */ GstVideoInfo info; - /* Subclasses can force an alpha channel in the (input thus output) - * colorspace format */ - gboolean needs_alpha; - /* < private > */ GstVideoAggregatorPadPrivate *priv; @@ -122,6 +118,9 @@ GstBuffer * gst_video_aggregator_pad_get_current_buffer (GstVideoAggregatorPad * GST_VIDEO_BAD_API GstVideoFrame * gst_video_aggregator_pad_get_prepared_frame (GstVideoAggregatorPad *pad); +GST_VIDEO_BAD_API +void gst_video_aggregator_pad_set_needs_alpha (GstVideoAggregatorPad *pad, gboolean needs_alpha); + #define GST_TYPE_VIDEO_AGGREGATOR (gst_video_aggregator_get_type()) #define GST_VIDEO_AGGREGATOR(obj) \ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VIDEO_AGGREGATOR, GstVideoAggregator)) diff --git a/gst/compositor/compositor.c b/gst/compositor/compositor.c index f5c83fe772..2c5b76bdb6 100644 --- a/gst/compositor/compositor.c +++ b/gst/compositor/compositor.c @@ -198,7 +198,8 @@ gst_compositor_pad_set_property (GObject * object, guint prop_id, break; case PROP_PAD_CROSSFADE_RATIO: pad->crossfade = g_value_get_double (value); - GST_VIDEO_AGGREGATOR_PAD (pad)->needs_alpha = pad->crossfade >= 0.0f; + gst_video_aggregator_pad_set_needs_alpha (GST_VIDEO_AGGREGATOR_PAD (pad), + pad->crossfade >= 0.0f); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);