https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cbf79d98c67b53322df8d…
commit cbf79d98c67b53322df8d6ab26bf25472747562d
Author: Amine Khaldi <amine.khaldi(a)reactos.org>
AuthorDate: Tue Jan 29 13:09:12 2019 +0100
Commit: Amine Khaldi <amine.khaldi(a)reactos.org>
CommitDate: Tue Jan 29 13:09:12 2019 +0100
[MSVFW32] Sync with Wine Staging 4.0. CORE-15682
---
dll/win32/msvfw32/mciwnd.c | 3 +-
dll/win32/msvfw32/msvideo_main.c | 176 +++++++++++++++++++--------------------
media/doc/README.WINE | 2 +-
3 files changed, 86 insertions(+), 95 deletions(-)
diff --git a/dll/win32/msvfw32/mciwnd.c b/dll/win32/msvfw32/mciwnd.c
index fc499732ef..50899e1fbd 100644
--- a/dll/win32/msvfw32/mciwnd.c
+++ b/dll/win32/msvfw32/mciwnd.c
@@ -1006,8 +1006,7 @@ end_of_mci_open:
cmdW = (LPWSTR)lParam;
mwi->lasterror = mciSendStringW(cmdW, mwi->return_string,
-
sizeof(mwi->return_string)/sizeof(mwi->return_string[0]),
- 0);
+ ARRAY_SIZE(mwi->return_string), 0);
if (mwi->lasterror)
MCIWND_notify_error(mwi);
diff --git a/dll/win32/msvfw32/msvideo_main.c b/dll/win32/msvfw32/msvideo_main.c
index 1c7dad1700..4b09913667 100644
--- a/dll/win32/msvfw32/msvideo_main.c
+++ b/dll/win32/msvfw32/msvideo_main.c
@@ -98,11 +98,6 @@ 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;
@@ -228,6 +223,15 @@ static int compare_fourcc(DWORD fcc1, DWORD fcc2)
return strncasecmp(fcc_str1, fcc_str2, 4);
}
+static DWORD get_size_image(LONG width, LONG height, WORD depth)
+{
+ DWORD ret = width * depth;
+ ret = (ret + 7) / 8; /* divide by byte size, rounding up */
+ ret = (ret + 3) & ~3; /* align to 4 bytes */
+ ret *= abs(height);
+ return ret;
+}
+
typedef BOOL (*enum_handler_t)(const char *name, const char *driver, unsigned int index,
void *param);
static BOOL enum_drivers(DWORD fccType, enum_handler_t handler, void* param)
@@ -315,8 +319,7 @@ static BOOL ICInfo_enum_handler(const char *name, const char *driver,
unsigned i
lpicinfo->dwVersionICM = ICVERSION;
lpicinfo->szName[0] = 0;
lpicinfo->szDescription[0] = 0;
- MultiByteToWideChar(CP_ACP, 0, driver, -1, lpicinfo->szDriver,
- sizeof(lpicinfo->szDriver)/sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, driver, -1, lpicinfo->szDriver,
ARRAY_SIZE(lpicinfo->szDriver));
return TRUE;
}
@@ -720,109 +723,98 @@ HIC VFWAPI ICLocate(DWORD fccType, DWORD fccHandler,
LPBITMAPINFOHEADER lpbiIn,
/***********************************************************************
* ICGetDisplayFormat [MSVFW32.@]
*/
-HIC VFWAPI ICGetDisplayFormat(
- HIC hic,LPBITMAPINFOHEADER lpbiIn,LPBITMAPINFOHEADER lpbiOut,
- INT depth,INT dx,INT dy)
+HIC VFWAPI ICGetDisplayFormat(HIC hic, BITMAPINFOHEADER *in, BITMAPINFOHEADER *out,
+ int depth, int width, int height)
{
- static const struct
- {
- int depth;
- int compression;
- }
- try_depths[] =
- {
- { 8, BI_RGB},
- {16, BI_RGB},
- {16, BI_BITFIELDS},
- {24, BI_RGB},
- {32, BI_RGB},
- };
-
- int screen_depth, i;
- BOOL found = FALSE;
- HIC tmphic;
- HDC hdc;
+ HIC tmphic = hic;
- TRACE("(%p,%p,%p,%d,%d,%d)!\n", hic, lpbiIn, lpbiOut, depth, dx, dy);
+ TRACE("(%p, %p, %p, %d, %d, %d)\n", hic, in, out, depth, width, height);
- 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 (!tmphic)
+ {
+ tmphic = ICLocate(ICTYPE_VIDEO, 0, in, NULL, ICMODE_DECOMPRESS);
+ if (!tmphic)
+ return NULL;
+ }
- if (dx <= 0) dx = lpbiIn->biWidth;
- if (dy <= 0) dy = lpbiIn->biHeight;
- if (!depth) depth = screen_depth;
+ if (ICDecompressQuery(tmphic, in, NULL))
+ goto err;
- /* Can we decompress it ? */
- if (ICDecompressQuery(tmphic, lpbiIn, NULL) != ICERR_OK)
- goto errout; /* no, sorry */
+ if (width <= 0 || height <= 0)
+ {
+ width = in->biWidth;
+ height = in->biHeight;
+ }
- ICSendMessage(tmphic, ICM_DECOMPRESS_GET_FORMAT, (DWORD_PTR)lpbiIn,
(DWORD_PTR)lpbiOut);
+ if (!depth)
+ depth = 32;
- lpbiOut->biSize = sizeof(BITMAPINFOHEADER);
- lpbiOut->biWidth = dx;
- lpbiOut->biHeight = dy;
- lpbiOut->biPlanes = 1;
+ *out = *in;
+ out->biSize = sizeof(*out);
+ out->biWidth = width;
+ out->biHeight = height;
+ out->biCompression = BI_RGB;
+ out->biSizeImage = get_size_image(width, height, depth);
- for (i = 0; i < sizeof(try_depths) / sizeof(try_depths[0]); i++)
+ /* first try the given depth */
+ out->biBitCount = depth;
+ out->biSizeImage = get_size_image(width, height, out->biBitCount);
+ if (!ICDecompressQuery(tmphic, in, out))
{
- if (!found && try_depths[i].depth != depth)
- continue;
-
- found = TRUE;
- lpbiOut->biBitCount = try_depths[i].depth;
- lpbiOut->biCompression = try_depths[i].compression;
- lpbiOut->biSizeImage = dx * get_stride(dy, lpbiOut->biBitCount);
+ if (depth == 8)
+ ICDecompressGetPalette(tmphic, in, out);
+ return tmphic;
+ }
- if (ICDecompressQuery(tmphic, lpbiIn, lpbiOut) == ICERR_OK)
- {
- if (try_depths[i].depth == 8)
- ICDecompressGetPalette(tmphic, lpbiIn, lpbiOut);
- goto success;
- }
+ /* then try 16, both with BI_RGB and BI_BITFIELDS */
+ if (depth <= 16)
+ {
+ out->biBitCount = 16;
+ out->biSizeImage = get_size_image(width, height, out->biBitCount);
+ if (!ICDecompressQuery(tmphic, in, out))
+ return tmphic;
+
+ out->biCompression = BI_BITFIELDS;
+ if (!ICDecompressQuery(tmphic, in, out))
+ return tmphic;
+ out->biCompression = BI_RGB;
}
- if (!found)
+ /* then try 24 */
+ if (depth <= 24)
{
- lpbiOut->biBitCount = depth;
- lpbiOut->biCompression = BI_RGB;
- 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 * get_stride(dy, lpbiOut->biBitCount);
- if (ICDecompressQuery(tmphic, lpbiIn, lpbiOut) == ICERR_OK)
- goto success;
+ out->biBitCount = 24;
+ out->biSizeImage = get_size_image(width, height, out->biBitCount);
+ if (!ICDecompressQuery(tmphic, in, out))
+ return tmphic;
}
- if (ICSendMessage(tmphic, ICM_DECOMPRESS_GET_FORMAT, (DWORD_PTR)lpbiIn,
(DWORD_PTR)lpbiOut))
- goto errout;
+ /* then try 32 */
+ if (depth <= 32)
+ {
+ out->biBitCount = 32;
+ out->biSizeImage = get_size_image(width, height, out->biBitCount);
+ if (!ICDecompressQuery(tmphic, in, out))
+ return tmphic;
+ }
- if (lpbiOut->biCompression != 0) {
- FIXME("Ooch, how come decompressor outputs compressed data
(%d)??\n",
- lpbiOut->biCompression);
- }
- if (lpbiOut->biSize < sizeof(*lpbiOut)) {
- FIXME("Ooch, size of output BIH is too small (%d)\n",
- lpbiOut->biSize);
- lpbiOut->biSize = sizeof(*lpbiOut);
- }
+ /* as a last resort, try 32 bpp with the original width and height */
+ out->biWidth = in->biWidth;
+ out->biHeight = in->biHeight;
+ out->biBitCount = 32;
+ out->biSizeImage = get_size_image(out->biWidth, out->biHeight,
out->biBitCount);
+ if (!ICDecompressQuery(tmphic, in, out))
+ return tmphic;
-success:
- TRACE("=> %p\n", tmphic);
- return tmphic;
+ /* finally, ask the compressor for its default output format */
+ if (!ICSendMessage(tmphic, ICM_DECOMPRESS_GET_FORMAT, (DWORD_PTR)in,
(DWORD_PTR)out))
+ return tmphic;
-errout:
- if (hic!=tmphic)
- ICClose(tmphic);
+err:
+ if (hic != tmphic)
+ ICClose(tmphic);
- TRACE("=> 0\n");
- return 0;
+ return NULL;
}
/***********************************************************************
@@ -1415,7 +1407,7 @@ HANDLE VFWAPI ICImageDecompress(
biSizeImage = lpbiOut->bmiHeader.biSizeImage;
if ( biSizeImage == 0 )
- biSizeImage = ((((lpbiOut->bmiHeader.biWidth * lpbiOut->bmiHeader.biBitCount + 7)
>> 3) + 3) & (~3)) * abs(lpbiOut->bmiHeader.biHeight);
+ biSizeImage = get_size_image(lpbiOut->bmiHeader.biWidth,
lpbiOut->bmiHeader.biHeight, lpbiOut->bmiHeader.biBitCount);
TRACE( "call ICDecompressBegin\n" );
diff --git a/media/doc/README.WINE b/media/doc/README.WINE
index 7444ffb993..77a1638632 100644
--- a/media/doc/README.WINE
+++ b/media/doc/README.WINE
@@ -125,7 +125,7 @@ reactos/dll/win32/mssip32 # Synced to WineStaging-3.3
reactos/dll/win32/mstask # Synced to WineStaging-3.3
reactos/dll/win32/msvcrt20 # Out of sync
reactos/dll/win32/msvcrt40 # Out of sync
-reactos/dll/win32/msvfw32 # Synced to WineStaging-3.3
+reactos/dll/win32/msvfw32 # Synced to WineStaging-4.0
reactos/dll/win32/msvidc32 # Synced to WineStaging-3.3
reactos/dll/win32/msxml # Synced to WineStaging-3.3
reactos/dll/win32/msxml2 # Synced to WineStaging-3.3