2005-04-15 20:17:14 +00:00
|
|
|
/*
|
2006-06-22 13:34:00 +00:00
|
|
|
* Modified for use with MPlayer, detailed changelog at
|
|
|
|
* http://svn.mplayerhq.hu/mplayer/trunk/
|
2005-04-15 20:17:14 +00:00
|
|
|
*/
|
|
|
|
|
2003-04-21 21:06:08 +00:00
|
|
|
#include "config.h"
|
2002-11-26 22:54:11 +00:00
|
|
|
#include "DMO_Filter.h"
|
2010-01-04 20:32:23 +00:00
|
|
|
#include "loader/drv.h"
|
|
|
|
#include "loader/com.h"
|
2002-11-26 22:54:11 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2010-01-04 20:32:23 +00:00
|
|
|
#include "loader/win32.h" // printf macro
|
2002-11-26 22:54:11 +00:00
|
|
|
|
2009-05-04 17:35:26 +00:00
|
|
|
void trapbug(void);
|
2002-11-26 22:54:11 +00:00
|
|
|
typedef long STDCALL (*GETCLASS) (const GUID*, const GUID*, void**);
|
|
|
|
|
|
|
|
void DMO_Filter_Destroy(DMO_Filter* This)
|
|
|
|
{
|
|
|
|
if (This->m_pOptim)
|
|
|
|
This->m_pOptim->vt->Release((IUnknown*)This->m_pOptim);
|
|
|
|
if (This->m_pInPlace)
|
|
|
|
This->m_pInPlace->vt->Release((IUnknown*)This->m_pInPlace);
|
|
|
|
if (This->m_pMedia)
|
|
|
|
This->m_pMedia->vt->Release((IUnknown*)This->m_pMedia);
|
|
|
|
|
|
|
|
free(This);
|
2003-04-21 21:06:08 +00:00
|
|
|
#ifdef WIN32_LOADER
|
2002-11-26 22:54:11 +00:00
|
|
|
CodecRelease();
|
2003-04-21 21:06:08 +00:00
|
|
|
#endif
|
2002-11-26 22:54:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DMO_Filter* DMO_FilterCreate(const char* dllname, const GUID* id,
|
|
|
|
DMO_MEDIA_TYPE* in_fmt,
|
|
|
|
DMO_MEDIA_TYPE* out_fmt)
|
|
|
|
{
|
|
|
|
HRESULT hr = 0;
|
|
|
|
const char* em = NULL;
|
2010-02-26 15:01:37 +00:00
|
|
|
DMO_Filter* This = malloc(sizeof(DMO_Filter));
|
2002-11-26 22:54:11 +00:00
|
|
|
if (!This)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
memset(This, 0, sizeof(DMO_Filter));
|
2003-04-21 21:06:08 +00:00
|
|
|
#ifdef WIN32_LOADER
|
2002-11-26 22:54:11 +00:00
|
|
|
CodecAlloc();
|
2003-04-21 21:06:08 +00:00
|
|
|
#endif
|
2002-11-26 22:54:11 +00:00
|
|
|
|
|
|
|
//This->Start = DS_Filter_Start;
|
|
|
|
//This->Stop = DS_Filter_Stop;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
GETCLASS func;
|
|
|
|
struct IClassFactory* factory = NULL;
|
|
|
|
struct IUnknown* object = NULL;
|
|
|
|
unsigned int i;
|
|
|
|
unsigned long inputs, outputs;
|
|
|
|
|
|
|
|
This->m_iHandle = LoadLibraryA(dllname);
|
|
|
|
if (!This->m_iHandle)
|
|
|
|
{
|
|
|
|
em = "could not open DMO DLL";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
func = (GETCLASS)GetProcAddress((unsigned)This->m_iHandle, "DllGetClassObject");
|
|
|
|
if (!func)
|
|
|
|
{
|
|
|
|
em = "illegal or corrupt DMO DLL";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
//trapbug();
|
2007-09-10 18:27:45 +00:00
|
|
|
hr = func(id, &IID_IClassFactory, (void*)&factory);
|
2002-11-26 22:54:11 +00:00
|
|
|
if (hr || !factory)
|
|
|
|
{
|
|
|
|
em = "no such class object";
|
|
|
|
break;
|
|
|
|
}
|
2007-09-10 18:27:45 +00:00
|
|
|
hr = factory->vt->CreateInstance(factory, 0, &IID_IUnknown, (void*)&object);
|
2002-11-26 22:54:11 +00:00
|
|
|
factory->vt->Release((IUnknown*)factory);
|
|
|
|
if (hr || !object)
|
|
|
|
{
|
|
|
|
em = "class factory failure";
|
|
|
|
break;
|
|
|
|
}
|
2007-09-10 18:27:45 +00:00
|
|
|
hr = object->vt->QueryInterface(object, &IID_IMediaObject, (void*)&This->m_pMedia);
|
2002-11-26 22:54:11 +00:00
|
|
|
if (hr == 0)
|
|
|
|
{
|
|
|
|
/* query for some extra available interface */
|
2007-09-10 18:27:45 +00:00
|
|
|
HRESULT r = object->vt->QueryInterface(object, &IID_IMediaObjectInPlace, (void*)&This->m_pInPlace);
|
2002-11-26 22:54:11 +00:00
|
|
|
if (r == 0 && This->m_pInPlace)
|
|
|
|
printf("DMO dll supports InPlace - PLEASE REPORT to developer\n");
|
2007-09-10 18:27:45 +00:00
|
|
|
r = object->vt->QueryInterface(object, &IID_IDMOVideoOutputOptimizations, (void*)&This->m_pOptim);
|
2002-11-26 22:54:11 +00:00
|
|
|
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");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
object->vt->Release((IUnknown*)object);
|
|
|
|
if (hr || !This->m_pMedia)
|
|
|
|
{
|
|
|
|
em = "object does not provide IMediaObject interface";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
hr = This->m_pMedia->vt->SetInputType(This->m_pMedia, 0, in_fmt, 0);
|
|
|
|
if (hr)
|
|
|
|
{
|
|
|
|
em = "input format not accepted";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (0) {
|
|
|
|
DMO_MEDIA_TYPE dmo;
|
2007-09-10 13:29:14 +00:00
|
|
|
//VIDEOINFOHEADER* vi;
|
2002-11-26 22:54:11 +00:00
|
|
|
memset(&dmo, 0, sizeof(dmo));
|
|
|
|
i = This->m_pMedia->vt->GetOutputType(This->m_pMedia, 0, 2, &dmo);
|
2008-12-11 21:29:01 +00:00
|
|
|
Debug printf("GetOutputType %x \n", i);
|
|
|
|
Debug printf("DMO 0x%x (%.4s) 0x%x (%.4s)\n"
|
|
|
|
//Debug printf("DMO 0x%x 0x%x\n"
|
2002-11-26 22:54:11 +00:00
|
|
|
":: fixszsamp:%d tempcomp:%d sampsz:%ld\n"
|
|
|
|
":: formtype: 0x%x\n"
|
|
|
|
":: unk %p cbform: %ld pbform:%p\n",
|
|
|
|
dmo.majortype.f1,
|
|
|
|
(const char*)&dmo.majortype.f1,
|
|
|
|
dmo.subtype.f1,
|
|
|
|
(const char*)&dmo.subtype.f1,
|
|
|
|
dmo.bFixedSizeSamples, dmo.bTemporalCompression,
|
|
|
|
dmo.lSampleSize,
|
|
|
|
dmo.formattype.f1,
|
|
|
|
dmo.pUnk, dmo.cbFormat, dmo.pbFormat
|
|
|
|
);
|
|
|
|
/* vi = (VIDEOINFOHEADER*) dmo.pbFormat;
|
|
|
|
vi = (VIDEOINFOHEADER*) out_fmt->pbFormat;
|
|
|
|
for (i = 0; i < out_fmt->cbFormat; i++)
|
2008-12-11 21:29:01 +00:00
|
|
|
Debug printf("BYTE %d %02x %02x\n", i, ((uint8_t*)dmo.pbFormat)[i], ((uint8_t*)out_fmt->pbFormat)[i]);
|
2002-11-26 22:54:11 +00:00
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = This->m_pMedia->vt->SetOutputType(This->m_pMedia, 0, out_fmt, 0);
|
|
|
|
if (hr)
|
|
|
|
{
|
|
|
|
em = "output format no accepted";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
inputs = outputs = 0;
|
|
|
|
hr = This->m_pMedia->vt->GetOutputSizeInfo(This->m_pMedia, 0, &inputs, &outputs);
|
2008-12-11 21:29:01 +00:00
|
|
|
Debug printf("GetOutput r=0x%lx size:%ld align:%ld\n", hr, inputs, outputs);
|
2002-11-26 22:54:11 +00:00
|
|
|
|
|
|
|
// This->m_pMedia->vt->AllocateStreamingResources(This->m_pMedia);
|
|
|
|
hr = This->m_pMedia->vt->GetStreamCount(This->m_pMedia, &inputs, &outputs);
|
2008-12-11 21:29:01 +00:00
|
|
|
Debug printf("StreamCount r=0x%lx %ld %ld\n", hr, inputs, outputs);
|
2002-11-26 22:54:11 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (em)
|
|
|
|
{
|
|
|
|
DMO_Filter_Destroy(This);
|
|
|
|
printf("IMediaObject ERROR: %p %s (0x%lx : %ld)\n", em, em ? em : "", hr, hr);
|
|
|
|
This = 0;
|
|
|
|
}
|
|
|
|
return This;
|
|
|
|
}
|