--- branches/dev-api-4/xvidcore/dshow/src/CXvidDecoder.cpp 2003/02/22 08:22:03 888 +++ branches/dev-api-4/xvidcore/dshow/src/CXvidDecoder.cpp 2003/12/09 14:32:52 1250 @@ -1,23 +1,27 @@ -/************************************************************************** +/***************************************************************************** * - * XVID DIRECTSHOW FRONTEND -- decoder fitler - * Copyright (c) 2002 Peter Ross + * XVID MPEG-4 VIDEO CODEC + * - XviD Decoder part of the DShow Filter - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * Copyright(C) 2002-2003 Peter Ross * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is free software ; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation ; either version 2 of the License, or + * (at your option) any later version. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY ; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - *************************************************************************/ + * You should have received a copy of the GNU General Public License + * along with this program ; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id: CXvidDecoder.cpp,v 1.1.2.4 2003-12-09 14:32:52 syskin Exp $ + * + ****************************************************************************/ /* this requires the directx sdk @@ -50,6 +54,7 @@ #include "CAbout.h" + const AMOVIESETUP_MEDIATYPE sudInputPinTypes[] = { { &MEDIATYPE_Video, &CLSID_XVID }, @@ -175,53 +180,20 @@ -/* dummy decore() */ - -static int dummy_xvid_decore(void * handle, int opt, void * param1, void * param2) -{ - return XVID_ERR_FAIL; -} - - /* constructor */ -#define XVID_DLL_NAME "xvid.dll" -#define XVID_GLOBAL_NAME "xvid_global" -#define XVID_DECORE_NAME "xvid_decore" - CXvidDecoder::CXvidDecoder(LPUNKNOWN punk, HRESULT *phr) : CVideoTransformFilter(NAME("CXvidDecoder"), punk, CLSID_XVID) { DPRINTF("Constructor"); - 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; - } - xvid_gbl_init_t init; memset(&init, 0, sizeof(init)); init.version = XVID_VERSION; - if (m_xvid_global(0, XVID_GBL_INIT, &init, NULL) < 0) + if (xvid_global(0, XVID_GBL_INIT, &init, NULL) < 0) { - MessageBox(0, XVID_GLOBAL_NAME "() failed", "Error", 0); + MessageBox(0, "xvid_global() failed", "Error", 0); return; } @@ -243,15 +215,9 @@ if (m_create.handle != NULL) { - m_xvid_decore(m_create.handle, XVID_DEC_DESTROY, 0, 0); + xvid_decore(m_create.handle, XVID_DEC_DESTROY, 0, 0); m_create.handle = NULL; } - - if (m_hdll != NULL) - { - FreeLibrary(m_hdll); - m_hdll = NULL; - } } @@ -326,6 +292,7 @@ /* get list of supported output colorspaces */ + HRESULT CXvidDecoder::GetMediaType(int iPosition, CMediaType *mtOut) { DPRINTF("GetMediaType"); @@ -356,9 +323,9 @@ { case 0 : #ifdef USE_IYUV - vih->bmiHeader.biCompression = MEDIASUBTYPE_IYUV.Data1; + vih->bmiHeader.biCompression = CLSID_MEDIASUBTYPE_IYUV.Data1; vih->bmiHeader.biBitCount = 12; - mtOut->SetSubtype(&MEDIASUBTYPE_IYUV); + mtOut->SetSubtype(&CLSID_MEDIASUBTYPE_IYUV); break; #endif case 1 : @@ -455,7 +422,7 @@ return S_FALSE; } - if (subtype == MEDIASUBTYPE_IYUV) + if (subtype == CLSID_MEDIASUBTYPE_IYUV) { DPRINTF("IYUV"); m_frame.output.csp = XVID_CSP_I420; @@ -586,7 +553,7 @@ if (m_create.handle == NULL) { - if (m_xvid_decore(0, XVID_DEC_CREATE, &m_create, 0) < 0) + if (xvid_decore(0, XVID_DEC_CREATE, &m_create, 0) < 0) { DPRINTF("*** XVID_DEC_CREATE error"); return S_FALSE; @@ -628,7 +595,8 @@ if (pIn->IsPreroll() != S_OK) { - 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); + if (length < 0) { DPRINTF("*** XVID_DEC_DECODE"); @@ -640,7 +608,7 @@ int tmp = m_frame.output.csp; m_frame.output.csp = XVID_CSP_NULL; - 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); if (length < 0) { DPRINTF("*** XVID_DEC_DECODE"); @@ -650,6 +618,12 @@ m_frame.output.csp = tmp; } + if (stats.type == XVID_TYPE_NOTHING) { + DPRINTF("B-Frame decoder lag"); + return S_FALSE; + } + + if (stats.type == XVID_TYPE_VOL) { if (stats.data.vol.width != m_create.width ||