]> git.sesse.net Git - vlc/commitdiff
* modules/codec/dmo: fixed dmo decoder on win32 + got rid of some of the dependencies...
authorGildas Bazin <gbazin@videolan.org>
Mon, 9 Aug 2004 10:25:42 +0000 (10:25 +0000)
committerGildas Bazin <gbazin@videolan.org>
Mon, 9 Aug 2004 10:25:42 +0000 (10:25 +0000)
modules/codec/dmo/buffer.c
modules/codec/dmo/dmo.c
modules/codec/dmo/dmo.h

index 71ef582a5a14c0dfe8a6c5ccf70fb07df0595a37..d0ea39e02227137038e0c4971dd9adb912ef64e3 100644 (file)
 #include <vlc/decoder.h>
 #include <vlc/vout.h>
 
-#define LOADER
-#ifdef LOADER
-#   include <wine/winerror.h>
-#   include <dmo/dmo.h>
-#   include <dmo/dmo_interfaces.h>
-#   include <dmo/dmo_guids.h>
-#   define _RECT32_
-#   define _GUID_DEFINED
-#   define _REFERENCE_TIME_
-#   define _VIDEOINFOHEADER_
+#ifndef WIN32
+#    define LOADER
 #else
 #   include <objbase.h>
 #endif
+
+#ifdef LOADER
+#   include <wine/winerror.h>
+#   include <wine/windef.h>
+#endif
+
 #include "codecs.h"
 #include "dmo.h"
 
index 4c9a5dab6e3a9f3b5f377715f9626923f3155844..9f23f38246cff91bf14037b9efeffc4a88cf23b7 100644 (file)
 #include <vlc/decoder.h>\r
 #include <vlc/vout.h>\r
 \r
-#define LOADER\r
+#ifndef WIN32\r
+#    define LOADER\r
+#else\r
+#   include <objbase.h>\r
+#endif\r
+\r
 #ifdef LOADER\r
 /* Need the w32dll loader from mplayer */\r
 #   include <wine/winerror.h>\r
-#   include <dmo/dmo.h>\r
-#   include <dmo/dmo_interfaces.h>\r
-#   include <dmo/dmo_guids.h>\r
 #   include <ldt_keeper.h>\r
-\r
-/* Avoid  codecs.h to redefine a few symbols */\r
-#   define _RECT32_\r
-#   define _GUID_DEFINED\r
-#   define _REFERENCE_TIME_\r
-#   define _VIDEOINFOHEADER_\r
-\r
-/* Ugly, wine loader and vlc doesn't use the same field name for GUID */\r
-#define Data1 f1\r
-#define Data2 f2\r
-#define Data3 f3\r
-#define Data4 f4\r
-\r
-/* Not Needed */\r
-HRESULT CoInitialize( LPVOID pvReserved ) { return (HRESULT)-1; }\r
-void CoUninitialize(void) { }\r
-\r
-/* */\r
-HMODULE   WINAPI LoadLibraryA(LPCSTR);\r
-FARPROC   WINAPI GetProcAddress(HMODULE,LPCSTR);\r
-int       WINAPI FreeLibrary(HMODULE);\r
-\r
-typedef long STDCALL (*GETCLASS) (const GUID*, const GUID*, void**);\r
-\r
-#else\r
-#   include <objbase.h>\r
+#   include <wine/windef.h>\r
 #endif\r
 \r
-#include "dmo.h"\r
 #include "codecs.h"\r
+#include "dmo.h"\r
+\r
+#ifdef LOADER\r
+/* Not Needed */\r
+long CoInitialize( void *pvReserved ) { return -1; }\r
+void CoUninitialize( void ) { }\r
+\r
+/* A few prototypes */\r
+HMODULE WINAPI LoadLibraryA(LPCSTR);\r
+#define LoadLibrary LoadLibraryA\r
+FARPROC WINAPI GetProcAddress(HMODULE,LPCSTR);\r
+int     WINAPI FreeLibrary(HMODULE);\r
+typedef long STDCALL (*GETCLASS) ( const GUID*, const GUID*, void** );\r
+#endif /* LOADER */\r
 \r
 static int pi_channels_maps[7] =\r
 {\r
@@ -155,8 +145,7 @@ static const struct
     /* */\r
     { 0, NULL, NULL }\r
 };\r
-\r
-#endif\r
+#endif /* LOADER */\r
 \r
 /*****************************************************************************\r
  * Open: open dmo codec\r
@@ -165,6 +154,7 @@ static int Open( vlc_object_t *p_this )
 {\r
 #ifndef LOADER\r
     return DecoderOpen( p_this );\r
+\r
 #else\r
     decoder_t *p_dec = (decoder_t*)p_this;\r
     int i;\r
@@ -173,24 +163,25 @@ static int Open( vlc_object_t *p_this )
 \r
     p_dec->p_sys = NULL;\r
 \r
-\r
     /* Probe if we support it */\r
     for( i = 0; codecs_table[i].i_fourcc != 0; i++ )\r
     {\r
         if( codecs_table[i].i_fourcc == p_dec->fmt_in.i_codec )\r
         {\r
             msg_Dbg( p_dec, "DMO codec for %4.4s may work with dll=%s",\r
-                     (char*)&p_dec->fmt_in.i_codec,\r
-                     codecs_table[i].psz_dll );\r
+                     (char*)&p_dec->fmt_in.i_codec, codecs_table[i].psz_dll );\r
 \r
             /* Set callbacks */\r
-            p_dec->pf_decode_video = (picture_t *(*)(decoder_t *, block_t **))DecodeBlock;\r
-            p_dec->pf_decode_audio = (aout_buffer_t *(*)(decoder_t *, block_t **))DecodeBlock;\r
+            p_dec->pf_decode_video =\r
+                (picture_t *(*)(decoder_t *, block_t **))DecodeBlock;\r
+            p_dec->pf_decode_audio =\r
+                (aout_buffer_t *(*)(decoder_t *, block_t **))DecodeBlock;\r
             return VLC_SUCCESS;\r
         }\r
     }\r
+\r
     return VLC_EGENERIC;\r
-#endif\r
+#endif /* LOADER */\r
 }\r
 \r
 /*****************************************************************************\r
@@ -232,15 +223,14 @@ static int DecoderOpen( vlc_object_t *p_this )
     }\r
 \r
 #ifndef LOADER\r
-  { /* <- ugly ? yes */\r
+  {\r
     IEnumDMO *p_enum_dmo = NULL;\r
     WCHAR *psz_dmo_name;\r
     GUID clsid_dmo;\r
-    HRESULT (STDCALL *OurDMOEnum)( const GUID *, uint32_t, uint32_t,\r
-                           const DMO_PARTIAL_MEDIATYPE *,\r
-                           uint32_t, const DMO_PARTIAL_MEDIATYPE *,\r
-                           IEnumDMO ** );\r
-\r
+    long (STDCALL *OurDMOEnum)( const GUID *, uint32_t, uint32_t,\r
+                               const DMO_PARTIAL_MEDIATYPE *,\r
+                               uint32_t, const DMO_PARTIAL_MEDIATYPE *,\r
+                               IEnumDMO ** );\r
 \r
     /* Load msdmo DLL */\r
     hmsdmo_dll = LoadLibrary( "msdmo.dll" );\r
@@ -293,11 +283,12 @@ static int DecoderOpen( vlc_object_t *p_this )
         goto error;\r
     }\r
   }\r
+\r
 #else   /* LOADER */\r
   {\r
     GETCLASS GetClass;\r
-    struct IClassFactory* cFactory = NULL;\r
-    struct IUnknown* cObject = NULL;\r
+    IClassFactory *cFactory = NULL;\r
+    IUnknown *cObject = NULL;\r
 \r
     int i_err;\r
     int i_codec;\r
@@ -316,7 +307,7 @@ static int DecoderOpen( vlc_object_t *p_this )
         return VLC_EGENERIC;\r
     }\r
 \r
-    GetClass = (GETCLASS)GetProcAddress( hmsdmo_dll, "DllGetClassObject");\r
+    GetClass = (GETCLASS)GetProcAddress( hmsdmo_dll, "DllGetClassObject" );\r
     if (!GetClass)\r
     {\r
         msg_Dbg( p_dec, "GetProcAddress failed to find DllGetClassObject()" );\r
@@ -324,7 +315,8 @@ static int DecoderOpen( vlc_object_t *p_this )
         return VLC_EGENERIC;\r
     }\r
 \r
-    i_err = GetClass( codecs_table[i_codec].p_guid, &IID_IClassFactory, (void**)&cFactory );\r
+    i_err = GetClass( codecs_table[i_codec].p_guid, &IID_IClassFactory,\r
+                      (void**)&cFactory );\r
     if( i_err || cFactory == NULL )\r
     {\r
         msg_Dbg( p_dec, "no such class object" );\r
@@ -332,7 +324,8 @@ static int DecoderOpen( vlc_object_t *p_this )
         return VLC_EGENERIC;\r
     }\r
 \r
-    i_err = cFactory->vt->CreateInstance( cFactory, 0, &IID_IUnknown, (void**)&cObject );\r
+    i_err = cFactory->vt->CreateInstance( cFactory, 0, &IID_IUnknown,\r
+                                          (void**)&cObject );\r
     cFactory->vt->Release((IUnknown*)cFactory );\r
     if( i_err || !cObject )\r
     {\r
@@ -340,25 +333,8 @@ static int DecoderOpen( vlc_object_t *p_this )
         FreeLibrary( hmsdmo_dll );\r
         return VLC_EGENERIC;\r
     }\r
-    i_err = cObject->vt->QueryInterface( cObject, &IID_IMediaObject, (void**)&p_dmo );\r
-#if 0\r
-    if (hr == 0)\r
-    {\r
-            /* query for some extra available interface */\r
-        HRESULT r = object->vt->QueryInterface(object, &IID_IMediaObjectInPlace, (void**)&This->m_pInPlace);\r
-            if (r == 0 && This->m_pInPlace)\r
-        printf("DMO dll supports InPlace - PLEASE REPORT to developer\n");\r
-        r = object->vt->QueryInterface(object, &IID_IDMOVideoOutputOptimizations, (void**)&This->m_pOptim);\r
-        if (r == 0 && This->m_pOptim)\r
-        {\r
-                unsigned long flags;\r
-        r = This->m_pOptim->vt->QueryOperationModePreferences(This->m_pOptim, 0, &flags);\r
-        printf("DMO dll supports VO Optimizations %ld %lx\n", r, flags);\r
-        if (flags & DMO_VOSF_NEEDS_PREVIOUS_SAMPLE)\r
-            printf("DMO dll might use previous sample when requested\n");\r
-        }\r
-    }\r
-#endif\r
+    i_err = cObject->vt->QueryInterface( cObject, &IID_IMediaObject,\r
+                                        (void**)&p_dmo );\r
     cObject->vt->Release((IUnknown*)cObject );\r
   }\r
 #endif  /* LOADER */\r
index 030c0b46052841aa2b3996c23d88756e2eb7afcc..785e982f602e811188bff6d32592bddfaff21254 100644 (file)
@@ -22,6 +22,7 @@
  *****************************************************************************/\r
 \r
 static const GUID IID_IUnknown = {0x00000000, 0x0000, 0x0000, {0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46}};\r
+static const GUID IID_IClassFactory = {0x00000001, 0x0000, 0x0000, {0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}};\r
 static const GUID IID_IMediaObject = {0xd8ad0f58, 0x5494, 0x4102, {0x97, 0xc5, 0xec, 0x79, 0x8e, 0x59, 0xbc, 0xf4}};\r
 static const GUID IID_IMediaBuffer = {0x59eff8b9, 0x938c, 0x4a26, {0x82, 0xf2, 0x95, 0xcb, 0x84, 0xcd, 0xc8, 0x37}};\r
 static const GUID MEDIATYPE_Video = {0x73646976, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};\r
@@ -33,9 +34,13 @@ static const GUID GUID_NULL = {0x0000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00,
 static const GUID MEDIASUBTYPE_I420 = {0x30323449, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};\r
 static const GUID MEDIASUBTYPE_YV12 = {0x32315659, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};\r
 \r
-#ifdef WIN32\r
-#   define IUnknown IUnknownHack\r
-#endif\r
+#define IUnknown IUnknownHack\r
+#define IClassFactory IClassFactoryHack\r
+typedef struct _IUnknown IUnknown;\r
+typedef struct _IClassFactory IClassFactory;\r
+typedef struct _IEnumDMO IEnumDMO;\r
+typedef struct _IMediaBuffer IMediaBuffer;\r
+typedef struct _IMediaObject IMediaObject;\r
 \r
 #ifndef STDCALL\r
 #define STDCALL __stdcall\r
@@ -59,25 +64,6 @@ typedef struct
 \r
 } DMO_PARTIAL_MEDIATYPE;\r
 \r
-/* Implementation of IMediaBuffer */\r
-typedef struct _CMediaBuffer\r
-{\r
-    IMediaBuffer_vt *vt;\r
-    int i_ref;\r
-    block_t *p_block;\r
-    int i_max_size;\r
-    vlc_bool_t b_own;\r
-\r
-} CMediaBuffer;\r
-\r
-CMediaBuffer *CMediaBufferCreate( block_t *, int, vlc_bool_t );\r
-\r
-#ifndef LOADER\r
-typedef struct _IUnknown IUnknown;\r
-typedef struct _IEnumDMO IEnumDMO;\r
-typedef struct _IMediaBuffer IMediaBuffer;\r
-typedef struct _IMediaObject IMediaObject;\r
-\r
 typedef struct\r
 #ifdef HAVE_ATTRIBUTE_PACKED\r
     __attribute__((__packed__))\r
@@ -123,6 +109,21 @@ typedef struct IUnknown_vt
 } IUnknown_vt;\r
 struct _IUnknown { IUnknown_vt* vt; };\r
 \r
+/*\r
+ * IClassFactory interface\r
+ */\r
+typedef struct IClassFactory_vt\r
+{\r
+    long (STDCALL *QueryInterface)(IUnknown *This, const GUID* riid,\r
+                                   void **ppvObject);\r
+    long (STDCALL *AddRef)(IUnknown *This) ;\r
+    long (STDCALL *Release)(IUnknown *This) ;\r
+    long (STDCALL *CreateInstance)(IClassFactory *This, IUnknown *pUnkOuter,\r
+                                   const GUID* riid, void** ppvObject);\r
+} IClassFactory_vt;\r
+\r
+struct _IClassFactory { IClassFactory_vt* vt; };\r
+\r
 /*\r
  * IEnumDMO interface\r
  */\r
@@ -245,5 +246,16 @@ typedef struct IMediaObject_vt
 \r
 } IMediaObject_vt;\r
 struct _IMediaObject { IMediaObject_vt* vt; };\r
-#endif  /* !define LOADER */\r
 \r
+/* Implementation of IMediaBuffer */\r
+typedef struct _CMediaBuffer\r
+{\r
+    IMediaBuffer_vt *vt;\r
+    int i_ref;\r
+    block_t *p_block;\r
+    int i_max_size;\r
+    vlc_bool_t b_own;\r
+\r
+} CMediaBuffer;\r
+\r
+CMediaBuffer *CMediaBufferCreate( block_t *, int, vlc_bool_t );\r