Rebase against ba9f3dc198dfc81bb40159077b73b797006bb73c

This commit is contained in:
Alistair Leslie-Hughes
2018-08-15 08:07:39 +10:00
parent 39cafb1db1
commit e7bff1bb4f
102 changed files with 208 additions and 10382 deletions

View File

@@ -1,389 +0,0 @@
From 9ae94214e0afa58f6b518ec34fd325a1ae57230a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Thu, 31 Mar 2016 00:58:04 +0200
Subject: msvfw32: Try different formarts in ICGetDisplayFormat.
---
dlls/msvfw32/msvideo_main.c | 90 +++++++++++++----
dlls/msvfw32/tests/msvfw.c | 240 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 308 insertions(+), 22 deletions(-)
diff --git a/dlls/msvfw32/msvideo_main.c b/dlls/msvfw32/msvideo_main.c
index cc5c85d..25b80ff 100644
--- a/dlls/msvfw32/msvideo_main.c
+++ b/dlls/msvfw32/msvideo_main.c
@@ -718,25 +718,80 @@ HIC VFWAPI ICGetDisplayFormat(
HIC hic,LPBITMAPINFOHEADER lpbiIn,LPBITMAPINFOHEADER lpbiOut,
INT depth,INT dx,INT dy)
{
- HIC tmphic = hic;
+ static const struct
+ {
+ int depth;
+ int compression;
+ }
+ try_depths[] =
+ {
+ { 8, BI_RGB},
+ {16, BI_RGB},
+ {16, BI_BITFIELDS},
+ {24, BI_RGB},
+ {32, BI_RGB},
+ };
- TRACE("(%p,%p,%p,%d,%d,%d)!\n",hic,lpbiIn,lpbiOut,depth,dx,dy);
+ int screen_depth, i;
+ BOOL found = FALSE;
+ HIC tmphic;
+ HDC hdc;
- if (!tmphic) {
- tmphic=ICLocate(ICTYPE_VIDEO,0,lpbiIn,NULL,ICMODE_DECOMPRESS);
- if (!tmphic)
- return tmphic;
- }
- if ((dy == lpbiIn->biHeight) && (dx == lpbiIn->biWidth))
- dy = dx = 0; /* no resize needed */
+ TRACE("(%p,%p,%p,%d,%d,%d)!\n", hic, lpbiIn, lpbiOut, depth, dx, dy);
+
+ tmphic = hic ? hic : ICLocate(ICTYPE_VIDEO, 0, lpbiIn, NULL, ICMODE_DECOMPRESS);
+ if (!tmphic) return tmphic;
+
+ hdc = GetDC(0);
+ screen_depth = GetDeviceCaps(hdc, BITSPIXEL) * GetDeviceCaps(hdc, PLANES);
+ ReleaseDC(0, hdc);
+
+ if (!dx) dx = lpbiIn->biWidth;
+ if (!dy) dy = lpbiIn->biHeight;
+ if (!depth) depth = screen_depth;
/* Can we decompress it ? */
- if (ICDecompressQuery(tmphic,lpbiIn,NULL) != 0)
+ if (ICDecompressQuery(tmphic, lpbiIn, NULL) != ICERR_OK)
goto errout; /* no, sorry */
ICSendMessage(tmphic, ICM_DECOMPRESS_GET_FORMAT, (DWORD_PTR)lpbiIn, (DWORD_PTR)lpbiOut);
- if (lpbiOut->biCompression != 0) {
+ lpbiOut->biSize = sizeof(BITMAPINFOHEADER);
+ lpbiOut->biWidth = dx;
+ lpbiOut->biHeight = dy;
+ lpbiOut->biPlanes = 1;
+ lpbiOut->biSizeImage = 0;
+
+ for (i = 0; i < sizeof(try_depths) / sizeof(try_depths[0]); i++)
+ {
+ if (!found && try_depths[i].depth != depth)
+ continue;
+
+ found = TRUE;
+ lpbiOut->biBitCount = try_depths[i].depth;
+ lpbiOut->biCompression = try_depths[i].compression;
+
+ if (ICDecompressQuery(tmphic, lpbiIn, lpbiOut) == ICERR_OK)
+ goto success;
+ }
+
+ if (!found)
+ {
+ lpbiOut->biBitCount = depth;
+ lpbiOut->biCompression = BI_RGB;
+ if (ICDecompressQuery(tmphic, lpbiIn, lpbiOut) == ICERR_OK)
+ goto success;
+
+ lpbiOut->biBitCount = screen_depth;
+ lpbiOut->biCompression = BI_RGB;
+ if (ICDecompressQuery(tmphic, lpbiIn, lpbiOut) == ICERR_OK)
+ goto success;
+ }
+
+ if (ICSendMessage(tmphic, ICM_DECOMPRESS_GET_FORMAT, (DWORD_PTR)lpbiIn, (DWORD_PTR)lpbiOut))
+ goto errout;
+
+ if (lpbiOut->biCompression != 0) {
FIXME("Ooch, how come decompressor outputs compressed data (%d)??\n",
lpbiOut->biCompression);
}
@@ -745,20 +800,11 @@ HIC VFWAPI ICGetDisplayFormat(
lpbiOut->biSize);
lpbiOut->biSize = sizeof(*lpbiOut);
}
- if (!depth) {
- HDC hdc;
-
- hdc = GetDC(0);
- depth = GetDeviceCaps(hdc,BITSPIXEL)*GetDeviceCaps(hdc,PLANES);
- ReleaseDC(0,hdc);
- if (depth==15) depth = 16;
- if (depth<8) depth = 8;
- }
- if (lpbiIn->biBitCount == 8)
- depth = 8;
+success:
TRACE("=> %p\n", tmphic);
return tmphic;
+
errout:
if (hic!=tmphic)
ICClose(tmphic);
diff --git a/dlls/msvfw32/tests/msvfw.c b/dlls/msvfw32/tests/msvfw.c
index 3fe6702..22b32ee 100644
--- a/dlls/msvfw32/tests/msvfw.c
+++ b/dlls/msvfw32/tests/msvfw.c
@@ -285,6 +285,245 @@ static void test_ICSeqCompress(void)
ok(err == ICERR_BADHANDLE, "Expected -8, got %d\n", err);
}
+struct msg_result
+{
+ int msg_index;
+ UINT msg;
+ BOOL output_format;
+ int width;
+ int height;
+ int bits;
+ int compression;
+ LRESULT result;
+ BOOL todo;
+};
+
+static struct msg_result expected_msgs[] =
+{
+ /* Wine bug - shouldn't be called */
+ { 0, DRV_LOAD, FALSE, 0, 0, 0, 0, TRUE, TRUE},
+ { 0, DRV_ENABLE, FALSE, 0, 0, 0, 0, 0, TRUE},
+
+ { 0, DRV_OPEN, FALSE, 0, 0, 0, 0, 0xdeadbeef, FALSE},
+
+ /* test 1 */
+ { 1, ICM_DECOMPRESS_QUERY, FALSE, 0, 0, 0, 0, ICERR_OK, FALSE},
+ { 2, ICM_DECOMPRESS_GET_FORMAT, TRUE, 320, 240, 16, BI_RGB, ICERR_BADFORMAT, FALSE},
+ { 3, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 8, BI_RGB, ICERR_BADFORMAT, FALSE},
+ { 4, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 16, BI_RGB, ICERR_BADFORMAT, FALSE},
+ { 5, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 16, BI_BITFIELDS, ICERR_BADFORMAT, FALSE},
+ { 6, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 24, BI_RGB, ICERR_BADFORMAT, FALSE},
+ { 7, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 32, BI_RGB, ICERR_BADFORMAT, FALSE},
+ { 8, ICM_DECOMPRESS_GET_FORMAT, TRUE, 640, 480, 32, BI_RGB, ICERR_OK, FALSE},
+
+ /* test 2 */
+ { 9, ICM_DECOMPRESS_QUERY, FALSE, 0, 0, 0, 0, ICERR_OK, FALSE},
+ {10, ICM_DECOMPRESS_GET_FORMAT, TRUE, 320, 240, 16, BI_RGB, ICERR_BADFORMAT, FALSE},
+ {11, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 8, BI_RGB, ICERR_BADFORMAT, FALSE},
+ {12, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 16, BI_RGB, ICERR_OK, FALSE},
+
+ /* test 3 */
+ {13, ICM_DECOMPRESS_QUERY, FALSE, 0, 0, 0, 0, ICERR_OK, FALSE},
+ {14, ICM_DECOMPRESS_GET_FORMAT, TRUE, 320, 240, 16, BI_RGB, ICERR_OK, FALSE},
+ {15, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 8, BI_RGB, ICERR_BADFORMAT, FALSE},
+ {16, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 16, BI_RGB, ICERR_OK, FALSE},
+
+ /* test 4 */
+ {17, ICM_DECOMPRESS_QUERY, FALSE, 0, 0, 0, 0, ICERR_OK, FALSE},
+ {18, ICM_DECOMPRESS_GET_FORMAT, TRUE, 320, 240, 16, BI_RGB, ICERR_BADFORMAT, FALSE},
+ {19, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 24, BI_RGB, ICERR_BADFORMAT, FALSE},
+ {20, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 32, BI_RGB, ICERR_BADFORMAT, FALSE},
+ {21, ICM_DECOMPRESS_GET_FORMAT, TRUE, 640, 480, 32, BI_RGB, ICERR_OK, FALSE},
+
+ /* test 5 */
+ {22, ICM_DECOMPRESS_QUERY, FALSE, 0, 0, 0, 0, ICERR_OK, FALSE},
+ {23, ICM_DECOMPRESS_GET_FORMAT, TRUE, 320, 240, 16, BI_RGB, ICERR_OK, FALSE},
+ {24, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 32, BI_RGB, ICERR_OK, FALSE},
+
+ /* test 6 */
+ {25, ICM_DECOMPRESS_QUERY, FALSE, 0, 0, 0, 0, ICERR_OK, FALSE},
+ {26, ICM_DECOMPRESS_GET_FORMAT, TRUE, 320, 240, 16, BI_RGB, ICERR_OK, FALSE},
+ {27, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 32, BI_RGB, ICERR_OK, FALSE},
+
+ /* test 7 */
+ {28, ICM_DECOMPRESS_QUERY, FALSE, 0, 0, 0, 0, ICERR_OK, FALSE},
+ {29, ICM_DECOMPRESS_GET_FORMAT, TRUE, 320, 240, 16, BI_RGB, ICERR_OK, FALSE},
+ {30, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 9, BI_RGB, ICERR_BADFORMAT, FALSE},
+ {31, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 32, BI_RGB, ICERR_BADFORMAT, FALSE},
+ {32, ICM_DECOMPRESS_GET_FORMAT, TRUE, 640, 480, 32, BI_RGB, ICERR_OK, FALSE},
+
+ /* test 8 */
+ {33, ICM_DECOMPRESS_QUERY, FALSE, 0, 0, 0, 0, ICERR_OK, FALSE},
+ {34, ICM_DECOMPRESS_GET_FORMAT, TRUE, 320, 240, 16, BI_RGB, ICERR_OK, FALSE},
+ {35, ICM_DECOMPRESS_QUERY, TRUE, 800, 600, 32, BI_RGB, ICERR_OK, FALSE},
+
+ /* Wine bug - shouldn't be called */
+ {36, DRV_DISABLE, FALSE, 0, 0, 0, 0, ICERR_OK, TRUE},
+ {36, DRV_FREE, FALSE, 0, 0, 0, 0, ICERR_OK, TRUE},
+};
+
+static int msg_index = 0;
+
+static struct msg_result *get_expected_msg(UINT msg)
+{
+ int i = 0;
+ for(; i < sizeof(expected_msgs) / sizeof(expected_msgs[0]); i++)
+ {
+ if (expected_msgs[i].msg_index == msg_index && expected_msgs[i].msg == msg)
+ return &expected_msgs[i];
+ }
+ return NULL;
+}
+
+LRESULT WINAPI driver_proc_test(DWORD_PTR dwDriverId, HDRVR hdrvr, UINT msg,
+ LPARAM lParam1, LPARAM lParam2)
+{
+ struct msg_result *expected = get_expected_msg(msg);
+ LRESULT res = expected ? expected->result : ICERR_UNSUPPORTED;
+
+ if (msg == DRV_CLOSE)
+ return ICERR_OK;
+
+ if (!expected)
+ {
+ ok(0, "unexpected message: %04x %ld %ld at msg index %d\n",
+ msg, lParam1, lParam2, msg_index);
+ return ICERR_UNSUPPORTED;
+ }
+ else if (expected->todo)
+ {
+ todo_wine ok(0, "unexpected message: %04x %ld %ld at msg index %d\n",
+ msg, lParam1, lParam2, msg_index);
+ return res;
+ }
+
+ switch (msg)
+ {
+ case ICM_DECOMPRESS_QUERY:
+ {
+ BITMAPINFOHEADER *out = (BITMAPINFOHEADER *)lParam2;
+
+ if (!lParam2)
+ {
+ trace("query -> without format\n");
+ ok(!expected->output_format, "Expected no output format pointer\n");
+ break;
+ }
+
+ ok(expected->output_format, "Expected output format pointer\n");
+ ok(out->biWidth == expected->width,
+ "Expected width %d, got %d\n", expected->width, out->biWidth);
+ ok(out->biHeight == expected->height,
+ "Expected height %d, got %d\n", expected->height, out->biHeight);
+ ok(out->biBitCount == expected->bits,
+ "Expected biBitCount %d, got %d\n", expected->bits, out->biBitCount);
+ ok(out->biCompression == expected->compression,
+ "Expected compression %d, got %d\n", expected->compression, out->biCompression);
+
+ trace("query -> width: %d, height: %d, bit: %d, compression: %d\n",
+ out->biWidth, out->biHeight, out->biBitCount, out->biCompression);
+ break;
+ }
+
+ case ICM_DECOMPRESS_GET_FORMAT:
+ {
+ BITMAPINFOHEADER *out = (BITMAPINFOHEADER *)lParam2;
+
+ if (!lParam2)
+ {
+ trace("format -> without format\n");
+ ok(!expected->output_format, "Expected no output format pointer\n");
+ break;
+ }
+
+ ok(expected->output_format, "Expected output format pointer\n");
+ ok(out->biWidth == expected->width,
+ "Expected width %d, got %d\n", expected->width, out->biWidth);
+ ok(out->biHeight == expected->height,
+ "Expected height %d, got %d\n", expected->height, out->biHeight);
+ ok(out->biBitCount == expected->bits,
+ "Expected biBitCount %d, got %d\n", expected->bits, out->biBitCount);
+ ok(out->biCompression == expected->compression,
+ "Expected compression %d, got %d\n", expected->compression, out->biCompression);
+
+ trace("format -> width: %d, height: %d, bit: %d, compression: %d\n",
+ out->biWidth, out->biHeight, out->biBitCount, out->biCompression);
+
+ out->biBitCount = 64;
+ break;
+ }
+ }
+
+ msg_index++;
+ return res;
+}
+
+
+void test_ICGetDisplayFormat(void)
+{
+ static const struct
+ {
+ int bits_wanted;
+ int bits_expected;
+ int dx;
+ int width_expected;
+ int dy;
+ int height_expected;
+ int msg_index;
+ }
+ tests[] =
+ {
+ { 8, 64, 0, 640, 0, 480, 9},
+ { 8, 16, 0, 640, 0, 480, 13},
+ { 8, 16, 0, 640, 0, 480, 17},
+ {24, 64, 0, 640, 0, 480, 22},
+ {32, 32, 0, 640, 0, 480, 25},
+ { 0, 32, 0, 640, 0, 480, 28},
+ { 9, 64, 0, 640, 0, 480, 33},
+ {32, 32, 800, 800, 600, 600, 36},
+ };
+
+ HIC ic, ic2;
+ BITMAPINFOHEADER in;
+ BITMAPINFOHEADER out;
+ int i;
+
+ ic = ICOpenFunction(ICTYPE_VIDEO, 0xdeadbeef, ICMODE_DECOMPRESS, driver_proc_test);
+ ok(!!ic, "Opening driver failed\n");
+
+ for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
+ {
+ memset(&in, 0, sizeof(in));
+ memset(&out, 0, sizeof(out));
+
+ in.biSize = sizeof(in);
+ in.biWidth = 640;
+ in.biHeight = 480;
+ in.biPlanes = 1;
+ in.biBitCount = 32;
+ in.biCompression = BI_PNG;
+ in.biSizeImage = 1024;
+
+ out.biBitCount = 16;
+ out.biWidth = 320;
+ out.biHeight = 240;
+
+ ic2 = ICGetDisplayFormat(ic, &in, &out, tests[i].bits_wanted, tests[i].dx, tests[i].dy);
+ ok(!!ic2, "Expected ICGetDisplayFormat to succeeded\n");
+
+ ok(out.biBitCount == tests[i].bits_expected,
+ "Expected biBitCount %d, got %d\n", tests[i].bits_expected, out.biBitCount);
+ ok(out.biWidth == tests[i].width_expected,
+ "Expected biWidth %d, got %d\n", tests[i].width_expected, out.biWidth);
+ ok(out.biHeight == tests[i].height_expected,
+ "Expected biHeight %d, got %d\n", tests[i].height_expected, out.biHeight);
+ ok(msg_index == tests[i].msg_index,
+ "Expected msg_index %d, got %d\n", tests[i].msg_index, msg_index);
+ }
+
+ ICClose(ic);
+}
+
static void test_ICInfo(void)
{
ICINFO info, info2;
@@ -324,5 +563,6 @@ START_TEST(msvfw)
test_OpenCase();
test_Locate();
test_ICSeqCompress();
+ test_ICGetDisplayFormat();
test_ICInfo();
}
--
2.9.0

View File

@@ -1,64 +0,0 @@
From 37a47ad2b8a776a15d1e0431c0e1c1924884fbe1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Thu, 31 Mar 2016 17:17:20 +0200
Subject: msvfw32: Add test for negative width/height values passed to
ICGetDisplayFormat.
---
dlls/msvfw32/msvideo_main.c | 4 ++--
dlls/msvfw32/tests/msvfw.c | 16 ++++++++++++++--
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/dlls/msvfw32/msvideo_main.c b/dlls/msvfw32/msvideo_main.c
index 28f405e..41bd234 100644
--- a/dlls/msvfw32/msvideo_main.c
+++ b/dlls/msvfw32/msvideo_main.c
@@ -747,8 +747,8 @@ HIC VFWAPI ICGetDisplayFormat(
screen_depth = GetDeviceCaps(hdc, BITSPIXEL) * GetDeviceCaps(hdc, PLANES);
ReleaseDC(0, hdc);
- if (!dx) dx = lpbiIn->biWidth;
- if (!dy) dy = lpbiIn->biHeight;
+ if (dx <= 0) dx = lpbiIn->biWidth;
+ if (dy <= 0) dy = lpbiIn->biHeight;
if (!depth) depth = screen_depth;
/* Can we decompress it ? */
diff --git a/dlls/msvfw32/tests/msvfw.c b/dlls/msvfw32/tests/msvfw.c
index 7fd4c43..36dec1d 100644
--- a/dlls/msvfw32/tests/msvfw.c
+++ b/dlls/msvfw32/tests/msvfw.c
@@ -357,9 +357,19 @@ static struct msg_result expected_msgs[] =
{34, ICM_DECOMPRESS_GET_FORMAT, TRUE, 320, 240, 16, BI_RGB, ICERR_OK, FALSE},
{35, ICM_DECOMPRESS_QUERY, TRUE, 800, 600, 32, BI_RGB, ICERR_OK, FALSE},
+ /* test 9 */
+ {36, ICM_DECOMPRESS_QUERY, FALSE, 0, 0, 0, 0, ICERR_OK, FALSE},
+ {37, ICM_DECOMPRESS_GET_FORMAT, TRUE, 320, 240, 16, BI_RGB, ICERR_OK, FALSE},
+ {38, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 32, BI_RGB, ICERR_OK, FALSE},
+
+ /* test 10 */
+ {39, ICM_DECOMPRESS_QUERY, FALSE, 0, 0, 0, 0, ICERR_OK, FALSE},
+ {40, ICM_DECOMPRESS_GET_FORMAT, TRUE, 320, 240, 16, BI_RGB, ICERR_OK, FALSE},
+ {41, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 32, BI_RGB, ICERR_OK, FALSE},
+
/* Wine bug - shouldn't be called */
- {36, DRV_DISABLE, FALSE, 0, 0, 0, 0, ICERR_OK, TRUE},
- {36, DRV_FREE, FALSE, 0, 0, 0, 0, ICERR_OK, TRUE},
+ {42, DRV_DISABLE, FALSE, 0, 0, 0, 0, ICERR_OK, TRUE},
+ {42, DRV_FREE, FALSE, 0, 0, 0, 0, ICERR_OK, TRUE},
};
static int msg_index = 0;
@@ -481,6 +491,8 @@ void test_ICGetDisplayFormat(void)
{ 0, 32, 0, 640, 0, 480, 28},
{ 9, 64, 0, 640, 0, 480, 33},
{32, 32, 800, 800, 600, 600, 36},
+ {32, 32, -1, 640, -1, 480, 39},
+ {32, 32, -90, 640, -60, 480, 42},
};
HIC ic, ic2;
--
2.7.1

View File

@@ -1,95 +0,0 @@
From cd04ddddb9d9fcf5011b49320682fefb0b7a28c1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sat, 2 Apr 2016 16:13:44 +0200
Subject: msvfw32: Set biSizeImage correctly in ICGetDisplayFormat.
---
dlls/msvfw32/msvideo_main.c | 4 +++-
dlls/msvfw32/tests/msvfw.c | 15 +++++++++++----
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/dlls/msvfw32/msvideo_main.c b/dlls/msvfw32/msvideo_main.c
index 41bd234..6f91859 100644
--- a/dlls/msvfw32/msvideo_main.c
+++ b/dlls/msvfw32/msvideo_main.c
@@ -761,7 +761,6 @@ HIC VFWAPI ICGetDisplayFormat(
lpbiOut->biWidth = dx;
lpbiOut->biHeight = dy;
lpbiOut->biPlanes = 1;
- lpbiOut->biSizeImage = 0;
for (i = 0; i < sizeof(try_depths) / sizeof(try_depths[0]); i++)
{
@@ -771,6 +770,7 @@ HIC VFWAPI ICGetDisplayFormat(
found = TRUE;
lpbiOut->biBitCount = try_depths[i].depth;
lpbiOut->biCompression = try_depths[i].compression;
+ lpbiOut->biSizeImage = dx * dy * lpbiOut->biBitCount / 8;
if (ICDecompressQuery(tmphic, lpbiIn, lpbiOut) == ICERR_OK)
goto success;
@@ -780,11 +780,13 @@ HIC VFWAPI ICGetDisplayFormat(
{
lpbiOut->biBitCount = depth;
lpbiOut->biCompression = BI_RGB;
+ lpbiOut->biSizeImage = (dx * dy * depth) / 8;
if (ICDecompressQuery(tmphic, lpbiIn, lpbiOut) == ICERR_OK)
goto success;
lpbiOut->biBitCount = screen_depth;
lpbiOut->biCompression = BI_RGB;
+ lpbiOut->biSizeImage = dx * dy * screen_depth / 8;
if (ICDecompressQuery(tmphic, lpbiIn, lpbiOut) == ICERR_OK)
goto success;
}
diff --git a/dlls/msvfw32/tests/msvfw.c b/dlls/msvfw32/tests/msvfw.c
index 36dec1d..252aba2 100644
--- a/dlls/msvfw32/tests/msvfw.c
+++ b/dlls/msvfw32/tests/msvfw.c
@@ -429,9 +429,12 @@ LRESULT WINAPI driver_proc_test(DWORD_PTR dwDriverId, HDRVR hdrvr, UINT msg,
"Expected biBitCount %d, got %d\n", expected->bits, out->biBitCount);
ok(out->biCompression == expected->compression,
"Expected compression %d, got %d\n", expected->compression, out->biCompression);
+ ok(out->biSizeImage == (out->biWidth * out->biHeight * out->biBitCount) / 8,
+ "Expected biSizeImage %d, got %d\n", (out->biWidth * out->biHeight * out->biBitCount) / 8,
+ out->biSizeImage);
- trace("query -> width: %d, height: %d, bit: %d, compression: %d\n",
- out->biWidth, out->biHeight, out->biBitCount, out->biCompression);
+ trace("query -> width: %d, height: %d, bit: %d, compression: %d, size: %d\n",
+ out->biWidth, out->biHeight, out->biBitCount, out->biCompression, out->biSizeImage);
break;
}
@@ -456,8 +459,8 @@ LRESULT WINAPI driver_proc_test(DWORD_PTR dwDriverId, HDRVR hdrvr, UINT msg,
ok(out->biCompression == expected->compression,
"Expected compression %d, got %d\n", expected->compression, out->biCompression);
- trace("format -> width: %d, height: %d, bit: %d, compression: %d\n",
- out->biWidth, out->biHeight, out->biBitCount, out->biCompression);
+ trace("format -> width: %d, height: %d, bit: %d, compression: %d, size: %d\n",
+ out->biWidth, out->biHeight, out->biBitCount, out->biCompression, out->biSizeImage);
out->biBitCount = 64;
break;
@@ -498,6 +501,7 @@ void test_ICGetDisplayFormat(void)
HIC ic, ic2;
BITMAPINFOHEADER in;
BITMAPINFOHEADER out;
+ int real_depth;
int i;
ic = ICOpenFunction(ICTYPE_VIDEO, 0xdeadbeef, ICMODE_DECOMPRESS, driver_proc_test);
@@ -529,6 +533,9 @@ void test_ICGetDisplayFormat(void)
"Expected biWidth %d, got %d\n", tests[i].width_expected, out.biWidth);
ok(out.biHeight == tests[i].height_expected,
"Expected biHeight %d, got %d\n", tests[i].height_expected, out.biHeight);
+ real_depth = (out.biBitCount > 32) ? 4 : out.biBitCount / 8;
+ ok(out.biSizeImage == out.biWidth * out.biHeight * real_depth,
+ "Expected biSizeImage %d, got %d\n", out.biWidth * out.biHeight * real_depth, out.biSizeImage);
ok(msg_index == tests[i].msg_index,
"Expected msg_index %d, got %d\n", tests[i].msg_index, msg_index);
}
--
2.7.1

View File

@@ -1,146 +0,0 @@
From 6c25d94295130d7ab3e07dd985311520d303aad2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sun, 3 Apr 2016 17:47:43 +0200
Subject: msvfw32: Take stride into account and ask for palette in
ICGetDisplayFormat.
---
dlls/msvfw32/msvideo_main.c | 15 ++++++++++++---
dlls/msvfw32/tests/msvfw.c | 45 ++++++++++++++++++++++++++++++++++++++-------
2 files changed, 50 insertions(+), 10 deletions(-)
diff --git a/dlls/msvfw32/msvideo_main.c b/dlls/msvfw32/msvideo_main.c
index 6f91859..e3a7719 100644
--- a/dlls/msvfw32/msvideo_main.c
+++ b/dlls/msvfw32/msvideo_main.c
@@ -98,6 +98,11 @@ static const char *wine_dbgstr_icerr( int ret )
return str;
}
+static inline int get_stride(int width, int depth)
+{
+ return ((depth * width + 31) >> 3) & ~3;
+}
+
static WINE_HIC* MSVIDEO_FirstHic /* = NULL */;
typedef struct _reg_driver reg_driver;
@@ -770,23 +775,27 @@ HIC VFWAPI ICGetDisplayFormat(
found = TRUE;
lpbiOut->biBitCount = try_depths[i].depth;
lpbiOut->biCompression = try_depths[i].compression;
- lpbiOut->biSizeImage = dx * dy * lpbiOut->biBitCount / 8;
+ lpbiOut->biSizeImage = dx * get_stride(dy, lpbiOut->biBitCount);
if (ICDecompressQuery(tmphic, lpbiIn, lpbiOut) == ICERR_OK)
+ {
+ if (try_depths[i].depth == 8)
+ ICDecompressGetPalette(tmphic, lpbiIn, lpbiOut);
goto success;
+ }
}
if (!found)
{
lpbiOut->biBitCount = depth;
lpbiOut->biCompression = BI_RGB;
- lpbiOut->biSizeImage = (dx * dy * depth) / 8;
+ lpbiOut->biSizeImage = dx * get_stride(dy, lpbiOut->biBitCount);
if (ICDecompressQuery(tmphic, lpbiIn, lpbiOut) == ICERR_OK)
goto success;
lpbiOut->biBitCount = screen_depth;
lpbiOut->biCompression = BI_RGB;
- lpbiOut->biSizeImage = dx * dy * screen_depth / 8;
+ lpbiOut->biSizeImage = dx * get_stride(dy, lpbiOut->biBitCount);
if (ICDecompressQuery(tmphic, lpbiIn, lpbiOut) == ICERR_OK)
goto success;
}
diff --git a/dlls/msvfw32/tests/msvfw.c b/dlls/msvfw32/tests/msvfw.c
index 252aba2..91628e2 100644
--- a/dlls/msvfw32/tests/msvfw.c
+++ b/dlls/msvfw32/tests/msvfw.c
@@ -25,6 +25,11 @@
#include "wine/test.h"
+static inline int get_stride(int width, int depth)
+{
+ return ((depth * width + 31) >> 3) & ~3;
+}
+
static void test_OpenCase(void)
{
HIC h;
@@ -367,9 +372,30 @@ static struct msg_result expected_msgs[] =
{40, ICM_DECOMPRESS_GET_FORMAT, TRUE, 320, 240, 16, BI_RGB, ICERR_OK, FALSE},
{41, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 32, BI_RGB, ICERR_OK, FALSE},
+ /* test 11 */
+ {42, ICM_DECOMPRESS_QUERY, FALSE, 0, 0, 0, 0, ICERR_OK, FALSE},
+ {43, ICM_DECOMPRESS_GET_FORMAT, TRUE, 320, 240, 16, BI_RGB, ICERR_OK, FALSE},
+ {44, ICM_DECOMPRESS_QUERY, TRUE, 270, 270, 8, BI_RGB, ICERR_OK, FALSE},
+ {45, ICM_DECOMPRESS_GET_PALETTE, FALSE, 0, 0, 0, 0, ICERR_UNSUPPORTED, FALSE},
+
+ /* test 12 */
+ {46, ICM_DECOMPRESS_QUERY, FALSE, 0, 0, 0, 0, ICERR_OK, FALSE},
+ {47, ICM_DECOMPRESS_GET_FORMAT, TRUE, 320, 240, 16, BI_RGB, ICERR_OK, FALSE},
+ {48, ICM_DECOMPRESS_QUERY, TRUE, 270, 270, 16, BI_RGB, ICERR_OK, FALSE},
+
+ /* test 13 */
+ {49, ICM_DECOMPRESS_QUERY, FALSE, 0, 0, 0, 0, ICERR_OK, FALSE},
+ {50, ICM_DECOMPRESS_GET_FORMAT, TRUE, 320, 240, 16, BI_RGB, ICERR_OK, FALSE},
+ {51, ICM_DECOMPRESS_QUERY, TRUE, 270, 270, 24, BI_RGB, ICERR_OK, FALSE},
+
+ /* test 14 */
+ {52, ICM_DECOMPRESS_QUERY, FALSE, 0, 0, 0, 0, ICERR_OK, FALSE},
+ {53, ICM_DECOMPRESS_GET_FORMAT, TRUE, 320, 240, 16, BI_RGB, ICERR_OK, FALSE},
+ {54, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 4, BI_RGB, ICERR_OK, FALSE},
+
/* Wine bug - shouldn't be called */
- {42, DRV_DISABLE, FALSE, 0, 0, 0, 0, ICERR_OK, TRUE},
- {42, DRV_FREE, FALSE, 0, 0, 0, 0, ICERR_OK, TRUE},
+ {55, DRV_DISABLE, FALSE, 0, 0, 0, 0, ICERR_OK, TRUE},
+ {55, DRV_FREE, FALSE, 0, 0, 0, 0, ICERR_OK, TRUE},
};
static int msg_index = 0;
@@ -429,8 +455,8 @@ LRESULT WINAPI driver_proc_test(DWORD_PTR dwDriverId, HDRVR hdrvr, UINT msg,
"Expected biBitCount %d, got %d\n", expected->bits, out->biBitCount);
ok(out->biCompression == expected->compression,
"Expected compression %d, got %d\n", expected->compression, out->biCompression);
- ok(out->biSizeImage == (out->biWidth * out->biHeight * out->biBitCount) / 8,
- "Expected biSizeImage %d, got %d\n", (out->biWidth * out->biHeight * out->biBitCount) / 8,
+ ok(out->biSizeImage == get_stride(out->biWidth, out->biBitCount) * out->biHeight,
+ "Expected biSizeImage %d, got %d\n", get_stride(out->biWidth, out->biBitCount) * out->biHeight,
out->biSizeImage);
trace("query -> width: %d, height: %d, bit: %d, compression: %d, size: %d\n",
@@ -496,6 +522,10 @@ void test_ICGetDisplayFormat(void)
{32, 32, 800, 800, 600, 600, 36},
{32, 32, -1, 640, -1, 480, 39},
{32, 32, -90, 640, -60, 480, 42},
+ { 8, 8, 270, 270, 270, 270, 46},
+ {16, 16, 270, 270, 270, 270, 49},
+ {24, 24, 270, 270, 270, 270, 52},
+ { 4, 4, 0, 640, 0, 480, 55},
};
HIC ic, ic2;
@@ -533,9 +563,10 @@ void test_ICGetDisplayFormat(void)
"Expected biWidth %d, got %d\n", tests[i].width_expected, out.biWidth);
ok(out.biHeight == tests[i].height_expected,
"Expected biHeight %d, got %d\n", tests[i].height_expected, out.biHeight);
- real_depth = (out.biBitCount > 32) ? 4 : out.biBitCount / 8;
- ok(out.biSizeImage == out.biWidth * out.biHeight * real_depth,
- "Expected biSizeImage %d, got %d\n", out.biWidth * out.biHeight * real_depth, out.biSizeImage);
+ real_depth = (out.biBitCount > 32) ? 32 : out.biBitCount;
+ ok(out.biSizeImage == get_stride(out.biWidth, real_depth) * out.biHeight,
+ "Expected biSizeImage %d, got %d\n", get_stride(out.biWidth, real_depth) * out.biHeight,
+ out.biSizeImage);
ok(msg_index == tests[i].msg_index,
"Expected msg_index %d, got %d\n", tests[i].msg_index, msg_index);
}
--
2.7.1

View File

@@ -1,15 +1,15 @@
From cd25e5befd357c848ae4e82f5166ea2465bd6ad7 Mon Sep 17 00:00:00 2001
From 9508597f0940703a95edd8fde9584ef11a9a1e1a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sun, 3 Apr 2016 18:22:29 +0200
Subject: [PATCH] iccvid: Fix calculation of stride and size.
---
dlls/iccvid/iccvid.c | 10 +++++++---
dlls/msvfw32/tests/msvfw.c | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+), 3 deletions(-)
dlls/iccvid/iccvid.c | 10 ++++++---
dlls/msvfw32/tests/msvfw.c | 45 ++++++++++++++++++++++++++++++++++++++
2 files changed, 52 insertions(+), 3 deletions(-)
diff --git a/dlls/iccvid/iccvid.c b/dlls/iccvid/iccvid.c
index 89d282b..3977d95 100644
index 89d282ba78..3977d95a41 100644
--- a/dlls/iccvid/iccvid.c
+++ b/dlls/iccvid/iccvid.c
@@ -169,6 +169,10 @@ int x, y;
@@ -45,10 +45,22 @@ index 89d282b..3977d95 100644
}
return size;
diff --git a/dlls/msvfw32/tests/msvfw.c b/dlls/msvfw32/tests/msvfw.c
index 127dc24..2507ead 100644
index 406a35b8f1..42f148230e 100644
--- a/dlls/msvfw32/tests/msvfw.c
+++ b/dlls/msvfw32/tests/msvfw.c
@@ -93,6 +93,7 @@ static void test_Locate(void)
@@ -25,6 +25,11 @@
#include "wine/test.h"
+static inline int get_stride(int width, int depth)
+{
+ return ((depth * width + 31) >> 3) & ~3;
+}
+
static void test_OpenCase(void)
{
HIC h;
@@ -88,6 +93,7 @@ static void test_Locate(void)
{
static BITMAPINFOHEADER bi = {sizeof(BITMAPINFOHEADER),32,8, 1,8, BI_RLE8, 0,100000,100000, 0,0};
static BITMAPINFOHEADER bo = {sizeof(BITMAPINFOHEADER),32,8, 1,8, BI_RGB, 0,100000,100000, 0,0};
@@ -56,7 +68,7 @@ index 127dc24..2507ead 100644
HIC h;
DWORD err;
@@ -128,6 +129,45 @@ static void test_Locate(void)
@@ -123,6 +129,45 @@ static void test_Locate(void)
ok(err == ICERR_OK, "Query cvid->RGB32 height<0: %d\n", err);
bo.biHeight = -bo.biHeight;
@@ -103,5 +115,5 @@ index 127dc24..2507ead 100644
bo.biBitCount = bi.biBitCount = 8;
--
1.9.1
2.18.0