[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 2113, Sun Jun 14 19:17:57 2015 UTC revision 2114, Sun Jun 14 19:18:14 2015 UTC
# Line 178  Line 178 
178  extern HINSTANCE g_xvid_hInst;  extern HINSTANCE g_xvid_hInst;
179    
180  static int GUI_Page = 0;  static int GUI_Page = 0;
181  static int Tray_Icon = 0;  static HWND MSG_hwnd = NULL; /* message handler window */
182    
183  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 );
184    
185  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 188  Line 189 
189          case WM_ICONMESSAGE:          case WM_ICONMESSAGE:
190                  switch(lParam)                  switch(lParam)
191                  {                  {
192                    case WM_LBUTTONUP:
193                  case WM_LBUTTONDBLCLK:                  case WM_LBUTTONDBLCLK:
194                          if (!GUI_Page) {                          if (!GUI_Page) {
195                                  GUI_Page = 1;                                  GUI_Page = 1;
# Line 204  Line 206 
206                  NOTIFYICONDATA nid;                  NOTIFYICONDATA nid;
207                  ZeroMemory(&nid,sizeof(NOTIFYICONDATA));                  ZeroMemory(&nid,sizeof(NOTIFYICONDATA));
208    
209                  nid.cbSize = NOTIFYICONDATA_V1_SIZE;                  nid.cbSize = sizeof(NOTIFYICONDATA);
210                  nid.hWnd = hwnd;                  nid.hWnd = hwnd;
211                  nid.uID = 1456;                  nid.uID = 1456;
   
212                  Shell_NotifyIcon(NIM_DELETE, &nid);                  Shell_NotifyIcon(NIM_DELETE, &nid);
                 Tray_Icon = 0;  
213          default:          default:
214                  return DefWindowProc(hwnd, uMsg, wParam, lParam);                  return DefWindowProc(hwnd, uMsg, wParam, lParam);
215          }          }
# Line 317  Line 317 
317      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...
318      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.
319    
320            m_tray_icon = 0;
321            m_startClock = clock();
322    
323  #if defined(XVID_USE_MFT)  #if defined(XVID_USE_MFT)
324          InitializeCriticalSection(&m_mft_lock);          InitializeCriticalSection(&m_mft_lock);
325          m_pInputType = NULL;          m_pInputType = NULL;
326          m_pOutputType = NULL;          m_pOutputType = NULL;
327            m_pOutputTypeBPP = 32;
328          m_rtFrame = 0;          m_rtFrame = 0;
329          m_duration = 0;          m_duration = 0;
330          m_discont = 0;          m_discont = 0;
331          m_frameRate.Denominator = 1;          m_frameRate.Denominator = 1;
332          m_frameRate.Numerator = 1;          m_frameRate.Numerator = 1;
333            m_thread_handle = NULL;
334  #endif  #endif
335    
336      LoadRegistryInfo();      LoadRegistryInfo();
# Line 340  Line 345 
345  #else  #else
346                  if ((sLen >= 11) && (_strnicmp(&(lpFilename[sLen - 11]), TEXT("dllhost.exe"), 11) == 0)) {                  if ((sLen >= 11) && (_strnicmp(&(lpFilename[sLen - 11]), TEXT("dllhost.exe"), 11) == 0)) {
347  #endif  #endif
348                          if (Tray_Icon == 0) Tray_Icon = -1; // create no tray icon upon thumbnail generation                          if (m_tray_icon == 0) m_tray_icon = -1; // create no tray icon upon thumbnail generation
349                  }                  }
                 else  
                         if (Tray_Icon == -1) Tray_Icon = 0; // can show tray icon  
350          }          }
351    
352  }  }
# Line 507  Line 510 
510  {  {
511      DPRINTF("Destructor");      DPRINTF("Destructor");
512    
513          if (Tray_Icon > 0) { /* Destroy tray icon */          if ((MSG_hwnd != NULL) && (m_tray_icon == 1)) { /* Destroy tray icon */
514                  NOTIFYICONDATA nid;                  SendMessage(MSG_hwnd, WM_CLOSE, 0, 0);
                 ZeroMemory(&nid,sizeof(NOTIFYICONDATA));  
   
                 nid.cbSize = NOTIFYICONDATA_V1_SIZE;  
                 nid.hWnd = MSG_hwnd;  
                 nid.uID = 1456;  
   
                 Shell_NotifyIcon(NIM_DELETE, &nid);  
                 Tray_Icon = 0;  
515          }          }
516    
517          /* Close xvidcore library */          /* Close xvidcore library */
518          CloseLib();          CloseLib();
519    
520            clock_t endClock = clock();
521            if (((endClock - m_startClock) / CLOCKS_PER_SEC) > 3) {
522                    SaveRegistryInfo((endClock - m_startClock) / (CLOCKS_PER_SEC / 10));
523            }
524    
525            if ((MSG_hwnd != 0) && (m_tray_icon == 1)) { /* Final clean-up */
526              MSG_hwnd = 0;
527              Sleep(200);
528              m_tray_icon = 0;
529    #if defined(XVID_USE_MFT)
530              if (m_thread_handle) {
531                      TerminateThread(m_thread_handle, 0);
532                      CloseHandle(m_thread_handle);
533                      m_thread_handle = NULL;
534              }
535    #endif
536            }
537    
538  #if defined(XVID_USE_MFT)  #if defined(XVID_USE_MFT)
539          DeleteCriticalSection(&m_mft_lock);          DeleteCriticalSection(&m_mft_lock);
540  #endif  #endif
# Line 824  Line 837 
837  /* (internal function) change colorspace */  /* (internal function) change colorspace */
838  #define CALC_BI_STRIDE(width,bitcount)  ((((width * bitcount) + 31) & ~31) >> 3)  #define CALC_BI_STRIDE(width,bitcount)  ((((width * bitcount) + 31) & ~31) >> 3)
839    
840  HRESULT CXvidDecoder::ChangeColorspace(GUID subtype, GUID formattype, void * format, int noflip)  HRESULT CXvidDecoder::ChangeColorspace(GUID subtype, GUID formattype, void *format, int *bitdepth, int noflip)
841  {  {
842          DWORD biWidth;          DWORD biWidth;
843            *bitdepth = 32;
844    
845          if (formattype == FORMAT_VideoInfo)          if (formattype == FORMAT_VideoInfo)
846          {          {
847                  VIDEOINFOHEADER * vih = (VIDEOINFOHEADER * )format;                  VIDEOINFOHEADER * vih = (VIDEOINFOHEADER * )format;
848                  biWidth = vih->bmiHeader.biWidth;                  biWidth = vih->bmiHeader.biWidth;
849                    *bitdepth = vih->bmiHeader.biBitCount;
850                  out_stride = CALC_BI_STRIDE(vih->bmiHeader.biWidth, vih->bmiHeader.biBitCount);                  out_stride = CALC_BI_STRIDE(vih->bmiHeader.biWidth, vih->bmiHeader.biBitCount);
851                  rgb_flip = (vih->bmiHeader.biHeight < 0 ? 0 : XVID_CSP_VFLIP);                  rgb_flip = (vih->bmiHeader.biHeight < 0 ? 0 : XVID_CSP_VFLIP);
852          }          }
# Line 839  Line 854 
854          {          {
855                  VIDEOINFOHEADER2 * vih2 = (VIDEOINFOHEADER2 * )format;                  VIDEOINFOHEADER2 * vih2 = (VIDEOINFOHEADER2 * )format;
856                  biWidth = vih2->bmiHeader.biWidth;                  biWidth = vih2->bmiHeader.biWidth;
857                    *bitdepth = vih2->bmiHeader.biBitCount;
858                  out_stride = CALC_BI_STRIDE(vih2->bmiHeader.biWidth, vih2->bmiHeader.biBitCount);                  out_stride = CALC_BI_STRIDE(vih2->bmiHeader.biWidth, vih2->bmiHeader.biBitCount);
859                  rgb_flip = (vih2->bmiHeader.biHeight < 0 ? 0 : XVID_CSP_VFLIP);                  rgb_flip = (vih2->bmiHeader.biHeight < 0 ? 0 : XVID_CSP_VFLIP);
860          }          }
# Line 918  Line 934 
934    
935  HRESULT CXvidDecoder::SetMediaType(PIN_DIRECTION direction, const CMediaType *pmt)  HRESULT CXvidDecoder::SetMediaType(PIN_DIRECTION direction, const CMediaType *pmt)
936  {  {
937            int bitdepth;
938          DPRINTF("SetMediaType");          DPRINTF("SetMediaType");
939    
940          if (direction == PINDIR_OUTPUT)          if (direction == PINDIR_OUTPUT)
941          {          {
942                  return ChangeColorspace(*pmt->Subtype(), *pmt->FormatType(), pmt->Format(), 0);                  return ChangeColorspace(*pmt->Subtype(), *pmt->FormatType(), pmt->Format(), &bitdepth, 0);
943          }          }
944    
945          return S_OK;          return S_OK;
# Line 944  Line 961 
961  {  {
962          DPRINTF("CompleteConnect");          DPRINTF("CompleteConnect");
963    
964          if ((direction == PINDIR_OUTPUT) && (Tray_Icon == 0)&& (g_config.bTrayIcon != 0))          if ((direction == PINDIR_OUTPUT) && (MSG_hwnd == 0) && (m_tray_icon == 0) && (g_config.bTrayIcon != 0))
965          {          {
966                  WNDCLASSEX wc;                  WNDCLASSEX wc;
967    
# Line 969  Line 986 
986                  NOTIFYICONDATA nid;                  NOTIFYICONDATA nid;
987                  ZeroMemory(&nid,sizeof(NOTIFYICONDATA));                  ZeroMemory(&nid,sizeof(NOTIFYICONDATA));
988    
989                  nid.cbSize = NOTIFYICONDATA_V1_SIZE;                  nid.cbSize = sizeof(NOTIFYICONDATA);
990                  nid.hWnd = MSG_hwnd;                  nid.hWnd = MSG_hwnd;
991                  nid.uID = 1456;                  nid.uID = 1456;
992                    nid.uVersion = NOTIFYICON_VERSION;
993                  nid.uCallbackMessage = WM_ICONMESSAGE;                  nid.uCallbackMessage = WM_ICONMESSAGE;
994                  nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON));                  nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON));
995                  strcpy_s(nid.szTip, 19, "Xvid Video Decoder");                  strcpy_s(nid.szTip, 19, "Xvid Video Decoder");
996                  nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;                  nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP | NIF_SHOWTIP;
997    
998                  Shell_NotifyIcon(NIM_ADD, &nid);                  Shell_NotifyIcon(NIM_ADD, &nid);
999                    Shell_NotifyIcon(NIM_SETVERSION, &nid);
1000    
1001                  DestroyIcon(nid.hIcon);                  DestroyIcon(nid.hIcon);
1002                  Tray_Icon = 1;                  m_tray_icon = 1;
1003          }          }
1004    
1005          return S_OK;          return S_OK;
# Line 1055  Line 1074 
1074          pOut->GetMediaType(&mtOut);          pOut->GetMediaType(&mtOut);
1075          if (mtOut != NULL)          if (mtOut != NULL)
1076          {          {
1077                    int bitdepth;
1078                  HRESULT result;                  HRESULT result;
1079    
1080                  result = ChangeColorspace(mtOut->subtype, mtOut->formattype, mtOut->pbFormat, 0);                  result = ChangeColorspace(mtOut->subtype, mtOut->formattype, mtOut->pbFormat, &bitdepth, 0);
1081                  DeleteMediaType(mtOut);                  DeleteMediaType(mtOut);
1082    
1083                  if (result != S_OK)                  if (result != S_OK)
# Line 1327  Line 1347 
1347                  pStreamInfo->cbAlignment = 0;                  pStreamInfo->cbAlignment = 0;
1348          }          }
1349          else {          else {
1350                  pStreamInfo->cbSize = m_create.width * abs(m_create.height) * 4; // XXX                  pStreamInfo->cbSize = (m_create.width * abs(m_create.height) * m_pOutputTypeBPP) >> 3;
1351                  pStreamInfo->cbAlignment = 1;                  pStreamInfo->cbAlignment = 1;
1352          }          }
1353    
# Line 1465  Line 1485 
1485                  break;                  break;
1486  }  }
1487          case 1 :          case 1 :
1488    if ( USE_YVYU )
1489    {
1490                csp = MFVideoFormat_YVYU;
1491                bitdepth = 4;
1492                break;
1493    }
1494            case 2 :
1495  if ( USE_UYVY )  if ( USE_UYVY )
1496  {  {
1497                  csp = MFVideoFormat_UYVY;                  csp = MFVideoFormat_UYVY;
1498                  bitdepth = 4;                  bitdepth = 4;
1499                  break;                  break;
1500  }  }
1501          case 2  :          case 3  :
1502                  if ( USE_IYUV )                  if ( USE_IYUV )
1503  {  {
1504                  csp = MFVideoFormat_IYUV;                  csp = MFVideoFormat_IYUV;
1505                  bitdepth = 3;                  bitdepth = 3;
1506                  break;                  break;
1507  }  }
1508          case 3  :          case 4  :
1509  if ( USE_YV12 )  if ( USE_YV12 )
1510  {  {
1511                  csp = MFVideoFormat_YV12;                  csp = MFVideoFormat_YV12;
1512                  bitdepth = 3;                  bitdepth = 3;
1513                  break;                  break;
1514  }  }
1515          case 4 :          case 5 :
1516  if ( USE_RGB32 )  if ( USE_RGB32 )
1517  {  {
1518                  csp = MFVideoFormat_RGB32;                  csp = MFVideoFormat_RGB32;
1519                  bitdepth = 8;                  bitdepth = 8;
1520                  break;                  break;
1521  }  }
1522          case 5 :          case 6 :
1523  if ( USE_RGB24 )  if ( USE_RGB24 )
1524  {  {
1525                  csp = MFVideoFormat_RGB24;                  csp = MFVideoFormat_RGB24;
1526                  bitdepth = 6;                  bitdepth = 6;
1527                  break;                  break;
1528  }  }
1529          case 6 :          case 7 :
1530  if ( USE_RG555 )  if ( USE_RG555 )
1531  {  {
1532                  csp = MFVideoFormat_RGB555;                  csp = MFVideoFormat_RGB555;
1533                  bitdepth = 4;                  bitdepth = 4;
1534                  break;                  break;
1535  }  }
1536          case 7 :          case 8 :
1537  if ( USE_RG565 )  if ( USE_RG565 )
1538  {  {
1539                  csp = MFVideoFormat_RGB565;                  csp = MFVideoFormat_RGB565;
# Line 1544  Line 1571 
1571          }          }
1572    
1573          if (SUCCEEDED(hr)) {          if (SUCCEEDED(hr)) {
1574                  hr = pOutputType->SetUINT32(MF_MT_SAMPLE_SIZE, (m_create.height * m_create.width * bitdepth)>>1);                  hr = pOutputType->SetUINT32(MF_MT_SAMPLE_SIZE, (abs(m_create.height) * m_create.width * bitdepth) >> 1);
1575          }          }
1576    
1577          if (SUCCEEDED(hr)) {          if (SUCCEEDED(hr)) {
1578                  hr = MFSetAttributeSize(pOutputType, MF_MT_FRAME_SIZE, m_create.width, m_create.height);                  hr = MFSetAttributeSize(pOutputType, MF_MT_FRAME_SIZE, m_create.width, abs(m_create.height));
1579          }          }
1580    
1581          if (SUCCEEDED(hr)) {          if (SUCCEEDED(hr)) {
# Line 1596  Line 1623 
1623                  hr = MF_E_TRANSFORM_CANNOT_CHANGE_MEDIATYPE_WHILE_PROCESSING;                  hr = MF_E_TRANSFORM_CANNOT_CHANGE_MEDIATYPE_WHILE_PROCESSING;
1624    
1625          if (SUCCEEDED(hr)) {          if (SUCCEEDED(hr)) {
1626          if (pType) { // /* Check the type */          if (pType) { /* Check the type */
1627              hr = OnCheckInputType(pType);              hr = OnCheckInputType(pType);
1628          }          }
1629          }          }
# Line 1611  Line 1638 
1638          return hr;          return hr;
1639  }  }
1640    
1641    DWORD WINAPI CreateTrayIcon(LPVOID lpParameter)
1642    {
1643            WNDCLASSEX wc;
1644    
1645            wc.cbSize = sizeof(WNDCLASSEX);
1646            wc.lpfnWndProc = msg_proc;
1647            wc.style = CS_HREDRAW | CS_VREDRAW;
1648            wc.cbWndExtra = 0;
1649            wc.cbClsExtra = 0;
1650            wc.hInstance = (HINSTANCE)g_xvid_hInst;
1651            wc.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH);
1652            wc.lpszMenuName = NULL;
1653            wc.lpszClassName = "XVID_MSG_WINDOW";
1654            wc.hIcon = NULL;
1655            wc.hIconSm = NULL;
1656            wc.hCursor = NULL;
1657            RegisterClassEx(&wc);
1658    
1659            MSG_hwnd = CreateWindowEx(0, "XVID_MSG_WINDOW", NULL, 0, CW_USEDEFAULT,
1660                    CW_USEDEFAULT, 0, 0, HWND_MESSAGE, NULL, (HINSTANCE)g_xvid_hInst, NULL);
1661    
1662            /* display the tray icon */
1663            NOTIFYICONDATA nid;
1664            ZeroMemory(&nid, sizeof(NOTIFYICONDATA));
1665    
1666            nid.cbSize = sizeof(NOTIFYICONDATA);
1667            nid.hWnd = MSG_hwnd;
1668            nid.uID = 1456;
1669            nid.uVersion = NOTIFYICON_VERSION;
1670            nid.uCallbackMessage = WM_ICONMESSAGE;
1671            nid.hIcon = LoadIcon(g_xvid_hInst, MAKEINTRESOURCE(IDI_ICON));
1672            strcpy_s(nid.szTip, 19, "Xvid Video Decoder");
1673            nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP | NIF_SHOWTIP;
1674    
1675            Shell_NotifyIcon(NIM_ADD, &nid);
1676            Shell_NotifyIcon(NIM_SETVERSION, &nid);
1677    
1678            DestroyIcon(nid.hIcon);
1679    
1680            MSG msg;
1681            while (MSG_hwnd && GetMessage(&msg, MSG_hwnd, 0, 0)) {
1682                    TranslateMessage(&msg);
1683                    DispatchMessage(&msg);
1684            }
1685    
1686            return 0;
1687    }
1688    
1689  HRESULT CXvidDecoder::MFTSetOutputType(DWORD dwOutputStreamID, IMFMediaType *pType, DWORD dwFlags)  HRESULT CXvidDecoder::MFTSetOutputType(DWORD dwOutputStreamID, IMFMediaType *pType, DWORD dwFlags)
1690  {  {
1691          DPRINTF("(MFT)SetOutputType");          DPRINTF("(MFT)SetOutputType");
# Line 1632  Line 1707 
1707          if (HasPendingOutput())          if (HasPendingOutput())
1708                  hr = MF_E_TRANSFORM_CANNOT_CHANGE_MEDIATYPE_WHILE_PROCESSING;                  hr = MF_E_TRANSFORM_CANNOT_CHANGE_MEDIATYPE_WHILE_PROCESSING;
1709    
1710            int bitdepth;
1711          if (SUCCEEDED(hr)) {          if (SUCCEEDED(hr)) {
1712                  if (pType) { /* Check the type */                  if (pType) { /* Check the type */
1713                          AM_MEDIA_TYPE *am;                          AM_MEDIA_TYPE *am;
1714                          hr = MFCreateAMMediaTypeFromMFMediaType(pType, GUID_NULL, &am);                          hr = MFCreateAMMediaTypeFromMFMediaType(pType, GUID_NULL, &am);
1715    
1716                          if (SUCCEEDED(hr)) {                          if (SUCCEEDED(hr)) {
1717                                  if (FAILED(ChangeColorspace(am->subtype, am->formattype, am->pbFormat, 1))) {                                  if (FAILED(ChangeColorspace(am->subtype, am->formattype, am->pbFormat, &bitdepth, 1))) {
1718                                          DPRINTF("(MFT)InternalCheckOutputType (MF_E_INVALIDTYPE)");                                          DPRINTF("(MFT)InternalCheckOutputType (MF_E_INVALIDTYPE)");
1719                                          return MF_E_INVALIDTYPE;                                          return MF_E_INVALIDTYPE;
1720                                  }                                  }
# Line 1651  Line 1727 
1727    
1728          if (SUCCEEDED(hr)) {          if (SUCCEEDED(hr)) {
1729                  if (bReallySet) { /* Set the type if needed */                  if (bReallySet) { /* Set the type if needed */
1730                          hr = OnSetOutputType(pType);                          hr = OnSetOutputType(pType, bitdepth);
1731                  }                  }
1732          }          }
1733    
1734          if (SUCCEEDED(hr) && (Tray_Icon == 0) && (g_config.bTrayIcon != 0))  /* Create message passing window */          if (SUCCEEDED(hr) && (MSG_hwnd == 0) && (m_tray_icon == 0) && (g_config.bTrayIcon != 0))
1735          {          {
1736                  WNDCLASSEX wc;                  m_thread_handle = CreateThread(NULL, 0, CreateTrayIcon, NULL, 0, NULL);  /* Create message passing window */
   
                 wc.cbSize = sizeof(WNDCLASSEX);  
                 wc.lpfnWndProc = msg_proc;  
                 wc.style = CS_HREDRAW | CS_VREDRAW;  
                 wc.cbWndExtra = 0;  
                 wc.cbClsExtra = 0;  
                 wc.hInstance = (HINSTANCE) g_xvid_hInst;  
                 wc.hbrBackground = (HBRUSH) GetStockObject(NULL_BRUSH);  
                 wc.lpszMenuName = NULL;  
                 wc.lpszClassName = "XVID_MSG_WINDOW";  
                 wc.hIcon = NULL;  
                 wc.hIconSm = NULL;  
                 wc.hCursor = NULL;  
                 RegisterClassEx(&wc);  
1737    
1738                  MSG_hwnd = CreateWindowEx(0, "XVID_MSG_WINDOW", NULL, 0, CW_USEDEFAULT,                  if (m_thread_handle)
1739                                    CW_USEDEFAULT, 0, 0, HWND_MESSAGE, NULL, (HINSTANCE) g_xvid_hInst, NULL);                      m_tray_icon = 1;
   
                 /* display the tray icon */  
                 NOTIFYICONDATA nid;  
                 ZeroMemory(&nid,sizeof(NOTIFYICONDATA));  
   
                 nid.cbSize = NOTIFYICONDATA_V1_SIZE;  
                 nid.hWnd = MSG_hwnd;  
                 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;  
1740          }          }
1741    
1742          LeaveCriticalSection(&m_mft_lock);          LeaveCriticalSection(&m_mft_lock);
1743    
1744          return hr;          return hr;
1745  }  }
1746    
# Line 1762  Line 1808 
1808    
1809          EnterCriticalSection(&m_mft_lock);          EnterCriticalSection(&m_mft_lock);
1810    
1811          /* If there's pending output sampels we don't accept new          /* If there's pending output samples we don't accept new
1812             input data until ProcessOutput() or Flush() was called */             input data until ProcessOutput() or Flush() was called */
1813          if (!HasPendingOutput()) {          if (!HasPendingOutput()) {
1814                  *pdwFlags = MFT_INPUT_STATUS_ACCEPT_DATA;                  *pdwFlags = MFT_INPUT_STATUS_ACCEPT_DATA;
# Line 1999  Line 2045 
2045                          }                          }
2046    
2047                          ar_x = par_x * stats.data.vol.width;                          ar_x = par_x * stats.data.vol.width;
2048                          ar_y = par_y * stats.data.vol.height;                          ar_y = par_y * stats.data.vol.height; /* TODO: Actually set the newly determined AR on the output sample type
2049                                                                                                               or it'll have no effect at all... */
2050                  }                  }
2051    
2052                  m_frame.bitstream = (BYTE*)m_frame.bitstream + length;                  m_frame.bitstream = (BYTE*)m_frame.bitstream + length;
# Line 2061  Line 2108 
2108    
2109          BYTE *Dst = NULL;          BYTE *Dst = NULL;
2110          DWORD buffer_size;          DWORD buffer_size;
2111            LONG stride = m_create.width;
2112          IMFMediaBuffer *pOutput = NULL;          IMFMediaBuffer *pOutput = NULL;
2113            IMF2DBuffer *pOutput2D = NULL;
2114    
2115          if (SUCCEEDED(hr)) {          if (SUCCEEDED(hr)) {
2116                  hr = pOutputSamples[0].pSample->GetBufferByIndex(0, &pOutput); /* Get output buffer */                  hr = pOutputSamples[0].pSample->GetBufferByIndex(0, &pOutput); /* Get output buffer */
# Line 2072  Line 2120 
2120                  hr = pOutput->GetMaxLength(&buffer_size);                  hr = pOutput->GetMaxLength(&buffer_size);
2121          }          }
2122    
2123          if (SUCCEEDED(hr))          if (SUCCEEDED(hr)) {
2124                    hr = pOutput->QueryInterface(IID_IMF2DBuffer, (void **)&pOutput2D);
2125            }
2126    
2127            if (SUCCEEDED(hr)) {
2128                    hr = pOutput2D->Lock2D(&Dst, &stride);
2129            }
2130            else {
2131                  hr = pOutput->Lock(&Dst, NULL, NULL);                  hr = pOutput->Lock(&Dst, NULL, NULL);
2132            }
2133    
2134          if (SUCCEEDED(hr)) {          if (SUCCEEDED(hr)) {
2135                  xvid_gbl_convert_t convert;                  xvid_gbl_convert_t convert;
# Line 2091  Line 2147 
2147    
2148                  convert.output.csp = m_frame.output.csp;                  convert.output.csp = m_frame.output.csp;
2149                  convert.output.plane[0] = Dst;                  convert.output.plane[0] = Dst;
2150                  convert.output.stride[0] = out_stride;                  convert.output.stride[0] = stride;
2151    
2152                  convert.width = m_create.width;                  convert.width = m_create.width;
2153                  convert.height = m_create.height;                  convert.height = m_create.height;
# Line 2100  Line 2156 
2156                  if (m_frame.output.plane[1] != NULL && Dst != NULL && xvid_global_func != NULL)                  if (m_frame.output.plane[1] != NULL && Dst != NULL && xvid_global_func != NULL)
2157                          if (xvid_global_func(0, XVID_GBL_CONVERT, &convert, NULL) < 0) /* CSP convert into output buffer */                          if (xvid_global_func(0, XVID_GBL_CONVERT, &convert, NULL) < 0) /* CSP convert into output buffer */
2158                                  hr = E_FAIL;                                  hr = E_FAIL;
   
2159                  m_frame.output.plane[1] = NULL;                  m_frame.output.plane[1] = NULL;
2160          }          }
2161    
# Line 2125  Line 2180 
2180                  }                  }
2181    
2182                  if (SUCCEEDED(hr))                  if (SUCCEEDED(hr))
2183                          hr = pOutput->SetCurrentLength(m_create.width * abs(m_create.height) * 4); // XXX                          hr = pOutput->SetCurrentLength((m_create.width * abs(m_create.height) * m_pOutputTypeBPP) >> 3);
2184          }          }
2185    
2186          if (pOutput) {          if (pOutput2D) {
2187                    pOutput2D->Unlock2D();
2188                    pOutput2D->Release();
2189                    if (pOutput)
2190                        pOutput->Release();
2191            }
2192            else if (pOutput) {
2193                  pOutput->Unlock();                  pOutput->Unlock();
2194                  pOutput->Release();                  pOutput->Release();
2195          }          }
# Line 2316  Line 2377 
2377          return hr;          return hr;
2378  }  }
2379    
2380  HRESULT CXvidDecoder::OnSetOutputType(IMFMediaType *pmt)  HRESULT CXvidDecoder::OnSetOutputType(IMFMediaType *pmt, int bitdepth)
2381  {  {
2382          if (m_pOutputType) m_pOutputType->Release();          if (m_pOutputType) m_pOutputType->Release();
2383    
2384          m_pOutputType = pmt;          m_pOutputType = pmt;
2385          m_pOutputType->AddRef();          m_pOutputType->AddRef();
2386            m_pOutputTypeBPP = bitdepth;
2387    
2388          return S_OK;          return S_OK;
2389  }  }

Legend:
Removed from v.2113  
changed lines
  Added in v.2114

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