Commit 81cc781d authored by Gildas Bazin's avatar Gildas Bazin

* modules/codec/dmo: fixed dmo decoder on win32 + got rid of some of the...

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