19 |
* along with this program ; if not, write to the Free Software |
* along with this program ; if not, write to the Free Software |
20 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 |
* |
* |
22 |
* $Id: CXvidDecoder.cpp,v 1.1.2.2 2003-06-09 13:49:00 edgomez Exp $ |
* $Id: CXvidDecoder.cpp,v 1.1.2.3 2003-11-15 02:51:41 suxen_drol Exp $ |
23 |
* |
* |
24 |
****************************************************************************/ |
****************************************************************************/ |
25 |
|
|
54 |
#include "CAbout.h" |
#include "CAbout.h" |
55 |
|
|
56 |
|
|
57 |
|
|
58 |
const AMOVIESETUP_MEDIATYPE sudInputPinTypes[] = |
const AMOVIESETUP_MEDIATYPE sudInputPinTypes[] = |
59 |
{ |
{ |
60 |
{ &MEDIATYPE_Video, &CLSID_XVID }, |
{ &MEDIATYPE_Video, &CLSID_XVID }, |
180 |
|
|
181 |
|
|
182 |
|
|
|
/* dummy decore() */ |
|
|
|
|
|
static int dummy_xvid_decore(void * handle, int opt, void * param1, void * param2) |
|
|
{ |
|
|
return XVID_ERR_FAIL; |
|
|
} |
|
|
|
|
|
|
|
183 |
|
|
184 |
/* constructor */ |
/* constructor */ |
185 |
|
|
|
#define XVID_DLL_NAME "xvid.dll" |
|
|
#define XVID_GLOBAL_NAME "xvid_global" |
|
|
#define XVID_DECORE_NAME "xvid_decore" |
|
|
|
|
186 |
CXvidDecoder::CXvidDecoder(LPUNKNOWN punk, HRESULT *phr) : |
CXvidDecoder::CXvidDecoder(LPUNKNOWN punk, HRESULT *phr) : |
187 |
CVideoTransformFilter(NAME("CXvidDecoder"), punk, CLSID_XVID) |
CVideoTransformFilter(NAME("CXvidDecoder"), punk, CLSID_XVID) |
188 |
{ |
{ |
189 |
DPRINTF("Constructor"); |
DPRINTF("Constructor"); |
190 |
|
|
|
m_xvid_decore = dummy_xvid_decore; |
|
|
|
|
|
m_hdll = LoadLibrary(XVID_DLL_NAME); |
|
|
if (m_hdll == NULL) { |
|
|
DPRINTF("dll load failed"); |
|
|
MessageBox(0, XVID_DLL_NAME " not found","Error", 0); |
|
|
return; |
|
|
} |
|
|
|
|
|
m_xvid_global = (int (__cdecl *)(void *, int, void *, void *))GetProcAddress(m_hdll, XVID_GLOBAL_NAME); |
|
|
if (m_xvid_global == NULL) { |
|
|
MessageBox(0, XVID_GLOBAL_NAME "() not found", "Error", 0); |
|
|
return; |
|
|
} |
|
|
|
|
|
m_xvid_decore = (int (__cdecl *)(void *, int, void *, void *))GetProcAddress(m_hdll, XVID_DECORE_NAME); |
|
|
if (m_xvid_decore == NULL) { |
|
|
MessageBox(0, XVID_DECORE_NAME "() not found", "Error", 0); |
|
|
return; |
|
|
} |
|
|
|
|
191 |
xvid_gbl_init_t init; |
xvid_gbl_init_t init; |
192 |
memset(&init, 0, sizeof(init)); |
memset(&init, 0, sizeof(init)); |
193 |
init.version = XVID_VERSION; |
init.version = XVID_VERSION; |
194 |
if (m_xvid_global(0, XVID_GBL_INIT, &init, NULL) < 0) |
if (xvid_global(0, XVID_GBL_INIT, &init, NULL) < 0) |
195 |
{ |
{ |
196 |
MessageBox(0, XVID_GLOBAL_NAME "() failed", "Error", 0); |
MessageBox(0, "xvid_global() failed", "Error", 0); |
197 |
return; |
return; |
198 |
} |
} |
199 |
|
|
215 |
|
|
216 |
if (m_create.handle != NULL) |
if (m_create.handle != NULL) |
217 |
{ |
{ |
218 |
m_xvid_decore(m_create.handle, XVID_DEC_DESTROY, 0, 0); |
xvid_decore(m_create.handle, XVID_DEC_DESTROY, 0, 0); |
219 |
m_create.handle = NULL; |
m_create.handle = NULL; |
220 |
} |
} |
|
|
|
|
if (m_hdll != NULL) |
|
|
{ |
|
|
FreeLibrary(m_hdll); |
|
|
m_hdll = NULL; |
|
|
} |
|
221 |
} |
} |
222 |
|
|
223 |
|
|
292 |
|
|
293 |
/* get list of supported output colorspaces */ |
/* get list of supported output colorspaces */ |
294 |
|
|
295 |
|
|
296 |
HRESULT CXvidDecoder::GetMediaType(int iPosition, CMediaType *mtOut) |
HRESULT CXvidDecoder::GetMediaType(int iPosition, CMediaType *mtOut) |
297 |
{ |
{ |
298 |
DPRINTF("GetMediaType"); |
DPRINTF("GetMediaType"); |
323 |
{ |
{ |
324 |
case 0 : |
case 0 : |
325 |
#ifdef USE_IYUV |
#ifdef USE_IYUV |
326 |
vih->bmiHeader.biCompression = MEDIASUBTYPE_IYUV.Data1; |
vih->bmiHeader.biCompression = CLSID_MEDIASUBTYPE_IYUV.Data1; |
327 |
vih->bmiHeader.biBitCount = 12; |
vih->bmiHeader.biBitCount = 12; |
328 |
mtOut->SetSubtype(&MEDIASUBTYPE_IYUV); |
mtOut->SetSubtype(&CLSID_MEDIASUBTYPE_IYUV); |
329 |
break; |
break; |
330 |
#endif |
#endif |
331 |
case 1 : |
case 1 : |
422 |
return S_FALSE; |
return S_FALSE; |
423 |
} |
} |
424 |
|
|
425 |
if (subtype == MEDIASUBTYPE_IYUV) |
if (subtype == CLSID_MEDIASUBTYPE_IYUV) |
426 |
{ |
{ |
427 |
DPRINTF("IYUV"); |
DPRINTF("IYUV"); |
428 |
m_frame.output.csp = XVID_CSP_I420; |
m_frame.output.csp = XVID_CSP_I420; |
553 |
|
|
554 |
if (m_create.handle == NULL) |
if (m_create.handle == NULL) |
555 |
{ |
{ |
556 |
if (m_xvid_decore(0, XVID_DEC_CREATE, &m_create, 0) < 0) |
if (xvid_decore(0, XVID_DEC_CREATE, &m_create, 0) < 0) |
557 |
{ |
{ |
558 |
DPRINTF("*** XVID_DEC_CREATE error"); |
DPRINTF("*** XVID_DEC_CREATE error"); |
559 |
return S_FALSE; |
return S_FALSE; |
595 |
|
|
596 |
if (pIn->IsPreroll() != S_OK) |
if (pIn->IsPreroll() != S_OK) |
597 |
{ |
{ |
598 |
length = m_xvid_decore(m_create.handle, XVID_DEC_DECODE, &m_frame, &stats); |
length = xvid_decore(m_create.handle, XVID_DEC_DECODE, &m_frame, &stats); |
599 |
if (length < 0) |
if (length < 0) |
600 |
{ |
{ |
601 |
DPRINTF("*** XVID_DEC_DECODE"); |
DPRINTF("*** XVID_DEC_DECODE"); |
607 |
int tmp = m_frame.output.csp; |
int tmp = m_frame.output.csp; |
608 |
m_frame.output.csp = XVID_CSP_NULL; |
m_frame.output.csp = XVID_CSP_NULL; |
609 |
|
|
610 |
length = m_xvid_decore(m_create.handle, XVID_DEC_DECODE, &m_frame, &stats); |
length = xvid_decore(m_create.handle, XVID_DEC_DECODE, &m_frame, &stats); |
611 |
if (length < 0) |
if (length < 0) |
612 |
{ |
{ |
613 |
DPRINTF("*** XVID_DEC_DECODE"); |
DPRINTF("*** XVID_DEC_DECODE"); |