https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c1718e271269eb95fe45d…
commit c1718e271269eb95fe45d06cfe0be79b6c6e3c36
Author: Amine Khaldi <amine.khaldi(a)reactos.org>
AuthorDate: Tue Mar 20 12:20:13 2018 +0100
Commit: Amine Khaldi <amine.khaldi(a)reactos.org>
CommitDate: Tue Mar 20 12:20:45 2018 +0100
[MSVFW32] Sync with Wine Staging 3.3. CORE-14434
---
dll/win32/msvfw32/CMakeLists.txt | 4 +-
dll/win32/msvfw32/drawdib.c | 12 ++-
dll/win32/msvfw32/mciwnd.c | 19 ++--
dll/win32/msvfw32/msvideo_main.c | 173 +++++++++++++++++++++++++-----------
dll/win32/msvfw32/msvideo_private.h | 28 +++---
dll/win32/msvfw32/precomp.h | 21 +++++
dll/win32/msvfw32/resource.h | 35 --------
dll/win32/msvfw32/rsrc.rc | 4 +-
media/doc/README.WINE | 2 +-
9 files changed, 185 insertions(+), 113 deletions(-)
diff --git a/dll/win32/msvfw32/CMakeLists.txt b/dll/win32/msvfw32/CMakeLists.txt
index 1b0571fc98..4bf2590bac 100644
--- a/dll/win32/msvfw32/CMakeLists.txt
+++ b/dll/win32/msvfw32/CMakeLists.txt
@@ -8,7 +8,7 @@ list(APPEND SOURCE
mciwnd.c
msvideo_main.c
drawdib.c
- msvideo_private.h
+ precomp.h
${CMAKE_CURRENT_BINARY_DIR}/msvfw32_stubs.c)
add_library(msvfw32 SHARED
@@ -19,5 +19,5 @@ add_library(msvfw32 SHARED
set_module_type(msvfw32 win32dll)
target_link_libraries(msvfw32 wine)
add_importlibs(msvfw32 winmm comctl32 user32 gdi32 advapi32 msvcrt kernel32 ntdll)
-add_pch(msvfw32 msvideo_private.h SOURCE)
+add_pch(msvfw32 precomp.h SOURCE)
add_cd_file(TARGET msvfw32 DESTINATION reactos/system32 FOR all)
diff --git a/dll/win32/msvfw32/drawdib.c b/dll/win32/msvfw32/drawdib.c
index 4cb032e7cf..27ac3b595f 100644
--- a/dll/win32/msvfw32/drawdib.c
+++ b/dll/win32/msvfw32/drawdib.c
@@ -20,7 +20,17 @@
* Handle palettes
*/
-#include "msvideo_private.h"
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "wingdi.h"
+#include "winuser.h"
+#include "vfw.h"
+
+#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(msvideo);
diff --git a/dll/win32/msvfw32/mciwnd.c b/dll/win32/msvfw32/mciwnd.c
index aa8e6f0055..fc499732ef 100644
--- a/dll/win32/msvfw32/mciwnd.c
+++ b/dll/win32/msvfw32/mciwnd.c
@@ -21,12 +21,19 @@
* Add support for MCIWNDF_RECORD.
*/
-#include "msvideo_private.h"
-
-#include <winternl.h>
-#include <digitalv.h>
-#include <commctrl.h>
-#include <wine/unicode.h>
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "winnls.h"
+#include "wingdi.h"
+#include "winuser.h"
+#include "winternl.h"
+#include "vfw.h"
+#include "digitalv.h"
+#include "commctrl.h"
+#include "wine/unicode.h"
+#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(mci);
diff --git a/dll/win32/msvfw32/msvideo_main.c b/dll/win32/msvfw32/msvideo_main.c
index ebe56ee4a8..1c7dad1700 100644
--- a/dll/win32/msvfw32/msvideo_main.c
+++ b/dll/win32/msvfw32/msvideo_main.c
@@ -26,12 +26,20 @@
* - no thread safety
*/
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "winreg.h"
+#include "winnls.h"
+#include "wingdi.h"
+#include "winuser.h"
+#include "commdlg.h"
+#include "vfw.h"
#include "msvideo_private.h"
-
-#include <winreg.h>
-#include <commdlg.h>
-
-#include "resource.h"
+#include "wine/debug.h"
/* Drivers32 settings */
#define HKLM_DRIVERS32 "Software\\Microsoft\\Windows
NT\\CurrentVersion\\Drivers32"
@@ -90,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;
@@ -215,48 +228,48 @@ static int compare_fourcc(DWORD fcc1, DWORD fcc2)
return strncasecmp(fcc_str1, fcc_str2, 4);
}
-typedef BOOL (*enum_handler_t)(const char*, unsigned int, void*);
+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)
{
- CHAR buf[2048], fccTypeStr[5], *s;
+ char fccTypeStr[4];
+ char name_buf[10];
+ char buf[2048];
+
DWORD i, cnt = 0, lRet;
BOOL result = FALSE;
HKEY hKey;
fourcc_to_string(fccTypeStr, fccType);
- fccTypeStr[4] = '.';
/* first, go through the registry entries */
lRet = RegOpenKeyExA(HKEY_LOCAL_MACHINE, HKLM_DRIVERS32, 0, KEY_QUERY_VALUE,
&hKey);
if (lRet == ERROR_SUCCESS)
{
- DWORD name, data, type;
i = 0;
for (;;)
- {
- name = 10;
- data = sizeof buf - name;
- lRet = RegEnumValueA(hKey, i++, buf, &name, 0, &type, (LPBYTE)(buf+name),
&data);
- if (lRet == ERROR_NO_MORE_ITEMS) break;
- if (lRet != ERROR_SUCCESS) continue;
- if (fccType && (name != 9 || strncasecmp(buf, fccTypeStr, 5))) continue;
- buf[name] = '=';
- if ((result = handler(buf, cnt++, param))) break;
- }
- RegCloseKey( hKey );
+ {
+ DWORD name_len = 10, driver_len = 128;
+ lRet = RegEnumValueA(hKey, i++, name_buf, &name_len, 0, 0, (BYTE *)buf,
&driver_len);
+ if (lRet == ERROR_NO_MORE_ITEMS) break;
+ if (name_len != 9 || name_buf[4] != '.') continue;
+ if (fccType && strncasecmp(name_buf, fccTypeStr, 4)) continue;
+ if ((result = handler(name_buf, buf, cnt++, param))) break;
+ }
+ RegCloseKey( hKey );
}
if (result) return result;
/* if that didn't work, go through the values in system.ini */
if (GetPrivateProfileSectionA("drivers32", buf, sizeof(buf),
"system.ini"))
{
- for (s = buf; *s; s += strlen(s) + 1)
- {
- TRACE("got %s\n", s);
- if (fccType && (strncasecmp(s, fccTypeStr, 5) || s[9] != '='))
continue;
- if ((result = handler(s, cnt++, param))) break;
- }
+ char *s;
+ for (s = buf; *s; s += strlen(s) + 1)
+ {
+ if (s[4] != '.' || s[9] != '=') continue;
+ if (fccType && strncasecmp(s, fccTypeStr, 4)) continue;
+ if ((result = handler(s, s + 10, cnt++, param))) break;
+ }
}
return result;
@@ -286,21 +299,23 @@ DWORD WINAPI VideoForWindowsVersion(void)
return 0x040003B6; /* 4.950 */
}
-static BOOL ICInfo_enum_handler(const char *drv, unsigned int nr, void *param)
+static BOOL ICInfo_enum_handler(const char *name, const char *driver, unsigned int nr,
void *param)
{
ICINFO *lpicinfo = param;
- DWORD fccHandler = mmioStringToFOURCCA(drv + 5, 0);
+ DWORD fccType = mmioStringToFOURCCA(name, 0);
+ DWORD fccHandler = mmioStringToFOURCCA(name + 5, 0);
if (lpicinfo->fccHandler != nr && compare_fourcc(lpicinfo->fccHandler,
fccHandler))
return FALSE;
+ lpicinfo->fccType = fccType;
lpicinfo->fccHandler = fccHandler;
lpicinfo->dwFlags = 0;
lpicinfo->dwVersion = 0;
lpicinfo->dwVersionICM = ICVERSION;
lpicinfo->szName[0] = 0;
lpicinfo->szDescription[0] = 0;
- MultiByteToWideChar(CP_ACP, 0, drv + 10, -1, lpicinfo->szDriver,
+ MultiByteToWideChar(CP_ACP, 0, driver, -1, lpicinfo->szDriver,
sizeof(lpicinfo->szDriver)/sizeof(WCHAR));
return TRUE;
@@ -639,10 +654,10 @@ static HIC try_driver(driver_info_t *info)
return 0;
}
-static BOOL ICLocate_enum_handler(const char *drv, unsigned int nr, void *param)
+static BOOL ICLocate_enum_handler(const char *name, const char *driver, unsigned int nr,
void *param)
{
driver_info_t *info = param;
- info->fccHandler = mmioStringToFOURCCA(drv + 5, 0);
+ info->fccHandler = mmioStringToFOURCCA(name + 5, 0);
info->hic = try_driver(info);
return info->hic != 0;
}
@@ -709,25 +724,86 @@ 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 <= 0) dx = lpbiIn->biWidth;
+ if (dy <= 0) 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;
+
+ 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;
+ 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 * 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;
+ }
+
+ 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);
}
@@ -736,20 +812,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/dll/win32/msvfw32/msvideo_private.h b/dll/win32/msvfw32/msvideo_private.h
index f0afd711d0..4ca97806e4 100644
--- a/dll/win32/msvfw32/msvideo_private.h
+++ b/dll/win32/msvfw32/msvideo_private.h
@@ -19,21 +19,12 @@
#ifndef __WINE_MSVIDEO_PRIVATE_H
#define __WINE_MSVIDEO_PRIVATE_H
-#include <stdarg.h>
-
-#define WIN32_NO_STATUS
-#define _INC_WINDOWS
-#define COM_NO_WINDOWS_H
-
#include <windef.h>
-#include <winbase.h>
-#include <winnls.h>
-#include <wingdi.h>
-#include <vfw.h>
-
-#include <wine/debug.h>
+#include <winuser.h>
#define ICM_CHOOSE_COMPRESSOR 1
+#define IDC_COMP_LIST 880
+#define IDS_FULLFRAMES 901
/* HIC struct (same layout as Win95 one) */
typedef struct tagWINE_HIC {
@@ -55,4 +46,17 @@ typedef struct tagWINE_HIC {
extern HMODULE MSVFW32_hModule DECLSPEC_HIDDEN;
+#define IDC_CONFIGURE 882
+#define IDC_ABOUT 883
+
+#define IDC_QUALITY_SCROLL 884
+#define IDC_QUALITY_TXT 886
+
+#define IDC_KEYFRAME_CHECKBOX 887
+#define IDC_KEYFRAME 888
+#define IDC_KEYFRAME_FRAMES 889
+#define IDC_DATARATE_CHECKBOX 894
+#define IDC_DATARATE 895
+#define IDC_DATARATE_KB 896
+
#endif /* __WINE_MSVIDEO_PRIVATE_H */
diff --git a/dll/win32/msvfw32/precomp.h b/dll/win32/msvfw32/precomp.h
new file mode 100644
index 0000000000..d67810a381
--- /dev/null
+++ b/dll/win32/msvfw32/precomp.h
@@ -0,0 +1,21 @@
+
+#ifndef _MSVIDEO_PRECOMP_H
+#define _MSVIDEO_PRECOMP_H
+
+#include <stdarg.h>
+
+#define WIN32_NO_STATUS
+#define _INC_WINDOWS
+#define COM_NO_WINDOWS_H
+
+#include <windef.h>
+#include <winbase.h>
+#include <winnls.h>
+#include <wingdi.h>
+#include <vfw.h>
+
+#include <wine/debug.h>
+
+#include "msvideo_private.h"
+
+#endif /* !_MSVIDEO_PRECOMP_H */
diff --git a/dll/win32/msvfw32/resource.h b/dll/win32/msvfw32/resource.h
deleted file mode 100644
index fae893b73f..0000000000
--- a/dll/win32/msvfw32/resource.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 1999 Marcus Meissner
- *
- * 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
- */
-
-#pragma once
-
-#define IDC_COMP_LIST 880
-#define IDS_FULLFRAMES 901
-
-#define IDC_CONFIGURE 882
-#define IDC_ABOUT 883
-
-#define IDC_QUALITY_SCROLL 884
-#define IDC_QUALITY_TXT 886
-
-#define IDC_KEYFRAME_CHECKBOX 887
-#define IDC_KEYFRAME 888
-#define IDC_KEYFRAME_FRAMES 889
-#define IDC_DATARATE_CHECKBOX 894
-#define IDC_DATARATE 895
-#define IDC_DATARATE_KB 896
diff --git a/dll/win32/msvfw32/rsrc.rc b/dll/win32/msvfw32/rsrc.rc
index 6b2ae0bbdf..9f502c6da5 100644
--- a/dll/win32/msvfw32/rsrc.rc
+++ b/dll/win32/msvfw32/rsrc.rc
@@ -16,10 +16,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include <windef.h>
-#include <winuser.h>
+#include "msvideo_private.h"
-#include "resource.h"
#include <reactos/manifest_dll.rc>
diff --git a/media/doc/README.WINE b/media/doc/README.WINE
index 5a8dc0f250..1f6c9f52fc 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 Wine-3.0
+reactos/dll/win32/msvfw32 # Synced to WineStaging-3.3
reactos/dll/win32/msvidc32 # Synced to Wine-3.0
reactos/dll/win32/msxml # Synced to WineStaging-2.9
reactos/dll/win32/msxml2 # Synced to WineStaging-2.9