--- trunk/xvidcore/dshow/src/CXvidDecoder.cpp 2010/10/17 18:31:52 1898 +++ trunk/xvidcore/dshow/src/CXvidDecoder.cpp 2011/01/27 13:18:13 1946 @@ -20,15 +20,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.20 2010-10-17 18:31: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 + * $Id: CXvidDecoder.cpp,v 1.27 2011-01-27 13:18:01 Isibaar Exp $ * ****************************************************************************/ @@ -44,8 +36,10 @@ C:\DX90SDK\Samples\C++\DirectShow\BaseClasses\Debug */ -//#define XVID_USE_MFT -//#define XVID_USE_TRAYICON +/* +#define XVID_USE_MFT +#define XVID_USE_TRAYICON +*/ #include @@ -136,7 +130,7 @@ { &CLSID_XVID, // Filter CLSID XVID_NAME_L, // Filter name - MERIT_PREFERRED, // Its merit + MERIT_PREFERRED+2, // Its merit sizeof(psudPins) / sizeof(AMOVIESETUP_PIN), // Number of pins psudPins // Pin details }; @@ -170,6 +164,7 @@ extern HINSTANCE g_xvid_hInst; static int GUI_Page = 0; +static int Tray_Icon = 0; extern "C" void CALLBACK Configure(HWND hWndParent, HINSTANCE hInstParent, LPSTR lpCmdLine, int nCmdShow ); LRESULT CALLBACK msg_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) @@ -190,7 +185,17 @@ return DefWindowProc(hwnd, uMsg, wParam, lParam); }; break; + + case WM_DESTROY: + NOTIFYICONDATA nid; + ZeroMemory(&nid,sizeof(NOTIFYICONDATA)); + + nid.cbSize = NOTIFYICONDATA_V1_SIZE; + nid.hWnd = hwnd; + nid.uID = 1456; + Shell_NotifyIcon(NIM_DELETE, &nid); + Tray_Icon = 0; default: return DefWindowProc(hwnd, uMsg, wParam, lParam); } @@ -301,10 +306,6 @@ xvid_decore_func = NULL; // Hmm, some strange errors appearing if I try to initialize... xvid_global_func = NULL; // ...this in constructor's init-list. So, they assigned here. -#ifdef XVID_USE_TRAYICON - MSG_hwnd = NULL; -#endif - #if defined(XVID_USE_MFT) InitializeCriticalSection(&m_mft_lock); m_pInputType = NULL; @@ -331,6 +332,11 @@ xvid_gbl_init_t init; memset(&init, 0, sizeof(init)); init.version = XVID_VERSION; + init.cpu_flags = g_config.cpu; + + xvid_gbl_info_t info; + memset(&info, 0, sizeof(info)); + info.version = XVID_VERSION; m_hdll = LoadLibrary(XVID_DLL_NAME); if (m_hdll == NULL) { @@ -366,9 +372,27 @@ return E_FAIL; } + if (xvid_global_func(0, XVID_GBL_INFO, &info, NULL) < 0) + { + xvid_global_func = NULL; + xvid_decore_func = NULL; + FreeLibrary(m_hdll); + m_hdll = NULL; + MessageBox(0, "xvid_global() failed", "Error", MB_TOPMOST); + return E_FAIL; + } + memset(&m_create, 0, sizeof(m_create)); m_create.version = XVID_VERSION; m_create.handle = NULL; + /* Decoder threads */ + if (g_config.cpu & XVID_CPU_FORCE) { + m_create.num_threads = g_config.num_threads; + } + else { + m_create.num_threads = info.num_threads; /* Autodetect */ + g_config.num_threads = info.num_threads; + } memset(&m_frame, 0, sizeof(m_frame)); m_frame.version = XVID_VERSION; @@ -456,22 +480,24 @@ CXvidDecoder::~CXvidDecoder() { DPRINTF("Destructor"); - CloseLib(); #ifdef XVID_USE_TRAYICON - if (MSG_hwnd != NULL) { + if (Tray_Icon) { /* Destroy tray icon */ NOTIFYICONDATA nid; - nid.cbSize = sizeof(NOTIFYICONDATA); + ZeroMemory(&nid,sizeof(NOTIFYICONDATA)); + + nid.cbSize = NOTIFYICONDATA_V1_SIZE; nid.hWnd = MSG_hwnd; - nid.uID = 100; + nid.uID = 1456; - Shell_NotifyIcon(NIM_DELETE, &nid); - - DestroyWindow(MSG_hwnd); - MSG_hwnd = NULL; + Shell_NotifyIcon(NIM_DELETE, &nid); + Tray_Icon = 0; } #endif + /* Close xvidcore library */ + CloseLib(); + #if defined(XVID_USE_MFT) DeleteCriticalSection(&m_mft_lock); #endif @@ -874,7 +900,7 @@ DPRINTF("CompleteConnect"); #ifdef XVID_USE_TRAYICON - if ((direction == PINDIR_OUTPUT) && (MSG_hwnd == NULL)) + if ((direction == PINDIR_OUTPUT) && (Tray_Icon == 0)) { WNDCLASSEX wc; @@ -897,17 +923,20 @@ /* display the tray icon */ NOTIFYICONDATA nid; - - nid.cbSize = sizeof(NOTIFYICONDATA); + ZeroMemory(&nid,sizeof(NOTIFYICONDATA)); + + nid.cbSize = NOTIFYICONDATA_V1_SIZE; nid.hWnd = MSG_hwnd; - nid.uID = 100; - nid.uVersion = NOTIFYICON_VERSION; + nid.uID = 1456; nid.uCallbackMessage = WM_ICONMESSAGE; nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON)); strcpy_s(nid.szTip, 19, "Xvid Video Decoder"); nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; Shell_NotifyIcon(NIM_ADD, &nid); + + DestroyIcon(nid.hIcon); + Tray_Icon = 1; } #endif @@ -919,22 +948,6 @@ { DPRINTF("BreakConnect"); -#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 - return S_OK; } @@ -1553,7 +1566,7 @@ EnterCriticalSection(&m_mft_lock); - /* Actually set the type or just test it? + /* Actually set the type or just test it? */ BOOL bReallySet = ((dwFlags & MFT_SET_TYPE_TEST_ONLY) == 0); /* If we have samples pending the type can't be changed right now */ @@ -1582,9 +1595,8 @@ hr = OnSetOutputType(pType); } } - #ifdef XVID_USE_TRAYICON - if (SUCCEEDED(hr) && MSG_hwnd == NULL) /* Create message passing window */ + if (SUCCEEDED(hr) && Tray_Icon == 0) /* Create message passing window */ { WNDCLASSEX wc; @@ -1607,17 +1619,20 @@ /* display the tray icon */ NOTIFYICONDATA nid; - - nid.cbSize = sizeof(NOTIFYICONDATA); + ZeroMemory(&nid,sizeof(NOTIFYICONDATA)); + + nid.cbSize = NOTIFYICONDATA_V1_SIZE; nid.hWnd = MSG_hwnd; - nid.uID = 100; - nid.uVersion = NOTIFYICON_VERSION; + nid.uID = 1456; nid.uCallbackMessage = WM_ICONMESSAGE; nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON)); strcpy_s(nid.szTip, 19, "Xvid Video Decoder"); nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; - + Shell_NotifyIcon(NIM_ADD, &nid); + + DestroyIcon(nid.hIcon); + Tray_Icon = 1; } #endif @@ -1950,6 +1965,9 @@ if (FAILED(pSample->GetSampleDuration(&m_timelength))) { m_timelength = INVALID_TIME; } + if (m_timestamp != INVALID_TIME && stats.type == XVID_TYPE_IVOP) { + m_rtFrame = m_timestamp; + } } LeaveCriticalSection(&m_mft_lock);