[svn] / branches / release-1_3-branch / xvidcore / dshow / src / CXvidDecoder.cpp Repository:
ViewVC logotype

Diff of /branches/release-1_3-branch/xvidcore/dshow/src/CXvidDecoder.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1898, Sun Oct 17 18:31:52 2010 UTC revision 1916, Wed Dec 22 15:21:13 2010 UTC
# Line 20  Line 20 
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 2010-12-22 15:21: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    
# Line 44  Line 36 
36          C:\DX90SDK\Samples\C++\DirectShow\BaseClasses\Debug          C:\DX90SDK\Samples\C++\DirectShow\BaseClasses\Debug
37  */  */
38    
39  //#define XVID_USE_MFT  #define XVID_USE_MFT
40  //#define XVID_USE_TRAYICON  #define XVID_USE_TRAYICON
41    
42  #include <windows.h>  #include <windows.h>
43    
# Line 170  Line 162 
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)
# Line 191  Line 184 
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          }          }
# Line 301  Line 304 
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;
# Line 331  Line 330 
330          xvid_gbl_init_t init;          xvid_gbl_init_t init;
331          memset(&init, 0, sizeof(init));          memset(&init, 0, sizeof(init));
332          init.version = XVID_VERSION;          init.version = XVID_VERSION;
333            init.cpu_flags = g_config.cpu;
334    
335            xvid_gbl_info_t info;
336            memset(&info, 0, sizeof(info));
337            info.version = XVID_VERSION;
338    
339          m_hdll = LoadLibrary(XVID_DLL_NAME);          m_hdll = LoadLibrary(XVID_DLL_NAME);
340          if (m_hdll == NULL) {          if (m_hdll == NULL) {
# Line 366  Line 370 
370                  return E_FAIL;                  return E_FAIL;
371          }          }
372    
373            if (xvid_global_func(0, XVID_GBL_INFO, &info, NULL) < 0)
374            {
375            xvid_global_func = NULL;
376            xvid_decore_func = NULL;
377            FreeLibrary(m_hdll);
378            m_hdll = NULL;
379                    MessageBox(0, "xvid_global() failed", "Error", MB_TOPMOST);
380                    return E_FAIL;
381            }
382    
383          memset(&m_create, 0, sizeof(m_create));          memset(&m_create, 0, sizeof(m_create));
384          m_create.version = XVID_VERSION;          m_create.version = XVID_VERSION;
385          m_create.handle = NULL;          m_create.handle = NULL;
386        /* Decoder threads */
387        if (g_config.cpu & XVID_CPU_FORCE) {
388                    m_create.num_threads = g_config.num_threads;
389            }
390            else {
391            m_create.num_threads = info.num_threads; /* Autodetect */
392                    g_config.num_threads = info.num_threads;
393            }
394    
395          memset(&m_frame, 0, sizeof(m_frame));          memset(&m_frame, 0, sizeof(m_frame));
396          m_frame.version = XVID_VERSION;          m_frame.version = XVID_VERSION;
# Line 456  Line 478 
478  CXvidDecoder::~CXvidDecoder()  CXvidDecoder::~CXvidDecoder()
479  {  {
480      DPRINTF("Destructor");      DPRINTF("Destructor");
         CloseLib();  
481    
482  #ifdef XVID_USE_TRAYICON  #ifdef XVID_USE_TRAYICON
483          if (MSG_hwnd != NULL) {          if (Tray_Icon) { /* Destroy tray icon */
484                  NOTIFYICONDATA nid;                  NOTIFYICONDATA nid;
485                  nid.cbSize = sizeof(NOTIFYICONDATA);                  ZeroMemory(&nid,sizeof(NOTIFYICONDATA));
486    
487                    nid.cbSize = NOTIFYICONDATA_V1_SIZE;
488                  nid.hWnd = MSG_hwnd;                  nid.hWnd = MSG_hwnd;
489                  nid.uID = 100;                  nid.uID = 1456;
490    
491                  Shell_NotifyIcon(NIM_DELETE, &nid);                  Shell_NotifyIcon(NIM_DELETE, &nid);
492                    Tray_Icon = 0;
                 DestroyWindow(MSG_hwnd);  
                 MSG_hwnd = NULL;  
493          }          }
494  #endif  #endif
495    
496            /* Close xvidcore library */
497            CloseLib();
498    
499  #if defined(XVID_USE_MFT)  #if defined(XVID_USE_MFT)
500          DeleteCriticalSection(&m_mft_lock);          DeleteCriticalSection(&m_mft_lock);
501  #endif  #endif
# Line 874  Line 898 
898          DPRINTF("CompleteConnect");          DPRINTF("CompleteConnect");
899    
900  #ifdef XVID_USE_TRAYICON  #ifdef XVID_USE_TRAYICON
901          if ((direction == PINDIR_OUTPUT) && (MSG_hwnd == NULL))          if ((direction == PINDIR_OUTPUT) && (Tray_Icon == 0))
902          {          {
903                  WNDCLASSEX wc;                  WNDCLASSEX wc;
904    
# Line 897  Line 921 
921    
922                  /* display the tray icon */                  /* display the tray icon */
923                  NOTIFYICONDATA nid;                  NOTIFYICONDATA nid;
924                    ZeroMemory(&nid,sizeof(NOTIFYICONDATA));
925    
926                  nid.cbSize = sizeof(NOTIFYICONDATA);                  nid.cbSize = NOTIFYICONDATA_V1_SIZE;
927                  nid.hWnd = MSG_hwnd;                  nid.hWnd = MSG_hwnd;
928                  nid.uID = 100;                  nid.uID = 1456;
                 nid.uVersion = NOTIFYICON_VERSION;  
929                  nid.uCallbackMessage = WM_ICONMESSAGE;                  nid.uCallbackMessage = WM_ICONMESSAGE;
930                  nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON));                  nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON));
931                  strcpy_s(nid.szTip, 19, "Xvid Video Decoder");                  strcpy_s(nid.szTip, 19, "Xvid Video Decoder");
932                  nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;                  nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
933    
934                  Shell_NotifyIcon(NIM_ADD, &nid);                  Shell_NotifyIcon(NIM_ADD, &nid);
935    
936                    DestroyIcon(nid.hIcon);
937                    Tray_Icon = 1;
938          }          }
939  #endif  #endif
940    
# Line 919  Line 946 
946  {  {
947          DPRINTF("BreakConnect");          DPRINTF("BreakConnect");
948    
 #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  
   
949          return S_OK;          return S_OK;
950  }  }
951    
# Line 1553  Line 1564 
1564    
1565          EnterCriticalSection(&m_mft_lock);          EnterCriticalSection(&m_mft_lock);
1566    
1567          /* Actually set the type or just test it?          /* Actually set the type or just test it? */
1568          BOOL bReallySet = ((dwFlags & MFT_SET_TYPE_TEST_ONLY) == 0);          BOOL bReallySet = ((dwFlags & MFT_SET_TYPE_TEST_ONLY) == 0);
1569    
1570          /* 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 */
# Line 1582  Line 1593 
1593                          hr = OnSetOutputType(pType);                          hr = OnSetOutputType(pType);
1594                  }                  }
1595          }          }
   
1596  #ifdef XVID_USE_TRAYICON  #ifdef XVID_USE_TRAYICON
1597          if (SUCCEEDED(hr) && MSG_hwnd == NULL) /* Create message passing window */          if (SUCCEEDED(hr) && Tray_Icon == 0) /* Create message passing window */
1598          {          {
1599                  WNDCLASSEX wc;                  WNDCLASSEX wc;
1600    
# Line 1607  Line 1617 
1617    
1618                  /* display the tray icon */                  /* display the tray icon */
1619                  NOTIFYICONDATA nid;                  NOTIFYICONDATA nid;
1620                    ZeroMemory(&nid,sizeof(NOTIFYICONDATA));
1621    
1622                  nid.cbSize = sizeof(NOTIFYICONDATA);                  nid.cbSize = NOTIFYICONDATA_V1_SIZE;
1623                  nid.hWnd = MSG_hwnd;                  nid.hWnd = MSG_hwnd;
1624                  nid.uID = 100;                  nid.uID = 1456;
                 nid.uVersion = NOTIFYICON_VERSION;  
1625                  nid.uCallbackMessage = WM_ICONMESSAGE;                  nid.uCallbackMessage = WM_ICONMESSAGE;
1626                  nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON));                  nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON));
1627                  strcpy_s(nid.szTip, 19, "Xvid Video Decoder");                  strcpy_s(nid.szTip, 19, "Xvid Video Decoder");
1628                  nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;                  nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
1629    
1630                  Shell_NotifyIcon(NIM_ADD, &nid);                  Shell_NotifyIcon(NIM_ADD, &nid);
1631    
1632                    DestroyIcon(nid.hIcon);
1633                    Tray_Icon = 1;
1634          }          }
1635  #endif  #endif
1636    
# Line 1950  Line 1963 
1963                  if (FAILED(pSample->GetSampleDuration(&m_timelength))) {                  if (FAILED(pSample->GetSampleDuration(&m_timelength))) {
1964                          m_timelength = INVALID_TIME;                          m_timelength = INVALID_TIME;
1965                  }                  }
1966                    if (m_timestamp != INVALID_TIME && stats.type == XVID_TYPE_IVOP) {
1967                            m_rtFrame = m_timestamp;
1968                    }
1969          }          }
1970    
1971          LeaveCriticalSection(&m_mft_lock);          LeaveCriticalSection(&m_mft_lock);

Legend:
Removed from v.1898  
changed lines
  Added in v.1916

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4