Zebediah Figura : quartz/vmr9: Fix copying from the d3d9 surface if the pitch doesn't match the width.

Alexandre Julliard julliard at winehq.org
Wed Feb 12 16:21:08 CST 2020


Module: wine
Branch: master
Commit: 6c8f52c4fbc100b0a38a34193f4e10a07b10f69a
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=6c8f52c4fbc100b0a38a34193f4e10a07b10f69a

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Wed Feb 12 09:34:15 2020 -0600

quartz/vmr9: Fix copying from the d3d9 surface if the pitch doesn't match the width.

Spotted by Henri Verbeet.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/quartz/vmr9.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/dlls/quartz/vmr9.c b/dlls/quartz/vmr9.c
index 928e98f605..bc2a905650 100644
--- a/dlls/quartz/vmr9.c
+++ b/dlls/quartz/vmr9.c
@@ -627,7 +627,10 @@ static HRESULT WINAPI VMR9_GetStaticImage(BaseControlVideo *iface, LONG *size, L
     IDirect3DSurface9 *rt = NULL, *surface = NULL;
     D3DLOCKED_RECT locked_rect;
     IDirect3DDevice9 *device;
+    unsigned int row_size;
     BITMAPINFOHEADER bih;
+    LONG i, size_left;
+    char *dst;
     HRESULT hr;
 
     TRACE("filter %p, size %d, image %p.\n", filter, *size, image);
@@ -661,10 +664,19 @@ static HRESULT WINAPI VMR9_GetStaticImage(BaseControlVideo *iface, LONG *size, L
     if (FAILED(hr = IDirect3DSurface9_LockRect(surface, &locked_rect, NULL, D3DLOCK_READONLY)))
         goto out;
 
-    memcpy(image, &bih, min(*size, sizeof(BITMAPINFOHEADER)));
-    if (*size > sizeof(BITMAPINFOHEADER))
-        memcpy((char *)image + sizeof(BITMAPINFOHEADER), locked_rect.pBits,
-                min(*size - sizeof(BITMAPINFOHEADER), bih.biSizeImage));
+    size_left = *size;
+    memcpy(image, &bih, min(size_left, sizeof(BITMAPINFOHEADER)));
+    size_left -= sizeof(BITMAPINFOHEADER);
+
+    dst = (char *)image + sizeof(BITMAPINFOHEADER);
+    row_size = bih.biWidth * bih.biBitCount / 8;
+
+    for (i = 0; i < bih.biHeight && size_left > 0; ++i)
+    {
+        memcpy(dst, (char *)locked_rect.pBits + (i * locked_rect.Pitch), min(row_size, size_left));
+        dst += row_size;
+        size_left -= row_size;
+    }
 
     IDirect3DSurface9_UnlockRect(surface);
 




More information about the wine-cvs mailing list