From a966f03cd738e413bab5b515d7c59f6ab17a2050 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Thu, 14 Nov 2024 10:59:35 -0500 Subject: [PATCH] wayland: dmabuf: Translate tiled strides GStreamer uses a different representation of tiled strides that needs to be translated before being sent to wayland. Part-of: --- .../gst-libs/gst/wayland/gstwllinuxdmabuf.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/wayland/gstwllinuxdmabuf.c b/subprojects/gst-plugins-bad/gst-libs/gst/wayland/gstwllinuxdmabuf.c index ac53e06816..54c5811c6c 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/wayland/gstwllinuxdmabuf.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/wayland/gstwllinuxdmabuf.c @@ -81,6 +81,19 @@ static const struct zwp_linux_buffer_params_v1_listener params_listener = { create_failed }; +static gint +get_drm_stride (const GstVideoFormatInfo * finfo, const gint * strides, + gint plane) +{ + gint stride = strides[plane]; + + if (!GST_VIDEO_FORMAT_INFO_IS_TILED (finfo)) + return stride; + + return GST_VIDEO_TILE_X_TILES (stride) * + GST_VIDEO_FORMAT_INFO_TILE_STRIDE (finfo, plane); +} + struct wl_buffer * gst_wl_linux_dmabuf_construct_wl_buffer (GstBuffer * buf, GstWlDisplay * display, const GstVideoInfoDmaDrm * drm_info) @@ -90,6 +103,7 @@ gst_wl_linux_dmabuf_construct_wl_buffer (GstBuffer * buf, guint64 modifier; guint i, width = 0, height = 0; GstVideoInfo info; + const GstVideoFormatInfo *finfo; const gsize *offsets = NULL; const gint *strides = NULL; GstVideoMeta *vmeta; @@ -111,12 +125,14 @@ gst_wl_linux_dmabuf_construct_wl_buffer (GstBuffer * buf, vmeta = gst_buffer_get_video_meta (buf); if (vmeta) { + finfo = drm_info->vinfo.finfo; width = vmeta->width; height = vmeta->height; nplanes = vmeta->n_planes; offsets = vmeta->offset; strides = vmeta->stride; } else if (gst_video_info_dma_drm_to_video_info (drm_info, &info)) { + finfo = info.finfo; nplanes = GST_VIDEO_INFO_N_PLANES (&info); width = info.width; height = info.height; @@ -142,7 +158,7 @@ gst_wl_linux_dmabuf_construct_wl_buffer (GstBuffer * buf, gsize skip; offset = offsets[i]; - stride = strides[i]; + stride = get_drm_stride (finfo, strides, i); if (gst_buffer_find_memory (buf, offset, 1, &mem_idx, &length, &skip)) { GstMemory *m = gst_buffer_peek_memory (buf, mem_idx); gint fd = gst_dmabuf_memory_get_fd (m);