[MPlayer-dev-eng] [PATCH] Re: Frapsvid.dll

Gianluigi Tiesi mplayer at netfarm.it
Sat May 14 06:31:09 CEST 2005


Here a patch to implement all d3d9 stuff needed by frapsvid without
mem-patching, the codec crashes elsewhere, but I think this patch could be committed.

Bye
-- 
Gianluigi Tiesi <sherpya at netfarm.it>
EDP Project Leader
Netfarm S.r.l. - http://www.netfarm.it/
Free Software: http://oss.netfarm.it/
-------------- next part --------------
Index: etc/codecs.conf
===================================================================
RCS file: /cvsroot/mplayer/main/etc/codecs.conf,v
retrieving revision 1.411
diff -u -r1.411 codecs.conf
--- etc/codecs.conf	4 May 2005 20:35:21 -0000	1.411
+++ etc/codecs.conf	14 May 2005 04:26:05 -0000
@@ -1724,6 +1724,16 @@
   dll "tsccvid.dll"
   out BGR32,BGR24,BGR15,BGR8 query,flip
 
+; Fraps - Realtime Video Capture - http://www.fraps.com/
+videocodec fraps
+  info "Realtime Video Capture"
+  status buggy
+  fourcc FPS1,fps1
+  driver vfw
+  dll "frapsvid.dll"
+  out YV12,I420,IYUV
+  out BGR32,BGR24
+
 ; raw formats:  (now RGB formats are autodetected)
 
 ; these raw codecs are used mostly by TV input
Index: loader/com.h
===================================================================
RCS file: /cvsroot/mplayer/main/loader/com.h,v
retrieving revision 1.8
diff -u -r1.8 com.h
--- loader/com.h	15 Apr 2005 20:17:11 -0000	1.8
+++ loader/com.h	14 May 2005 04:26:05 -0000
@@ -77,9 +77,95 @@
     struct IClassFactory_vt* vt;
 };
 
-long CoCreateInstance(GUID* rclsid, struct IUnknown* pUnkOuter,
+long CoCreateInstance(GUID* rclsid, struct IUnknown* pUnkOuter,
 		      long dwClsContext, const GUID* riid, void** ppv);
 
+/* directx stuff */
+#define MAX_DEVICE_IDENTIFIER_STRING        512
+
+typedef struct _D3DADAPTER_IDENTIFIER9 {
+    char Driver[MAX_DEVICE_IDENTIFIER_STRING];
+    char Description[MAX_DEVICE_IDENTIFIER_STRING];
+    char DeviceName[32];
+    LARGE_INTEGER DriverVersion;
+    DWORD DriverVersionLowPart;
+    DWORD DriverVersionHighPart;
+    DWORD VendorId;
+    DWORD DeviceId;
+    DWORD SubSysId;
+    DWORD Revision;
+    GUID DeviceIdentifier;
+    DWORD WHQLLevel;
+} D3DADAPTER_IDENTIFIER9;
+
+
+#define D3DFORMAT           DWORD /* Really this would be an enum */
+#define D3DDEVTYPE          DWORD /* Really this would be an enum */
+#define D3DRESOURCETYPE     DWORD /* Really this would be an enum */
+#define D3DMULTISAMPLE_TYPE DWORD /* Really this would be an enum */
+
+#ifndef BOOL
+#define BOOL unsigned int
+#endif
+
+#define THIS_ struct IUnknown* _this,
+#define PURE
+
+/* Display Modes */
+typedef struct _D3DDISPLAYMODE
+{
+    UINT            Width;
+    UINT            Height;
+    UINT            RefreshRate;
+    D3DFORMAT       Format;
+} D3DDISPLAYMODE;
+
+
+struct IDirect3D9_vt
+{
+    /* IUnknown */
+    long STDCALL (*QueryInterface)(struct IUnknown* _this, const GUID* iid, void** ppv);
+    long STDCALL (*AddRef)(struct IUnknown* _this);
+    long STDCALL (*Release)(struct IUnknown* _this);
+
+    /* IDirect3D9 */
+    long STDCALL (*RegisterSoftwareDevice)(struct IUnknown* _this, void* pInitializeFunction);
+    UINT STDCALL (*GetAdapterCount)(struct IUnknown* _this);
+    long STDCALL (*GetAdapterIdentifier)(struct IUnknown* _this,
+                   UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier);
+    UINT STDCALL (*GetAdapterModeCount)(struct IUnknown* _this, UINT Adapter, D3DFORMAT Format);
+    long STDCALL (*EnumAdapterModes)(struct IUnknown* _this, UINT Adapter,
+                   D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode);
+    long STDCALL (*GetAdapterDisplayMode)(struct IUnknown* _this, UINT Adapter, D3DDISPLAYMODE* pMode);
+    long STDCALL (*CheckDeviceType)(struct IUnknown* _this, UINT Adapter,
+                  D3DDEVTYPE DevType, D3DFORMAT AdapterFormat,
+                  D3DFORMAT BackBufferFormat, BOOL bWindowed);
+    long STDCALL (*CheckDeviceFormat)(struct IUnknown* _this, UINT Adapter,
+                  D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage,
+                  D3DRESOURCETYPE RType,D3DFORMAT CheckFormat);
+    long STDCALL (*CheckDeviceMultiSampleType)(struct IUnknown* _this, UINT Adapter,
+                   D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed,
+                   D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels);
+    long STDCALL (*CheckDepthStencilMatch)(struct IUnknown* _this, UINT Adapter,
+                   D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat,
+                   D3DFORMAT DepthStencilFormat);
+    long STDCALL (*CheckDeviceFormatConversion)(struct IUnknown* _this, UINT Adapter, D3DDEVTYPE DeviceType,
+                   D3DFORMAT SourceFormat, D3DFORMAT TargetFormat);
+    long STDCALL (*GetDeviceCaps)(struct IUnknown* _this, UINT Adapter,
+                   D3DDEVTYPE DeviceType, /* D3DCAPS9* */ void* pCaps);
+    HMONITOR STDCALL(*GetAdapterMonitor)(struct IUnknown* _this, UINT Adapter);
+    long STDCALL (*CreateDevice)(struct IUnknown* _this, UINT Adapter,
+                  D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags,
+                  /* D3DPRESENT_PARAMETERS* */ void* pPresentationParameters,
+                  /*IDirect3DDevice9** */ void** ppReturnedDeviceInterface);
+};
+
+struct IDirect3D9
+{
+    struct IDirect3D9_vt* vt;
+};
+
+
 #ifdef __cplusplus
 };
 #endif /* __cplusplus */
Index: loader/win32.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/win32.c,v
retrieving revision 1.98
diff -u -r1.98 win32.c
--- loader/win32.c	15 Apr 2005 20:17:12 -0000	1.98
+++ loader/win32.c	14 May 2005 04:26:05 -0000
@@ -575,6 +575,7 @@
 #define	MODULE_HANDLE_msvcrt	((HMODULE)0x126)
 #define	MODULE_HANDLE_ole32	((HMODULE)0x127)
 #define	MODULE_HANDLE_winmm	((HMODULE)0x128)
+#define	MODULE_HANDLE_d3d9	((HMODULE)0x129)
 
 static HMODULE WINAPI expGetModuleHandleA(const char* name)
 {
@@ -2376,6 +2377,8 @@
 	return MODULE_HANDLE_ole32;
     if (strcasecmp(name, "winmm.dll") == 0 || strcasecmp(name, "winmm") == 0)
 	return MODULE_HANDLE_winmm;
+    if (strcasecmp(name, "d3d9.dll") == 0 || strcasecmp(name, "d3d9") == 0)
+	return MODULE_HANDLE_d3d9;
 
     result=LoadLibraryA(name);
     dbgprintf("Returned LoadLibraryA(0x%x='%s'), def_path=%s => 0x%x\n", name, name, def_path, result);
@@ -2418,6 +2421,8 @@
 	result=LookupExternalByName("ole32.dll", name); break;
     case MODULE_HANDLE_winmm:
 	result=LookupExternalByName("winmm.dll", name); break;
+    case MODULE_HANDLE_d3d9:
+	result=LookupExternalByName("d3d9.dll", name); break;
     default:
 	result=GetProcAddress(mod, name);
     }
@@ -4121,6 +4126,16 @@
     return dst;
 }
 
+static char* expstrstr(const char *haystack, const char *needle)
+{
+   char *result=strstr(haystack, needle);
+   if(result)
+        dbgprintf("strstr(0x%x='%s', 0x%x='%s') => 0x%x='%s'\n", haystack, haystack, needle, needle, result, result);
+   else
+        dbgprintf("strstr(0x%x='%s', 0x%x='%s') => 0\n", haystack, haystack, needle, needle);
+   return result; 
+}
+
 static char* expstrrchr(char* string, int value)
 {
     char* result=strrchr(string, value);
@@ -4170,6 +4185,12 @@
     dbgprintf("strcmp(0x%x='%s', 0x%x='%s') => %d\n", str1, str1, str2, str2, result);
     return result;
 }
+static int exp_strnicmp(const char* str1, const char* str2,int x)
+{
+    int result=strncasecmp(str1, str2,x);
+    dbgprintf("_strnicmp(0x%x='%s', 0x%x='%s') => %d\n", str1, str1, str2, str2, result);
+    return result;
+}
 static char* expstrcat(char* str1, const char* str2)
 {
     char* result = strcat(str1, str2);
@@ -4669,6 +4690,43 @@
 }
 #endif
 
+/* frapvids.dll */
+static long WINAPI IDirect3D9_GetAdapterIdentifier(struct IUnknown* _this, UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier)
+{
+    dbgprintf("IDirect3D9::GetAdapterIdentifier(0x%08x, %d, 0x%08x, 0x%08x)\n",
+              _this, Adapter, Flags, pIdentifier);
+    memset(pIdentifier, 0, sizeof(D3DADAPTER_IDENTIFIER9));
+    strcat(pIdentifier->Driver, "mplayer");
+    return 0;
+}
+
+static long WINAPI IDirect3D9_Release(struct IUnknown* _this)
+{
+    struct IDirect3D9 *ctx = (struct IDirect3D9 *) _this;
+    dbgprintf("IDirect3D9::Release() -> 0x%x\n", _this);
+    if (!ctx) return -1;
+    if (ctx->vt) free(ctx->vt);
+    free(ctx);
+    return 0;
+}
+	
+static struct WINAPI IDirect3D9* expDirect3DCreate9(unsigned int sdkversion)
+{
+    struct IDirect3D9 *ctx = (struct IDirect3D9 *) malloc(sizeof(struct IDirect3D9));
+    if (!ctx) return 0;
+
+    memset(ctx, 0, sizeof(struct IDirect3D9));
+    ctx->vt = (struct IDirect3D9_vt *) malloc(sizeof(struct IDirect3D9_vt));
+    memset(ctx->vt, 0, sizeof(struct IDirect3D9_vt));
+
+    /* Fill needed methods */
+    ctx->vt->Release = IDirect3D9_Release;
+    ctx->vt->GetAdapterIdentifier = IDirect3D9_GetAdapterIdentifier;
+
+    dbgprintf("Direct3DCreate9(%d) => 0x%x\n", sdkversion, ctx);
+    return ctx;
+}
+
 /* for m3jpeg */
 static int WINAPI expSetThreadIdealProcessor(HANDLE thread, int proc)
 {
@@ -4912,6 +4970,7 @@
     {"??3 at YAXPAX@Z", -1, expdelete},
     {"??2 at YAPAXI@Z", -1, expnew},
     {"_adjust_fdiv", -1, (void*)&_adjust_fdiv},
+    FF(strstr, -1)
     FF(strrchr, -1)
     FF(strchr, -1)
     FF(strlen, -1)
@@ -4920,6 +4979,7 @@
     FF(wcscpy, -1)
     FF(strcmp, -1)
     FF(strncmp, -1)
+    FF(_strnicmp, -1)
     FF(strcat, -1)
     FF(_stricmp,-1)
     FF(_strdup,-1)
@@ -5130,6 +5190,10 @@
 };
 #endif
 
+struct exports exp_d3d9[]={
+    FF(Direct3DCreate9, -1)
+};
+
 struct exports exp_comdlg32[]={
     FF(GetOpenFileNameA, -1)
 };
@@ -5157,6 +5221,7 @@
 #ifdef QTX
     LL(ddraw)
 #endif
+    LL(d3d9)
     LL(comdlg32)
 };
 
Index: loader/dshow/guids.h
===================================================================
RCS file: /cvsroot/mplayer/main/loader/dshow/guids.h,v
retrieving revision 1.8
diff -u -r1.8 guids.h
--- loader/dshow/guids.h	26 Nov 2002 21:00:20 -0000	1.8
+++ loader/dshow/guids.h	14 May 2005 04:26:05 -0000
@@ -1,6 +1,7 @@
 #ifndef DS_GUIDS_H
 #define DS_GUIDS_H
 
+#include "wine/winbase.h"
 #include "com.h"
 #include "wine/module.h"
 #include "wine/windef.h"


More information about the MPlayer-dev-eng mailing list