Wine-Devel
By thread
wine-devel@list.winehq.org
By month
Messages by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
June 2022
- 68 participants
- 3274 messages
[PATCH v4 7/7] mfplat/tests: Merge and reorganize image format tests.
by Giovanni Mascellani
Signed-off-by: Giovanni Mascellani <gmascellani(a)codeweavers.com>
---
v2:
* Added
v4:
* Rebased on top of previous modifications
* Tweak the comments a little bit
---
dlls/mfplat/tests/mfplat.c | 290 ++++++++++++++++++-------------------
1 file changed, 141 insertions(+), 149 deletions(-)
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c
index 0b02bd67172..dac9dad1004 100644
--- a/dlls/mfplat/tests/mfplat.c
+++ b/dlls/mfplat/tests/mfplat.c
@@ -4233,87 +4233,128 @@ static const struct image_size_test
UINT32 height;
UINT32 size;
UINT32 plane_size; /* Matches image size when 0. */
+ UINT32 max_length;
+ UINT32 contiguous_length;
+ UINT32 pitch;
}
image_size_tests[] =
{
- { &MFVideoFormat_RGB8, 3, 5, 20 },
- { &MFVideoFormat_RGB8, 1, 1, 4 },
- { &MFVideoFormat_RGB555, 3, 5, 40 },
- { &MFVideoFormat_RGB555, 1, 1, 4 },
- { &MFVideoFormat_RGB565, 3, 5, 40 },
- { &MFVideoFormat_RGB565, 1, 1, 4 },
- { &MFVideoFormat_RGB24, 3, 5, 60 },
- { &MFVideoFormat_RGB24, 1, 1, 4 },
- { &MFVideoFormat_RGB32, 3, 5, 60 },
- { &MFVideoFormat_RGB32, 1, 1, 4 },
- { &MFVideoFormat_ARGB32, 3, 5, 60 },
- { &MFVideoFormat_ARGB32, 1, 1, 4 },
- { &MFVideoFormat_A2R10G10B10, 3, 5, 60 },
- { &MFVideoFormat_A2R10G10B10, 1, 1, 4 },
- { &MFVideoFormat_A16B16G16R16F, 3, 5, 120 },
- { &MFVideoFormat_A16B16G16R16F, 1, 1, 8 },
-
- /* YUV */
- { &MFVideoFormat_NV12, 1, 3, 9, 4 },
- { &MFVideoFormat_NV12, 1, 2, 6, 3 },
- { &MFVideoFormat_NV12, 2, 2, 6, 6 },
- { &MFVideoFormat_NV12, 3, 2, 12, 9 },
- { &MFVideoFormat_NV12, 4, 2, 12 },
- { &MFVideoFormat_NV12, 320, 240, 115200 },
- { &MFVideoFormat_AYUV, 1, 1, 4 },
- { &MFVideoFormat_AYUV, 2, 1, 8 },
- { &MFVideoFormat_AYUV, 1, 2, 8 },
- { &MFVideoFormat_AYUV, 4, 3, 48 },
- { &MFVideoFormat_AYUV, 320, 240, 307200 },
- { &MFVideoFormat_IMC1, 1, 1, 4 },
- { &MFVideoFormat_IMC1, 2, 1, 4 },
- { &MFVideoFormat_IMC1, 1, 2, 8 },
- { &MFVideoFormat_IMC1, 4, 3, 24 },
- { &MFVideoFormat_IMC1, 320, 240, 153600 },
- { &MFVideoFormat_IMC3, 1, 1, 4 },
- { &MFVideoFormat_IMC3, 2, 1, 4 },
- { &MFVideoFormat_IMC3, 1, 2, 8 },
- { &MFVideoFormat_IMC3, 4, 3, 24 },
- { &MFVideoFormat_IMC3, 320, 240, 153600 },
- { &MFVideoFormat_IMC2, 1, 3, 9, 4 },
- { &MFVideoFormat_IMC2, 1, 2, 6, 3 },
- { &MFVideoFormat_IMC2, 2, 2, 6, 6 },
- { &MFVideoFormat_IMC2, 3, 2, 12, 9 },
- { &MFVideoFormat_IMC2, 4, 2, 12 },
- { &MFVideoFormat_IMC2, 320, 240, 115200 },
- { &MFVideoFormat_IMC4, 1, 3, 9, 4 },
- { &MFVideoFormat_IMC4, 1, 2, 6, 3 },
- { &MFVideoFormat_IMC4, 2, 2, 6, 6 },
- { &MFVideoFormat_IMC4, 3, 2, 12, 9 },
- { &MFVideoFormat_IMC4, 4, 2, 12 },
- { &MFVideoFormat_IMC4, 320, 240, 115200 },
- { &MFVideoFormat_YV12, 1, 1, 3, 1 },
- { &MFVideoFormat_YV12, 2, 1, 3 },
- { &MFVideoFormat_YV12, 1, 2, 6, 3 },
- { &MFVideoFormat_YV12, 4, 3, 18 },
- { &MFVideoFormat_YV12, 320, 240, 115200 },
-
- { &MFVideoFormat_I420, 1, 1, 3, 1 },
- { &MFVideoFormat_I420, 2, 1, 3 },
- { &MFVideoFormat_I420, 1, 2, 6, 3 },
- { &MFVideoFormat_I420, 4, 3, 18 },
- { &MFVideoFormat_I420, 320, 240, 115200 },
-
- { &MFVideoFormat_IYUV, 1, 1, 3, 1 },
- { &MFVideoFormat_IYUV, 2, 1, 3 },
- { &MFVideoFormat_IYUV, 1, 2, 6, 3 },
- { &MFVideoFormat_IYUV, 4, 3, 18 },
- { &MFVideoFormat_IYUV, 320, 240, 115200 },
-
- { &MFVideoFormat_YUY2, 2, 1, 4 },
- { &MFVideoFormat_YUY2, 4, 3, 24 },
- { &MFVideoFormat_YUY2, 128, 128, 32768 },
- { &MFVideoFormat_YUY2, 320, 240, 153600 },
-
- { &MFVideoFormat_UYVY, 2, 1, 4 },
- { &MFVideoFormat_UYVY, 4, 3, 24 },
- { &MFVideoFormat_UYVY, 128, 128, 32768 },
- { &MFVideoFormat_UYVY, 320, 240, 153600 },
+ /* RGB */
+ { &MFVideoFormat_RGB8, 3, 5, 20, 0, 320, 20, 64 },
+ { &MFVideoFormat_RGB8, 1, 1, 4, 0, 64, 4, 64 },
+ { &MFVideoFormat_RGB555, 3, 5, 40, 0, 320, 40, 64 },
+ { &MFVideoFormat_RGB555, 1, 1, 4, 0, 64, 4, 64 },
+ { &MFVideoFormat_RGB565, 3, 5, 40, 0, 320, 40, 64 },
+ { &MFVideoFormat_RGB565, 1, 1, 4, 0, 64, 4, 64 },
+ { &MFVideoFormat_RGB24, 3, 5, 60, 0, 320, 60, 64 },
+ { &MFVideoFormat_RGB24, 1, 1, 4, 0, 64, 4, 64 },
+ { &MFVideoFormat_RGB32, 3, 5, 60, 0, 320, 60, 64 },
+ { &MFVideoFormat_RGB32, 1, 1, 4, 0, 64, 4, 64 },
+ { &MFVideoFormat_ARGB32, 3, 5, 60, 0, 320, 60, 64 },
+ { &MFVideoFormat_ARGB32, 1, 1, 4, 0, 64, 4, 64 },
+ { &MFVideoFormat_A2R10G10B10, 3, 5, 60, 0, 320, 60, 64 },
+ { &MFVideoFormat_A2R10G10B10, 1, 1, 4, 0, 64, 4, 64 },
+ { &MFVideoFormat_A16B16G16R16F, 3, 5, 120, 0, 320, 120, 64 },
+ { &MFVideoFormat_A16B16G16R16F, 1, 1, 8, 0, 64, 8, 64 },
+
+ /* YUV 4:4:4, 32 bpp, packed */
+ { &MFVideoFormat_AYUV, 1, 1, 4, 0, 64, 4, 64 },
+ { &MFVideoFormat_AYUV, 2, 1, 8, 0, 64, 8, 64 },
+ { &MFVideoFormat_AYUV, 1, 2, 8, 0, 128, 8, 64 },
+ { &MFVideoFormat_AYUV, 4, 3, 48, 0, 192, 48, 64 },
+ { &MFVideoFormat_AYUV, 320, 240, 307200, 0, 307200, 307200, 1280 },
+
+ /* YUV 4:2:2, 16 bpp, packed */
+ { &MFVideoFormat_YUY2, 2, 1, 4, 0, 64, 4, 64 },
+ { &MFVideoFormat_YUY2, 4, 3, 24, 0, 192, 24, 64 },
+ { &MFVideoFormat_YUY2, 128, 128, 32768, 0, 32768, 32768, 256 },
+ { &MFVideoFormat_YUY2, 320, 240, 153600, 0, 153600, 153600, 640 },
+
+ { &MFVideoFormat_UYVY, 2, 1, 4, 0, 64, 4, 64 },
+ { &MFVideoFormat_UYVY, 4, 3, 24, 0, 192, 24, 64 },
+ { &MFVideoFormat_UYVY, 128, 128, 32768, 0, 32768, 32768, 256 },
+ { &MFVideoFormat_UYVY, 320, 240, 153600, 0, 153600, 153600, 640 },
+
+ /* YUV 4:2:0, 16 bpp, planar (the secondary plane has the same
+ * height, half the width and the same stride as the primary
+ * one) */
+ { &MFVideoFormat_IMC1, 1, 1, 4, 0, 256, 8, 128 },
+ { &MFVideoFormat_IMC1, 2, 1, 4, 0, 256, 8, 128 },
+ { &MFVideoFormat_IMC1, 1, 2, 8, 0, 512, 16, 128 },
+ { &MFVideoFormat_IMC1, 2, 2, 8, 0, 512, 16, 128 },
+ { &MFVideoFormat_IMC1, 2, 4, 16, 0, 1024, 32, 128 },
+ { &MFVideoFormat_IMC1, 4, 2, 16, 0, 512, 32, 128 },
+ { &MFVideoFormat_IMC1, 4, 3, 24, 0, 768, 48, 128 },
+ { &MFVideoFormat_IMC1, 320, 240, 153600, 0, 307200, 307200, 640 },
+
+ { &MFVideoFormat_IMC3, 1, 1, 4, 0, 256, 8, 128 },
+ { &MFVideoFormat_IMC3, 2, 1, 4, 0, 256, 8, 128 },
+ { &MFVideoFormat_IMC3, 1, 2, 8, 0, 512, 16, 128 },
+ { &MFVideoFormat_IMC3, 2, 2, 8, 0, 512, 16, 128 },
+ { &MFVideoFormat_IMC3, 2, 4, 16, 0, 1024, 32, 128 },
+ { &MFVideoFormat_IMC3, 4, 2, 16, 0, 512, 32, 128 },
+ { &MFVideoFormat_IMC3, 4, 3, 24, 0, 768, 48, 128 },
+ { &MFVideoFormat_IMC3, 320, 240, 153600, 0, 307200, 307200, 640 },
+
+ /* YUV 4:2:0, 12 bpp, planar, full stride (the secondary plane has
+ * half the height, the same width and the same stride as the
+ * primary one) */
+ { &MFVideoFormat_NV12, 1, 3, 9, 4, 288, 4, 64 },
+ { &MFVideoFormat_NV12, 1, 2, 6, 3, 192, 3, 64 },
+ { &MFVideoFormat_NV12, 2, 2, 6, 6, 192, 6, 64 },
+ { &MFVideoFormat_NV12, 2, 4, 12, 0, 384, 12, 64 },
+ { &MFVideoFormat_NV12, 3, 2, 12, 9, 192, 9, 64 },
+ { &MFVideoFormat_NV12, 4, 2, 12, 0, 192, 12, 64 },
+ { &MFVideoFormat_NV12, 320, 240, 115200, 0, 115200, 115200, 320 },
+
+ /* YUV 4:2:0, 12 bpp, planar, half stride (the secondary plane has
+ * the same height, half the width and half the stride of the
+ * primary one) */
+ { &MFVideoFormat_IMC2, 1, 3, 9, 4, 576, 3, 128 },
+ { &MFVideoFormat_IMC2, 3, 5, 30, 22, 960, 20, 128 },
+ { &MFVideoFormat_IMC2, 1, 2, 6, 3, 384, 2, 128 },
+ { &MFVideoFormat_IMC2, 2, 2, 6, 6, 384, 6, 128 },
+ { &MFVideoFormat_IMC2, 2, 4, 12, 0, 768, 12, 128 },
+ { &MFVideoFormat_IMC2, 3, 2, 12, 9, 384, 8, 128 },
+ { &MFVideoFormat_IMC2, 4, 2, 12, 0, 384, 12, 128 },
+ { &MFVideoFormat_IMC2, 320, 240, 115200, 0, 138240, 115200, 384 },
+
+ { &MFVideoFormat_IMC4, 1, 3, 9, 4, 576, 3, 128 },
+ { &MFVideoFormat_IMC4, 3, 5, 30, 22, 960, 20, 128 },
+ { &MFVideoFormat_IMC4, 1, 2, 6, 3, 384, 2, 128 },
+ { &MFVideoFormat_IMC4, 2, 2, 6, 6, 384, 6, 128 },
+ { &MFVideoFormat_IMC4, 2, 4, 12, 0, 768, 12, 128 },
+ { &MFVideoFormat_IMC4, 3, 2, 12, 9, 384, 8, 128 },
+ { &MFVideoFormat_IMC4, 4, 2, 12, 0, 384, 12, 128 },
+ { &MFVideoFormat_IMC4, 320, 240, 115200, 0, 138240, 115200, 384 },
+
+ { &MFVideoFormat_YV12, 1, 1, 3, 1, 192, 1, 128 },
+ { &MFVideoFormat_YV12, 2, 1, 3, 0, 192, 3, 128 },
+ { &MFVideoFormat_YV12, 1, 2, 6, 3, 384, 2, 128 },
+ { &MFVideoFormat_YV12, 2, 2, 6, 0, 384, 6, 128 },
+ { &MFVideoFormat_YV12, 2, 4, 12, 0, 768, 12, 128 },
+ { &MFVideoFormat_YV12, 4, 2, 12, 0, 384, 12, 128 },
+ { &MFVideoFormat_YV12, 4, 3, 18, 0, 576, 18, 128 },
+ { &MFVideoFormat_YV12, 320, 240, 115200, 0, 138240, 115200, 384 },
+
+ { &MFVideoFormat_I420, 1, 1, 3, 1, 192, 1, 128 },
+ { &MFVideoFormat_I420, 2, 1, 3, 0, 192, 3, 128 },
+ { &MFVideoFormat_I420, 1, 2, 6, 3, 384, 2, 128 },
+ { &MFVideoFormat_I420, 2, 2, 6, 0, 384, 6, 128 },
+ { &MFVideoFormat_I420, 2, 4, 12, 0, 768, 12, 128 },
+ { &MFVideoFormat_I420, 4, 2, 12, 0, 384, 12, 128 },
+ { &MFVideoFormat_I420, 4, 3, 18, 0, 576, 18, 128 },
+ { &MFVideoFormat_I420, 320, 240, 115200, 0, 138240, 115200, 384 },
+
+ { &MFVideoFormat_IYUV, 1, 1, 3, 1, 192, 1, 128 },
+ { &MFVideoFormat_IYUV, 2, 1, 3, 0, 192, 3, 128 },
+ { &MFVideoFormat_IYUV, 1, 2, 6, 3, 384, 2, 128 },
+ { &MFVideoFormat_IYUV, 2, 2, 6, 0, 384, 6, 128 },
+ { &MFVideoFormat_IYUV, 2, 4, 12, 0, 768, 12, 128 },
+ { &MFVideoFormat_IYUV, 4, 2, 12, 0, 384, 12, 128 },
+ { &MFVideoFormat_IYUV, 4, 3, 18, 0, 576, 18, 128 },
+ { &MFVideoFormat_IYUV, 320, 240, 115200, 0, 138240, 115200, 384 },
+
};
static void test_MFCalculateImageSize(void)
@@ -4366,7 +4407,8 @@ static void test_MFGetPlaneSize(void)
hr = pMFGetPlaneSize(ptr->subtype->Data1, ptr->width, ptr->height, &size);
ok(hr == S_OK, "%u: failed to get plane size, hr %#lx.\n", i, hr);
- ok(size == plane_size, "%u: unexpected plane size %lu, expected %u.\n", i, size, plane_size);
+ ok(size == plane_size, "%u: unexpected plane size %lu, expected %u. Size %u x %u, format %s.\n", i, size, plane_size,
+ ptr->width, ptr->height, wine_dbgstr_an((char*)&ptr->subtype->Data1, 4));
}
}
@@ -5706,61 +5748,6 @@ static void test_MFGetStrideForBitmapInfoHeader(void)
static void test_MFCreate2DMediaBuffer(void)
{
- static const struct _2d_buffer_test
- {
- unsigned int width;
- unsigned int height;
- unsigned int fourcc;
- unsigned int contiguous_length;
- int pitch;
- unsigned int max_length;
- } _2d_buffer_tests[] =
- {
- { 2, 2, MAKEFOURCC('N','V','1','2'), 6, 64, 192 },
- { 4, 2, MAKEFOURCC('N','V','1','2'), 12, 64 },
- { 2, 4, MAKEFOURCC('N','V','1','2'), 12, 64 },
- { 1, 3, MAKEFOURCC('N','V','1','2'), 4, 64 },
- { 4, 16, MAKEFOURCC('N','V','1','2'), 96, 64, 1536 },
-
- { 2, 2, MAKEFOURCC('I','M','C','2'), 6, 128, 384 },
- { 4, 2, MAKEFOURCC('I','M','C','2'), 12, 128 },
- { 2, 4, MAKEFOURCC('I','M','C','2'), 12, 128 },
- { 3, 5, MAKEFOURCC('I','M','C','2'), 20, 128 },
- { 2, 2, MAKEFOURCC('I','M','C','4'), 6, 128 },
- { 4, 2, MAKEFOURCC('I','M','C','4'), 12, 128 },
- { 2, 4, MAKEFOURCC('I','M','C','4'), 12, 128 },
- { 3, 5, MAKEFOURCC('I','M','C','4'), 20, 128 },
-
- { 4, 2, MAKEFOURCC('I','M','C','1'), 32, 128 },
- { 4, 4, MAKEFOURCC('I','M','C','1'), 64, 128 },
- { 4, 16, MAKEFOURCC('I','M','C','1'), 256, 128, 4096 },
- { 4, 20, MAKEFOURCC('I','M','C','1'), 320, 128 },
-
- { 4, 2, MAKEFOURCC('I','M','C','3'), 32, 128 },
- { 4, 4, MAKEFOURCC('I','M','C','3'), 64, 128 },
- { 4, 16, MAKEFOURCC('I','M','C','3'), 256, 128, 4096 },
- { 4, 20, MAKEFOURCC('I','M','C','3'), 320, 128 },
-
- { 4, 2, MAKEFOURCC('Y','V','1','2'), 12, 128 },
- { 4, 4, MAKEFOURCC('Y','V','1','2'), 24, 128 },
- { 4, 16, MAKEFOURCC('Y','V','1','2'), 96, 128, 3072 },
-
- { 4, 2, MAKEFOURCC('A','Y','U','V'), 32, 64 },
- { 4, 4, MAKEFOURCC('A','Y','U','V'), 64, 64 },
- { 4, 16, MAKEFOURCC('A','Y','U','V'), 256, 64, 1024 },
-
- { 4, 2, MAKEFOURCC('Y','U','Y','2'), 16, 64 },
- { 4, 4, MAKEFOURCC('Y','U','Y','2'), 32, 64 },
- { 4, 16, MAKEFOURCC('Y','U','Y','2'), 128, 64, 1024 },
-
- { 4, 2, MAKEFOURCC('U','Y','V','Y'), 16, 64 },
- { 4, 4, MAKEFOURCC('U','Y','V','Y'), 32, 64 },
- { 4, 16, MAKEFOURCC('U','Y','V','Y'), 128, 64, 1024 },
-
- { 2, 4, D3DFMT_A8R8G8B8, 32, 64 },
- { 1, 4, D3DFMT_A8R8G8B8, 16, 64 },
- { 4, 1, D3DFMT_A8R8G8B8, 16, 64 },
- };
static const char two_aas[] = { 0xaa, 0xaa };
static const char eight_bbs[] = { 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb };
DWORD max_length, length, length2;
@@ -5958,18 +5945,17 @@ static void test_MFCreate2DMediaBuffer(void)
IMFMediaBuffer_Release(buffer);
- for (i = 0; i < ARRAY_SIZE(_2d_buffer_tests); ++i)
+ for (i = 0; i < ARRAY_SIZE(image_size_tests); ++i)
{
- const struct _2d_buffer_test *ptr = &_2d_buffer_tests[i];
+ const struct image_size_test *ptr = &image_size_tests[i];
- hr = pMFCreate2DMediaBuffer(ptr->width, ptr->height, ptr->fourcc, FALSE, &buffer);
+ hr = pMFCreate2DMediaBuffer(ptr->width, ptr->height, ptr->subtype->Data1, FALSE, &buffer);
ok(hr == S_OK, "Failed to create a buffer, hr %#lx.\n", hr);
hr = IMFMediaBuffer_GetMaxLength(buffer, &length);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- if (ptr->max_length)
- ok(length == ptr->max_length, "%u: unexpected maximum length %lu for %u x %u, format %s.\n",
- i, length, ptr->width, ptr->height, wine_dbgstr_an((char *)&ptr->fourcc, 4));
+ ok(length == ptr->max_length, "%u: unexpected maximum length %lu for %u x %u, format %s.\n",
+ i, length, ptr->width, ptr->height, wine_dbgstr_guid(ptr->subtype));
hr = IMFMediaBuffer_QueryInterface(buffer, &IID_IMF2DBuffer, (void **)&_2dbuffer);
ok(hr == S_OK, "Failed to get interface, hr %#lx.\n", hr);
@@ -5977,14 +5963,14 @@ static void test_MFCreate2DMediaBuffer(void)
hr = IMF2DBuffer_GetContiguousLength(_2dbuffer, &length);
ok(hr == S_OK, "Failed to get length, hr %#lx.\n", hr);
ok(length == ptr->contiguous_length, "%d: unexpected contiguous length %lu for %u x %u, format %s.\n",
- i, length, ptr->width, ptr->height, wine_dbgstr_an((char *)&ptr->fourcc, 4));
+ i, length, ptr->width, ptr->height, wine_dbgstr_guid(ptr->subtype));
hr = IMFMediaBuffer_Lock(buffer, &data, &length2, NULL);
ok(hr == S_OK, "Failed to lock buffer, hr %#lx.\n", hr);
ok(length2 == ptr->contiguous_length, "%d: unexpected linear buffer length %lu for %u x %u, format %s.\n",
- i, length2, ptr->width, ptr->height, wine_dbgstr_an((char *)&ptr->fourcc, 4));
+ i, length2, ptr->width, ptr->height, wine_dbgstr_guid(ptr->subtype));
- hr = pMFGetStrideForBitmapInfoHeader(ptr->fourcc, ptr->width, &stride);
+ hr = pMFGetStrideForBitmapInfoHeader(ptr->subtype->Data1, ptr->width, &stride);
ok(hr == S_OK, "Failed to get stride, hr %#lx.\n", hr);
stride = abs(stride);
@@ -5998,7 +5984,7 @@ static void test_MFCreate2DMediaBuffer(void)
data += ptr->height * stride;
/* secondary planes */
- switch (ptr->fourcc)
+ switch (ptr->subtype->Data1)
{
case MAKEFOURCC('I','M','C','1'):
case MAKEFOURCC('I','M','C','3'):
@@ -6011,6 +5997,9 @@ static void test_MFCreate2DMediaBuffer(void)
case MAKEFOURCC('I','M','C','2'):
case MAKEFOURCC('I','M','C','4'):
+ case MAKEFOURCC('Y','V','1','2'):
+ case MAKEFOURCC('I','4','2','0'):
+ case MAKEFOURCC('I','Y','U','V'):
ok(stride * 3 / 2 * ptr->height <= length2, "Insufficient buffer space: expected at least %lu bytes, got only %lu\n",
stride * 3 / 2 * ptr->height, length2);
for (j = 0; j < ptr->height; j++)
@@ -6048,7 +6037,7 @@ static void test_MFCreate2DMediaBuffer(void)
data += ptr->height * pitch;
/* secondary planes */
- switch (ptr->fourcc)
+ switch (ptr->subtype->Data1)
{
case MAKEFOURCC('I','M','C','1'):
case MAKEFOURCC('I','M','C','3'):
@@ -6061,6 +6050,9 @@ static void test_MFCreate2DMediaBuffer(void)
case MAKEFOURCC('I','M','C','2'):
case MAKEFOURCC('I','M','C','4'):
+ case MAKEFOURCC('Y','V','1','2'):
+ case MAKEFOURCC('I','4','2','0'):
+ case MAKEFOURCC('I','Y','U','V'):
for (j = 0; j < ptr->height; j++)
for (k = 0; k < stride / 2; k++)
ok(data[j * (pitch / 2) + k] == (((j + ptr->height) % 16) << 4) + (k % 16),
@@ -6084,7 +6076,7 @@ static void test_MFCreate2DMediaBuffer(void)
ok(hr == S_OK, "Failed to unlock buffer, hr %#lx.\n", hr);
ok(pitch == ptr->pitch, "%d: unexpected pitch %ld, expected %d, %u x %u, format %s.\n", i, pitch, ptr->pitch,
- ptr->width, ptr->height, wine_dbgstr_an((char *)&ptr->fourcc, 4));
+ ptr->width, ptr->height, wine_dbgstr_guid(ptr->subtype));
ret = TRUE;
hr = IMF2DBuffer_IsContiguousFormat(_2dbuffer, &ret);
@@ -6097,11 +6089,11 @@ static void test_MFCreate2DMediaBuffer(void)
}
/* Alignment tests */
- for (i = 0; i < ARRAY_SIZE(_2d_buffer_tests); ++i)
+ for (i = 0; i < ARRAY_SIZE(image_size_tests); ++i)
{
- const struct _2d_buffer_test *ptr = &_2d_buffer_tests[i];
+ const struct image_size_test *ptr = &image_size_tests[i];
- hr = pMFCreate2DMediaBuffer(ptr->width, ptr->height, ptr->fourcc, FALSE, &buffer);
+ hr = pMFCreate2DMediaBuffer(ptr->width, ptr->height, ptr->subtype->Data1, FALSE, &buffer);
ok(hr == S_OK, "Failed to create a buffer, hr %#lx.\n", hr);
hr = IMFMediaBuffer_QueryInterface(buffer, &IID_IMF2DBuffer, (void **)&_2dbuffer);
--
2.36.1
June 21, 2022
[PATCH v4 6/7] mfplat/buffer: Support YV12, I420 and IYUV image formats.
by Giovanni Mascellani
Signed-off-by: Giovanni Mascellani <gmascellani(a)codeweavers.com>
---
v2:
* Added
v4:
* Fix typo in subject
---
dlls/mfplat/buffer.c | 36 ++++++++++++++++++++++++++----------
1 file changed, 26 insertions(+), 10 deletions(-)
diff --git a/dlls/mfplat/buffer.c b/dlls/mfplat/buffer.c
index eff6a43dc70..3c2adf63c6d 100644
--- a/dlls/mfplat/buffer.c
+++ b/dlls/mfplat/buffer.c
@@ -1317,13 +1317,25 @@ static HRESULT create_1d_buffer(DWORD max_length, DWORD alignment, IMFMediaBuffe
static p_copy_image_func get_2d_buffer_copy_func(DWORD fourcc)
{
- if (fourcc == MAKEFOURCC('N','V','1','2'))
- return copy_image_nv12;
- if (fourcc == MAKEFOURCC('I','M','C','1') || fourcc == MAKEFOURCC('I','M','C','3'))
- return copy_image_imc1;
- if (fourcc == MAKEFOURCC('I','M','C','2') || fourcc == MAKEFOURCC('I','M','C','4'))
- return copy_image_imc2;
- return NULL;
+ switch (fourcc)
+ {
+ case MAKEFOURCC('N','V','1','2'):
+ return copy_image_nv12;
+
+ case MAKEFOURCC('I','M','C','1'):
+ case MAKEFOURCC('I','M','C','3'):
+ return copy_image_imc1;
+
+ case MAKEFOURCC('I','M','C','2'):
+ case MAKEFOURCC('I','M','C','4'):
+ case MAKEFOURCC('Y','V','1','2'):
+ case MAKEFOURCC('I','4','2','0'):
+ case MAKEFOURCC('I','Y','U','V'):
+ return copy_image_imc2;
+
+ default:
+ return NULL;
+ }
}
static HRESULT create_2d_buffer(DWORD width, DWORD height, DWORD fourcc, BOOL bottom_up, IMFMediaBuffer **buffer)
@@ -1359,12 +1371,12 @@ static HRESULT create_2d_buffer(DWORD width, DWORD height, DWORD fourcc, BOOL bo
break;
case MAKEFOURCC('I','M','C','2'):
case MAKEFOURCC('I','M','C','4'):
- plane_size = stride * 3 / 2 * height;
- break;
- case MAKEFOURCC('N','V','1','2'):
case MAKEFOURCC('Y','V','1','2'):
case MAKEFOURCC('I','4','2','0'):
case MAKEFOURCC('I','Y','U','V'):
+ plane_size = stride * 3 / 2 * height;
+ break;
+ case MAKEFOURCC('N','V','1','2'):
plane_size = stride * height * 3 / 2;
break;
default:
@@ -1381,6 +1393,8 @@ static HRESULT create_2d_buffer(DWORD width, DWORD height, DWORD fourcc, BOOL bo
case MAKEFOURCC('I','M','C','3'):
case MAKEFOURCC('I','M','C','4'):
case MAKEFOURCC('Y','V','1','2'):
+ case MAKEFOURCC('I','4','2','0'):
+ case MAKEFOURCC('I','Y','U','V'):
row_alignment = MF_128_BYTE_ALIGNMENT;
break;
default:
@@ -1399,6 +1413,8 @@ static HRESULT create_2d_buffer(DWORD width, DWORD height, DWORD fourcc, BOOL bo
case MAKEFOURCC('Y','V','1','2'):
case MAKEFOURCC('I','M','C','2'):
case MAKEFOURCC('I','M','C','4'):
+ case MAKEFOURCC('I','4','2','0'):
+ case MAKEFOURCC('I','Y','U','V'):
max_length = pitch * height * 3 / 2;
break;
default:
--
2.36.1
June 21, 2022
[PATCH v4 5/7] mfplat/tests: Remove duplicated tests.
by Giovanni Mascellani
The same tests are already performed in test_MFGetPlaneSize().
Signed-off-by: Giovanni Mascellani <gmascellani(a)codeweavers.com>
---
v2:
* Added
---
dlls/mfplat/tests/mfplat.c | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c
index 48f7a444add..0b02bd67172 100644
--- a/dlls/mfplat/tests/mfplat.c
+++ b/dlls/mfplat/tests/mfplat.c
@@ -4318,7 +4318,6 @@ image_size_tests[] =
static void test_MFCalculateImageSize(void)
{
- DWORD plane_size;
unsigned int i;
UINT32 size;
HRESULT hr;
@@ -4340,15 +4339,6 @@ static void test_MFCalculateImageSize(void)
ok(hr == S_OK || (is_broken && hr == E_INVALIDARG), "%u: failed to calculate image size, hr %#lx.\n", i, hr);
ok(size == ptr->size, "%u: unexpected image size %u, expected %u. Size %u x %u, format %s.\n", i, size, ptr->size,
ptr->width, ptr->height, wine_dbgstr_an((char *)&ptr->subtype->Data1, 4));
-
- if (pMFGetPlaneSize)
- {
- unsigned int expected = ptr->plane_size ? ptr->plane_size : ptr->size;
-
- hr = pMFGetPlaneSize(ptr->subtype->Data1, ptr->width, ptr->height, &plane_size);
- ok(hr == S_OK, "%u: failed to get plane size, hr %#lx.\n", i, hr);
- ok(plane_size == expected, "%u: unexpected plane size %lu, expected %u.\n", i, plane_size, expected);
- }
}
}
--
2.36.1
June 21, 2022
[PATCH v4 4/7] mfplat/buffer: Deduplicate common code between Lock2D() and Lock2DSize().
by Giovanni Mascellani
Signed-off-by: Giovanni Mascellani <gmascellani(a)codeweavers.com>
---
v2:
* Remove the trace in memory_2d_buffer_Lock2D()
v3:
* Redirect all invocations to helper functions.
v4:
* Rework helper functions.
---
dlls/mfplat/buffer.c | 103 ++++++++++++++++++++++---------------------
1 file changed, 52 insertions(+), 51 deletions(-)
diff --git a/dlls/mfplat/buffer.c b/dlls/mfplat/buffer.c
index a7ba306223d..eff6a43dc70 100644
--- a/dlls/mfplat/buffer.c
+++ b/dlls/mfplat/buffer.c
@@ -655,18 +655,11 @@ static const IMF2DBuffer2Vtbl memory_2d_buffer_vtbl =
memory_2d_buffer_Copy2DTo,
};
-static HRESULT WINAPI d3d9_surface_buffer_Lock2D(IMF2DBuffer2 *iface, BYTE **scanline0, LONG *pitch)
+static HRESULT d3d9_surface_buffer_lock(struct buffer *buffer, MF2DBuffer_LockFlags flags, BYTE **scanline0,
+ LONG *pitch, BYTE **buffer_start, DWORD *buffer_length)
{
- struct buffer *buffer = impl_from_IMF2DBuffer2(iface);
HRESULT hr = S_OK;
- TRACE("%p, %p, %p.\n", iface, scanline0, pitch);
-
- if (!scanline0 || !pitch)
- return E_POINTER;
-
- EnterCriticalSection(&buffer->cs);
-
if (buffer->_2d.linear_buffer)
hr = MF_E_UNEXPECTED;
else if (!buffer->_2d.locks)
@@ -679,8 +672,29 @@ static HRESULT WINAPI d3d9_surface_buffer_Lock2D(IMF2DBuffer2 *iface, BYTE **sca
buffer->_2d.locks++;
*scanline0 = buffer->d3d9_surface.rect.pBits;
*pitch = buffer->d3d9_surface.rect.Pitch;
+ if (buffer_start)
+ *buffer_start = *scanline0;
+ if (buffer_length)
+ *buffer_length = buffer->d3d9_surface.rect.Pitch * buffer->_2d.height;
}
+ return hr;
+}
+
+static HRESULT WINAPI d3d9_surface_buffer_Lock2D(IMF2DBuffer2 *iface, BYTE **scanline0, LONG *pitch)
+{
+ struct buffer *buffer = impl_from_IMF2DBuffer2(iface);
+ HRESULT hr;
+
+ TRACE("%p, %p, %p.\n", iface, scanline0, pitch);
+
+ if (!scanline0 || !pitch)
+ return E_POINTER;
+
+ EnterCriticalSection(&buffer->cs);
+
+ hr = d3d9_surface_buffer_lock(buffer, MF2DBuffer_LockFlags_ReadWrite, scanline0, pitch, NULL, NULL);
+
LeaveCriticalSection(&buffer->cs);
return hr;
@@ -744,7 +758,7 @@ static HRESULT WINAPI d3d9_surface_buffer_Lock2DSize(IMF2DBuffer2 *iface, MF2DBu
LONG *pitch, BYTE **buffer_start, DWORD *buffer_length)
{
struct buffer *buffer = impl_from_IMF2DBuffer2(iface);
- HRESULT hr = S_OK;
+ HRESULT hr;
TRACE("%p, %#x, %p, %p, %p, %p.\n", iface, flags, scanline0, pitch, buffer_start, buffer_length);
@@ -753,23 +767,7 @@ static HRESULT WINAPI d3d9_surface_buffer_Lock2DSize(IMF2DBuffer2 *iface, MF2DBu
EnterCriticalSection(&buffer->cs);
- if (buffer->_2d.linear_buffer)
- hr = MF_E_UNEXPECTED;
- else if (!buffer->_2d.locks)
- {
- hr = IDirect3DSurface9_LockRect(buffer->d3d9_surface.surface, &buffer->d3d9_surface.rect, NULL, 0);
- }
-
- if (SUCCEEDED(hr))
- {
- buffer->_2d.locks++;
- *scanline0 = buffer->d3d9_surface.rect.pBits;
- *pitch = buffer->d3d9_surface.rect.Pitch;
- if (buffer_start)
- *buffer_start = *scanline0;
- if (buffer_length)
- *buffer_length = buffer->d3d9_surface.rect.Pitch * buffer->_2d.height;
- }
+ hr = d3d9_surface_buffer_lock(buffer, flags, scanline0, pitch, buffer_start, buffer_length);
LeaveCriticalSection(&buffer->cs);
@@ -1030,18 +1028,11 @@ static HRESULT WINAPI dxgi_surface_buffer_SetCurrentLength(IMFMediaBuffer *iface
return S_OK;
}
-static HRESULT WINAPI dxgi_surface_buffer_Lock2D(IMF2DBuffer2 *iface, BYTE **scanline0, LONG *pitch)
+static HRESULT dxgi_surface_buffer_lock2d(struct buffer *buffer, MF2DBuffer_LockFlags flags,
+ BYTE **scanline0, LONG *pitch, BYTE **buffer_start, DWORD *buffer_length)
{
- struct buffer *buffer = impl_from_IMF2DBuffer2(iface);
HRESULT hr = S_OK;
- TRACE("%p, %p, %p.\n", iface, scanline0, pitch);
-
- if (!scanline0 || !pitch)
- return E_POINTER;
-
- EnterCriticalSection(&buffer->cs);
-
if (buffer->_2d.linear_buffer)
hr = MF_E_UNEXPECTED;
else if (!buffer->_2d.locks++)
@@ -1051,6 +1042,10 @@ static HRESULT WINAPI dxgi_surface_buffer_Lock2D(IMF2DBuffer2 *iface, BYTE **sca
{
*scanline0 = buffer->dxgi_surface.map_desc.pData;
*pitch = buffer->dxgi_surface.map_desc.RowPitch;
+ if (buffer_start)
+ *buffer_start = *scanline0;
+ if (buffer_length)
+ *buffer_length = buffer->dxgi_surface.map_desc.RowPitch * buffer->_2d.height;
}
LeaveCriticalSection(&buffer->cs);
@@ -1058,6 +1053,25 @@ static HRESULT WINAPI dxgi_surface_buffer_Lock2D(IMF2DBuffer2 *iface, BYTE **sca
return hr;
}
+static HRESULT WINAPI dxgi_surface_buffer_Lock2D(IMF2DBuffer2 *iface, BYTE **scanline0, LONG *pitch)
+{
+ struct buffer *buffer = impl_from_IMF2DBuffer2(iface);
+ HRESULT hr;
+
+ TRACE("%p, %p, %p.\n", iface, scanline0, pitch);
+
+ if (!scanline0 || !pitch)
+ return E_POINTER;
+
+ EnterCriticalSection(&buffer->cs);
+
+ hr = dxgi_surface_buffer_lock2d(buffer, MF2DBuffer_LockFlags_ReadWrite, scanline0, pitch, NULL, NULL);
+
+ LeaveCriticalSection(&buffer->cs);
+
+ return hr;
+}
+
static HRESULT WINAPI dxgi_surface_buffer_Unlock2D(IMF2DBuffer2 *iface)
{
struct buffer *buffer = impl_from_IMF2DBuffer2(iface);
@@ -1113,7 +1127,7 @@ static HRESULT WINAPI dxgi_surface_buffer_Lock2DSize(IMF2DBuffer2 *iface, MF2DBu
BYTE **scanline0, LONG *pitch, BYTE **buffer_start, DWORD *buffer_length)
{
struct buffer *buffer = impl_from_IMF2DBuffer2(iface);
- HRESULT hr = S_OK;
+ HRESULT hr;
TRACE("%p, %#x, %p, %p, %p, %p.\n", iface, flags, scanline0, pitch, buffer_start, buffer_length);
@@ -1122,20 +1136,7 @@ static HRESULT WINAPI dxgi_surface_buffer_Lock2DSize(IMF2DBuffer2 *iface, MF2DBu
EnterCriticalSection(&buffer->cs);
- if (buffer->_2d.linear_buffer)
- hr = MF_E_UNEXPECTED;
- else if (!buffer->_2d.locks++)
- hr = dxgi_surface_buffer_map(buffer);
-
- if (SUCCEEDED(hr))
- {
- *scanline0 = buffer->dxgi_surface.map_desc.pData;
- *pitch = buffer->dxgi_surface.map_desc.RowPitch;
- if (buffer_start)
- *buffer_start = *scanline0;
- if (buffer_length)
- *buffer_length = buffer->dxgi_surface.map_desc.RowPitch * buffer->_2d.height;
- }
+ hr = dxgi_surface_buffer_lock2d(buffer, flags, scanline0, pitch, buffer_start, buffer_length);
LeaveCriticalSection(&buffer->cs);
--
2.36.1
June 21, 2022
[PATCH v4 3/7] mfplat/buffer: Fix the image copy function for IMC2/IMC4 buffers with odd height.
by Giovanni Mascellani
Signed-off-by: Giovanni Mascellani <gmascellani(a)codeweavers.com>
---
v4:
* Rebased on "Use a more unique pattern when testing image formats."
---
dlls/mfplat/buffer.c | 3 +--
dlls/mfplat/tests/mfplat.c | 1 -
2 files changed, 1 insertion(+), 3 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 d242e69d4cc..48f7a444add 100644
--- a/dlls/mfplat/tests/mfplat.c
+++ b/dlls/mfplat/tests/mfplat.c
@@ -6073,7 +6073,6 @@ static void test_MFCreate2DMediaBuffer(void)
case MAKEFOURCC('I','M','C','4'):
for (j = 0; j < ptr->height; j++)
for (k = 0; k < stride / 2; k++)
- todo_if(ptr->height % 2 == 1 && j >= 2)
ok(data[j * (pitch / 2) + k] == (((j + ptr->height) % 16) << 4) + (k % 16),
"Unexpected byte %02x instead of %02x at test %d row %d column %d.\n",
data[j * (pitch / 2) + k], (((j + ptr->height) % 16) << 4) + (k % 16), i, j + ptr->height, k);
--
2.36.1
June 21, 2022
[PATCH v4 2/7] mfplat/tests: Use a more unique pattern when testing image formats.
by Giovanni Mascellani
Signed-off-by: Giovanni Mascellani <gmascellani(a)codeweavers.com>
---
v4:
* Added
---
dlls/mfplat/tests/mfplat.c | 82 +++++++++++++++++++++++++++++---------
1 file changed, 64 insertions(+), 18 deletions(-)
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c
index 6ad667a7404..d242e69d4cc 100644
--- a/dlls/mfplat/tests/mfplat.c
+++ b/dlls/mfplat/tests/mfplat.c
@@ -5994,7 +5994,48 @@ static void test_MFCreate2DMediaBuffer(void)
ok(length2 == ptr->contiguous_length, "%d: unexpected linear buffer length %lu for %u x %u, format %s.\n",
i, length2, ptr->width, ptr->height, wine_dbgstr_an((char *)&ptr->fourcc, 4));
- memset(data, 0xff, length2);
+ hr = pMFGetStrideForBitmapInfoHeader(ptr->fourcc, ptr->width, &stride);
+ ok(hr == S_OK, "Failed to get stride, hr %#lx.\n", hr);
+ stride = abs(stride);
+
+ /* primary plane */
+ ok(ptr->height * stride <= length2, "Insufficient buffer space: expected at least %lu bytes, got only %lu\n",
+ ptr->height * stride, length2);
+ for (j = 0; j < ptr->height; j++)
+ for (k = 0; k < stride; k++)
+ data[j * stride + k] = ((j % 16) << 4) + (k % 16);
+
+ data += ptr->height * stride;
+
+ /* secondary planes */
+ switch (ptr->fourcc)
+ {
+ case MAKEFOURCC('I','M','C','1'):
+ case MAKEFOURCC('I','M','C','3'):
+ ok(2 * ptr->height * stride <= length2, "Insufficient buffer space: expected at least %lu bytes, got only %lu\n",
+ 2 * ptr->height * stride, length2);
+ for (j = 0; j < ptr->height; j++)
+ for (k = 0; k < stride / 2; k++)
+ data[j * stride + k] = (((j + ptr->height) % 16) << 4) + (k % 16);
+ break;
+
+ case MAKEFOURCC('I','M','C','2'):
+ case MAKEFOURCC('I','M','C','4'):
+ ok(stride * 3 / 2 * ptr->height <= length2, "Insufficient buffer space: expected at least %lu bytes, got only %lu\n",
+ stride * 3 / 2 * ptr->height, length2);
+ for (j = 0; j < ptr->height; j++)
+ for (k = 0; k < stride / 2; k++)
+ data[j * (stride / 2) + k] = (((j + ptr->height) % 16) << 4) + (k % 16);
+ break;
+
+ case MAKEFOURCC('N','V','1','2'):
+ ok(stride * ptr->height * 3 / 2 <= length2, "Insufficient buffer space: expected at least %lu bytes, got only %lu\n",
+ stride * ptr->height * 3 / 2, length2);
+ for (j = 0; j < ptr->height / 2; j++)
+ for (k = 0; k < stride; k++)
+ data[j * stride + k] = (((j + ptr->height) % 16) << 4) + (k % 16);
+ break;
+ }
hr = IMFMediaBuffer_Unlock(buffer);
ok(hr == S_OK, "Failed to unlock buffer, hr %#lx.\n", hr);
@@ -6008,37 +6049,42 @@ static void test_MFCreate2DMediaBuffer(void)
ok(pitch == pitch2, "Unexpected pitch.\n");
/* primary plane */
- for(j = 0; j < ptr->height; j++)
- for (k = 0; k < ptr->width; 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 = 0; j < ptr->height; j++)
+ for (k = 0; k < stride; k++)
+ ok(data[j * pitch + k] == ((j % 16) << 4) + (k % 16),
+ "Unexpected byte %02x instead of %02x at test %d row %d column %d.\n",
+ data[j * pitch + k], ((j % 16) << 4) + (k % 16), i, j, k);
- hr = pMFGetStrideForBitmapInfoHeader(ptr->fourcc, ptr->width, &stride);
- ok(hr == S_OK, "Failed to get stride, hr %#lx.\n", hr);
+ data += ptr->height * pitch;
/* secondary planes */
switch (ptr->fourcc)
{
case MAKEFOURCC('I','M','C','1'):
case MAKEFOURCC('I','M','C','3'):
- for (j = ptr->height; j < length2 / stride; 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 = 0; j < ptr->height; j++)
+ for (k = 0; k < stride / 2; k++)
+ ok(data[j * pitch + k] == (((j + ptr->height) % 16) << 4) + (k % 16),
+ "Unexpected byte %02x instead of %02x at test %d row %d column %d.\n",
+ data[j * pitch + k], (((j + ptr->height) % 16) << 4) + (k % 16), i, j + ptr->height, k);
break;
case MAKEFOURCC('I','M','C','2'):
case MAKEFOURCC('I','M','C','4'):
- for (j = ptr->height; j < length2 / stride; 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);
+ for (j = 0; j < ptr->height; j++)
+ for (k = 0; k < stride / 2; k++)
+ todo_if(ptr->height % 2 == 1 && j >= 2)
+ ok(data[j * (pitch / 2) + k] == (((j + ptr->height) % 16) << 4) + (k % 16),
+ "Unexpected byte %02x instead of %02x at test %d row %d column %d.\n",
+ data[j * (pitch / 2) + k], (((j + ptr->height) % 16) << 4) + (k % 16), i, j + ptr->height, k);
break;
case MAKEFOURCC('N','V','1','2'):
- for (j = ptr->height; j < length2 / stride; j++)
- for (k = 0; k < ptr->width; 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 = 0; j < ptr->height / 2; j++)
+ for (k = 0; k < stride; k++)
+ ok(data[j * pitch + k] == (((j + ptr->height) % 16) << 4) + (k % 16),
+ "Unexpected byte %02x instead of %02x at test %d row %d column %d.\n",
+ data[j * pitch + k], (((j + ptr->height) % 16) << 4) + (k % 16), i, j + ptr->height, k);
break;
default:
--
2.36.1
June 21, 2022
[PATCH v4 1/7] mfplat/buffer: Fix size for IMC2/IMC4 buffers with odd height.
by Giovanni Mascellani
Signed-off-by: Giovanni Mascellani <gmascellani(a)codeweavers.com>
---
v2:
* Remove the multiplier
* The missing test cases will be reinsterted in a later commit
---
dlls/mfplat/buffer.c | 22 ++++++++++++++++++---
dlls/mfplat/tests/mfplat.c | 40 ++++++++++++++++----------------------
2 files changed, 36 insertions(+), 26 deletions(-)
diff --git a/dlls/mfplat/buffer.c b/dlls/mfplat/buffer.c
index eada3df18ad..39407ccc9e2 100644
--- a/dlls/mfplat/buffer.c
+++ b/dlls/mfplat/buffer.c
@@ -1351,8 +1351,25 @@ static HRESULT create_2d_buffer(DWORD width, DWORD height, DWORD fourcc, BOOL bo
if (is_yuv && bottom_up)
return MF_E_INVALIDMEDIATYPE;
- if (FAILED(hr = MFGetPlaneSize(fourcc, width, height, &plane_size)))
- return hr;
+ switch (fourcc)
+ {
+ case MAKEFOURCC('I','M','C','1'):
+ case MAKEFOURCC('I','M','C','3'):
+ plane_size = stride * height * 2;
+ break;
+ case MAKEFOURCC('I','M','C','2'):
+ case MAKEFOURCC('I','M','C','4'):
+ plane_size = stride * 3 / 2 * height;
+ break;
+ case MAKEFOURCC('N','V','1','2'):
+ case MAKEFOURCC('Y','V','1','2'):
+ case MAKEFOURCC('I','4','2','0'):
+ case MAKEFOURCC('I','Y','U','V'):
+ plane_size = stride * height * 3 / 2;
+ break;
+ default:
+ plane_size = stride * height;
+ }
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
@@ -1377,7 +1394,6 @@ static HRESULT create_2d_buffer(DWORD width, DWORD height, DWORD fourcc, BOOL bo
case MAKEFOURCC('I','M','C','1'):
case MAKEFOURCC('I','M','C','3'):
max_length = pitch * height * 2;
- plane_size *= 2;
break;
case MAKEFOURCC('N','V','1','2'):
case MAKEFOURCC('Y','V','1','2'):
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c
index 67cf8954c36..6ad667a7404 100644
--- a/dlls/mfplat/tests/mfplat.c
+++ b/dlls/mfplat/tests/mfplat.c
@@ -5723,48 +5723,49 @@ static void test_MFCreate2DMediaBuffer(void)
unsigned int fourcc;
unsigned int contiguous_length;
int pitch;
- unsigned int plane_multiplier;
unsigned int max_length;
} _2d_buffer_tests[] =
{
- { 2, 2, MAKEFOURCC('N','V','1','2'), 6, 64, 0, 192 },
+ { 2, 2, MAKEFOURCC('N','V','1','2'), 6, 64, 192 },
{ 4, 2, MAKEFOURCC('N','V','1','2'), 12, 64 },
{ 2, 4, MAKEFOURCC('N','V','1','2'), 12, 64 },
{ 1, 3, MAKEFOURCC('N','V','1','2'), 4, 64 },
- { 4, 16, MAKEFOURCC('N','V','1','2'), 96, 64, 0, 1536 },
+ { 4, 16, MAKEFOURCC('N','V','1','2'), 96, 64, 1536 },
- { 2, 2, MAKEFOURCC('I','M','C','2'), 6, 128, 0, 384 },
+ { 2, 2, MAKEFOURCC('I','M','C','2'), 6, 128, 384 },
{ 4, 2, MAKEFOURCC('I','M','C','2'), 12, 128 },
{ 2, 4, MAKEFOURCC('I','M','C','2'), 12, 128 },
+ { 3, 5, MAKEFOURCC('I','M','C','2'), 20, 128 },
{ 2, 2, MAKEFOURCC('I','M','C','4'), 6, 128 },
{ 4, 2, MAKEFOURCC('I','M','C','4'), 12, 128 },
{ 2, 4, MAKEFOURCC('I','M','C','4'), 12, 128 },
+ { 3, 5, MAKEFOURCC('I','M','C','4'), 20, 128 },
- { 4, 2, MAKEFOURCC('I','M','C','1'), 32, 128, 2 },
- { 4, 4, MAKEFOURCC('I','M','C','1'), 64, 128, 2 },
- { 4, 16, MAKEFOURCC('I','M','C','1'), 256, 128, 2, 4096 },
- { 4, 20, MAKEFOURCC('I','M','C','1'), 320, 128, 2 },
+ { 4, 2, MAKEFOURCC('I','M','C','1'), 32, 128 },
+ { 4, 4, MAKEFOURCC('I','M','C','1'), 64, 128 },
+ { 4, 16, MAKEFOURCC('I','M','C','1'), 256, 128, 4096 },
+ { 4, 20, MAKEFOURCC('I','M','C','1'), 320, 128 },
- { 4, 2, MAKEFOURCC('I','M','C','3'), 32, 128, 2 },
- { 4, 4, MAKEFOURCC('I','M','C','3'), 64, 128, 2 },
- { 4, 16, MAKEFOURCC('I','M','C','3'), 256, 128, 2, 4096 },
- { 4, 20, MAKEFOURCC('I','M','C','3'), 320, 128, 2 },
+ { 4, 2, MAKEFOURCC('I','M','C','3'), 32, 128 },
+ { 4, 4, MAKEFOURCC('I','M','C','3'), 64, 128 },
+ { 4, 16, MAKEFOURCC('I','M','C','3'), 256, 128, 4096 },
+ { 4, 20, MAKEFOURCC('I','M','C','3'), 320, 128 },
{ 4, 2, MAKEFOURCC('Y','V','1','2'), 12, 128 },
{ 4, 4, MAKEFOURCC('Y','V','1','2'), 24, 128 },
- { 4, 16, MAKEFOURCC('Y','V','1','2'), 96, 128, 0, 3072 },
+ { 4, 16, MAKEFOURCC('Y','V','1','2'), 96, 128, 3072 },
{ 4, 2, MAKEFOURCC('A','Y','U','V'), 32, 64 },
{ 4, 4, MAKEFOURCC('A','Y','U','V'), 64, 64 },
- { 4, 16, MAKEFOURCC('A','Y','U','V'), 256, 64, 0, 1024 },
+ { 4, 16, MAKEFOURCC('A','Y','U','V'), 256, 64, 1024 },
{ 4, 2, MAKEFOURCC('Y','U','Y','2'), 16, 64 },
{ 4, 4, MAKEFOURCC('Y','U','Y','2'), 32, 64 },
- { 4, 16, MAKEFOURCC('Y','U','Y','2'), 128, 64, 0, 1024 },
+ { 4, 16, MAKEFOURCC('Y','U','Y','2'), 128, 64, 1024 },
{ 4, 2, MAKEFOURCC('U','Y','V','Y'), 16, 64 },
{ 4, 4, MAKEFOURCC('U','Y','V','Y'), 32, 64 },
- { 4, 16, MAKEFOURCC('U','Y','V','Y'), 128, 64, 0, 1024 },
+ { 4, 16, MAKEFOURCC('U','Y','V','Y'), 128, 64, 1024 },
{ 2, 4, D3DFMT_A8R8G8B8, 32, 64 },
{ 1, 4, D3DFMT_A8R8G8B8, 16, 64 },
@@ -5998,13 +5999,6 @@ static void test_MFCreate2DMediaBuffer(void)
hr = IMFMediaBuffer_Unlock(buffer);
ok(hr == S_OK, "Failed to unlock buffer, hr %#lx.\n", hr);
- hr = pMFGetPlaneSize(ptr->fourcc, ptr->width, ptr->height, &length2);
- ok(hr == S_OK, "Failed to get plane size, hr %#lx.\n", hr);
- if (ptr->plane_multiplier)
- length2 *= ptr->plane_multiplier;
- ok(length2 == length, "%d: contiguous length %lu does not match plane size %lu, %u x %u, format %s.\n", i, length,
- length2, ptr->width, ptr->height, wine_dbgstr_an((char *)&ptr->fourcc, 4));
-
hr = IMF2DBuffer_Lock2D(_2dbuffer, &data, &pitch);
ok(hr == S_OK, "Failed to lock buffer, hr %#lx.\n", hr);
--
2.36.1
June 21, 2022
Re: [PATCH 2/2] secur32: Implement SECPKG_ATTR_CIPHER_INFO.
by Hans Leidekker
On Tue, 2022-06-21 at 13:16 +0300, Dmitry Timoshkov wrote:
> Hans Leidekker <wine(a)gitlab.winehq.org> wrote:
> > +static NTSTATUS wow64_schan_get_cipher_info( void *args )
> > +{
> > + struct
> > + {
> > + schan_session session;
> > + PTR32 info;
> > + } const *params32 = args;
> > + struct get_cipher_info_params params =
> > + {
> > + params32->session,
> > + ULongToPtr(params32->info),
> > + };
> > + return schan_get_connection_info(¶ms);
> > +}
>
> Probably it should forward to schan_get_cipher_info().
Thanks, I pushed a fix.
June 21, 2022
[PATCH v2 2/2] secur32: Implement SECPKG_ATTR_CIPHER_INFO.
by Hans Leidekker
From: Hans Leidekker <hans(a)codeweavers.com>
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53180
---
dlls/secur32/schannel.c | 8 ++
dlls/secur32/schannel_gnutls.c | 222 +++++++++++++++++++++++++++++++++
dlls/secur32/secur32_priv.h | 7 ++
dlls/secur32/tests/schannel.c | 29 +++++
4 files changed, 266 insertions(+)
diff --git a/dlls/secur32/schannel.c b/dlls/secur32/schannel.c
index 5b4fb196aca..7dc9bd1d21a 100644
--- a/dlls/secur32/schannel.c
+++ b/dlls/secur32/schannel.c
@@ -1244,6 +1244,12 @@ static SECURITY_STATUS SEC_ENTRY schan_QueryContextAttributesW(
struct get_application_protocol_params params = { ctx->session, protocol };
return GNUTLS_CALL( get_application_protocol, ¶ms );
}
+ case SECPKG_ATTR_CIPHER_INFO:
+ {
+ SecPkgContext_CipherInfo *info = buffer;
+ struct get_cipher_info_params params = { ctx->session, info };
+ return GNUTLS_CALL( get_cipher_info, ¶ms );
+ }
default:
FIXME("Unhandled attribute %#lx\n", attribute);
@@ -1282,6 +1288,8 @@ static SECURITY_STATUS SEC_ENTRY schan_QueryContextAttributesA(
return schan_QueryContextAttributesW(context_handle, attribute, buffer);
case SECPKG_ATTR_APPLICATION_PROTOCOL:
return schan_QueryContextAttributesW(context_handle, attribute, buffer);
+ case SECPKG_ATTR_CIPHER_INFO:
+ return schan_QueryContextAttributesW(context_handle, attribute, buffer);
default:
FIXME("Unhandled attribute %#lx\n", attribute);
diff --git a/dlls/secur32/schannel_gnutls.c b/dlls/secur32/schannel_gnutls.c
index ad319518a7a..58e787b7600 100644
--- a/dlls/secur32/schannel_gnutls.c
+++ b/dlls/secur32/schannel_gnutls.c
@@ -698,6 +698,211 @@ static NTSTATUS schan_get_connection_info( void *args )
return SEC_E_OK;
}
+static DWORD get_protocol_version( gnutls_session_t session )
+{
+ gnutls_protocol_t proto = pgnutls_protocol_get_version( session );
+
+ switch (proto)
+ {
+ case GNUTLS_SSL3: return 0x300;
+ case GNUTLS_TLS1_0: return 0x301;
+ case GNUTLS_TLS1_1: return 0x302;
+ case GNUTLS_TLS1_2: return 0x303;
+ case GNUTLS_DTLS1_0: return 0x201;
+ case GNUTLS_DTLS1_2: return 0x202;
+ default:
+ FIXME( "unknown protocol %u\n", proto );
+ return 0;
+ }
+}
+
+static const WCHAR *get_cipher_str( gnutls_session_t session )
+{
+ static const WCHAR aesW[] = {'A','E','S',0};
+ static const WCHAR unknownW[] = {'<','u','n','k','n','o','w','n','>',0};
+ gnutls_cipher_algorithm_t cipher = pgnutls_cipher_get( session );
+
+ switch (cipher)
+ {
+ case GNUTLS_CIPHER_AES_128_CBC:
+ case GNUTLS_CIPHER_AES_192_CBC:
+ case GNUTLS_CIPHER_AES_256_CBC:
+ case GNUTLS_CIPHER_AES_128_GCM:
+ case GNUTLS_CIPHER_AES_256_GCM:
+ case GNUTLS_CIPHER_AES_128_CCM:
+ case GNUTLS_CIPHER_AES_256_CCM:
+ return aesW;
+ default:
+ FIXME( "unknown cipher %u\n", cipher );
+ return unknownW;
+ }
+}
+
+static DWORD get_cipher_len( gnutls_session_t session )
+{
+ gnutls_cipher_algorithm_t cipher = pgnutls_cipher_get( session );
+
+ switch (cipher)
+ {
+ case GNUTLS_CIPHER_AES_128_CBC:
+ case GNUTLS_CIPHER_AES_128_GCM:
+ case GNUTLS_CIPHER_AES_128_CCM:
+ return 128;
+ case GNUTLS_CIPHER_AES_192_CBC:
+ return 192;
+ case GNUTLS_CIPHER_AES_256_CBC:
+ case GNUTLS_CIPHER_AES_256_GCM:
+ case GNUTLS_CIPHER_AES_256_CCM:
+ return 256;
+ default:
+ FIXME( "unknown cipher %u\n", cipher );
+ return 0;
+ }
+}
+
+static DWORD get_cipher_block_len( gnutls_session_t session )
+{
+ gnutls_cipher_algorithm_t cipher = pgnutls_cipher_get( session );
+ return pgnutls_cipher_get_block_size( cipher );
+}
+
+static const WCHAR *get_hash_str( gnutls_session_t session, BOOL full )
+{
+ static const WCHAR shaW[] = {'S','H','A',0};
+ static const WCHAR sha1W[] = {'S','H','A','1',0};
+ static const WCHAR sha224W[] = {'S','H','A','2','2','4',0};
+ static const WCHAR sha256W[] = {'S','H','A','2','5','6',0};
+ static const WCHAR sha384W[] = {'S','H','A','3','8','4',0};
+ static const WCHAR sha512W[] = {'S','H','A','5','1','2',0};
+ static const WCHAR unknownW[] = {'<','u','n','k','n','o','w','n','>',0};
+ gnutls_mac_algorithm_t mac = pgnutls_mac_get( session );
+
+ switch (mac)
+ {
+ case GNUTLS_MAC_SHA1: return full ? sha1W : shaW;
+ case GNUTLS_MAC_SHA224: return sha224W;
+ case GNUTLS_MAC_SHA256: return sha256W;
+ case GNUTLS_MAC_SHA384: return sha384W;
+ case GNUTLS_MAC_SHA512: return sha512W;
+ default:
+ FIXME( "unknown mac %u\n", mac );
+ return unknownW;
+ }
+}
+
+static DWORD get_hash_len( gnutls_session_t session )
+{
+ gnutls_mac_algorithm_t mac = pgnutls_mac_get( session );
+ return pgnutls_mac_get_key_size( mac ) * 8;
+}
+
+static const WCHAR *get_exchange_str( gnutls_session_t session, BOOL full )
+{
+ static const WCHAR ecdhW[] = {'E','C','D','H',0};
+ static const WCHAR ecdheW[] = {'E','C','D','H','E',0};
+ static const WCHAR unknownW[] = {'<','u','n','k','n','o','w','n','>',0};
+ gnutls_kx_algorithm_t kx = pgnutls_kx_get( session );
+
+ switch (kx)
+ {
+ case GNUTLS_KX_ECDHE_RSA:
+ case GNUTLS_KX_ECDHE_ECDSA:
+ return full ? ecdheW : ecdhW;
+ default:
+ FIXME( "unknown kx %u\n", kx );
+ return unknownW;
+ }
+}
+
+static const WCHAR *get_certificate_str( gnutls_session_t session )
+{
+ static const WCHAR rsaW[] = {'R','S','A',0};
+ static const WCHAR ecdsaW[] = {'E','C','D','S','A',0};
+ static const WCHAR unknownW[] = {'<','u','n','k','n','o','w','n','>',0};
+ gnutls_kx_algorithm_t kx = pgnutls_kx_get( session );
+
+ switch (kx)
+ {
+ case GNUTLS_KX_RSA:
+ case GNUTLS_KX_RSA_EXPORT:
+ case GNUTLS_KX_DHE_RSA:
+ case GNUTLS_KX_ECDHE_RSA: return rsaW;
+ case GNUTLS_KX_ECDHE_ECDSA: return ecdsaW;
+ default:
+ FIXME( "unknown kx %u\n", kx );
+ return unknownW;
+ }
+}
+
+static const WCHAR *get_chaining_mode_str( gnutls_session_t session )
+{
+ static const WCHAR cbcW[] = {'C','B','C',0};
+ static const WCHAR ccmW[] = {'C','C','M',0};
+ static const WCHAR gcmW[] = {'G','C','M',0};
+ static const WCHAR unknownW[] = {'<','u','n','k','n','o','w','n','>',0};
+ gnutls_cipher_algorithm_t cipher = pgnutls_cipher_get( session );
+
+ switch (cipher)
+ {
+ case GNUTLS_CIPHER_AES_128_CBC:
+ case GNUTLS_CIPHER_AES_192_CBC:
+ case GNUTLS_CIPHER_AES_256_CBC:
+ return cbcW;
+ case GNUTLS_CIPHER_AES_128_GCM:
+ case GNUTLS_CIPHER_AES_256_GCM:
+ return gcmW;
+ case GNUTLS_CIPHER_AES_128_CCM:
+ case GNUTLS_CIPHER_AES_256_CCM:
+ return ccmW;
+ default:
+ FIXME( "unknown cipher %u\n", cipher );
+ return unknownW;
+ }
+}
+
+static NTSTATUS schan_get_cipher_info( void *args )
+{
+ const WCHAR tlsW[] = {'T','L','S','_',0};
+ const WCHAR underscoreW[] = {'_',0};
+ const WCHAR widthW[] = {'_','W','I','T','H','_',0};
+ const struct get_cipher_info_params *params = args;
+ gnutls_session_t session = session_from_handle( params->session );
+ SecPkgContext_CipherInfo *info = params->info;
+ char buf[11];
+ WCHAR *ptr;
+ int len;
+
+ info->dwProtocol = get_protocol_version( session );
+ info->dwCipherSuite = 0; /* FIXME */
+ info->dwBaseCipherSuite = 0; /* FIXME */
+ wcscpy( info->szCipher, get_cipher_str( session ) );
+ info->dwCipherLen = get_cipher_len( session );
+ info->dwCipherBlockLen = get_cipher_block_len( session );
+ wcscpy( info->szHash, get_hash_str( session, TRUE ) );
+ info->dwHashLen = get_hash_len( session );
+ wcscpy( info->szExchange, get_exchange_str( session, FALSE ) );
+ info->dwMinExchangeLen = 0;
+ info->dwMaxExchangeLen = 65536;
+ wcscpy( info->szCertificate, get_certificate_str( session ) );
+ info->dwKeyType = 0; /* FIXME */
+
+ wcscpy( info->szCipherSuite, tlsW );
+ wcscat( info->szCipherSuite, get_exchange_str( session, TRUE ) );
+ wcscat( info->szCipherSuite, underscoreW );
+ wcscat( info->szCipherSuite, info->szCertificate );
+ wcscat( info->szCipherSuite, widthW );
+ wcscat( info->szCipherSuite, info->szCipher );
+ wcscat( info->szCipherSuite, underscoreW );
+ len = sprintf( buf, "%u", (unsigned int)info->dwCipherLen ) + 1;
+ ptr = info->szCipherSuite + wcslen( info->szCipherSuite );
+ ntdll_umbstowcs( buf, len, ptr, len );
+ wcscat( info->szCipherSuite, underscoreW );
+ wcscat( info->szCipherSuite, get_chaining_mode_str( session ) );
+ wcscat( info->szCipherSuite, underscoreW );
+ wcscat( info->szCipherSuite, get_hash_str( session, FALSE ) );
+ return SEC_E_OK;
+}
+
static NTSTATUS schan_get_unique_channel_binding( void *args )
{
const struct get_unique_channel_binding_params *params = args;
@@ -1271,6 +1476,7 @@ const unixlib_entry_t __wine_unix_call_funcs[] =
schan_dispose_session,
schan_free_certificate_credentials,
schan_get_application_protocol,
+ schan_get_cipher_info,
schan_get_connection_info,
schan_get_enabled_protocols,
schan_get_key_signature_algorithm,
@@ -1386,6 +1592,21 @@ static NTSTATUS wow64_schan_get_connection_info( void *args )
return schan_get_connection_info(¶ms);
}
+static NTSTATUS wow64_schan_get_cipher_info( void *args )
+{
+ struct
+ {
+ schan_session session;
+ PTR32 info;
+ } const *params32 = args;
+ struct get_cipher_info_params params =
+ {
+ params32->session,
+ ULongToPtr(params32->info),
+ };
+ return schan_get_cipher_info(¶ms);
+}
+
static NTSTATUS wow64_schan_get_session_peer_certificate( void *args )
{
struct
@@ -1582,6 +1803,7 @@ const unixlib_entry_t __wine_unix_call_wow64_funcs[] =
schan_dispose_session,
wow64_schan_free_certificate_credentials,
wow64_schan_get_application_protocol,
+ wow64_schan_get_cipher_info,
wow64_schan_get_connection_info,
schan_get_enabled_protocols,
schan_get_key_signature_algorithm,
diff --git a/dlls/secur32/secur32_priv.h b/dlls/secur32/secur32_priv.h
index 5753ed47ffa..d1321b7d6fd 100644
--- a/dlls/secur32/secur32_priv.h
+++ b/dlls/secur32/secur32_priv.h
@@ -126,6 +126,12 @@ struct get_connection_info_params
SecPkgContext_ConnectionInfo *info;
};
+struct get_cipher_info_params
+{
+ schan_session session;
+ SecPkgContext_CipherInfo *info;
+};
+
struct get_session_peer_certificate_params
{
schan_session session;
@@ -206,6 +212,7 @@ enum schan_funcs
unix_dispose_session,
unix_free_certificate_credentials,
unix_get_application_protocol,
+ unix_get_cipher_info,
unix_get_connection_info,
unix_get_enabled_protocols,
unix_get_key_signature_algorithm,
diff --git a/dlls/secur32/tests/schannel.c b/dlls/secur32/tests/schannel.c
index 314b43a2607..c68474e9eae 100644
--- a/dlls/secur32/tests/schannel.c
+++ b/dlls/secur32/tests/schannel.c
@@ -1038,6 +1038,7 @@ static void test_communication(void)
CRYPT_DATA_BLOB pfx;
HCERTSTORE store;
SecPkgContext_NegotiationInfoA info;
+ SecPkgContext_CipherInfo cipher;
SecBufferDesc buffers[2];
SecBuffer *buf;
unsigned buf_size = 8192;
@@ -1291,6 +1292,34 @@ static void test_communication(void)
ok(conn_info.dwHashStrength >= 128, "conn_info.dwHashStrength = %ld\n", conn_info.dwHashStrength);
}
+ memset(&cipher, 0, sizeof(cipher));
+ cipher.dwVersion = SECPKGCONTEXT_CIPHERINFO_V1;
+ status = pQueryContextAttributesA(&context, SECPKG_ATTR_CIPHER_INFO, &cipher);
+ ok(status == SEC_E_OK || broken(status == SEC_E_UNSUPPORTED_FUNCTION) /* < vista */, "got %08lx\n", status);
+ if (status == SEC_E_OK)
+ {
+ ok(cipher.dwProtocol == 0x301, "got %lx\n", cipher.dwProtocol);
+ todo_wine ok(cipher.dwCipherSuite == 0xc014, "got %lx\n", cipher.dwCipherSuite);
+ todo_wine ok(cipher.dwBaseCipherSuite == 0xc014, "got %lx\n", cipher.dwBaseCipherSuite);
+ ok(!wcscmp(cipher.szCipherSuite, L"TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA") ||
+ !wcscmp(cipher.szCipherSuite, L"TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P256"), /* < win10 */
+ "got %s\n", wine_dbgstr_w(cipher.szCipherSuite));
+ ok(!wcscmp(cipher.szCipher, L"AES"), "got %s\n", wine_dbgstr_w(cipher.szCipher));
+ ok(cipher.dwCipherLen == 256, "got %lu\n", cipher.dwCipherLen);
+ ok(cipher.dwCipherBlockLen == 16, "got %lu\n", cipher.dwCipherBlockLen);
+ ok(!wcscmp(cipher.szHash, L"SHA1"), "got %s\n", wine_dbgstr_w(cipher.szHash));
+ ok(cipher.dwHashLen == 160, "got %lu\n", cipher.dwHashLen);
+ ok(!wcscmp(cipher.szExchange, L"ECDH") || !wcscmp(cipher.szExchange, L"ECDH_P256"), /* < win10 */
+ "got %s\n", wine_dbgstr_w(cipher.szExchange));
+ ok(cipher.dwMinExchangeLen == 0 || cipher.dwMinExchangeLen == 256, /* < win10 */
+ "got %lu\n", cipher.dwMinExchangeLen);
+ ok(cipher.dwMaxExchangeLen == 65536 || cipher.dwMaxExchangeLen == 256, /* < win10 */
+ "got %lu\n", cipher.dwMaxExchangeLen);
+ ok(!wcscmp(cipher.szCertificate, L"RSA"), "got %s\n", wine_dbgstr_w(cipher.szCertificate));
+ todo_wine ok(cipher.dwKeyType == 0x1d || cipher.dwKeyType == 0x17, /* < win10 */
+ "got %#lx\n", cipher.dwKeyType);
+ }
+
status = pQueryContextAttributesA(&context, SECPKG_ATTR_KEY_INFO, &key_info);
ok(status == SEC_E_OK, "QueryContextAttributesW(SECPKG_ATTR_KEY_INFO) failed: %08lx\n", status);
if(status == SEC_E_OK) {
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/291
June 21, 2022
[PATCH v2 1/2] include: Move SECPKG_ATTR defines to a new header and add missing definitions.
by Hans Leidekker
From: Hans Leidekker <hans(a)codeweavers.com>
---
include/minschannel.h | 44 +++++++++++++++++++++++++++++++++++++++++++
include/schannel.h | 39 ++++++++++++++++++++++----------------
2 files changed, 67 insertions(+), 16 deletions(-)
create mode 100644 include/minschannel.h
diff --git a/include/minschannel.h b/include/minschannel.h
new file mode 100644
index 00000000000..c30ae85922b
--- /dev/null
+++ b/include/minschannel.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2022 Hans Leidekker for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef __WINE_MINSCHANNEL_H__
+#define __WINE_MINSCHANNEL_H__
+
+#define SECPKG_ATTR_ISSUER_LIST 0x50
+#define SECPKG_ATTR_REMOTE_CRED 0x51
+#define SECPKG_ATTR_LOCAL_CRED 0x52
+#define SECPKG_ATTR_REMOTE_CERT_CONTEXT 0x53
+#define SECPKG_ATTR_LOCAL_CERT_CONTEXT 0x54
+#define SECPKG_ATTR_ROOT_STORE 0x55
+#define SECPKG_ATTR_SUPPORTED_ALGS 0x56
+#define SECPKG_ATTR_CIPHER_STRENGTHS 0x57
+#define SECPKG_ATTR_SUPPORTED_PROTOCOLS 0x58
+#define SECPKG_ATTR_ISSUER_LIST_EX 0x59
+#define SECPKG_ATTR_CONNECTION_INFO 0x5a
+#define SECPKG_ATTR_EAP_KEY_BLOCK 0x5b
+#define SECPKG_ATTR_MAPPED_CRED_ATTR 0x5c
+#define SECPKG_ATTR_SESSION_INFO 0x5d
+#define SECPKG_ATTR_APP_DATA 0x5e
+#define SECPKG_ATTR_REMOTE_CERTIFICATES 0x5f
+#define SECPKG_ATTR_CLIENT_CERT_POLICY 0x60
+#define SECPKG_ATTR_CC_POLICY_RESULT 0x61
+#define SECPKG_ATTR_USE_NCRYPT 0x62
+#define SECPKG_ATTR_LOCAL_CERT_INFO 0x63
+#define SECPKG_ATTR_CIPHER_INFO 0x64
+
+#endif /* __WINE_MINSCHANNEL_H__ */
diff --git a/include/schannel.h b/include/schannel.h
index 556ec1882c9..3aa85832fd3 100644
--- a/include/schannel.h
+++ b/include/schannel.h
@@ -18,6 +18,7 @@
#ifndef __WINE_SCHANNEL_H__
#define __WINE_SCHANNEL_H__
+#include <minschannel.h>
#include <wincrypt.h>
/* Package names */
@@ -179,22 +180,6 @@ static const WCHAR SCHANNEL_NAME_W[] = { 'S','c','h','a','n','n','e','l',0 };
#define SCH_CRED_IGNORE_NO_REVOCATION_CHECK 2048
#define SCH_CRED_IGNORE_REVOCATION_OFFLINE 4096
-#define SECPKG_ATTR_ISSUER_LIST 0x50
-#define SECPKG_ATTR_REMOTE_CRED 0x51
-#define SECPKG_ATTR_LOCAL_CRED 0x52
-#define SECPKG_ATTR_REMOTE_CERT_CONTEXT 0x53
-#define SECPKG_ATTR_LOCAL_CERT_CONTEXT 0x54
-#define SECPKG_ATTR_ROOT_STORE 0x55
-#define SECPKG_ATTR_SUPPORTED_ALGS 0x56
-#define SECPKG_ATTR_CIPHER_STRENGTHS 0x57
-#define SECPKG_ATTR_SUPPORTED_PROTOCOLS 0x58
-#define SECPKG_ATTR_ISSUER_LIST_EX 0x59
-#define SECPKG_ATTR_CONNECTION_INFO 0x5a
-#define SECPKG_ATTR_EAP_KEY_BLOCK 0x5b
-#define SECPKG_ATTR_MAPPED_CRED_ATTR 0x5c
-#define SECPKG_ATTR_SESSION_INFO 0x5d
-#define SECPKG_ATTR_APP_DATA 0x5e
-
#define UNISP_RPC_ID 14
struct _HMAPPER;
@@ -299,4 +284,26 @@ typedef struct _SecPkgContext_ConnectionInfo
DWORD dwExchStrength;
} SecPkgContext_ConnectionInfo, *PSecPkgContext_ConnectionInfo;
+#define SECPKGCONTEXT_CIPHERINFO_V1 1
+#define SZ_ALG_MAX_SIZE 64
+
+typedef struct _SecPkgContext_CipherInfo
+{
+ DWORD dwVersion;
+ DWORD dwProtocol;
+ DWORD dwCipherSuite;
+ DWORD dwBaseCipherSuite;
+ WCHAR szCipherSuite[SZ_ALG_MAX_SIZE];
+ WCHAR szCipher[SZ_ALG_MAX_SIZE];
+ DWORD dwCipherLen;
+ DWORD dwCipherBlockLen;
+ WCHAR szHash[SZ_ALG_MAX_SIZE];
+ DWORD dwHashLen;
+ WCHAR szExchange[SZ_ALG_MAX_SIZE];
+ DWORD dwMinExchangeLen;
+ DWORD dwMaxExchangeLen;
+ WCHAR szCertificate[SZ_ALG_MAX_SIZE];
+ DWORD dwKeyType;
+} SecPkgContext_CipherInfo, *PSecPkgContext_CipherInfo;
+
#endif /* __WINE_SCHANNEL_H__ */
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/291
June 21, 2022