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.24 2010-12-18 10:16:46 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 |
|
|
162 |
extern HINSTANCE g_xvid_hInst; |
extern HINSTANCE g_xvid_hInst; |
163 |
|
|
164 |
static int GUI_Page = 0; |
static int GUI_Page = 0; |
165 |
|
static int Tray_Icon = 0; |
166 |
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 ); |
167 |
|
|
168 |
LRESULT CALLBACK msg_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
LRESULT CALLBACK msg_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
184 |
}; |
}; |
185 |
break; |
break; |
186 |
|
|
187 |
|
case WM_DESTROY: |
188 |
|
NOTIFYICONDATA nid; |
189 |
|
ZeroMemory(&nid,sizeof(NOTIFYICONDATA)); |
190 |
|
|
191 |
|
nid.cbSize = NOTIFYICONDATA_V1_SIZE; |
192 |
|
nid.hWnd = hwnd; |
193 |
|
nid.uID = 1456; |
194 |
|
|
195 |
|
Shell_NotifyIcon(NIM_DELETE, &nid); |
196 |
|
Tray_Icon = 0; |
197 |
default: |
default: |
198 |
return DefWindowProc(hwnd, uMsg, wParam, lParam); |
return DefWindowProc(hwnd, uMsg, wParam, lParam); |
199 |
} |
} |
304 |
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... |
305 |
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. |
306 |
|
|
|
#ifdef XVID_USE_TRAYICON |
|
|
MSG_hwnd = NULL; |
|
|
#endif |
|
|
|
|
307 |
#if defined(XVID_USE_MFT) |
#if defined(XVID_USE_MFT) |
308 |
InitializeCriticalSection(&m_mft_lock); |
InitializeCriticalSection(&m_mft_lock); |
309 |
m_pInputType = NULL; |
m_pInputType = NULL; |
331 |
memset(&init, 0, sizeof(init)); |
memset(&init, 0, sizeof(init)); |
332 |
init.version = XVID_VERSION; |
init.version = XVID_VERSION; |
333 |
|
|
334 |
|
xvid_gbl_info_t info; |
335 |
|
memset(&info, 0, sizeof(info)); |
336 |
|
info.version = XVID_VERSION; |
337 |
|
|
338 |
m_hdll = LoadLibrary(XVID_DLL_NAME); |
m_hdll = LoadLibrary(XVID_DLL_NAME); |
339 |
if (m_hdll == NULL) { |
if (m_hdll == NULL) { |
340 |
DPRINTF("dll load failed"); |
DPRINTF("dll load failed"); |
369 |
return E_FAIL; |
return E_FAIL; |
370 |
} |
} |
371 |
|
|
372 |
|
if (xvid_global_func(0, XVID_GBL_INFO, &info, NULL) < 0) |
373 |
|
{ |
374 |
|
xvid_global_func = NULL; |
375 |
|
xvid_decore_func = NULL; |
376 |
|
FreeLibrary(m_hdll); |
377 |
|
m_hdll = NULL; |
378 |
|
MessageBox(0, "xvid_global() failed", "Error", MB_TOPMOST); |
379 |
|
return E_FAIL; |
380 |
|
} |
381 |
|
|
382 |
memset(&m_create, 0, sizeof(m_create)); |
memset(&m_create, 0, sizeof(m_create)); |
383 |
m_create.version = XVID_VERSION; |
m_create.version = XVID_VERSION; |
384 |
m_create.handle = NULL; |
m_create.handle = NULL; |
385 |
|
m_create.num_threads = (!g_config.num_threads) ? info.num_threads : g_config.num_threads; |
386 |
|
|
387 |
memset(&m_frame, 0, sizeof(m_frame)); |
memset(&m_frame, 0, sizeof(m_frame)); |
388 |
m_frame.version = XVID_VERSION; |
m_frame.version = XVID_VERSION; |
470 |
CXvidDecoder::~CXvidDecoder() |
CXvidDecoder::~CXvidDecoder() |
471 |
{ |
{ |
472 |
DPRINTF("Destructor"); |
DPRINTF("Destructor"); |
|
CloseLib(); |
|
473 |
|
|
474 |
#ifdef XVID_USE_TRAYICON |
#ifdef XVID_USE_TRAYICON |
475 |
if (MSG_hwnd != NULL) { |
if (Tray_Icon) { /* Destroy tray icon */ |
476 |
NOTIFYICONDATA nid; |
NOTIFYICONDATA nid; |
477 |
nid.cbSize = sizeof(NOTIFYICONDATA); |
ZeroMemory(&nid,sizeof(NOTIFYICONDATA)); |
478 |
|
|
479 |
|
nid.cbSize = NOTIFYICONDATA_V1_SIZE; |
480 |
nid.hWnd = MSG_hwnd; |
nid.hWnd = MSG_hwnd; |
481 |
nid.uID = 100; |
nid.uID = 1456; |
482 |
|
|
483 |
Shell_NotifyIcon(NIM_DELETE, &nid); |
Shell_NotifyIcon(NIM_DELETE, &nid); |
484 |
|
Tray_Icon = 0; |
|
DestroyWindow(MSG_hwnd); |
|
|
MSG_hwnd = NULL; |
|
485 |
} |
} |
486 |
#endif |
#endif |
487 |
|
|
488 |
|
/* Close xvidcore library */ |
489 |
|
CloseLib(); |
490 |
|
|
491 |
#if defined(XVID_USE_MFT) |
#if defined(XVID_USE_MFT) |
492 |
DeleteCriticalSection(&m_mft_lock); |
DeleteCriticalSection(&m_mft_lock); |
493 |
#endif |
#endif |
890 |
DPRINTF("CompleteConnect"); |
DPRINTF("CompleteConnect"); |
891 |
|
|
892 |
#ifdef XVID_USE_TRAYICON |
#ifdef XVID_USE_TRAYICON |
893 |
if ((direction == PINDIR_OUTPUT) && (MSG_hwnd == NULL)) |
if ((direction == PINDIR_OUTPUT) && (Tray_Icon == 0)) |
894 |
{ |
{ |
895 |
WNDCLASSEX wc; |
WNDCLASSEX wc; |
896 |
|
|
913 |
|
|
914 |
/* display the tray icon */ |
/* display the tray icon */ |
915 |
NOTIFYICONDATA nid; |
NOTIFYICONDATA nid; |
916 |
|
ZeroMemory(&nid,sizeof(NOTIFYICONDATA)); |
917 |
|
|
918 |
nid.cbSize = sizeof(NOTIFYICONDATA); |
nid.cbSize = NOTIFYICONDATA_V1_SIZE; |
919 |
nid.hWnd = MSG_hwnd; |
nid.hWnd = MSG_hwnd; |
920 |
nid.uID = 100; |
nid.uID = 1456; |
|
nid.uVersion = NOTIFYICON_VERSION; |
|
921 |
nid.uCallbackMessage = WM_ICONMESSAGE; |
nid.uCallbackMessage = WM_ICONMESSAGE; |
922 |
nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON)); |
nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON)); |
923 |
strcpy_s(nid.szTip, 19, "Xvid Video Decoder"); |
strcpy_s(nid.szTip, 19, "Xvid Video Decoder"); |
924 |
nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; |
nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; |
925 |
|
|
926 |
Shell_NotifyIcon(NIM_ADD, &nid); |
Shell_NotifyIcon(NIM_ADD, &nid); |
927 |
|
|
928 |
|
DestroyIcon(nid.hIcon); |
929 |
|
Tray_Icon = 1; |
930 |
} |
} |
931 |
#endif |
#endif |
932 |
|
|
938 |
{ |
{ |
939 |
DPRINTF("BreakConnect"); |
DPRINTF("BreakConnect"); |
940 |
|
|
|
#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 |
|
|
|
|
941 |
return S_OK; |
return S_OK; |
942 |
} |
} |
943 |
|
|
1556 |
|
|
1557 |
EnterCriticalSection(&m_mft_lock); |
EnterCriticalSection(&m_mft_lock); |
1558 |
|
|
1559 |
/* Actually set the type or just test it? |
/* Actually set the type or just test it? */ |
1560 |
BOOL bReallySet = ((dwFlags & MFT_SET_TYPE_TEST_ONLY) == 0); |
BOOL bReallySet = ((dwFlags & MFT_SET_TYPE_TEST_ONLY) == 0); |
1561 |
|
|
1562 |
/* 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 */ |
1587 |
} |
} |
1588 |
|
|
1589 |
#ifdef XVID_USE_TRAYICON |
#ifdef XVID_USE_TRAYICON |
1590 |
if (SUCCEEDED(hr) && MSG_hwnd == NULL) /* Create message passing window */ |
if (SUCCEEDED(hr) && Tray_Icon == 0) /* Create message passing window */ |
1591 |
{ |
{ |
1592 |
WNDCLASSEX wc; |
WNDCLASSEX wc; |
1593 |
|
|
1610 |
|
|
1611 |
/* display the tray icon */ |
/* display the tray icon */ |
1612 |
NOTIFYICONDATA nid; |
NOTIFYICONDATA nid; |
1613 |
|
ZeroMemory(&nid,sizeof(NOTIFYICONDATA)); |
1614 |
|
|
1615 |
nid.cbSize = sizeof(NOTIFYICONDATA); |
nid.cbSize = NOTIFYICONDATA_V1_SIZE; |
1616 |
nid.hWnd = MSG_hwnd; |
nid.hWnd = MSG_hwnd; |
1617 |
nid.uID = 100; |
nid.uID = 1456; |
|
nid.uVersion = NOTIFYICON_VERSION; |
|
1618 |
nid.uCallbackMessage = WM_ICONMESSAGE; |
nid.uCallbackMessage = WM_ICONMESSAGE; |
1619 |
nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON)); |
nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON)); |
1620 |
strcpy_s(nid.szTip, 19, "Xvid Video Decoder"); |
strcpy_s(nid.szTip, 19, "Xvid Video Decoder"); |
1621 |
nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; |
nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; |
1622 |
|
|
1623 |
Shell_NotifyIcon(NIM_ADD, &nid); |
Shell_NotifyIcon(NIM_ADD, &nid); |
1624 |
|
|
1625 |
|
DestroyIcon(nid.hIcon); |
1626 |
|
Tray_Icon = 1; |
1627 |
} |
} |
1628 |
#endif |
#endif |
1629 |
|
|