compositor: fix drawing of transparent background
authorMathieu Duponchelle <mathieu@centricular.com>
Thu, 18 Feb 2021 15:16:33 +0000 (16:16 +0100)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 1 Mar 2021 23:38:35 +0000 (23:38 +0000)
When drawing the background multithreaded, y_start needs to be
scaled to obtain the correct byte offset from which to start
memsetting (yoffset).

Fixes #871

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1042>

gst/compositor/compositor.c

index f9d012a..c86793e 100644 (file)
@@ -1124,6 +1124,7 @@ _draw_background (GstCompositor * comp, GstVideoFrame * outframe,
         const GstVideoFormatInfo *info;
         guint8 *pdata;
         gsize rowsize, plane_stride;
+        gint yoffset;
 
         info = outframe->info.finfo;
         pdata = GST_VIDEO_FRAME_PLANE_DATA (outframe, plane);
@@ -1131,8 +1132,11 @@ _draw_background (GstCompositor * comp, GstVideoFrame * outframe,
         rowsize = GST_VIDEO_FRAME_COMP_WIDTH (outframe, plane)
             * GST_VIDEO_FRAME_COMP_PSTRIDE (outframe, plane);
         height =
-            GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT (info, plane, y_end - y_start);
-        pdata += y_start * plane_stride;
+            GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT (info, plane, (y_end - y_start));
+
+        yoffset = GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT (info, plane, y_start);
+
+        pdata += yoffset * plane_stride;
         for (i = 0; i < height; ++i) {
           memset (pdata, 0, rowsize);
           pdata += plane_stride;