[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 2018, Wed Jun 15 19:09:17 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    #endif
42    
43  #define XVID_USE_TRAYICON  #define XVID_USE_TRAYICON
 */  
44    
45  #include <windows.h>  #include <windows.h>
46    
# Line 312  Line 313 
313    
314  /* constructor */  /* constructor */
315    
 #define XVID_DLL_NAME "xvidcore.dll"  
   
316  CXvidDecoder::CXvidDecoder(LPUNKNOWN punk, HRESULT *phr) :  CXvidDecoder::CXvidDecoder(LPUNKNOWN punk, HRESULT *phr) :
317      CVideoTransformFilter(NAME("CXvidDecoder"), punk, CLSID_XVID), m_hdll (NULL)      CVideoTransformFilter(TEXT("CXvidDecoder"), punk, CLSID_XVID), m_hdll (NULL)
318  {  {
319          DPRINTF("Constructor");          DPRINTF("Constructor");
320    
# Line 357  Line 356 
356          m_hdll = LoadLibrary(XVID_DLL_NAME);          m_hdll = LoadLibrary(XVID_DLL_NAME);
357          if (m_hdll == NULL) {          if (m_hdll == NULL) {
358                  DPRINTF("dll load failed");                  DPRINTF("dll load failed");
359                  MessageBox(0, XVID_DLL_NAME " not found","Error", MB_TOPMOST);                  MessageBox(0, XVID_DLL_NAME TEXT(" not found"), TEXT("Error"), MB_TOPMOST);
360                  return E_FAIL;                  return E_FAIL;
361          }          }
362    
# Line 365  Line 364 
364          if (xvid_global_func == NULL) {          if (xvid_global_func == NULL) {
365          FreeLibrary(m_hdll);          FreeLibrary(m_hdll);
366          m_hdll = NULL;          m_hdll = NULL;
367                  MessageBox(0, "xvid_global() not found", "Error", MB_TOPMOST);                  MessageBox(0, TEXT("xvid_global() not found"), TEXT("Error"), MB_TOPMOST);
368                  return E_FAIL;                  return E_FAIL;
369          }          }
370    
# Line 374  Line 373 
373          xvid_global_func = NULL;          xvid_global_func = NULL;
374          FreeLibrary(m_hdll);          FreeLibrary(m_hdll);
375          m_hdll = NULL;          m_hdll = NULL;
376                  MessageBox(0, "xvid_decore() not found", "Error", MB_TOPMOST);                  MessageBox(0, TEXT("xvid_decore() not found"), TEXT("Error"), MB_TOPMOST);
377                  return E_FAIL;                  return E_FAIL;
378          }          }
379    
# Line 384  Line 383 
383          xvid_decore_func = NULL;          xvid_decore_func = NULL;
384          FreeLibrary(m_hdll);          FreeLibrary(m_hdll);
385          m_hdll = NULL;          m_hdll = NULL;
386                  MessageBox(0, "xvid_global() failed", "Error", MB_TOPMOST);                  MessageBox(0, TEXT("xvid_global() failed"), TEXT("Error"), MB_TOPMOST);
387                  return E_FAIL;                  return E_FAIL;
388          }          }
389    
# Line 394  Line 393 
393          xvid_decore_func = NULL;          xvid_decore_func = NULL;
394          FreeLibrary(m_hdll);          FreeLibrary(m_hdll);
395          m_hdll = NULL;          m_hdll = NULL;
396                  MessageBox(0, "xvid_global() failed", "Error", MB_TOPMOST);                  MessageBox(0, TEXT("xvid_global() failed"), TEXT("Error"), MB_TOPMOST);
397                  return E_FAIL;                  return E_FAIL;
398          }          }
399    
# Line 816  Line 815 
815  /* (internal function) change colorspace */  /* (internal function) change colorspace */
816  #define CALC_BI_STRIDE(width,bitcount)  ((((width * bitcount) + 31) & ~31) >> 3)  #define CALC_BI_STRIDE(width,bitcount)  ((((width * bitcount) + 31) & ~31) >> 3)
817    
818  HRESULT CXvidDecoder::ChangeColorspace(GUID subtype, GUID formattype, void * format)  HRESULT CXvidDecoder::ChangeColorspace(GUID subtype, GUID formattype, void * format, int noflip)
819  {  {
820          DWORD biWidth;          DWORD biWidth;
821    
# Line 839  Line 838 
838                  return S_FALSE;                  return S_FALSE;
839          }          }
840    
841            if (noflip) rgb_flip = 0;
842    
843          if (subtype == CLSID_MEDIASUBTYPE_IYUV)          if (subtype == CLSID_MEDIASUBTYPE_IYUV)
844          {          {
845                  DPRINTF("IYUV");                  DPRINTF("IYUV");
# Line 912  Line 913 
913    
914          if (direction == PINDIR_OUTPUT)          if (direction == PINDIR_OUTPUT)
915          {          {
916                  return ChangeColorspace(*pmt->Subtype(), *pmt->FormatType(), pmt->Format());                  return ChangeColorspace(*pmt->Subtype(), *pmt->FormatType(), pmt->Format(), 0);
917          }          }
918    
919          return S_OK;          return S_OK;
# Line 947  Line 948 
948                  wc.hInstance = (HINSTANCE) g_xvid_hInst;                  wc.hInstance = (HINSTANCE) g_xvid_hInst;
949                  wc.hbrBackground = (HBRUSH) GetStockObject(NULL_BRUSH);                  wc.hbrBackground = (HBRUSH) GetStockObject(NULL_BRUSH);
950                  wc.lpszMenuName = NULL;                  wc.lpszMenuName = NULL;
951                  wc.lpszClassName = "XVID_MSG_WINDOW";                  wc.lpszClassName = TEXT("XVID_MSG_WINDOW");
952                  wc.hIcon = NULL;                  wc.hIcon = NULL;
953                  wc.hIconSm = NULL;                  wc.hIconSm = NULL;
954                  wc.hCursor = NULL;                  wc.hCursor = NULL;
955                  RegisterClassEx(&wc);                  RegisterClassEx(&wc);
956    
957                  MSG_hwnd = CreateWindowEx(0, "XVID_MSG_WINDOW", NULL, 0, CW_USEDEFAULT,                  MSG_hwnd = CreateWindowEx(0, TEXT("XVID_MSG_WINDOW"), NULL, 0, CW_USEDEFAULT,
958                                    CW_USEDEFAULT, 0, 0, HWND_MESSAGE, NULL, (HINSTANCE) g_xvid_hInst, NULL);                                    CW_USEDEFAULT, 0, 0, HWND_MESSAGE, NULL, (HINSTANCE) g_xvid_hInst, NULL);
959    
960                  /* display the tray icon */                  /* display the tray icon */
# Line 965  Line 966 
966                  nid.uID = 1456;                  nid.uID = 1456;
967                  nid.uCallbackMessage = WM_ICONMESSAGE;                  nid.uCallbackMessage = WM_ICONMESSAGE;
968                  nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON));                  nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON));
969                  strcpy_s(nid.szTip, 19, "Xvid Video Decoder");                  lstrcpy(nid.szTip, TEXT("Xvid Video Decoder"));
970                  nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;                  nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
971    
972                  Shell_NotifyIcon(NIM_ADD, &nid);                  Shell_NotifyIcon(NIM_ADD, &nid);
# Line 1049  Line 1050 
1050          {          {
1051                  HRESULT result;                  HRESULT result;
1052    
1053                  result = ChangeColorspace(mtOut->subtype, mtOut->formattype, mtOut->pbFormat);                  result = ChangeColorspace(mtOut->subtype, mtOut->formattype, mtOut->pbFormat, 0);
1054                  DeleteMediaType(mtOut);                  DeleteMediaType(mtOut);
1055    
1056                  if (result != S_OK)                  if (result != S_OK)
# Line 1630  Line 1631 
1631                          hr = MFCreateAMMediaTypeFromMFMediaType(pType, GUID_NULL, &am);                          hr = MFCreateAMMediaTypeFromMFMediaType(pType, GUID_NULL, &am);
1632    
1633                          if (SUCCEEDED(hr)) {                          if (SUCCEEDED(hr)) {
1634                                  if (FAILED(ChangeColorspace(am->subtype, am->formattype, am->pbFormat))) {                                  if (FAILED(ChangeColorspace(am->subtype, am->formattype, am->pbFormat, 1))) {
1635                                          DPRINTF("(MFT)InternalCheckOutputType (MF_E_INVALIDTYPE)");                                          DPRINTF("(MFT)InternalCheckOutputType (MF_E_INVALIDTYPE)");
1636                                          return MF_E_INVALIDTYPE;                                          return MF_E_INVALIDTYPE;
1637                                  }                                  }
# Line 1659  Line 1660 
1660                  wc.hInstance = (HINSTANCE) g_xvid_hInst;                  wc.hInstance = (HINSTANCE) g_xvid_hInst;
1661                  wc.hbrBackground = (HBRUSH) GetStockObject(NULL_BRUSH);                  wc.hbrBackground = (HBRUSH) GetStockObject(NULL_BRUSH);
1662                  wc.lpszMenuName = NULL;                  wc.lpszMenuName = NULL;
1663                  wc.lpszClassName = "XVID_MSG_WINDOW";                  wc.lpszClassName = TEXT("XVID_MSG_WINDOW");
1664                  wc.hIcon = NULL;                  wc.hIcon = NULL;
1665                  wc.hIconSm = NULL;                  wc.hIconSm = NULL;
1666                  wc.hCursor = NULL;                  wc.hCursor = NULL;
1667                  RegisterClassEx(&wc);                  RegisterClassEx(&wc);
1668    
1669                  MSG_hwnd = CreateWindowEx(0, "XVID_MSG_WINDOW", NULL, 0, CW_USEDEFAULT,                  MSG_hwnd = CreateWindowEx(0, TEXT("XVID_MSG_WINDOW"), NULL, 0, CW_USEDEFAULT,
1670                                    CW_USEDEFAULT, 0, 0, HWND_MESSAGE, NULL, (HINSTANCE) g_xvid_hInst, NULL);                                    CW_USEDEFAULT, 0, 0, HWND_MESSAGE, NULL, (HINSTANCE) g_xvid_hInst, NULL);
1671    
1672                  /* display the tray icon */                  /* display the tray icon */
# Line 1677  Line 1678 
1678                  nid.uID = 1456;                  nid.uID = 1456;
1679                  nid.uCallbackMessage = WM_ICONMESSAGE;                  nid.uCallbackMessage = WM_ICONMESSAGE;
1680                  nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON));                  nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON));
1681                  strcpy_s(nid.szTip, 19, "Xvid Video Decoder");                  lstrcpy(nid.szTip, TEXT("Xvid Video Decoder"));
1682                  nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;                  nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
1683    
1684                  Shell_NotifyIcon(NIM_ADD, &nid);                  Shell_NotifyIcon(NIM_ADD, &nid);
# Line 1906  Line 1907 
1907          EnterCriticalSection(&m_mft_lock);          EnterCriticalSection(&m_mft_lock);
1908    
1909          HRESULT hr = S_OK;          HRESULT hr = S_OK;
1910          IMFMediaBuffer *pBuffer;          IMFMediaBuffer *pBuffer = NULL;
1911    
1912          if (SUCCEEDED(hr)) {          if (SUCCEEDED(hr)) {
1913                  hr = pSample->ConvertToContiguousBuffer(&pBuffer);                  hr = pSample->ConvertToContiguousBuffer(&pBuffer);
# Line 2160  Line 2161 
2161          }          }
2162    
2163          if (m_hdll == NULL) {          if (m_hdll == NULL) {
2164                  HRESULT hr = OpenLib();                  HRESULT hr2 = OpenLib();
2165    
2166                  if (FAILED(hr) || (m_hdll == NULL)) // Paranoid checks.                  if (FAILED(hr2) || (m_hdll == NULL)) // Paranoid checks.
2167                          hr = MF_E_INVALIDTYPE;                          hr = MF_E_INVALIDTYPE;
2168          }          }
2169    

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

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