3 |
* XVID MPEG-4 VIDEO CODEC |
* XVID MPEG-4 VIDEO CODEC |
4 |
* - Xvid Decoder part of the DShow Filter - |
* - Xvid Decoder part of the DShow Filter - |
5 |
* |
* |
6 |
* Copyright(C) 2002-2010 Peter Ross <pross@xvid.org> |
* Copyright(C) 2002-2011 Peter Ross <pross@xvid.org> |
7 |
* 2003-2010 Michael Militzer <michael@xvid.org> |
* 2003-2012 Michael Militzer <michael@xvid.org> |
8 |
* |
* |
9 |
* This program is free software ; you can redistribute it and/or modify |
* This program is free software ; you can redistribute it and/or modify |
10 |
* it under the terms of the GNU General Public License as published by |
* it under the terms of the GNU General Public License as published by |
20 |
* along with this program ; if not, write to the Free Software |
* along with this program ; if not, write to the Free Software |
21 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
22 |
* |
* |
23 |
* $Id: CXvidDecoder.cpp,v 1.25.2.3 2011-02-14 16:58:54 Isibaar Exp $ |
* $Id$ |
24 |
* |
* |
25 |
****************************************************************************/ |
****************************************************************************/ |
26 |
|
|
36 |
C:\DX90SDK\Samples\C++\DirectShow\BaseClasses\Debug |
C:\DX90SDK\Samples\C++\DirectShow\BaseClasses\Debug |
37 |
*/ |
*/ |
38 |
|
|
39 |
/* |
#ifdef ENABLE_MFT |
40 |
#define XVID_USE_MFT |
#define XVID_USE_MFT |
41 |
#define XVID_USE_TRAYICON |
#endif |
|
*/ |
|
42 |
|
|
43 |
#include <windows.h> |
#include <windows.h> |
44 |
|
|
175 |
/* note: g_cTemplates must be global; used by strmbase.lib(dllentry.cpp,dllsetup.cpp) */ |
/* note: g_cTemplates must be global; used by strmbase.lib(dllentry.cpp,dllsetup.cpp) */ |
176 |
int g_cTemplates = sizeof(g_Templates) / sizeof(CFactoryTemplate); |
int g_cTemplates = sizeof(g_Templates) / sizeof(CFactoryTemplate); |
177 |
|
|
|
#ifdef XVID_USE_TRAYICON |
|
178 |
extern HINSTANCE g_xvid_hInst; |
extern HINSTANCE g_xvid_hInst; |
179 |
|
|
180 |
static int GUI_Page = 0; |
static int GUI_Page = 0; |
216 |
|
|
217 |
return TRUE; /* ok */ |
return TRUE; /* ok */ |
218 |
} |
} |
|
#endif |
|
219 |
|
|
220 |
STDAPI DllRegisterServer() |
STDAPI DllRegisterServer() |
221 |
{ |
{ |
240 |
/* Register the MFT decoder */ |
/* Register the MFT decoder */ |
241 |
MFTRegister(CLSID_XVID, // CLSID |
MFTRegister(CLSID_XVID, // CLSID |
242 |
MFT_CATEGORY_VIDEO_DECODER, // Category |
MFT_CATEGORY_VIDEO_DECODER, // Category |
243 |
const_cast<LPWSTR>(XVID_NAME_L), // Friendly name |
const_cast<LPWSTR>(XVID_NAME_MFT_L), // Friendly name |
244 |
0, // Flags |
0, // Flags |
245 |
inputs_num, // Number of input types |
inputs_num, // Number of input types |
246 |
mft_bs, // Input types |
mft_bs, // Input types |
309 |
|
|
310 |
/* constructor */ |
/* constructor */ |
311 |
|
|
|
#define XVID_DLL_NAME "xvidcore.dll" |
|
|
|
|
312 |
CXvidDecoder::CXvidDecoder(LPUNKNOWN punk, HRESULT *phr) : |
CXvidDecoder::CXvidDecoder(LPUNKNOWN punk, HRESULT *phr) : |
313 |
CVideoTransformFilter(NAME("CXvidDecoder"), punk, CLSID_XVID), m_hdll (NULL) |
CVideoTransformFilter(NAME("CXvidDecoder"), punk, CLSID_XVID), m_hdll (NULL) |
314 |
{ |
{ |
331 |
LoadRegistryInfo(); |
LoadRegistryInfo(); |
332 |
|
|
333 |
*phr = OpenLib(); |
*phr = OpenLib(); |
334 |
|
|
335 |
|
{ |
336 |
|
TCHAR lpFilename[MAX_PATH]; |
337 |
|
int sLen = GetModuleFileName(NULL, lpFilename, MAX_PATH); |
338 |
|
#ifdef _UNICODE |
339 |
|
if ((sLen >= 11) && (_wcsnicmp(&(lpFilename[sLen - 11]), TEXT("dllhost.exe"), 11) == 0)) { |
340 |
|
#else |
341 |
|
if ((sLen >= 11) && (_strnicmp(&(lpFilename[sLen - 11]), TEXT("dllhost.exe"), 11) == 0)) { |
342 |
|
#endif |
343 |
|
if (Tray_Icon == 0) Tray_Icon = -1; // create no tray icon upon thumbnail generation |
344 |
|
} |
345 |
|
else |
346 |
|
if (Tray_Icon == -1) Tray_Icon = 0; // can show tray icon |
347 |
|
} |
348 |
|
|
349 |
} |
} |
350 |
|
|
351 |
HRESULT CXvidDecoder::OpenLib() |
HRESULT CXvidDecoder::OpenLib() |
507 |
{ |
{ |
508 |
DPRINTF("Destructor"); |
DPRINTF("Destructor"); |
509 |
|
|
510 |
#ifdef XVID_USE_TRAYICON |
if (Tray_Icon > 0) { /* Destroy tray icon */ |
|
if (Tray_Icon) { /* Destroy tray icon */ |
|
511 |
NOTIFYICONDATA nid; |
NOTIFYICONDATA nid; |
512 |
ZeroMemory(&nid,sizeof(NOTIFYICONDATA)); |
ZeroMemory(&nid,sizeof(NOTIFYICONDATA)); |
513 |
|
|
518 |
Shell_NotifyIcon(NIM_DELETE, &nid); |
Shell_NotifyIcon(NIM_DELETE, &nid); |
519 |
Tray_Icon = 0; |
Tray_Icon = 0; |
520 |
} |
} |
|
#endif |
|
521 |
|
|
522 |
/* Close xvidcore library */ |
/* Close xvidcore library */ |
523 |
CloseLib(); |
CloseLib(); |
824 |
/* (internal function) change colorspace */ |
/* (internal function) change colorspace */ |
825 |
#define CALC_BI_STRIDE(width,bitcount) ((((width * bitcount) + 31) & ~31) >> 3) |
#define CALC_BI_STRIDE(width,bitcount) ((((width * bitcount) + 31) & ~31) >> 3) |
826 |
|
|
827 |
HRESULT CXvidDecoder::ChangeColorspace(GUID subtype, GUID formattype, void * format) |
HRESULT CXvidDecoder::ChangeColorspace(GUID subtype, GUID formattype, void * format, int noflip) |
828 |
{ |
{ |
829 |
DWORD biWidth; |
DWORD biWidth; |
830 |
|
|
847 |
return S_FALSE; |
return S_FALSE; |
848 |
} |
} |
849 |
|
|
850 |
|
if (noflip) rgb_flip = 0; |
851 |
|
|
852 |
if (subtype == CLSID_MEDIASUBTYPE_IYUV) |
if (subtype == CLSID_MEDIASUBTYPE_IYUV) |
853 |
{ |
{ |
854 |
DPRINTF("IYUV"); |
DPRINTF("IYUV"); |
922 |
|
|
923 |
if (direction == PINDIR_OUTPUT) |
if (direction == PINDIR_OUTPUT) |
924 |
{ |
{ |
925 |
return ChangeColorspace(*pmt->Subtype(), *pmt->FormatType(), pmt->Format()); |
return ChangeColorspace(*pmt->Subtype(), *pmt->FormatType(), pmt->Format(), 0); |
926 |
} |
} |
927 |
|
|
928 |
return S_OK; |
return S_OK; |
944 |
{ |
{ |
945 |
DPRINTF("CompleteConnect"); |
DPRINTF("CompleteConnect"); |
946 |
|
|
947 |
#ifdef XVID_USE_TRAYICON |
if ((direction == PINDIR_OUTPUT) && (Tray_Icon == 0)&& (g_config.bTrayIcon != 0)) |
|
if ((direction == PINDIR_OUTPUT) && (Tray_Icon == 0)) |
|
948 |
{ |
{ |
949 |
WNDCLASSEX wc; |
WNDCLASSEX wc; |
950 |
|
|
982 |
DestroyIcon(nid.hIcon); |
DestroyIcon(nid.hIcon); |
983 |
Tray_Icon = 1; |
Tray_Icon = 1; |
984 |
} |
} |
|
#endif |
|
985 |
|
|
986 |
return S_OK; |
return S_OK; |
987 |
} |
} |
1057 |
{ |
{ |
1058 |
HRESULT result; |
HRESULT result; |
1059 |
|
|
1060 |
result = ChangeColorspace(mtOut->subtype, mtOut->formattype, mtOut->pbFormat); |
result = ChangeColorspace(mtOut->subtype, mtOut->formattype, mtOut->pbFormat, 0); |
1061 |
DeleteMediaType(mtOut); |
DeleteMediaType(mtOut); |
1062 |
|
|
1063 |
if (result != S_OK) |
if (result != S_OK) |
1638 |
hr = MFCreateAMMediaTypeFromMFMediaType(pType, GUID_NULL, &am); |
hr = MFCreateAMMediaTypeFromMFMediaType(pType, GUID_NULL, &am); |
1639 |
|
|
1640 |
if (SUCCEEDED(hr)) { |
if (SUCCEEDED(hr)) { |
1641 |
if (FAILED(ChangeColorspace(am->subtype, am->formattype, am->pbFormat))) { |
if (FAILED(ChangeColorspace(am->subtype, am->formattype, am->pbFormat, 1))) { |
1642 |
DPRINTF("(MFT)InternalCheckOutputType (MF_E_INVALIDTYPE)"); |
DPRINTF("(MFT)InternalCheckOutputType (MF_E_INVALIDTYPE)"); |
1643 |
return MF_E_INVALIDTYPE; |
return MF_E_INVALIDTYPE; |
1644 |
} |
} |
1654 |
hr = OnSetOutputType(pType); |
hr = OnSetOutputType(pType); |
1655 |
} |
} |
1656 |
} |
} |
1657 |
#ifdef XVID_USE_TRAYICON |
|
1658 |
if (SUCCEEDED(hr) && Tray_Icon == 0) /* Create message passing window */ |
if (SUCCEEDED(hr) && (Tray_Icon == 0) && (g_config.bTrayIcon != 0)) /* Create message passing window */ |
1659 |
{ |
{ |
1660 |
WNDCLASSEX wc; |
WNDCLASSEX wc; |
1661 |
|
|
1693 |
DestroyIcon(nid.hIcon); |
DestroyIcon(nid.hIcon); |
1694 |
Tray_Icon = 1; |
Tray_Icon = 1; |
1695 |
} |
} |
|
#endif |
|
1696 |
|
|
1697 |
LeaveCriticalSection(&m_mft_lock); |
LeaveCriticalSection(&m_mft_lock); |
1698 |
return hr; |
return hr; |