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.20 2010-10-17 18:31:46 Isibaar Exp $ |
* $Id: CXvidDecoder.cpp,v 1.25.2.2 2011-01-27 13:18:13 Isibaar Exp $ |
|
* |
|
|
****************************************************************************/ |
|
|
|
|
|
/**************************************************************************** |
|
|
* |
|
|
* 2003/12/11 - added some additional options, mainly to make the deblocking |
|
|
* code from xvidcore available. Most of the new code is taken |
|
|
* from Nic's dshow filter, (C) Nic, http://nic.dnsalias.com |
|
24 |
* |
* |
25 |
****************************************************************************/ |
****************************************************************************/ |
26 |
|
|
36 |
C:\DX90SDK\Samples\C++\DirectShow\BaseClasses\Debug |
C:\DX90SDK\Samples\C++\DirectShow\BaseClasses\Debug |
37 |
*/ |
*/ |
38 |
|
|
39 |
//#define XVID_USE_MFT |
/* |
40 |
//#define XVID_USE_TRAYICON |
#define XVID_USE_MFT |
41 |
|
#define XVID_USE_TRAYICON |
42 |
|
*/ |
43 |
|
|
44 |
#include <windows.h> |
#include <windows.h> |
45 |
|
|
130 |
{ |
{ |
131 |
&CLSID_XVID, // Filter CLSID |
&CLSID_XVID, // Filter CLSID |
132 |
XVID_NAME_L, // Filter name |
XVID_NAME_L, // Filter name |
133 |
MERIT_PREFERRED, // Its merit |
MERIT_PREFERRED+2, // Its merit |
134 |
sizeof(psudPins) / sizeof(AMOVIESETUP_PIN), // Number of pins |
sizeof(psudPins) / sizeof(AMOVIESETUP_PIN), // Number of pins |
135 |
psudPins // Pin details |
psudPins // Pin details |
136 |
}; |
}; |
164 |
extern HINSTANCE g_xvid_hInst; |
extern HINSTANCE g_xvid_hInst; |
165 |
|
|
166 |
static int GUI_Page = 0; |
static int GUI_Page = 0; |
167 |
|
static int Tray_Icon = 0; |
168 |
extern "C" void CALLBACK Configure(HWND hWndParent, HINSTANCE hInstParent, LPSTR lpCmdLine, int nCmdShow ); |
extern "C" void CALLBACK Configure(HWND hWndParent, HINSTANCE hInstParent, LPSTR lpCmdLine, int nCmdShow ); |
169 |
|
|
170 |
LRESULT CALLBACK msg_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
LRESULT CALLBACK msg_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
186 |
}; |
}; |
187 |
break; |
break; |
188 |
|
|
189 |
|
case WM_DESTROY: |
190 |
|
NOTIFYICONDATA nid; |
191 |
|
ZeroMemory(&nid,sizeof(NOTIFYICONDATA)); |
192 |
|
|
193 |
|
nid.cbSize = NOTIFYICONDATA_V1_SIZE; |
194 |
|
nid.hWnd = hwnd; |
195 |
|
nid.uID = 1456; |
196 |
|
|
197 |
|
Shell_NotifyIcon(NIM_DELETE, &nid); |
198 |
|
Tray_Icon = 0; |
199 |
default: |
default: |
200 |
return DefWindowProc(hwnd, uMsg, wParam, lParam); |
return DefWindowProc(hwnd, uMsg, wParam, lParam); |
201 |
} |
} |
306 |
xvid_decore_func = NULL; // Hmm, some strange errors appearing if I try to initialize... |
xvid_decore_func = NULL; // Hmm, some strange errors appearing if I try to initialize... |
307 |
xvid_global_func = NULL; // ...this in constructor's init-list. So, they assigned here. |
xvid_global_func = NULL; // ...this in constructor's init-list. So, they assigned here. |
308 |
|
|
|
#ifdef XVID_USE_TRAYICON |
|
|
MSG_hwnd = NULL; |
|
|
#endif |
|
|
|
|
309 |
#if defined(XVID_USE_MFT) |
#if defined(XVID_USE_MFT) |
310 |
InitializeCriticalSection(&m_mft_lock); |
InitializeCriticalSection(&m_mft_lock); |
311 |
m_pInputType = NULL; |
m_pInputType = NULL; |
332 |
xvid_gbl_init_t init; |
xvid_gbl_init_t init; |
333 |
memset(&init, 0, sizeof(init)); |
memset(&init, 0, sizeof(init)); |
334 |
init.version = XVID_VERSION; |
init.version = XVID_VERSION; |
335 |
|
init.cpu_flags = g_config.cpu; |
336 |
|
|
337 |
|
xvid_gbl_info_t info; |
338 |
|
memset(&info, 0, sizeof(info)); |
339 |
|
info.version = XVID_VERSION; |
340 |
|
|
341 |
m_hdll = LoadLibrary(XVID_DLL_NAME); |
m_hdll = LoadLibrary(XVID_DLL_NAME); |
342 |
if (m_hdll == NULL) { |
if (m_hdll == NULL) { |
372 |
return E_FAIL; |
return E_FAIL; |
373 |
} |
} |
374 |
|
|
375 |
|
if (xvid_global_func(0, XVID_GBL_INFO, &info, NULL) < 0) |
376 |
|
{ |
377 |
|
xvid_global_func = NULL; |
378 |
|
xvid_decore_func = NULL; |
379 |
|
FreeLibrary(m_hdll); |
380 |
|
m_hdll = NULL; |
381 |
|
MessageBox(0, "xvid_global() failed", "Error", MB_TOPMOST); |
382 |
|
return E_FAIL; |
383 |
|
} |
384 |
|
|
385 |
memset(&m_create, 0, sizeof(m_create)); |
memset(&m_create, 0, sizeof(m_create)); |
386 |
m_create.version = XVID_VERSION; |
m_create.version = XVID_VERSION; |
387 |
m_create.handle = NULL; |
m_create.handle = NULL; |
388 |
|
/* Decoder threads */ |
389 |
|
if (g_config.cpu & XVID_CPU_FORCE) { |
390 |
|
m_create.num_threads = g_config.num_threads; |
391 |
|
} |
392 |
|
else { |
393 |
|
m_create.num_threads = info.num_threads; /* Autodetect */ |
394 |
|
g_config.num_threads = info.num_threads; |
395 |
|
} |
396 |
|
|
397 |
memset(&m_frame, 0, sizeof(m_frame)); |
memset(&m_frame, 0, sizeof(m_frame)); |
398 |
m_frame.version = XVID_VERSION; |
m_frame.version = XVID_VERSION; |
480 |
CXvidDecoder::~CXvidDecoder() |
CXvidDecoder::~CXvidDecoder() |
481 |
{ |
{ |
482 |
DPRINTF("Destructor"); |
DPRINTF("Destructor"); |
|
CloseLib(); |
|
483 |
|
|
484 |
#ifdef XVID_USE_TRAYICON |
#ifdef XVID_USE_TRAYICON |
485 |
if (MSG_hwnd != NULL) { |
if (Tray_Icon) { /* Destroy tray icon */ |
486 |
NOTIFYICONDATA nid; |
NOTIFYICONDATA nid; |
487 |
nid.cbSize = sizeof(NOTIFYICONDATA); |
ZeroMemory(&nid,sizeof(NOTIFYICONDATA)); |
488 |
|
|
489 |
|
nid.cbSize = NOTIFYICONDATA_V1_SIZE; |
490 |
nid.hWnd = MSG_hwnd; |
nid.hWnd = MSG_hwnd; |
491 |
nid.uID = 100; |
nid.uID = 1456; |
492 |
|
|
493 |
Shell_NotifyIcon(NIM_DELETE, &nid); |
Shell_NotifyIcon(NIM_DELETE, &nid); |
494 |
|
Tray_Icon = 0; |
|
DestroyWindow(MSG_hwnd); |
|
|
MSG_hwnd = NULL; |
|
495 |
} |
} |
496 |
#endif |
#endif |
497 |
|
|
498 |
|
/* Close xvidcore library */ |
499 |
|
CloseLib(); |
500 |
|
|
501 |
#if defined(XVID_USE_MFT) |
#if defined(XVID_USE_MFT) |
502 |
DeleteCriticalSection(&m_mft_lock); |
DeleteCriticalSection(&m_mft_lock); |
503 |
#endif |
#endif |
900 |
DPRINTF("CompleteConnect"); |
DPRINTF("CompleteConnect"); |
901 |
|
|
902 |
#ifdef XVID_USE_TRAYICON |
#ifdef XVID_USE_TRAYICON |
903 |
if ((direction == PINDIR_OUTPUT) && (MSG_hwnd == NULL)) |
if ((direction == PINDIR_OUTPUT) && (Tray_Icon == 0)) |
904 |
{ |
{ |
905 |
WNDCLASSEX wc; |
WNDCLASSEX wc; |
906 |
|
|
923 |
|
|
924 |
/* display the tray icon */ |
/* display the tray icon */ |
925 |
NOTIFYICONDATA nid; |
NOTIFYICONDATA nid; |
926 |
|
ZeroMemory(&nid,sizeof(NOTIFYICONDATA)); |
927 |
|
|
928 |
nid.cbSize = sizeof(NOTIFYICONDATA); |
nid.cbSize = NOTIFYICONDATA_V1_SIZE; |
929 |
nid.hWnd = MSG_hwnd; |
nid.hWnd = MSG_hwnd; |
930 |
nid.uID = 100; |
nid.uID = 1456; |
|
nid.uVersion = NOTIFYICON_VERSION; |
|
931 |
nid.uCallbackMessage = WM_ICONMESSAGE; |
nid.uCallbackMessage = WM_ICONMESSAGE; |
932 |
nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON)); |
nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON)); |
933 |
strcpy_s(nid.szTip, 19, "Xvid Video Decoder"); |
strcpy_s(nid.szTip, 19, "Xvid Video Decoder"); |
934 |
nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; |
nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; |
935 |
|
|
936 |
Shell_NotifyIcon(NIM_ADD, &nid); |
Shell_NotifyIcon(NIM_ADD, &nid); |
937 |
|
|
938 |
|
DestroyIcon(nid.hIcon); |
939 |
|
Tray_Icon = 1; |
940 |
} |
} |
941 |
#endif |
#endif |
942 |
|
|
948 |
{ |
{ |
949 |
DPRINTF("BreakConnect"); |
DPRINTF("BreakConnect"); |
950 |
|
|
|
#ifdef XVID_USE_TRAYICON |
|
|
if ((direction == PINDIR_OUTPUT) && (MSG_hwnd != NULL)) { |
|
|
NOTIFYICONDATA nid; |
|
|
|
|
|
nid.cbSize = sizeof(NOTIFYICONDATA); |
|
|
nid.hWnd = MSG_hwnd; |
|
|
nid.uID = 100; |
|
|
nid.uVersion = NOTIFYICON_VERSION; |
|
|
|
|
|
if(Shell_NotifyIcon(NIM_DELETE, &nid) == TRUE) { |
|
|
DestroyWindow(MSG_hwnd); |
|
|
MSG_hwnd = NULL; |
|
|
} |
|
|
} |
|
|
#endif |
|
|
|
|
951 |
return S_OK; |
return S_OK; |
952 |
} |
} |
953 |
|
|
1566 |
|
|
1567 |
EnterCriticalSection(&m_mft_lock); |
EnterCriticalSection(&m_mft_lock); |
1568 |
|
|
1569 |
/* Actually set the type or just test it? |
/* Actually set the type or just test it? */ |
1570 |
BOOL bReallySet = ((dwFlags & MFT_SET_TYPE_TEST_ONLY) == 0); |
BOOL bReallySet = ((dwFlags & MFT_SET_TYPE_TEST_ONLY) == 0); |
1571 |
|
|
1572 |
/* If we have samples pending the type can't be changed right now */ |
/* If we have samples pending the type can't be changed right now */ |
1595 |
hr = OnSetOutputType(pType); |
hr = OnSetOutputType(pType); |
1596 |
} |
} |
1597 |
} |
} |
|
|
|
1598 |
#ifdef XVID_USE_TRAYICON |
#ifdef XVID_USE_TRAYICON |
1599 |
if (SUCCEEDED(hr) && MSG_hwnd == NULL) /* Create message passing window */ |
if (SUCCEEDED(hr) && Tray_Icon == 0) /* Create message passing window */ |
1600 |
{ |
{ |
1601 |
WNDCLASSEX wc; |
WNDCLASSEX wc; |
1602 |
|
|
1619 |
|
|
1620 |
/* display the tray icon */ |
/* display the tray icon */ |
1621 |
NOTIFYICONDATA nid; |
NOTIFYICONDATA nid; |
1622 |
|
ZeroMemory(&nid,sizeof(NOTIFYICONDATA)); |
1623 |
|
|
1624 |
nid.cbSize = sizeof(NOTIFYICONDATA); |
nid.cbSize = NOTIFYICONDATA_V1_SIZE; |
1625 |
nid.hWnd = MSG_hwnd; |
nid.hWnd = MSG_hwnd; |
1626 |
nid.uID = 100; |
nid.uID = 1456; |
|
nid.uVersion = NOTIFYICON_VERSION; |
|
1627 |
nid.uCallbackMessage = WM_ICONMESSAGE; |
nid.uCallbackMessage = WM_ICONMESSAGE; |
1628 |
nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON)); |
nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON)); |
1629 |
strcpy_s(nid.szTip, 19, "Xvid Video Decoder"); |
strcpy_s(nid.szTip, 19, "Xvid Video Decoder"); |
1630 |
nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; |
nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; |
1631 |
|
|
1632 |
Shell_NotifyIcon(NIM_ADD, &nid); |
Shell_NotifyIcon(NIM_ADD, &nid); |
1633 |
|
|
1634 |
|
DestroyIcon(nid.hIcon); |
1635 |
|
Tray_Icon = 1; |
1636 |
} |
} |
1637 |
#endif |
#endif |
1638 |
|
|
1965 |
if (FAILED(pSample->GetSampleDuration(&m_timelength))) { |
if (FAILED(pSample->GetSampleDuration(&m_timelength))) { |
1966 |
m_timelength = INVALID_TIME; |
m_timelength = INVALID_TIME; |
1967 |
} |
} |
1968 |
|
if (m_timestamp != INVALID_TIME && stats.type == XVID_TYPE_IVOP) { |
1969 |
|
m_rtFrame = m_timestamp; |
1970 |
|
} |
1971 |
} |
} |
1972 |
|
|
1973 |
LeaveCriticalSection(&m_mft_lock); |
LeaveCriticalSection(&m_mft_lock); |