--- branches/dev-api-4/xvidcore/dshow/src/CXvidDecoder.cpp 2004/01/07 13:50:28 1307 +++ branches/dev-api-4/xvidcore/dshow/src/CXvidDecoder.cpp 2004/02/03 06:57:24 1351 @@ -3,7 +3,7 @@ * XVID MPEG-4 VIDEO CODEC * - XviD Decoder part of the DShow Filter - * - * Copyright(C) 2002-2003 Peter Ross + * Copyright(C) 2002-2004 Peter Ross * * 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 @@ -19,7 +19,7 @@ * 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.9 2004-01-07 13:50:28 syskin Exp $ + * $Id: CXvidDecoder.cpp,v 1.1.2.17 2004-02-03 06:57:24 syskin Exp $ * ****************************************************************************/ @@ -60,21 +60,20 @@ #include "IXvidDecoder.h" #include "CXvidDecoder.h" #include "CAbout.h" +#include "config.h" +#include "debug.h" -// Externs defined here -PostProcessing_Settings PPSettings; -int rgb_flip; - -bool USE_IYUV; -bool USE_YV12; -bool USE_YUY2; -bool USE_YVYU; -bool USE_UYVY; -bool USE_RGB32; -bool USE_RGB24; -bool USE_RG555; -bool USE_RG565; +static int rgb_flip; +static bool USE_IYUV; +static bool USE_YV12; +static bool USE_YUY2; +static bool USE_YVYU; +static bool USE_UYVY; +static bool USE_RGB32; +static bool USE_RGB24; +static bool USE_RG555; +static bool USE_RG565; const AMOVIESETUP_MEDIATYPE sudInputPinTypes[] = { @@ -84,6 +83,7 @@ { &MEDIATYPE_Video, &CLSID_DIVX_UC }, { &MEDIATYPE_Video, &CLSID_DX50 }, { &MEDIATYPE_Video, &CLSID_DX50_UC }, + { &MEDIATYPE_Video, &CLSID_MP4V }, }; const AMOVIESETUP_MEDIATYPE sudOutputPinTypes[] = @@ -150,6 +150,8 @@ }; + +/* note: g_cTemplates must be global; used by strmbase.lib(dllentry.cpp,dllsetup.cpp) */ int g_cTemplates = sizeof(g_Templates) / sizeof(CFactoryTemplate); @@ -246,19 +248,7 @@ memset(&m_frame, 0, sizeof(m_frame)); m_frame.version = XVID_VERSION; - HKEY hKey; - DWORD size; - RegOpenKeyEx(XVID_REG_KEY, XVID_REG_SUBKEY, 0, KEY_READ, &hKey); - - // Set the default post-processing settings - REG_GET_N("Brightness", PPSettings.nBrightness, 25) - REG_GET_N("Deblock_Y", PPSettings.bDeblock_Y, 1) - REG_GET_N("Deblock_UV", PPSettings.bDeblock_UV, 1) - REG_GET_N("Dering", PPSettings.bDering, 1) - REG_GET_N("FilmEffect", PPSettings.bFilmEffect, 1) - REG_GET_N("ForceColorspace", PPSettings.nForceColorspace, 0) - - RegCloseKey(hKey); + LoadRegistryInfo(); USE_IYUV = false; USE_YV12 = false; @@ -270,7 +260,7 @@ USE_RG555 = false; USE_RG565 = false; - switch ( PPSettings.nForceColorspace ) + switch ( g_config.nForceColorspace ) { case FORCE_NONE: USE_IYUV = true; @@ -339,8 +329,10 @@ { VIDEOINFOHEADER * vih = (VIDEOINFOHEADER *) mtIn->Format(); hdr = &vih->bmiHeader; - ar_x = vih->bmiHeader.biXPelsPerMeter*hdr->biWidth; - ar_y = vih->bmiHeader.biYPelsPerMeter*hdr->biHeight; + /* PAR (x:y) is (1/ppm_X):(1/ppm_Y) where ppm is pixels-per-meter + which is equal to ppm_Y:ppm_X */ + ar_x = vih->bmiHeader.biYPelsPerMeter*hdr->biWidth; + ar_y = vih->bmiHeader.biXPelsPerMeter*hdr->biHeight; } else if (*mtIn->FormatType() == FORMAT_VideoInfo2) { @@ -365,10 +357,18 @@ switch(hdr->biCompression) { + + case FOURCC_MP4V: + if (!(g_config.supported_4cc & SUPPORT_MP4V)) return VFW_E_TYPE_NOT_ACCEPTED; + break; + case FOURCC_DIVX : + if (!(g_config.supported_4cc & SUPPORT_DIVX)) return VFW_E_TYPE_NOT_ACCEPTED; + break; + case FOURCC_DX50 : + if (!(g_config.supported_4cc & SUPPORT_DX50)) return VFW_E_TYPE_NOT_ACCEPTED; case FOURCC_XVID : -// case FOURCC_DIVX : -// case FOURCC_DX50 : break; + default : DPRINTF("Unknown fourcc: 0x%08x (%c%c%c%c)", @@ -379,7 +379,6 @@ (hdr->biCompression>>24)&0xff); return VFW_E_TYPE_NOT_ACCEPTED; } - return S_OK; } @@ -402,7 +401,7 @@ return E_OUTOFMEMORY; } - ZeroMemory(vih, sizeof (VIDEOINFOHEADER)); + ZeroMemory(vih, sizeof (VIDEOINFOHEADER2)); vih->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); vih->bmiHeader.biWidth = m_create.width; vih->bmiHeader.biHeight = m_create.height; @@ -535,28 +534,33 @@ if (subtype == CLSID_MEDIASUBTYPE_IYUV) { DPRINTF("IYUV"); + rgb_flip = 0; m_frame.output.csp = XVID_CSP_I420; m_frame.output.stride[0] = (m_frame.output.stride[0] * 2) / 3; /* planar format fix */ } else if (subtype == MEDIASUBTYPE_YV12) { DPRINTF("YV12"); + rgb_flip = 0; m_frame.output.csp = XVID_CSP_YV12; m_frame.output.stride[0] = (m_frame.output.stride[0] * 2) / 3; /* planar format fix */ } else if (subtype == MEDIASUBTYPE_YUY2) { DPRINTF("YUY2"); + rgb_flip = 0; m_frame.output.csp = XVID_CSP_YUY2; } else if (subtype == MEDIASUBTYPE_YVYU) { DPRINTF("YVYU"); + rgb_flip = 0; m_frame.output.csp = XVID_CSP_YVYU; } else if (subtype == MEDIASUBTYPE_UYVY) { DPRINTF("UYVY"); + rgb_flip = 0; m_frame.output.csp = XVID_CSP_UYVY; } else if (subtype == MEDIASUBTYPE_RGB32) @@ -702,20 +706,20 @@ if (pIn->IsDiscontinuity() == S_OK) m_frame.general = XVID_DISCONTINUITY; - if (PPSettings.bDeblock_Y) + if (g_config.nDeblock_Y) m_frame.general |= XVID_DEBLOCKY; - if (PPSettings.bDeblock_UV) + if (g_config.nDeblock_UV) m_frame.general |= XVID_DEBLOCKUV; /* - if (PPSettings.bDering) + if (g_config.nDering) m_frame.general |= XVID_DERING; */ - if (PPSettings.bFilmEffect) + if (g_config.nFilmEffect) m_frame.general |= XVID_FILMEFFECT; m_frame.output.csp &= ~XVID_CSP_VFLIP; - m_frame.output.csp |= rgb_flip^(PPSettings.bFlipVideo ? XVID_CSP_VFLIP : 0); + m_frame.output.csp |= rgb_flip^(g_config.nFlipVideo ? XVID_CSP_VFLIP : 0); repeat : @@ -753,7 +757,7 @@ m_frame.general = tmp_gen; } - if (stats.type == XVID_TYPE_NOTHING) { + if (stats.type == XVID_TYPE_NOTHING && length > 0) { DPRINTF("B-Frame decoder lag"); return S_FALSE; }