[svn] / trunk / xvidcore / dshow / src / CXvidDecoder.cpp Repository:
ViewVC logotype

Diff of /trunk/xvidcore/dshow/src/CXvidDecoder.cpp

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

revision 1949, Mon Feb 14 16:59:16 2011 UTC revision 2022, Wed Jul 6 13:50:28 2011 UTC
# Line 3  Line 3 
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-2011 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
# 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.28 2011-02-14 16:59:16 Isibaar Exp $   * $Id$
24   *   *
25   ****************************************************************************/   ****************************************************************************/
26    
# Line 36  Line 36 
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    
# Line 176  Line 175 
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;
# Line 218  Line 216 
216    
217          return TRUE; /* ok */          return TRUE; /* ok */
218  }  }
 #endif  
219    
220  STDAPI DllRegisterServer()  STDAPI DllRegisterServer()
221  {  {
# Line 312  Line 309 
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(TEXT("CXvidDecoder"), punk, CLSID_XVID), m_hdll (NULL)
314  {  {
315          DPRINTF("Constructor");          DPRINTF("Constructor");
316    
# Line 357  Line 352 
352          m_hdll = LoadLibrary(XVID_DLL_NAME);          m_hdll = LoadLibrary(XVID_DLL_NAME);
353          if (m_hdll == NULL) {          if (m_hdll == NULL) {
354                  DPRINTF("dll load failed");                  DPRINTF("dll load failed");
355                  MessageBox(0, XVID_DLL_NAME " not found","Error", MB_TOPMOST);                  MessageBox(0, XVID_DLL_NAME TEXT(" not found"), TEXT("Error"), MB_TOPMOST);
356                  return E_FAIL;                  return E_FAIL;
357          }          }
358    
# Line 365  Line 360 
360          if (xvid_global_func == NULL) {          if (xvid_global_func == NULL) {
361          FreeLibrary(m_hdll);          FreeLibrary(m_hdll);
362          m_hdll = NULL;          m_hdll = NULL;
363                  MessageBox(0, "xvid_global() not found", "Error", MB_TOPMOST);                  MessageBox(0, TEXT("xvid_global() not found"), TEXT("Error"), MB_TOPMOST);
364                  return E_FAIL;                  return E_FAIL;
365          }          }
366    
# Line 374  Line 369 
369          xvid_global_func = NULL;          xvid_global_func = NULL;
370          FreeLibrary(m_hdll);          FreeLibrary(m_hdll);
371          m_hdll = NULL;          m_hdll = NULL;
372                  MessageBox(0, "xvid_decore() not found", "Error", MB_TOPMOST);                  MessageBox(0, TEXT("xvid_decore() not found"), TEXT("Error"), MB_TOPMOST);
373                  return E_FAIL;                  return E_FAIL;
374          }          }
375    
# Line 384  Line 379 
379          xvid_decore_func = NULL;          xvid_decore_func = NULL;
380          FreeLibrary(m_hdll);          FreeLibrary(m_hdll);
381          m_hdll = NULL;          m_hdll = NULL;
382                  MessageBox(0, "xvid_global() failed", "Error", MB_TOPMOST);                  MessageBox(0, TEXT("xvid_global() failed"), TEXT("Error"), MB_TOPMOST);
383                  return E_FAIL;                  return E_FAIL;
384          }          }
385    
# Line 394  Line 389 
389          xvid_decore_func = NULL;          xvid_decore_func = NULL;
390          FreeLibrary(m_hdll);          FreeLibrary(m_hdll);
391          m_hdll = NULL;          m_hdll = NULL;
392                  MessageBox(0, "xvid_global() failed", "Error", MB_TOPMOST);                  MessageBox(0, TEXT("xvid_global() failed"), TEXT("Error"), MB_TOPMOST);
393                  return E_FAIL;                  return E_FAIL;
394          }          }
395    
# Line 497  Line 492 
492  {  {
493      DPRINTF("Destructor");      DPRINTF("Destructor");
494    
 #ifdef XVID_USE_TRAYICON  
495          if (Tray_Icon) { /* Destroy tray icon */          if (Tray_Icon) { /* Destroy tray icon */
496                  NOTIFYICONDATA nid;                  NOTIFYICONDATA nid;
497                  ZeroMemory(&nid,sizeof(NOTIFYICONDATA));                  ZeroMemory(&nid,sizeof(NOTIFYICONDATA));
# Line 509  Line 503 
503                  Shell_NotifyIcon(NIM_DELETE, &nid);                  Shell_NotifyIcon(NIM_DELETE, &nid);
504                  Tray_Icon = 0;                  Tray_Icon = 0;
505          }          }
 #endif  
506    
507          /* Close xvidcore library */          /* Close xvidcore library */
508          CloseLib();          CloseLib();
# Line 816  Line 809 
809  /* (internal function) change colorspace */  /* (internal function) change colorspace */
810  #define CALC_BI_STRIDE(width,bitcount)  ((((width * bitcount) + 31) & ~31) >> 3)  #define CALC_BI_STRIDE(width,bitcount)  ((((width * bitcount) + 31) & ~31) >> 3)
811    
812  HRESULT CXvidDecoder::ChangeColorspace(GUID subtype, GUID formattype, void * format)  HRESULT CXvidDecoder::ChangeColorspace(GUID subtype, GUID formattype, void * format, int noflip)
813  {  {
814          DWORD biWidth;          DWORD biWidth;
815    
# Line 839  Line 832 
832                  return S_FALSE;                  return S_FALSE;
833          }          }
834    
835            if (noflip) rgb_flip = 0;
836    
837          if (subtype == CLSID_MEDIASUBTYPE_IYUV)          if (subtype == CLSID_MEDIASUBTYPE_IYUV)
838          {          {
839                  DPRINTF("IYUV");                  DPRINTF("IYUV");
# Line 912  Line 907 
907    
908          if (direction == PINDIR_OUTPUT)          if (direction == PINDIR_OUTPUT)
909          {          {
910                  return ChangeColorspace(*pmt->Subtype(), *pmt->FormatType(), pmt->Format());                  return ChangeColorspace(*pmt->Subtype(), *pmt->FormatType(), pmt->Format(), 0);
911          }          }
912    
913          return S_OK;          return S_OK;
# Line 934  Line 929 
929  {  {
930          DPRINTF("CompleteConnect");          DPRINTF("CompleteConnect");
931    
932  #ifdef XVID_USE_TRAYICON          if ((direction == PINDIR_OUTPUT) && (Tray_Icon == 0) && (g_config.bTrayIcon != 0))
         if ((direction == PINDIR_OUTPUT) && (Tray_Icon == 0))  
933          {          {
934                  WNDCLASSEX wc;                  WNDCLASSEX wc;
935    
# Line 947  Line 941 
941                  wc.hInstance = (HINSTANCE) g_xvid_hInst;                  wc.hInstance = (HINSTANCE) g_xvid_hInst;
942                  wc.hbrBackground = (HBRUSH) GetStockObject(NULL_BRUSH);                  wc.hbrBackground = (HBRUSH) GetStockObject(NULL_BRUSH);
943                  wc.lpszMenuName = NULL;                  wc.lpszMenuName = NULL;
944                  wc.lpszClassName = "XVID_MSG_WINDOW";                  wc.lpszClassName = TEXT("XVID_MSG_WINDOW");
945                  wc.hIcon = NULL;                  wc.hIcon = NULL;
946                  wc.hIconSm = NULL;                  wc.hIconSm = NULL;
947                  wc.hCursor = NULL;                  wc.hCursor = NULL;
948                  RegisterClassEx(&wc);                  RegisterClassEx(&wc);
949    
950                  MSG_hwnd = CreateWindowEx(0, "XVID_MSG_WINDOW", NULL, 0, CW_USEDEFAULT,                  MSG_hwnd = CreateWindowEx(0, TEXT("XVID_MSG_WINDOW"), NULL, 0, CW_USEDEFAULT,
951                                    CW_USEDEFAULT, 0, 0, HWND_MESSAGE, NULL, (HINSTANCE) g_xvid_hInst, NULL);                                    CW_USEDEFAULT, 0, 0, HWND_MESSAGE, NULL, (HINSTANCE) g_xvid_hInst, NULL);
952    
953                  /* display the tray icon */                  /* display the tray icon */
# Line 965  Line 959 
959                  nid.uID = 1456;                  nid.uID = 1456;
960                  nid.uCallbackMessage = WM_ICONMESSAGE;                  nid.uCallbackMessage = WM_ICONMESSAGE;
961                  nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON));                  nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON));
962                  strcpy_s(nid.szTip, 19, "Xvid Video Decoder");                  lstrcpy(nid.szTip, TEXT("Xvid Video Decoder"));
963                  nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;                  nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
964    
965                  Shell_NotifyIcon(NIM_ADD, &nid);                  Shell_NotifyIcon(NIM_ADD, &nid);
# Line 973  Line 967 
967                  DestroyIcon(nid.hIcon);                  DestroyIcon(nid.hIcon);
968                  Tray_Icon = 1;                  Tray_Icon = 1;
969          }          }
 #endif  
970    
971          return S_OK;          return S_OK;
972  }  }
# Line 1049  Line 1042 
1042          {          {
1043                  HRESULT result;                  HRESULT result;
1044    
1045                  result = ChangeColorspace(mtOut->subtype, mtOut->formattype, mtOut->pbFormat);                  result = ChangeColorspace(mtOut->subtype, mtOut->formattype, mtOut->pbFormat, 0);
1046                  DeleteMediaType(mtOut);                  DeleteMediaType(mtOut);
1047    
1048                  if (result != S_OK)                  if (result != S_OK)
# Line 1630  Line 1623 
1623                          hr = MFCreateAMMediaTypeFromMFMediaType(pType, GUID_NULL, &am);                          hr = MFCreateAMMediaTypeFromMFMediaType(pType, GUID_NULL, &am);
1624    
1625                          if (SUCCEEDED(hr)) {                          if (SUCCEEDED(hr)) {
1626                                  if (FAILED(ChangeColorspace(am->subtype, am->formattype, am->pbFormat))) {                                  if (FAILED(ChangeColorspace(am->subtype, am->formattype, am->pbFormat, 1))) {
1627                                          DPRINTF("(MFT)InternalCheckOutputType (MF_E_INVALIDTYPE)");                                          DPRINTF("(MFT)InternalCheckOutputType (MF_E_INVALIDTYPE)");
1628                                          return MF_E_INVALIDTYPE;                                          return MF_E_INVALIDTYPE;
1629                                  }                                  }
# Line 1646  Line 1639 
1639                          hr = OnSetOutputType(pType);                          hr = OnSetOutputType(pType);
1640                  }                  }
1641          }          }
1642  #ifdef XVID_USE_TRAYICON  
1643          if (SUCCEEDED(hr) && Tray_Icon == 0) /* Create message passing window */          if (SUCCEEDED(hr) && (Tray_Icon == 0) && (g_config.bTrayIcon != 0)) /* Create message passing window */
1644          {          {
1645                  WNDCLASSEX wc;                  WNDCLASSEX wc;
1646    
# Line 1659  Line 1652 
1652                  wc.hInstance = (HINSTANCE) g_xvid_hInst;                  wc.hInstance = (HINSTANCE) g_xvid_hInst;
1653                  wc.hbrBackground = (HBRUSH) GetStockObject(NULL_BRUSH);                  wc.hbrBackground = (HBRUSH) GetStockObject(NULL_BRUSH);
1654                  wc.lpszMenuName = NULL;                  wc.lpszMenuName = NULL;
1655                  wc.lpszClassName = "XVID_MSG_WINDOW";                  wc.lpszClassName = TEXT("XVID_MSG_WINDOW");
1656                  wc.hIcon = NULL;                  wc.hIcon = NULL;
1657                  wc.hIconSm = NULL;                  wc.hIconSm = NULL;
1658                  wc.hCursor = NULL;                  wc.hCursor = NULL;
1659                  RegisterClassEx(&wc);                  RegisterClassEx(&wc);
1660    
1661                  MSG_hwnd = CreateWindowEx(0, "XVID_MSG_WINDOW", NULL, 0, CW_USEDEFAULT,                  MSG_hwnd = CreateWindowEx(0, TEXT("XVID_MSG_WINDOW"), NULL, 0, CW_USEDEFAULT,
1662                                    CW_USEDEFAULT, 0, 0, HWND_MESSAGE, NULL, (HINSTANCE) g_xvid_hInst, NULL);                                    CW_USEDEFAULT, 0, 0, HWND_MESSAGE, NULL, (HINSTANCE) g_xvid_hInst, NULL);
1663    
1664                  /* display the tray icon */                  /* display the tray icon */
# Line 1677  Line 1670 
1670                  nid.uID = 1456;                  nid.uID = 1456;
1671                  nid.uCallbackMessage = WM_ICONMESSAGE;                  nid.uCallbackMessage = WM_ICONMESSAGE;
1672                  nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON));                  nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON));
1673                  strcpy_s(nid.szTip, 19, "Xvid Video Decoder");                  lstrcpy(nid.szTip, TEXT("Xvid Video Decoder"));
1674                  nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;                  nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
1675    
1676                  Shell_NotifyIcon(NIM_ADD, &nid);                  Shell_NotifyIcon(NIM_ADD, &nid);
# Line 1685  Line 1678 
1678                  DestroyIcon(nid.hIcon);                  DestroyIcon(nid.hIcon);
1679                  Tray_Icon = 1;                  Tray_Icon = 1;
1680          }          }
 #endif  
1681    
1682          LeaveCriticalSection(&m_mft_lock);          LeaveCriticalSection(&m_mft_lock);
1683          return hr;          return hr;
# Line 1906  Line 1898 
1898          EnterCriticalSection(&m_mft_lock);          EnterCriticalSection(&m_mft_lock);
1899    
1900          HRESULT hr = S_OK;          HRESULT hr = S_OK;
1901          IMFMediaBuffer *pBuffer;          IMFMediaBuffer *pBuffer = NULL;
1902    
1903          if (SUCCEEDED(hr)) {          if (SUCCEEDED(hr)) {
1904                  hr = pSample->ConvertToContiguousBuffer(&pBuffer);                  hr = pSample->ConvertToContiguousBuffer(&pBuffer);
# Line 2160  Line 2152 
2152          }          }
2153    
2154          if (m_hdll == NULL) {          if (m_hdll == NULL) {
2155                  HRESULT hr = OpenLib();                  HRESULT hr2 = OpenLib();
2156    
2157                  if (FAILED(hr) || (m_hdll == NULL)) // Paranoid checks.                  if (FAILED(hr2) || (m_hdll == NULL)) // Paranoid checks.
2158                          hr = MF_E_INVALIDTYPE;                          hr = MF_E_INVALIDTYPE;
2159          }          }
2160    

Legend:
Removed from v.1949  
changed lines
  Added in v.2022

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