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 @@
#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"
......
......@@ -32,44 +32,34 @@
#include <vlc/decoder.h>
#include <vlc/vout.h>
#define LOADER
#ifndef WIN32
# define LOADER
#else
# include <objbase.h>
#endif
#ifdef LOADER
/* Need the w32dll loader from mplayer */
# include <wine/winerror.h>
# include <dmo/dmo.h>
# include <dmo/dmo_interfaces.h>
# include <dmo/dmo_guids.h>
# include <ldt_keeper.h>
# include <wine/windef.h>
#endif
/* 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
#include "codecs.h"
#include "dmo.h"
#ifdef LOADER
/* Not Needed */
HRESULT CoInitialize( LPVOID pvReserved ) { return (HRESULT)-1; }
void CoUninitialize(void) { }
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**);
#else
# include <objbase.h>
#endif
#include "dmo.h"
#include "codecs.h"
typedef long STDCALL (*GETCLASS) ( const GUID*, const GUID*, void** );
#endif /* LOADER */
static int pi_channels_maps[7] =
{
......@@ -155,8 +145,7 @@ static const struct
/* */
{ 0, NULL, NULL }
};
#endif
#endif /* LOADER */
/*****************************************************************************
* Open: open dmo codec
......@@ -165,6 +154,7 @@ static int Open( vlc_object_t *p_this )
{
#ifndef LOADER
return DecoderOpen( p_this );
#else
decoder_t *p_dec = (decoder_t*)p_this;
int i;
......@@ -173,24 +163,25 @@ static int Open( vlc_object_t *p_this )
p_dec->p_sys = NULL;
/* Probe if we support it */
for( i = 0; codecs_table[i].i_fourcc != 0; i++ )
{
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",
(char*)&p_dec->fmt_in.i_codec,
codecs_table[i].psz_dll );
(char*)&p_dec->fmt_in.i_codec, codecs_table[i].psz_dll );
/* Set callbacks */
p_dec->pf_decode_video = (picture_t *(*)(decoder_t *, block_t **))DecodeBlock;
p_dec->pf_decode_audio = (aout_buffer_t *(*)(decoder_t *, block_t **))DecodeBlock;
p_dec->pf_decode_video =
(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_EGENERIC;
#endif
#endif /* LOADER */
}
/*****************************************************************************
......@@ -232,16 +223,15 @@ static int DecoderOpen( vlc_object_t *p_this )
}
#ifndef LOADER
{ /* <- ugly ? yes */
{
IEnumDMO *p_enum_dmo = NULL;
WCHAR *psz_dmo_name;
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 *,
uint32_t, const DMO_PARTIAL_MEDIATYPE *,
IEnumDMO ** );
/* Load msdmo DLL */
hmsdmo_dll = LoadLibrary( "msdmo.dll" );
if( hmsdmo_dll == NULL )
......@@ -293,11 +283,12 @@ static int DecoderOpen( vlc_object_t *p_this )
goto error;
}
}
#else /* LOADER */
{
GETCLASS GetClass;
struct IClassFactory* cFactory = NULL;
struct IUnknown* cObject = NULL;
IClassFactory *cFactory = NULL;
IUnknown *cObject = NULL;
int i_err;
int i_codec;
......@@ -316,7 +307,7 @@ static int DecoderOpen( vlc_object_t *p_this )
return VLC_EGENERIC;
}
GetClass = (GETCLASS)GetProcAddress( hmsdmo_dll, "DllGetClassObject");
GetClass = (GETCLASS)GetProcAddress( hmsdmo_dll, "DllGetClassObject" );
if (!GetClass)
{
msg_Dbg( p_dec, "GetProcAddress failed to find DllGetClassObject()" );
......@@ -324,7 +315,8 @@ static int DecoderOpen( vlc_object_t *p_this )
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 )
{
msg_Dbg( p_dec, "no such class object" );
......@@ -332,7 +324,8 @@ static int DecoderOpen( vlc_object_t *p_this )
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 );
if( i_err || !cObject )
{
......@@ -340,25 +333,8 @@ static int DecoderOpen( vlc_object_t *p_this )
FreeLibrary( hmsdmo_dll );
return VLC_EGENERIC;
}
i_err = cObject->vt->QueryInterface( cObject, &IID_IMediaObject, (void**)&p_dmo );
#if 0
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
i_err = cObject->vt->QueryInterface( cObject, &IID_IMediaObject,
(void**)&p_dmo );
cObject->vt->Release((IUnknown*)cObject );
}
#endif /* LOADER */
......
......@@ -22,6 +22,7 @@
*****************************************************************************/
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_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}};
......@@ -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_YV12 = {0x32315659, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
#ifdef WIN32
# define IUnknown IUnknownHack
#endif
#define IUnknown IUnknownHack
#define IClassFactory IClassFactoryHack
typedef struct _IUnknown IUnknown;
typedef struct _IClassFactory IClassFactory;
typedef struct _IEnumDMO IEnumDMO;
typedef struct _IMediaBuffer IMediaBuffer;
typedef struct _IMediaObject IMediaObject;
#ifndef STDCALL
#define STDCALL __stdcall
......@@ -59,25 +64,6 @@ typedef struct
} 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
#ifdef HAVE_ATTRIBUTE_PACKED
__attribute__((__packed__))
......@@ -123,6 +109,21 @@ typedef struct IUnknown_vt
} IUnknown_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
*/
......@@ -245,5 +246,16 @@ typedef struct IMediaObject_vt
} IMediaObject_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