From ff5637a14c52e6ec592592c88938104b087e925c Mon Sep 17 00:00:00 2001 From: Martin Krastev Date: Tue, 25 Jan 2022 15:11:08 +0200 Subject: Garbled XvPutImage output for FOURCC_YV12 when using 3D-accel-texture adaptor A helper for the PutImage callback in adaptor 'XA G3D Textured Video' was not taking into account the source data pitches for YV12 format, resulting in garbled frames for misaligned frame widths. Issue reported by Doug Brown. This patch is based off the patch proposed by Doug. Repro of the original issue: gst-launch-1.0 videotestsrc ! video/x-raw,format=YV12,width=449,height=240 ! xvimagesink Reported-by: Doug Brown Signed-off-by: Martin Krastev Reviewed-by: Zack Rusin --- vmwgfx/vmwgfx_tex_video.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/vmwgfx/vmwgfx_tex_video.c b/vmwgfx/vmwgfx_tex_video.c index 480a5f1..260494d 100644 --- a/vmwgfx/vmwgfx_tex_video.c +++ b/vmwgfx/vmwgfx_tex_video.c @@ -634,9 +634,16 @@ copy_packed_data(ScrnInfoPtr pScrn, yp = buf + offsets[0]; vp = buf + offsets[1]; up = buf + offsets[2]; - memcpy(ymap, yp, w*h); - memcpy(vmap, vp, w*h/4); - memcpy(umap, up, w*h/4); + for (i = 0; i < h; ++i) { + memcpy(ymap + w * i, yp, w); + yp += pitches[0]; + } + for (i = 0; i < h / 2; ++i) { + memcpy(vmap + w * i / 2, vp, w / 2); + memcpy(umap + w * i / 2, up, w / 2); + vp += pitches[1]; + up += pitches[2]; + } break; } case FOURCC_UYVY: -- cgit v1.2.3