From 0b6cd6862e209f9d45e7e05ed8c3dd5a55ddf232 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 24 May 2021 14:25:55 +0300 Subject: [PATCH] compositor: Consider the converter-config when deciding whether one pad obscures another If the converter configuration is set to not fill any borders, or if the border fill color is not full opaque, then the pad has to be handled as potentially transparent and can't be considered to obscure another one. This prevents pads from being wrongly skipped and doing alpha-blending with uninitialized memory. Part-of: --- gst/compositor/compositor.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gst/compositor/compositor.c b/gst/compositor/compositor.c index 16012aa..1fa5a79 100644 --- a/gst/compositor/compositor.c +++ b/gst/compositor/compositor.c @@ -357,6 +357,9 @@ _pad_obscures_rectangle (GstVideoAggregator * vagg, GstVideoAggregatorPad * pad, { GstVideoRectangle pad_rect; GstCompositorPad *cpad = GST_COMPOSITOR_PAD (pad); + GstStructure *converter_config = NULL; + gboolean fill_border = TRUE; + guint32 border_argb = 0xff000000; /* No buffer to obscure the rectangle with */ if (!gst_video_aggregator_pad_has_current_buffer (pad)) @@ -369,6 +372,20 @@ _pad_obscures_rectangle (GstVideoAggregator * vagg, GstVideoAggregatorPad * pad, if (cpad->alpha != 1.0 || GST_VIDEO_INFO_HAS_ALPHA (&pad->info)) return FALSE; + /* If a converter-config is set and it is either configured to not fill any + * borders, or configured to use a non-opaque color, then we have to handle + * the pad as potentially containing transparency */ + g_object_get (pad, "converter-config", &converter_config, NULL); + if (converter_config) { + gst_structure_get (converter_config, GST_VIDEO_CONVERTER_OPT_BORDER_ARGB, + G_TYPE_UINT, &border_argb, NULL); + gst_structure_get (converter_config, GST_VIDEO_CONVERTER_OPT_FILL_BORDER, + G_TYPE_BOOLEAN, &fill_border, NULL); + } + gst_clear_structure (&converter_config); + if (!fill_border || (border_argb & 0xff000000) != 0xff000000) + return FALSE; + pad_rect.x = cpad->xpos; pad_rect.y = cpad->ypos; /* Handle pixel and display aspect ratios to find the actual size */ -- 2.7.4