[PATCH v2 2/8] mfplat/buffer: Fix image copy function for IMC2/IMC4 buffers with odd height.

Giovanni Mascellani gmascellani at codeweavers.com
Tue Jun 14 05:50:45 CDT 2022


Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
---
 dlls/mfplat/buffer.c       | 3 +--
 dlls/mfplat/tests/mfplat.c | 9 ++++-----
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/dlls/mfplat/buffer.c b/dlls/mfplat/buffer.c
index 39407ccc9e2..a7ba306223d 100644
--- a/dlls/mfplat/buffer.c
+++ b/dlls/mfplat/buffer.c
@@ -100,8 +100,7 @@ static void copy_image_imc1(BYTE *dest, LONG dest_stride, const BYTE *src, LONG
 
 static void copy_image_imc2(BYTE *dest, LONG dest_stride, const BYTE *src, LONG src_stride, DWORD width, DWORD lines)
 {
-    MFCopyImage(dest, dest_stride, src, src_stride, width / 2, lines / 2);
-    MFCopyImage(dest + dest_stride / 2, dest_stride, src + src_stride / 2, src_stride, width / 2, lines / 2);
+    MFCopyImage(dest, dest_stride / 2, src, src_stride / 2, width / 2, lines);
 }
 
 static inline struct buffer *impl_from_IMFMediaBuffer(IMFMediaBuffer *iface)
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c
index 1b5e8cf7ed5..52608c05929 100644
--- a/dlls/mfplat/tests/mfplat.c
+++ b/dlls/mfplat/tests/mfplat.c
@@ -6027,12 +6027,11 @@ static void test_MFCreate2DMediaBuffer(void)
 
             case MAKEFOURCC('I','M','C','2'):
             case MAKEFOURCC('I','M','C','4'):
-                for (j = ptr->height; j < length2 / stride; j++)
+                for (j = 0; ptr->height * stride + j * (stride / 2) < length2; j++)
                     for (k = 0; k < ptr->width / 2; k++)
-                        ok(data[j * pitch + k] == 0xff, "Unexpected byte %02x at test %d row %d column %d.\n", data[j * pitch + k], i, j, k);
-                for (j = ptr->height; j < length2 / stride; j++)
-                    for (k = pitch / 2; k < pitch / 2 + ptr->width / 2; k++)
-                        ok(data[j * pitch + k] == 0xff, "Unexpected byte %02x at test %d row %d column %d.\n", data[j * pitch + k], i, j, k);
+                        ok(data[ptr->height * pitch + j * (pitch / 2) + k] == 0xff,
+                                "Unexpected byte %02x at test %d row %d column %d.\n",
+                                data[ptr->height * pitch + j * (pitch / 2) + k], i, j, k);
                 break;
 
             case MAKEFOURCC('N','V','1','2'):
-- 
2.36.1




More information about the wine-devel mailing list