From f6bf17e24601a6e5ba91d147a2532b9ce03f984c Mon Sep 17 00:00:00 2001 From: Hugues Fruchet Date: Mon, 11 Sep 2023 14:12:12 +0200 Subject: [PATCH 2/5] waylandsink: Fix rendering of unaligned content Non 16 pixels aligned YUV content is displayed with a stride effect with waylandsink/gtkwaylandsink. Fix this by forcing 16 pixels alignment of width when creating zwp linux dmabuf wayland plane. This should not have any effect because of well aligned stride/offset but it does... so align width as a temporary workaround till problem is fully understood. To reproduce issue: export WAYLAND_DEBUG=1 gst-launch-1.0 videotestsrc ! video/x-raw, format=NV12, width=306, height=480 ! waylandsink drm-device=/dev/dri/card0 2>&1 | grep zwp [3956691.525] -> zwp_linux_buffer_params_v1@21.add(fd 19, 0, 0, 384, 0, 0) [3956691.555] -> zwp_linux_buffer_params_v1@21.add(fd 20, 1, 184320, 384, 0, 0) [3956691.580] -> zwp_linux_buffer_params_v1@21.create(306, 480, 842094158, 0) -------------------------------------------------------^^^ => bad rendering with stride effect With this fix: [ 48713.010] -> zwp_linux_buffer_params_v1@21.add(fd 19, 0, 0, 384, 0, 0) [ 48713.039] -> zwp_linux_buffer_params_v1@21.add(fd 20, 1, 184320, 384, 0, 0) [ 48713.065] -> zwp_linux_buffer_params_v1@21.create(320, 480, 842094158, 0) -------------------------------------------------------^^^ => rendering is correct Signed-off-by: Hugues Fruchet Upstream-Status: Pending --- gst-libs/gst/wayland/gstwllinuxdmabuf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gst-libs/gst/wayland/gstwllinuxdmabuf.c b/gst-libs/gst/wayland/gstwllinuxdmabuf.c index deb5d32..2fbe57e 100644 --- a/gst-libs/gst/wayland/gstwllinuxdmabuf.c +++ b/gst-libs/gst/wayland/gstwllinuxdmabuf.c @@ -154,6 +154,9 @@ gst_wl_linux_dmabuf_construct_wl_buffer (GstBuffer * buf, } } + //FIXME, otherwise stride effect with non 16-pixels aligned videos + width = GST_ROUND_UP_16(width); + /* Request buffer creation */ zwp_linux_buffer_params_v1_add_listener (params, ¶ms_listener, &data); zwp_linux_buffer_params_v1_create (params, width, height, format, flags); -- 2.25.1