diff options
author | kinddragon <kinddragon@users.sourceforge.net> | 2010-05-02 05:20:06 +0400 |
---|---|---|
committer | kinddragon <kinddragon@users.sourceforge.net> | 2010-05-02 05:20:06 +0400 |
commit | 15b2b39f278d9eb6b2b9ac59591bca4f57abae9a (patch) | |
tree | e1b2871c068304378583c6b0b09bb70d0dbde890 /src | |
parent | 54e9d9b9b122b78647d514b742e99c6cfd3b3e11 (diff) |
DX7 presenters splitter to several files
Improved Reset() handling (ticket #12)
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@1826 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src')
30 files changed, 1737 insertions, 1347 deletions
diff --git a/src/SubPic/ISubPic.cpp b/src/SubPic/ISubPic.cpp index 5531f6116..d1ea06335 100644 --- a/src/SubPic/ISubPic.cpp +++ b/src/SubPic/ISubPic.cpp @@ -975,6 +975,8 @@ ISubPicAllocatorPresenterImpl::ISubPicAllocatorPresenterImpl(HWND hWnd, HRESULT& , m_VideoRect(0, 0, 0, 0), m_WindowRect(0, 0, 0, 0)
, m_fps(25.0)
, m_rtSubtitleDelay(0)
+ , m_bDeviceResetRequested(false)
+ , m_bPendingResetDevice(false)
{
if(!IsWindow(m_hWnd))
{
diff --git a/src/SubPic/ISubPic.h b/src/SubPic/ISubPic.h index 030d03fb6..67aa89825 100644 --- a/src/SubPic/ISubPic.h +++ b/src/SubPic/ISubPic.h @@ -395,6 +395,8 @@ interface ISubPicAllocatorPresenter : public IUnknown STDMETHOD (SetVideoAngle) (Vector v, bool fRepaint = true) PURE;
STDMETHOD (SetPixelShader) (LPCSTR pSrcData, LPCSTR pTarget) PURE;
+
+ STDMETHOD_(bool, ResetDevice) () PURE;
};
[uuid("767AEBA8-A084-488a-89C8-F6B74E53A90F")]
@@ -425,6 +427,9 @@ protected: CComPtr<ISubPicAllocator> m_pAllocator;
CComPtr<ISubPicQueue> m_pSubPicQueue;
+ bool m_bDeviceResetRequested;
+ bool m_bPendingResetDevice;
+
void AlphaBltSubPic(CSize size, SubPicDesc* pTarget = NULL);
XForm m_xform;
@@ -456,6 +461,8 @@ public: STDMETHODIMP GetDIB(BYTE* lpDib, DWORD* size) {return E_NOTIMPL;}
+ STDMETHODIMP_(bool) ResetDevice() {return E_NOTIMPL;}
+
STDMETHODIMP SetVideoAngle(Vector v, bool fRepaint = true);
STDMETHODIMP SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget) {return E_NOTIMPL;}
STDMETHODIMP SetPixelShader2(LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace)
diff --git a/src/apps/mplayerc/AllocatorCommon.cpp b/src/apps/mplayerc/AllocatorCommon.cpp index fcd81dfa5..154271c66 100644 --- a/src/apps/mplayerc/AllocatorCommon.cpp +++ b/src/apps/mplayerc/AllocatorCommon.cpp @@ -166,7 +166,9 @@ CString GetWindowsErrorMessage(HRESULT _Error, HMODULE _Module) case S_PRESENT_OCCLUDED :
return _T("S_PRESENT_OCCLUDED");
case D3DERR_DEVICEHUNG :
- return _T("D3DERR_DEVICEHUNG");
+ return _T("D3DERR_DEVICEHUNG");
+ case E_UNEXPECTED :
+ return _T("E_UNEXPECTED");
}
CString errmsg;
diff --git a/src/apps/mplayerc/AllocatorCommon.h b/src/apps/mplayerc/AllocatorCommon.h index 2f9b29624..88ea58548 100644 --- a/src/apps/mplayerc/AllocatorCommon.h +++ b/src/apps/mplayerc/AllocatorCommon.h @@ -62,3 +62,18 @@ extern const wchar_t *GetD3DFormatStr(D3DFORMAT Format); extern HRESULT CreateAP9(const CLSID& clsid, HWND hWnd, ISubPicAllocatorPresenter** ppAP);
extern HRESULT CreateEVR(const CLSID& clsid, HWND hWnd, ISubPicAllocatorPresenter** ppAP);
+
+// Support ffdshow queuing.
+// This interface is used to check version of Media Player Classic.
+// {A273C7F6-25D4-46b0-B2C8-4F7FADC44E37}
+DEFINE_GUID(IID_IVMRffdshow9,
+ 0xa273c7f6, 0x25d4, 0x46b0, 0xb2, 0xc8, 0x4f, 0x7f, 0xad, 0xc4, 0x4e, 0x37);
+
+MIDL_INTERFACE("A273C7F6-25D4-46b0-B2C8-4F7FADC44E37")
+IVMRffdshow9 :
+public IUnknown
+{
+public:
+ virtual STDMETHODIMP support_ffdshow(void) = 0;
+};
+
diff --git a/src/apps/mplayerc/AllocatorCommon7.cpp b/src/apps/mplayerc/AllocatorCommon7.cpp new file mode 100644 index 000000000..fb9d1eeb7 --- /dev/null +++ b/src/apps/mplayerc/AllocatorCommon7.cpp @@ -0,0 +1,70 @@ +/*
+ * $Id: DX7AllocatorPresenter.cpp 1813 2010-04-27 02:03:56Z kinddragon $
+ *
+ * (C) 2003-2006 Gabest
+ * (C) 2006-2010 see AUTHORS
+ *
+ * This file is part of mplayerc.
+ *
+ * Mplayerc is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Mplayerc is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "stdafx.h"
+#include "../../DSUtil/DSUtil.h"
+
+#include <initguid.h>
+#include "DX7AllocatorPresenter.h"
+#include "VMR7AllocatorPresenter.h"
+#include "RM7AllocatorPresenter.h"
+#include "QT7AllocatorPresenter.h"
+
+
+bool IsVMR7InGraph(IFilterGraph* pFG)
+{
+ BeginEnumFilters(pFG, pEF, pBF)
+ if(CComQIPtr<IVMRWindowlessControl>(pBF)) return(true);
+ EndEnumFilters
+ return(false);
+}
+
+using namespace DSObjects;
+
+//
+
+HRESULT CreateAP7(const CLSID& clsid, HWND hWnd, ISubPicAllocatorPresenter** ppAP)
+{
+ CheckPointer(ppAP, E_POINTER);
+
+ *ppAP = NULL;
+
+ HRESULT hr;
+ if(clsid == CLSID_VMR7AllocatorPresenter && !(*ppAP = DNew CVMR7AllocatorPresenter(hWnd, hr))
+ || clsid == CLSID_RM7AllocatorPresenter && !(*ppAP = DNew CRM7AllocatorPresenter(hWnd, hr))
+ || clsid == CLSID_QT7AllocatorPresenter && !(*ppAP = DNew CQT7AllocatorPresenter(hWnd, hr)))
+ return E_OUTOFMEMORY;
+
+ if(*ppAP == NULL)
+ return E_FAIL;
+
+ (*ppAP)->AddRef();
+
+ if(FAILED(hr))
+ {
+ (*ppAP)->Release();
+ *ppAP = NULL;
+ }
+
+ return hr;
+}
diff --git a/src/apps/mplayerc/AllocatorCommon7.h b/src/apps/mplayerc/AllocatorCommon7.h new file mode 100644 index 000000000..38120c13a --- /dev/null +++ b/src/apps/mplayerc/AllocatorCommon7.h @@ -0,0 +1,43 @@ +/*
+ * $Id: DX7AllocatorPresenter.h 1790 2010-04-18 20:29:12Z tetsuo55 $
+ *
+ * (C) 2003-2006 Gabest
+ * (C) 2006-2010 see AUTHORS
+ *
+ * This file is part of mplayerc.
+ *
+ * Mplayerc is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Mplayerc is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#pragma once
+
+#include "../../SubPic/ISubPic.h"
+
+
+// {495CF191-810D-44c7-92C5-E7D46AE00F44}
+DEFINE_GUID(CLSID_VMR7AllocatorPresenter,
+ 0x495cf191, 0x810d, 0x44c7, 0x92, 0xc5, 0xe7, 0xd4, 0x6a, 0xe0, 0xf, 0x44);
+
+// {97B3462E-1752-4dfb-A038-271060BC7A94}
+DEFINE_GUID(CLSID_RM7AllocatorPresenter,
+ 0x97b3462e, 0x1752, 0x4dfb, 0xa0, 0x38, 0x27, 0x10, 0x60, 0xbc, 0x7a, 0x94);
+
+// {36CC5A71-441C-462a-9D10-48A19485938D}
+DEFINE_GUID(CLSID_QT7AllocatorPresenter,
+ 0x36cc5a71, 0x441c, 0x462a, 0x9d, 0x10, 0x48, 0xa1, 0x94, 0x85, 0x93, 0x8d);
+
+extern HRESULT CreateAP7(const CLSID& clsid, HWND hWnd, ISubPicAllocatorPresenter** ppAP);
+
+extern bool IsVMR7InGraph(IFilterGraph* pFG);
diff --git a/src/apps/mplayerc/DX7AllocatorPresenter.cpp b/src/apps/mplayerc/DX7AllocatorPresenter.cpp index b3877b9cc..2f5a2333f 100644 --- a/src/apps/mplayerc/DX7AllocatorPresenter.cpp +++ b/src/apps/mplayerc/DX7AllocatorPresenter.cpp @@ -23,267 +23,82 @@ #include "stdafx.h"
#include "mplayerc.h"
-#include <atlbase.h>
-#include <atlcoll.h>
-#include "../../DSUtil/DSUtil.h"
-#include <initguid.h>
#include "DX7AllocatorPresenter.h"
-#include <ddraw.h>
-#include <d3d.h>
#include "../../SubPic/DX7SubPic.h"
-#include <RealMedia/pntypes.h>
-#include <RealMedia/pnwintyp.h>
-#include <RealMedia/pncom.h>
-#include <RealMedia/rmavsurf.h>
-#include "IQTVideoSurface.h"
-#include "IPinHook.h"
-
-
-bool IsVMR7InGraph(IFilterGraph* pFG)
-{
- BeginEnumFilters(pFG, pEF, pBF)
- if(CComQIPtr<IVMRWindowlessControl>(pBF)) return(true);
- EndEnumFilters
- return(false);
-}
-
-namespace DSObjects
-{
-
-class CDX7AllocatorPresenter
- : public ISubPicAllocatorPresenterImpl
-{
-protected:
- CSize m_ScreenSize;
-
- CComPtr<IDirectDraw7> m_pDD;
- CComQIPtr<IDirect3D7, &IID_IDirect3D7> m_pD3D;
- CComPtr<IDirect3DDevice7> m_pD3DDev;
-
- CComPtr<IDirectDrawSurface7> m_pPrimary, m_pBackBuffer;
- CComPtr<IDirectDrawSurface7> m_pVideoTexture, m_pVideoSurface;
-
- virtual HRESULT CreateDevice();
- virtual HRESULT AllocSurfaces();
- virtual void DeleteSurfaces();
-
- bool ResetDevice();
-
-public:
- CDX7AllocatorPresenter(HWND hWnd, HRESULT& hr);
-
- // ISubPicAllocatorPresenter
- STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
- STDMETHODIMP_(bool) Paint(bool fAll);
- STDMETHODIMP GetDIB(BYTE* lpDib, DWORD* size);
-};
-
-class CVMR7AllocatorPresenter
- : public CDX7AllocatorPresenter
- , public IVMRSurfaceAllocator
- , public IVMRImagePresenter
- , public IVMRWindowlessControl
-{
- CComPtr<IVMRSurfaceAllocatorNotify> m_pIVMRSurfAllocNotify;
- CComPtr<IVMRSurfaceAllocator> m_pSA;
-
- HRESULT CreateDevice();
- void DeleteSurfaces();
-
- bool m_fUseInternalTimer;
-
-public:
- CVMR7AllocatorPresenter(HWND hWnd, HRESULT& hr);
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // ISubPicAllocatorPresenter
- STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
- STDMETHODIMP_(void) SetTime(REFERENCE_TIME rtNow);
-
- // IVMRSurfaceAllocator
- STDMETHODIMP AllocateSurface(DWORD_PTR dwUserID, VMRALLOCATIONINFO* lpAllocInfo, DWORD* lpdwBuffer, LPDIRECTDRAWSURFACE7* lplpSurface);
- STDMETHODIMP FreeSurface(DWORD_PTR dwUserID);
- STDMETHODIMP PrepareSurface(DWORD_PTR dwUserID, IDirectDrawSurface7* lpSurface, DWORD dwSurfaceFlags);
- STDMETHODIMP AdviseNotify(IVMRSurfaceAllocatorNotify* lpIVMRSurfAllocNotify);
-
- // IVMRImagePresenter
- STDMETHODIMP StartPresenting(DWORD_PTR dwUserID);
- STDMETHODIMP StopPresenting(DWORD_PTR dwUserID);
- STDMETHODIMP PresentImage(DWORD_PTR dwUserID, VMRPRESENTATIONINFO* lpPresInfo);
-
- // IVMRWindowlessControl
- STDMETHODIMP GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight);
- STDMETHODIMP GetMinIdealVideoSize(LONG* lpWidth, LONG* lpHeight);
- STDMETHODIMP GetMaxIdealVideoSize(LONG* lpWidth, LONG* lpHeight);
- STDMETHODIMP SetVideoPosition(const LPRECT lpSRCRect, const LPRECT lpDSTRect);
- STDMETHODIMP GetVideoPosition(LPRECT lpSRCRect, LPRECT lpDSTRect);
- STDMETHODIMP GetAspectRatioMode(DWORD* lpAspectRatioMode);
- STDMETHODIMP SetAspectRatioMode(DWORD AspectRatioMode);
- STDMETHODIMP SetVideoClippingWindow(HWND hwnd);
- STDMETHODIMP RepaintVideo(HWND hwnd, HDC hdc);
- STDMETHODIMP DisplayModeChanged();
- STDMETHODIMP GetCurrentImage(BYTE** lpDib);
- STDMETHODIMP SetBorderColor(COLORREF Clr);
- STDMETHODIMP GetBorderColor(COLORREF* lpClr);
- STDMETHODIMP SetColorKey(COLORREF Clr);
- STDMETHODIMP GetColorKey(COLORREF* lpClr);
-};
-
-class CRM7AllocatorPresenter
- : public CDX7AllocatorPresenter
- , public IRMAVideoSurface
-{
- CComPtr<IDirectDrawSurface7> m_pVideoSurfaceOff;
- CComPtr<IDirectDrawSurface7> m_pVideoSurfaceYUY2;
-
- RMABitmapInfoHeader m_bitmapInfo;
- RMABitmapInfoHeader m_lastBitmapInfo;
-
-protected:
- HRESULT AllocSurfaces();
- void DeleteSurfaces();
-
-public:
- CRM7AllocatorPresenter(HWND hWnd, HRESULT& hr);
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // IRMAVideoSurface
- STDMETHODIMP Blt(UCHAR* pImageData, RMABitmapInfoHeader* pBitmapInfo, REF(PNxRect) inDestRect, REF(PNxRect) inSrcRect);
- STDMETHODIMP BeginOptimizedBlt(RMABitmapInfoHeader* pBitmapInfo);
- STDMETHODIMP OptimizedBlt(UCHAR* pImageBits, REF(PNxRect) rDestRect, REF(PNxRect) rSrcRect);
- STDMETHODIMP EndOptimizedBlt();
- STDMETHODIMP GetOptimizedFormat(REF(RMA_COMPRESSION_TYPE) ulType);
- STDMETHODIMP GetPreferredFormat(REF(RMA_COMPRESSION_TYPE) ulType);
-};
-
-class CQT7AllocatorPresenter
- : public CDX7AllocatorPresenter
- , public IQTVideoSurface
-{
- CComPtr<IDirectDrawSurface7> m_pVideoSurfaceOff;
-
-protected:
- HRESULT AllocSurfaces();
- void DeleteSurfaces();
-
-public:
- CQT7AllocatorPresenter(HWND hWnd, HRESULT& hr);
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // IQTVideoSurface
- STDMETHODIMP BeginBlt(const BITMAP& bm);
- STDMETHODIMP DoBlt(const BITMAP& bm);
-};
-
-}
using namespace DSObjects;
//
-HRESULT CreateAP7(const CLSID& clsid, HWND hWnd, ISubPicAllocatorPresenter** ppAP)
-{
- CheckPointer(ppAP, E_POINTER);
-
- *ppAP = NULL;
-
- HRESULT hr;
- if(clsid == CLSID_VMR7AllocatorPresenter && !(*ppAP = DNew CVMR7AllocatorPresenter(hWnd, hr))
- || clsid == CLSID_RM7AllocatorPresenter && !(*ppAP = DNew CRM7AllocatorPresenter(hWnd, hr))
- || clsid == CLSID_QT7AllocatorPresenter && !(*ppAP = DNew CQT7AllocatorPresenter(hWnd, hr)))
- return E_OUTOFMEMORY;
-
- if(*ppAP == NULL)
- return E_FAIL;
-
- (*ppAP)->AddRef();
-
- if(FAILED(hr))
- {
- (*ppAP)->Release();
- *ppAP = NULL;
- }
-
- return hr;
-}
-
-//
-
static HRESULT TextureBlt(CComPtr<IDirect3DDevice7> pD3DDev, CComPtr<IDirectDrawSurface7> pTexture, Vector dst[4], CRect src)
{
- if(!pTexture)
- return E_POINTER;
+ if(!pTexture)
+ return E_POINTER;
- HRESULT hr;
+ HRESULT hr;
- do
- {
- DDSURFACEDESC2 ddsd;
- INITDDSTRUCT(ddsd);
- if(FAILED(hr = pTexture->GetSurfaceDesc(&ddsd)))
- break;
+ do
+ {
+ DDSURFACEDESC2 ddsd;
+ INITDDSTRUCT(ddsd);
+ if(FAILED(hr = pTexture->GetSurfaceDesc(&ddsd)))
+ break;
- float w = (float)ddsd.dwWidth;
- float h = (float)ddsd.dwHeight;
+ float w = (float)ddsd.dwWidth;
+ float h = (float)ddsd.dwHeight;
- struct
- {
- float x, y, z, rhw;
- float tu, tv;
- }
- pVertices[] =
- {
- {(float)dst[0].x, (float)dst[0].y, (float)dst[0].z, 1.0f/(float)dst[0].z, (float)src.left / w, (float)src.top / h},
- {(float)dst[1].x, (float)dst[1].y, (float)dst[1].z, 1.0f/(float)dst[1].z, (float)src.right / w, (float)src.top / h},
- {(float)dst[2].x, (float)dst[2].y, (float)dst[2].z, 1.0f/(float)dst[2].z, (float)src.left / w, (float)src.bottom / h},
- {(float)dst[3].x, (float)dst[3].y, (float)dst[3].z, 1.0f/(float)dst[3].z, (float)src.right / w, (float)src.bottom / h},
- };
+ struct
+ {
+ float x, y, z, rhw;
+ float tu, tv;
+ }
+ pVertices[] =
+ {
+ {(float)dst[0].x, (float)dst[0].y, (float)dst[0].z, 1.0f/(float)dst[0].z, (float)src.left / w, (float)src.top / h},
+ {(float)dst[1].x, (float)dst[1].y, (float)dst[1].z, 1.0f/(float)dst[1].z, (float)src.right / w, (float)src.top / h},
+ {(float)dst[2].x, (float)dst[2].y, (float)dst[2].z, 1.0f/(float)dst[2].z, (float)src.left / w, (float)src.bottom / h},
+ {(float)dst[3].x, (float)dst[3].y, (float)dst[3].z, 1.0f/(float)dst[3].z, (float)src.right / w, (float)src.bottom / h},
+ };
- for(int i = 0; i < countof(pVertices); i++)
- {
- pVertices[i].x -= 0.5;
- pVertices[i].y -= 0.5;
- }
+ for(int i = 0; i < countof(pVertices); i++)
+ {
+ pVertices[i].x -= 0.5;
+ pVertices[i].y -= 0.5;
+ }
- hr = pD3DDev->SetTexture(0, pTexture);
+ hr = pD3DDev->SetTexture(0, pTexture);
- pD3DDev->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
- pD3DDev->SetRenderState(D3DRENDERSTATE_LIGHTING, FALSE);
- pD3DDev->SetRenderState(D3DRENDERSTATE_BLENDENABLE, FALSE);
- pD3DDev->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, FALSE);
+ pD3DDev->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
+ pD3DDev->SetRenderState(D3DRENDERSTATE_LIGHTING, FALSE);
+ pD3DDev->SetRenderState(D3DRENDERSTATE_BLENDENABLE, FALSE);
+ pD3DDev->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, FALSE);
- pD3DDev->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTFG_LINEAR);
- pD3DDev->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTFN_LINEAR);
- pD3DDev->SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTFP_LINEAR);
+ pD3DDev->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTFG_LINEAR);
+ pD3DDev->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTFN_LINEAR);
+ pD3DDev->SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTFP_LINEAR);
- pD3DDev->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP);
+ pD3DDev->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP);
- //
+ //
- if(FAILED(hr = pD3DDev->BeginScene()))
- break;
+ if(FAILED(hr = pD3DDev->BeginScene()))
+ break;
- hr = pD3DDev->DrawPrimitive(D3DPT_TRIANGLESTRIP,
- D3DFVF_XYZRHW | D3DFVF_TEX1,
- pVertices, 4, D3DDP_WAIT);
- pD3DDev->EndScene();
+ hr = pD3DDev->DrawPrimitive(D3DPT_TRIANGLESTRIP,
+ D3DFVF_XYZRHW | D3DFVF_TEX1,
+ pVertices, 4, D3DDP_WAIT);
+ pD3DDev->EndScene();
- //
+ //
- pD3DDev->SetTexture(0, NULL);
+ pD3DDev->SetTexture(0, NULL);
- return S_OK;
- }
- while(0);
+ return S_OK;
+ }
+ while(0);
- return E_FAIL;
+ return E_FAIL;
}
//
@@ -292,7 +107,7 @@ static HRESULT TextureBlt(CComPtr<IDirect3DDevice7> pD3DDev, CComPtr<IDirectDraw CDX7AllocatorPresenter::CDX7AllocatorPresenter(HWND hWnd, HRESULT& hr)
: ISubPicAllocatorPresenterImpl(hWnd, hr, NULL)
- , m_ScreenSize(0, 0)
+ , m_ScreenSize(0, 0)
{
if(FAILED(hr)) return;
@@ -323,8 +138,8 @@ HRESULT CDX7AllocatorPresenter::CreateDevice() DDSURFACEDESC2 ddsd;
INITDDSTRUCT(ddsd);
if(FAILED(m_pDD->GetDisplayMode(&ddsd)) ||
- ddsd.ddpfPixelFormat.dwRGBBitCount <= 8)
- return DDERR_INVALIDMODE;
+ ddsd.ddpfPixelFormat.dwRGBBitCount <= 8)
+ return DDERR_INVALIDMODE;
m_ScreenSize.SetSize(ddsd.dwWidth, ddsd.dwHeight);
@@ -335,12 +150,12 @@ HRESULT CDX7AllocatorPresenter::CreateDevice() INITDDSTRUCT(ddsd);
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
- if(FAILED(hr = m_pDD->CreateSurface(&ddsd, &m_pPrimary, NULL)))
- return hr;
+ if(FAILED(hr = m_pDD->CreateSurface(&ddsd, &m_pPrimary, NULL)))
+ return hr;
CComPtr<IDirectDrawClipper> pcClipper;
if(FAILED(hr = m_pDD->CreateClipper(0, &pcClipper, NULL)))
- return hr;
+ return hr;
pcClipper->SetHWnd(0, m_hWnd);
m_pPrimary->SetClipper(pcClipper);
@@ -352,11 +167,11 @@ HRESULT CDX7AllocatorPresenter::CreateDevice() ddsd.dwWidth = m_ScreenSize.cx;
ddsd.dwHeight = m_ScreenSize.cy;
if(FAILED(hr = m_pDD->CreateSurface(&ddsd, &m_pBackBuffer, NULL)))
- return hr;
+ return hr;
pcClipper = NULL;
if(FAILED(hr = m_pDD->CreateClipper(0, &pcClipper, NULL)))
- return hr;
+ return hr;
BYTE rgnDataBuffer[1024];
HRGN hrgn = CreateRectRgn(0, 0, ddsd.dwWidth, ddsd.dwHeight);
GetRegionData(hrgn, sizeof(rgnDataBuffer), (RGNDATA*)rgnDataBuffer);
@@ -511,9 +326,15 @@ STDMETHODIMP CDX7AllocatorPresenter::CreateRenderer(IUnknown** ppRenderer) STDMETHODIMP_(bool) CDX7AllocatorPresenter::Paint(bool fAll)
{
+ if (m_bPendingResetDevice)
+ {
+ SendResetRequest();
+ return false;
+ }
+
CAutoLock cAutoLock(this);
- if(m_WindowRect.right <= m_WindowRect.left || m_WindowRect.bottom <= m_WindowRect.top
+ if(m_WindowRect.right <= m_WindowRect.left || m_WindowRect.bottom <= m_WindowRect.top
|| m_NativeVideoSize.cx <= 0 || m_NativeVideoSize.cy <= 0
|| !m_pPrimary || !m_pBackBuffer || !m_pVideoSurface)
return(false);
@@ -571,21 +392,38 @@ STDMETHODIMP_(bool) CDX7AllocatorPresenter::Paint(bool fAll) hr = m_pPrimary->Blt(rDstPri, m_pBackBuffer, rSrcPri, DDBLT_WAIT, NULL);
if(hr == DDERR_SURFACELOST)
- ResetDevice();
+ {
+ m_bPendingResetDevice = true;
+ SendResetRequest();
+ return false;
+ }
return(true);
}
-bool CDX7AllocatorPresenter::ResetDevice()
+void CDX7AllocatorPresenter::SendResetRequest()
+{
+ if (!m_bDeviceResetRequested)
+ {
+ m_bDeviceResetRequested = true;
+ AfxGetApp()->m_pMainWnd->PostMessage(WM_RESET_DEVICE);
+ }
+}
+
+STDMETHODIMP_(bool) CDX7AllocatorPresenter::ResetDevice()
{
HRESULT hr;
DeleteSurfaces();
if(FAILED(hr = CreateDevice()) || FAILED(hr = AllocSurfaces()))
{
- //DDERR_UNSUPPORTEDMODE
+ //DDERR_UNSUPPORTEDMODE - 0x8876024e
TRACE("ResetDevice failed: 0x%08x\n", (LONG)hr);
+ m_bDeviceResetRequested = false;
return false;
}
+ TRACE("ResetDevice\n");
+ m_bPendingResetDevice = false;
+ m_bDeviceResetRequested = false;
return true;
}
@@ -647,760 +485,3 @@ STDMETHODIMP CDX7AllocatorPresenter::GetDIB(BYTE* lpDib, DWORD* size) return S_OK;
}
-
-//
-// CVMR7AllocatorPresenter
-//
-
-#define MY_USER_ID 0x6ABE51
-
-CVMR7AllocatorPresenter::CVMR7AllocatorPresenter(HWND hWnd, HRESULT& hr)
- : CDX7AllocatorPresenter(hWnd, hr)
- , m_fUseInternalTimer(false)
-{
- if(FAILED(hr))
- return;
-
- if(FAILED(hr = m_pSA.CoCreateInstance(CLSID_AllocPresenter)))
- {
- hr = E_FAIL;
- return;
- }
-}
-
-STDMETHODIMP CVMR7AllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
-{
- CheckPointer(ppv, E_POINTER);
-
- return
- QI(IVMRSurfaceAllocator)
- QI(IVMRImagePresenter)
- QI(IVMRWindowlessControl)
- __super::NonDelegatingQueryInterface(riid, ppv);
-}
-
-HRESULT CVMR7AllocatorPresenter::CreateDevice()
-{
- HRESULT hr = __super::CreateDevice();
- if(FAILED(hr)) return hr;
-
- if(m_pIVMRSurfAllocNotify)
- {
- HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- if(FAILED(hr = m_pIVMRSurfAllocNotify->ChangeDDrawDevice(m_pDD, hMonitor)))
- return(false);
- }
-
- return hr;
-}
-
-void CVMR7AllocatorPresenter::DeleteSurfaces()
-{
- CAutoLock cAutoLock(this);
-
- m_pSA->FreeSurface(MY_USER_ID);
-
- __super::DeleteSurfaces();
-}
-
-// ISubPicAllocatorPresenter
-
-STDMETHODIMP CVMR7AllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
-{
- CheckPointer(ppRenderer, E_POINTER);
-
- *ppRenderer = NULL;
-
- HRESULT hr;
-
- do
- {
- CComPtr<IBaseFilter> pBF;
-
- if(FAILED(hr = pBF.CoCreateInstance(CLSID_VideoMixingRenderer)))
- break;
-
- CComQIPtr<IVMRFilterConfig> pConfig = pBF;
- if(!pConfig)
- break;
-
- if(FAILED(hr = pConfig->SetRenderingMode(VMRMode_Renderless)))
- break;
-
- CComQIPtr<IVMRSurfaceAllocatorNotify> pSAN = pBF;
- if(!pSAN)
- break;
-
- if(FAILED(hr = pSAN->AdviseSurfaceAllocator(MY_USER_ID, static_cast<IVMRSurfaceAllocator*>(this)))
- || FAILED(hr = AdviseNotify(pSAN)))
- break;
-
- CComPtr<IPin> pPin = GetFirstPin(pBF);
- CComQIPtr<IMemInputPin> pMemInputPin = pPin;
- m_fUseInternalTimer = HookNewSegmentAndReceive((IPinC*)(IPin*)pPin, (IMemInputPinC*)(IMemInputPin*)pMemInputPin);
-
- *ppRenderer = (IUnknown*)pBF.Detach();
-
- return S_OK;
- }
- while(0);
-
- return E_FAIL;
-}
-
-STDMETHODIMP_(void) CVMR7AllocatorPresenter::SetTime(REFERENCE_TIME rtNow)
-{
- __super::SetTime(rtNow);
-// m_fUseInternalTimer = false;
-}
-
-// IVMRSurfaceAllocator
-
-STDMETHODIMP CVMR7AllocatorPresenter::AllocateSurface(DWORD_PTR dwUserID, VMRALLOCATIONINFO* lpAllocInfo, DWORD* lpdwBuffer, LPDIRECTDRAWSURFACE7* lplpSurface)
-{
- if(!lpAllocInfo || !lpdwBuffer || !lplpSurface)
- return E_POINTER;
-
- if(!m_pIVMRSurfAllocNotify)
- return E_FAIL;
-
- HRESULT hr;
-
- DeleteSurfaces();
-
- // HACK: yv12 will fail to blt onto the backbuffer anyway, but if we first
- // allocate it and then let our FreeSurface callback call m_pSA->FreeSurface,
- // then that might stall for about 30 seconds because of some unknown buggy code
- // behind <ddraw surface>->Release()
-
- if(lpAllocInfo->lpHdr->biBitCount < 16)
- return E_FAIL;
-
- hr = m_pSA->AllocateSurface(dwUserID, lpAllocInfo, lpdwBuffer, lplpSurface);
- if(FAILED(hr))
- return hr;
-
- m_NativeVideoSize = CSize(abs(lpAllocInfo->lpHdr->biWidth), abs(lpAllocInfo->lpHdr->biHeight));
- m_AspectRatio = m_NativeVideoSize;
- int arx = lpAllocInfo->szAspectRatio.cx, ary = lpAllocInfo->szAspectRatio.cy;
- if(arx > 0 && ary > 0) m_AspectRatio.SetSize(arx, ary);
-
- if(FAILED(hr = AllocSurfaces()))
- return hr;
-
- // test if the colorspace is acceptable
- if(FAILED(hr = m_pVideoSurface->Blt(NULL, *lplpSurface, NULL, DDBLT_WAIT, NULL)))
- {
- DeleteSurfaces();
- return hr;
- }
-
- DDBLTFX fx;
- INITDDSTRUCT(fx);
- fx.dwFillColor = 0;
- m_pVideoSurface->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
-
- return hr;
-}
-
-STDMETHODIMP CVMR7AllocatorPresenter::FreeSurface(DWORD_PTR dwUserID)
-{
- DeleteSurfaces();
- return S_OK;
-}
-
-STDMETHODIMP CVMR7AllocatorPresenter::PrepareSurface(DWORD_PTR dwUserID, IDirectDrawSurface7* lpSurface, DWORD dwSurfaceFlags)
-{
- SetThreadName(-1, "CVMR7AllocatorPresenter");
-
- if(!lpSurface)
- return E_POINTER;
-
- // FIXME: sometimes the msmpeg4/divx3/wmv decoder wants to reuse our
- // surface (expects it to point to the same mem every time), and to avoid
- // problems we can't call m_pSA->PrepareSurface (flips? clears?).
- return S_OK;
- /*
- return m_pSA->PrepareSurface(dwUserID, lpSurface, dwSurfaceFlags);
- */
-}
-
-STDMETHODIMP CVMR7AllocatorPresenter::AdviseNotify(IVMRSurfaceAllocatorNotify* lpIVMRSurfAllocNotify)
-{
- CAutoLock cAutoLock(this);
-
- m_pIVMRSurfAllocNotify = lpIVMRSurfAllocNotify;
-
- HRESULT hr;
- HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- if(FAILED(hr = m_pIVMRSurfAllocNotify->SetDDrawDevice(m_pDD, hMonitor)))
- return hr;
-
- return m_pSA->AdviseNotify(lpIVMRSurfAllocNotify);
-}
-
-// IVMRImagePresenter
-
-STDMETHODIMP CVMR7AllocatorPresenter::StartPresenting(DWORD_PTR dwUserID)
-{
- CAutoLock cAutoLock(this);
-
- ASSERT(m_pD3DDev);
-
- return m_pD3DDev ? S_OK : E_FAIL;
-}
-
-STDMETHODIMP CVMR7AllocatorPresenter::StopPresenting(DWORD_PTR dwUserID)
-{
- return S_OK;
-}
-
-extern bool g_bNoDuration;
-extern bool g_bExternalSubtitleTime;
-
-STDMETHODIMP CVMR7AllocatorPresenter::PresentImage(DWORD_PTR dwUserID, VMRPRESENTATIONINFO* lpPresInfo)
-{
- if(!lpPresInfo || !lpPresInfo->lpSurf)
- return E_POINTER;
-
- if (!m_pD3DDev)
- {
- if (!ResetDevice())
- return DDERR_SURFACELOST;
- }
-
- CAutoLock cAutoLock(this);
-
- m_pVideoSurface->Blt(NULL, lpPresInfo->lpSurf, NULL, DDBLT_WAIT, NULL);
-
- if(lpPresInfo->rtEnd > lpPresInfo->rtStart)
- {
- REFERENCE_TIME rtTimePerFrame = lpPresInfo->rtEnd - lpPresInfo->rtStart;
- m_fps = 10000000.0 / rtTimePerFrame;
-
- if(m_pSubPicQueue)
- {
- m_pSubPicQueue->SetFPS(m_fps);
-
- if(m_fUseInternalTimer && !g_bExternalSubtitleTime)
- {
- __super::SetTime(g_tSegmentStart + g_tSampleStart);
- }
- }
- }
-
- CSize VideoSize = m_NativeVideoSize;
- int arx = lpPresInfo->szAspectRatio.cx, ary = lpPresInfo->szAspectRatio.cy;
- if(arx > 0 && ary > 0) VideoSize.cx = VideoSize.cy*arx/ary;
- if(VideoSize != GetVideoSize())
- {
- m_AspectRatio.SetSize(arx, ary);
- AfxGetApp()->m_pMainWnd->PostMessage(WM_REARRANGERENDERLESS);
- }
-
- Paint(true);
-
- return S_OK;
-}
-
-// IVMRWindowlessControl
-//
-// It is only implemented (partially) for the dvd navigator's
-// menu handling, which needs to know a few things about the
-// location of our window.
-
-STDMETHODIMP CVMR7AllocatorPresenter::GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight)
-{
- CSize vs = m_NativeVideoSize, ar = m_AspectRatio;
- // DVD Nav. bug workaround fix
- vs.cx = vs.cy * ar.cx / ar.cy;
- if(lpWidth) *lpWidth = vs.cx;
- if(lpHeight) *lpHeight = vs.cy;
- if(lpARWidth) *lpARWidth = ar.cx;
- if(lpARHeight) *lpARHeight = ar.cy;
- return S_OK;
-}
-
-STDMETHODIMP CVMR7AllocatorPresenter::GetMinIdealVideoSize(LONG* lpWidth, LONG* lpHeight)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CVMR7AllocatorPresenter::GetMaxIdealVideoSize(LONG* lpWidth, LONG* lpHeight)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CVMR7AllocatorPresenter::SetVideoPosition(const LPRECT lpSRCRect, const LPRECT lpDSTRect)
-{
- return E_NOTIMPL; // we have our own method for this
-}
-
-STDMETHODIMP CVMR7AllocatorPresenter::GetVideoPosition(LPRECT lpSRCRect, LPRECT lpDSTRect)
-{
- CopyRect(lpSRCRect, CRect(CPoint(0, 0), m_NativeVideoSize));
- CopyRect(lpDSTRect, &m_VideoRect);
- // DVD Nav. bug workaround fix
- GetNativeVideoSize(&lpSRCRect->right, &lpSRCRect->bottom, NULL, NULL);
- return S_OK;
-}
-
-STDMETHODIMP CVMR7AllocatorPresenter::GetAspectRatioMode(DWORD* lpAspectRatioMode)
-{
- if(lpAspectRatioMode) *lpAspectRatioMode = AM_ARMODE_STRETCHED;
- return S_OK;
-}
-
-STDMETHODIMP CVMR7AllocatorPresenter::SetAspectRatioMode(DWORD AspectRatioMode)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CVMR7AllocatorPresenter::SetVideoClippingWindow(HWND hwnd)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CVMR7AllocatorPresenter::RepaintVideo(HWND hwnd, HDC hdc)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CVMR7AllocatorPresenter::DisplayModeChanged()
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CVMR7AllocatorPresenter::GetCurrentImage(BYTE** lpDib)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CVMR7AllocatorPresenter::SetBorderColor(COLORREF Clr)
-{
- return E_NOTIMPL;
-}
-
-STDMETHODIMP CVMR7AllocatorPresenter::GetBorderColor(COLORREF* lpClr)
-{
- if(lpClr) *lpClr = 0;
- return S_OK;
-}
-
-STDMETHODIMP CVMR7AllocatorPresenter::SetColorKey(COLORREF Clr)
-{
- return E_NOTIMPL;
-}
-STDMETHODIMP CVMR7AllocatorPresenter::GetColorKey(COLORREF* lpClr)
-{
- return E_NOTIMPL;
-}
-
-//
-
-static HRESULT AllocDX7Surface(IDirectDraw7* pDD, CSize size, DWORD compression, int bpp, IDirectDrawSurface7** pSurface)
-{
- if(!pDD || !pSurface || size.cx <= 0 || size.cy <= 0)
- return E_POINTER;
-
- *pSurface = NULL;
-
- DDSURFACEDESC2 ddsd;
- INITDDSTRUCT(ddsd);
- ddsd.dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT;
- ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN|DDSCAPS_VIDEOMEMORY;
- ddsd.dwWidth = size.cx;
- ddsd.dwHeight = size.cy;
- ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
-
- if(compression >= 0x1000)
- {
- ddsd.ddpfPixelFormat.dwFlags = DDPF_FOURCC;
- ddsd.ddpfPixelFormat.dwFourCC = compression;
- }
- else if((compression == 0 || compression == 3) && (bpp == 15 || bpp == 16 || bpp == 24 || bpp == 32))
- {
- ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
- ddsd.ddpfPixelFormat.dwRGBBitCount = max(bpp, 16);
- ddsd.ddpfPixelFormat.dwRGBAlphaBitMask = (bpp == 16) ? 0x0000 : (bpp == 15) ? 0x8000 : 0xFF000000;
- ddsd.ddpfPixelFormat.dwRBitMask = (bpp == 16) ? 0xf800 : (bpp == 15) ? 0x7c00 : 0x00FF0000;
- ddsd.ddpfPixelFormat.dwGBitMask = (bpp == 16) ? 0x07e0 : (bpp == 15) ? 0x03e0 : 0x0000FF00;
- ddsd.ddpfPixelFormat.dwBBitMask = (bpp == 16) ? 0x001F : (bpp == 15) ? 0x001F : 0x000000FF;
- }
-
- return pDD->CreateSurface(&ddsd, pSurface, NULL);
-}
-
-//
-// CRM7AllocatorPresenter
-//
-
-CRM7AllocatorPresenter::CRM7AllocatorPresenter(HWND hWnd, HRESULT& hr)
- : CDX7AllocatorPresenter(hWnd, hr)
-{
-}
-
-STDMETHODIMP CRM7AllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
-{
- CheckPointer(ppv, E_POINTER);
-
- return
- QI2(IRMAVideoSurface)
- __super::NonDelegatingQueryInterface(riid, ppv);
-}
-
-HRESULT CRM7AllocatorPresenter::AllocSurfaces()
-{
- CAutoLock cAutoLock(this);
-
- m_pVideoSurfaceOff = NULL;
- m_pVideoSurfaceYUY2 = NULL;
-
- DDSURFACEDESC2 ddsd;
- DDBLTFX fx;
-
- INITDDSTRUCT(ddsd);
- ddsd.dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT;
- ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
- ddsd.dwWidth = m_NativeVideoSize.cx;
- ddsd.dwHeight = m_NativeVideoSize.cy;
- ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
- ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
- ddsd.ddpfPixelFormat.dwRGBBitCount = 32;
- ddsd.ddpfPixelFormat.dwRGBAlphaBitMask = 0xFF000000;
- ddsd.ddpfPixelFormat.dwRBitMask = 0x00FF0000;
- ddsd.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
- ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
-
- HRESULT hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurfaceOff, NULL);
- if(FAILED(hr)) return E_FAIL;
-
- INITDDSTRUCT(fx);
- fx.dwFillColor = 0;
- m_pVideoSurfaceOff->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
-
- INITDDSTRUCT(ddsd);
- ddsd.dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT;
- ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
- ddsd.dwWidth = m_NativeVideoSize.cx;
- ddsd.dwHeight = m_NativeVideoSize.cy;
- ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
- ddsd.ddpfPixelFormat.dwFlags = DDPF_FOURCC;
- ddsd.ddpfPixelFormat.dwYUVBitCount = 16;
- ddsd.ddpfPixelFormat.dwFourCC = '2YUY';
-
- hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurfaceYUY2, NULL);
-
- if(FAILED(m_pVideoSurfaceOff->Blt(NULL, m_pVideoSurfaceYUY2, NULL, DDBLT_WAIT, NULL)))
- m_pVideoSurfaceYUY2 = NULL;
-
- if(m_pVideoSurfaceYUY2)
- {
- INITDDSTRUCT(fx);
- fx.dwFillColor = 0x80108010;
- m_pVideoSurfaceYUY2->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
- }
-
- return __super::AllocSurfaces();
-}
-
-void CRM7AllocatorPresenter::DeleteSurfaces()
-{
- CAutoLock cAutoLock(this);
-
- m_pVideoSurfaceOff = NULL;
- m_pVideoSurfaceYUY2 = NULL;
-
- __super::DeleteSurfaces();
-}
-
-// IRMAVideoSurface
-
-STDMETHODIMP CRM7AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader* pBitmapInfo, REF(PNxRect) inDestRect, REF(PNxRect) inSrcRect)
-{
- if(!m_pVideoSurface || !m_pVideoSurfaceOff)
- return E_FAIL;
-
- bool fRGB = false;
- bool fYUY2 = false;
-
- CRect src((RECT*)&inSrcRect), dst((RECT*)&inDestRect), src2(CPoint(0,0), src.Size());
- if(src.Width() > dst.Width() || src.Height() > dst.Height())
- return E_FAIL;
-
- DDSURFACEDESC2 ddsd;
-
- if(pBitmapInfo->biCompression == '024I')
- {
- DWORD pitch = pBitmapInfo->biWidth;
- DWORD size = pitch*abs(pBitmapInfo->biHeight);
-
- BYTE* y = pImageData + src.top*pitch + src.left;
- BYTE* u = pImageData + size + src.top*(pitch/2) + src.left/2;
- BYTE* v = pImageData + size + size/4 + src.top*(pitch/2) + src.left/2;
-
- if(m_pVideoSurfaceYUY2)
- {
- INITDDSTRUCT(ddsd);
- if(SUCCEEDED(m_pVideoSurfaceYUY2->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL)))
- {
- BitBltFromI420ToYUY2(src.Width(), src.Height(), (BYTE*)ddsd.lpSurface, ddsd.lPitch, y, u, v, pitch);
- m_pVideoSurfaceYUY2->Unlock(src2);
- fYUY2 = true;
- }
- }
- else
- {
- INITDDSTRUCT(ddsd);
- if(SUCCEEDED(m_pVideoSurfaceOff->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL)))
- {
- BitBltFromI420ToRGB(src.Width(), src.Height(), (BYTE*)ddsd.lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount, y, u, v, pitch);
- m_pVideoSurfaceOff->Unlock(src2);
- fRGB = true;
- }
- }
- }
- else if(pBitmapInfo->biCompression == '2YUY')
- {
- DWORD w = pBitmapInfo->biWidth;
- DWORD h = abs(pBitmapInfo->biHeight);
- DWORD pitch = pBitmapInfo->biWidth*2;
-
- BYTE* yvyu = pImageData + src.top*pitch + src.left*2;
-
- if(m_pVideoSurfaceYUY2)
- {
- INITDDSTRUCT(ddsd);
- if(SUCCEEDED(m_pVideoSurfaceYUY2->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL)))
- {
- BitBltFromYUY2ToYUY2(src.Width(), src.Height(), (BYTE*)ddsd.lpSurface, ddsd.lPitch, yvyu, pitch);
- m_pVideoSurfaceYUY2->Unlock(src2);
- fYUY2 = true;
- }
- }
- else
- {
- INITDDSTRUCT(ddsd);
- if(SUCCEEDED(m_pVideoSurfaceOff->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL)))
- {
- BitBltFromYUY2ToRGB(src.Width(), src.Height(), (BYTE*)ddsd.lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount, yvyu, pitch);
- m_pVideoSurfaceOff->Unlock(src2);
- fRGB = true;
- }
- }
- }
- else if(pBitmapInfo->biCompression == 0 || pBitmapInfo->biCompression == 3
- || pBitmapInfo->biCompression == 'BGRA')
- {
- DWORD w = pBitmapInfo->biWidth;
- DWORD h = abs(pBitmapInfo->biHeight);
- DWORD pitch = pBitmapInfo->biWidth*pBitmapInfo->biBitCount>>3;
-
- BYTE* rgb = pImageData + src.top*pitch + src.left*(pBitmapInfo->biBitCount>>3);
-
- INITDDSTRUCT(ddsd);
- if(SUCCEEDED(m_pVideoSurfaceOff->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL)))
- {
- BYTE* lpSurface = (BYTE*)ddsd.lpSurface;
- if(pBitmapInfo->biHeight > 0)
- {
- lpSurface += ddsd.lPitch*(src.Height()-1);
- ddsd.lPitch = -ddsd.lPitch;
- }
- BitBltFromRGBToRGB(src.Width(), src.Height(), lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount, rgb, pitch, pBitmapInfo->biBitCount);
- fRGB = true;
- m_pVideoSurfaceOff->Unlock(src2);
- }
- }
-
- if(!fRGB && !fYUY2)
- {
- DDBLTFX fx;
- INITDDSTRUCT(fx);
- fx.dwFillColor = 0;
- m_pVideoSurfaceOff->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
-
- HDC hDC;
- if(SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC)))
- {
- CString str;
- str.Format(_T("Sorry, this format is not supported"));
-
- SetBkColor(hDC, 0);
- SetTextColor(hDC, 0x404040);
- TextOut(hDC, 10, 10, str, str.GetLength());
-
- m_pVideoSurfaceOff->ReleaseDC(hDC);
-
- fRGB = true;
- }
- }
-
-
- HRESULT hr;
-
- if(fRGB)
- hr = m_pVideoSurface->Blt(dst, m_pVideoSurfaceOff, src2, DDBLT_WAIT, NULL);
- if(fYUY2)
- hr = m_pVideoSurface->Blt(dst, m_pVideoSurfaceYUY2, src2, DDBLT_WAIT, NULL);
-
- Paint(true);
-
- return PNR_OK;
-}
-
-STDMETHODIMP CRM7AllocatorPresenter::BeginOptimizedBlt(RMABitmapInfoHeader* pBitmapInfo)
-{
- CAutoLock cAutoLock(this);
- DeleteSurfaces();
- m_NativeVideoSize = m_AspectRatio = CSize(pBitmapInfo->biWidth, abs(pBitmapInfo->biHeight));
- if(FAILED(AllocSurfaces())) return E_FAIL;
- return PNR_NOTIMPL;
-}
-
-STDMETHODIMP CRM7AllocatorPresenter::OptimizedBlt(UCHAR* pImageBits, REF(PNxRect) rDestRect, REF(PNxRect) rSrcRect)
-{
- return PNR_NOTIMPL;
-}
-
-STDMETHODIMP CRM7AllocatorPresenter::EndOptimizedBlt()
-{
- return PNR_NOTIMPL;
-}
-
-STDMETHODIMP CRM7AllocatorPresenter::GetOptimizedFormat(REF(RMA_COMPRESSION_TYPE) ulType)
-{
- return PNR_NOTIMPL;
-}
-
-STDMETHODIMP CRM7AllocatorPresenter::GetPreferredFormat(REF(RMA_COMPRESSION_TYPE) ulType)
-{
- ulType = RMA_I420;
- return PNR_OK;
-}
-
-//
-// CQT7AllocatorPresenter
-//
-
-CQT7AllocatorPresenter::CQT7AllocatorPresenter(HWND hWnd, HRESULT& hr)
- : CDX7AllocatorPresenter(hWnd, hr)
-{
-}
-
-STDMETHODIMP CQT7AllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
-{
- CheckPointer(ppv, E_POINTER);
-
- return
- QI(IQTVideoSurface)
- __super::NonDelegatingQueryInterface(riid, ppv);
-}
-
-HRESULT CQT7AllocatorPresenter::AllocSurfaces()
-{
- CAutoLock cAutoLock(this);
-
- m_pVideoSurfaceOff = NULL;
-
- DDSURFACEDESC2 ddsd;
- INITDDSTRUCT(ddsd);
- ddsd.dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT;
- ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
- ddsd.dwWidth = m_NativeVideoSize.cx;
- ddsd.dwHeight = m_NativeVideoSize.cy;
- ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
- ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
- ddsd.ddpfPixelFormat.dwRGBBitCount = 32;
- ddsd.ddpfPixelFormat.dwRGBAlphaBitMask = 0xFF000000;
- ddsd.ddpfPixelFormat.dwRBitMask = 0x00FF0000;
- ddsd.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
- ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
-
- HRESULT hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurfaceOff, NULL);
- if(FAILED(hr)) return E_FAIL;
-
- DDBLTFX fx;
- INITDDSTRUCT(fx);
- fx.dwFillColor = 0;
- m_pVideoSurfaceOff->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
-
- return __super::AllocSurfaces();
-}
-
-void CQT7AllocatorPresenter::DeleteSurfaces()
-{
- CAutoLock cAutoLock(this);
-
- m_pVideoSurfaceOff = NULL;
-
- __super::DeleteSurfaces();
-}
-
-// IQTVideoSurface
-
-STDMETHODIMP CQT7AllocatorPresenter::BeginBlt(const BITMAP& bm)
-{
- CAutoLock cAutoLock(this);
-
- DeleteSurfaces();
-
- m_NativeVideoSize = m_AspectRatio = CSize(bm.bmWidth, abs(bm.bmHeight));
-
- HRESULT hr;
- if(FAILED(hr = AllocSurfaces()))
- return hr;
-
- return S_OK;
-}
-
-STDMETHODIMP CQT7AllocatorPresenter::DoBlt(const BITMAP& bm)
-{
- if(!m_pVideoSurface || !m_pVideoSurfaceOff)
- return E_FAIL;
-
- bool fOk = false;
-
- DDSURFACEDESC2 ddsd;
- INITDDSTRUCT(ddsd);
- if(FAILED(m_pVideoSurfaceOff->GetSurfaceDesc(&ddsd)))
- return E_FAIL;
-
- int w = bm.bmWidth;
- int h = abs(bm.bmHeight);
- int bpp = bm.bmBitsPixel;
-
- if((bpp == 16 || bpp == 24 || bpp == 32) && w == ddsd.dwWidth && h == ddsd.dwHeight)
- {
- INITDDSTRUCT(ddsd);
- if(SUCCEEDED(m_pVideoSurfaceOff->Lock(NULL, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL)))
- {
- BitBltFromRGBToRGB(
- w, h,
- (BYTE*)ddsd.lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount,
- (BYTE*)bm.bmBits, bm.bmWidthBytes, bm.bmBitsPixel);
- m_pVideoSurfaceOff->Unlock(NULL);
- fOk = true;
- }
- }
-
- if(!fOk)
- {
- DDBLTFX fx;
- INITDDSTRUCT(fx);
- fx.dwFillColor = 0;
- m_pVideoSurfaceOff->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
-
- HDC hDC;
- if(SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC)))
- {
- CString str;
- str.Format(_T("Sorry, this format is not supported"));
-
- SetBkColor(hDC, 0);
- SetTextColor(hDC, 0x404040);
- TextOut(hDC, 10, 10, str, str.GetLength());
-
- m_pVideoSurfaceOff->ReleaseDC(hDC);
- }
- }
-
- m_pVideoSurface->Blt(NULL, m_pVideoSurfaceOff, NULL, DDBLT_WAIT, NULL);
-
- Paint(true);
-
- return S_OK;
-}
diff --git a/src/apps/mplayerc/DX7AllocatorPresenter.h b/src/apps/mplayerc/DX7AllocatorPresenter.h index 504e50fe4..da59c1ef8 100644 --- a/src/apps/mplayerc/DX7AllocatorPresenter.h +++ b/src/apps/mplayerc/DX7AllocatorPresenter.h @@ -23,21 +23,42 @@ #pragma once
-#include "../../SubPic/ISubPic.h"
+#include "AllocatorCommon7.h"
+#include <ddraw.h>
+#include <d3d.h>
+namespace DSObjects
+{
-// {495CF191-810D-44c7-92C5-E7D46AE00F44}
-DEFINE_GUID(CLSID_VMR7AllocatorPresenter,
- 0x495cf191, 0x810d, 0x44c7, 0x92, 0xc5, 0xe7, 0xd4, 0x6a, 0xe0, 0xf, 0x44);
+ class CDX7AllocatorPresenter
+ : public ISubPicAllocatorPresenterImpl
+ {
+ protected:
+ CSize m_ScreenSize;
-// {97B3462E-1752-4dfb-A038-271060BC7A94}
-DEFINE_GUID(CLSID_RM7AllocatorPresenter,
- 0x97b3462e, 0x1752, 0x4dfb, 0xa0, 0x38, 0x27, 0x10, 0x60, 0xbc, 0x7a, 0x94);
+ CComPtr<IDirectDraw7> m_pDD;
+ CComQIPtr<IDirect3D7, &IID_IDirect3D7> m_pD3D;
+ CComPtr<IDirect3DDevice7> m_pD3DDev;
-// {36CC5A71-441C-462a-9D10-48A19485938D}
-DEFINE_GUID(CLSID_QT7AllocatorPresenter,
- 0x36cc5a71, 0x441c, 0x462a, 0x9d, 0x10, 0x48, 0xa1, 0x94, 0x85, 0x93, 0x8d);
+ CComPtr<IDirectDrawSurface7> m_pPrimary;
+ CComPtr<IDirectDrawSurface7> m_pBackBuffer;
+ CComPtr<IDirectDrawSurface7> m_pVideoTexture;
+ CComPtr<IDirectDrawSurface7> m_pVideoSurface;
-extern HRESULT CreateAP7(const CLSID& clsid, HWND hWnd, ISubPicAllocatorPresenter** ppAP);
+ virtual HRESULT CreateDevice();
+ virtual HRESULT AllocSurfaces();
+ virtual void DeleteSurfaces();
-extern bool IsVMR7InGraph(IFilterGraph* pFG);
+ void SendResetRequest();
+
+ public:
+ CDX7AllocatorPresenter(HWND hWnd, HRESULT& hr);
+
+ // ISubPicAllocatorPresenter
+ STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
+ STDMETHODIMP_(bool) Paint(bool fAll);
+ STDMETHODIMP GetDIB(BYTE* lpDib, DWORD* size);
+ STDMETHODIMP_(bool) ResetDevice();
+ };
+
+}
diff --git a/src/apps/mplayerc/DX9AllocatorPresenter.cpp b/src/apps/mplayerc/DX9AllocatorPresenter.cpp index 07ec23e24..4c1f586c6 100644 --- a/src/apps/mplayerc/DX9AllocatorPresenter.cpp +++ b/src/apps/mplayerc/DX9AllocatorPresenter.cpp @@ -32,6 +32,9 @@ CCritSec g_ffdshowReceive;
bool queue_ffdshow_support = false;
+// only for debugging
+//#define DISABLE_USING_D3D9EX
+
#define FRAMERATE_MAX_DELTA 3000
//#pragma optimize("", off)
//#pragma inline_depth(0)
@@ -212,10 +215,8 @@ CDX9AllocatorPresenter::CDX9AllocatorPresenter(HWND hWnd, HRESULT& hr, bool bIsE , m_iVMR9Surface(0)
, m_nCurSurface(0)
, m_rtTimePerFrame(0)
- , m_bInterlaced(0)
+ , m_bInterlaced(false)
, m_nUsedBuffer(0)
- , m_bNeedPendingResetDevice(0)
- , m_bPendingResetDevice(0)
, m_OrderedPaint(0)
, m_bCorrectedFrameTime(0)
, m_FrameTimeCorrection(0)
@@ -224,16 +225,13 @@ CDX9AllocatorPresenter::CDX9AllocatorPresenter(HWND hWnd, HRESULT& hr, bool bIsE , m_bAlternativeVSync(0)
, m_bIsEVR(bIsEVR)
, m_VSyncMode(0)
- , m_TextScale(1.0)
-
+ , m_TextScale(1.0)
+ , m_MainThreadId(0)
+ , m_bNeedCheckSample(true)
+ , m_pDirectDraw(NULL)
+ , m_hVSyncThread(NULL)
+ , m_hEvtQuit(NULL)
{
-
- m_MainThreadId = 0;
- m_bNeedCheckSample = true;
- m_pDirectDraw = NULL;
- m_hVSyncThread = NULL;
- m_hEvtQuit = NULL;
-
m_bIsFullscreen = (AfxGetApp()->m_pMainWnd != NULL) && (((CMainFrame*)AfxGetApp()->m_pMainWnd)->IsD3DFullScreenMode());
HINSTANCE hDll;
@@ -270,13 +268,27 @@ CDX9AllocatorPresenter::CDX9AllocatorPresenter(HWND hWnd, HRESULT& hr, bool bIsE (FARPROC &)m_pDwmEnableComposition = GetProcAddress(m_hDWMAPI, "DwmEnableComposition");
}
- m_hD3D9 = LoadLibrary(L"d3d9.dll");
+ m_pDirect3DCreate9Ex = NULL;
+ m_hD3D9 = LoadLibrary(L"d3d9.dll");
+#ifdef DISABLE_USING_D3D9EX
if (m_hD3D9)
- {
- (FARPROC &)m_pDirect3DCreate9Ex = GetProcAddress(m_hD3D9, "Direct3DCreate9Ex");
- }
- else
- m_pDirect3DCreate9Ex = NULL;
+ (FARPROC &)m_pDirect3DCreate9Ex = GetProcAddress(m_hD3D9, "Direct3DCreate9Ex");
+#endif
+
+ if (m_pDirect3DCreate9Ex)
+ {
+ m_pDirect3DCreate9Ex(D3D_SDK_VERSION, &m_pD3DEx);
+ if(!m_pD3DEx)
+ m_pDirect3DCreate9Ex(D3D9b_SDK_VERSION, &m_pD3DEx);
+ }
+ if(!m_pD3DEx)
+ {
+ m_pD3D.Attach(Direct3DCreate9(D3D_SDK_VERSION));
+ if(!m_pD3D)
+ m_pD3D.Attach(Direct3DCreate9(D3D9b_SDK_VERSION));
+ }
+ else
+ m_pD3D = m_pD3DEx;
m_DetectedFrameRate = 0.0;
m_DetectedFrameTime = 0.0;
@@ -747,6 +759,7 @@ void CDX9AllocatorPresenter::VSyncThread() DWORD WINAPI CDX9AllocatorPresenter::VSyncThreadStatic(LPVOID lpParam)
{
+ SetThreadName(-1, "CEVRAllocatorPresenter::VSyncThread");
CDX9AllocatorPresenter* pThis = (CDX9AllocatorPresenter*) lpParam;
pThis->VSyncThread();
return 0;
@@ -903,35 +916,13 @@ HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error) {
CExternalPixelShader &Shader = m_pPixelShaders.GetNext(pos);
Shader.m_pPixelShader = NULL;
- }
-
- m_pD3DEx = NULL;
- m_pD3D = NULL;
-
- if (m_pDirect3DCreate9Ex)
- {
- m_pDirect3DCreate9Ex(D3D_SDK_VERSION, &m_pD3DEx);
- if(!m_pD3DEx)
- {
- m_pDirect3DCreate9Ex(D3D9b_SDK_VERSION, &m_pD3DEx);
- }
- }
- if(!m_pD3DEx)
- {
- m_pD3D.Attach(Direct3DCreate9(D3D_SDK_VERSION));
- if(!m_pD3D)
- {
- m_pD3D.Attach(Direct3DCreate9(D3D9b_SDK_VERSION));
- }
- if(!m_pD3D)
- {
- _Error += L"Failed to create D3D9\n";
- return E_UNEXPECTED;
- }
- }
- else
- m_pD3D = m_pD3DEx;
+ }
+ if(!m_pD3D)
+ {
+ _Error += L"Failed to create D3D9\n";
+ return E_UNEXPECTED;
+ }
D3DDISPLAYMODE d3ddm;
HRESULT hr;
@@ -1120,7 +1111,9 @@ HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error) D3DCREATE_SOFTWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED, //D3DCREATE_MANAGED
&pp, &m_pD3DDev);
}
- }
+ }
+
+ m_MainThreadId = GetCurrentThreadId();
if (m_pD3DDevEx)
{
@@ -1273,7 +1266,7 @@ HRESULT CDX9AllocatorPresenter::AllocSurfaces(D3DFORMAT Format) }
m_pScreenSizeTemporaryTexture[0] = NULL;
- m_pScreenSizeTemporaryTexture[1] = NULL;
+ m_pScreenSizeTemporaryTexture[1] = NULL;
m_SurfaceType = Format;
@@ -2291,10 +2284,10 @@ void CDX9AllocatorPresenter::UpdateAlphaBitmap() STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll)
{
- if (!m_pD3DDev)
+ if (m_bPendingResetDevice)
{
- if (!ResetDevice()) // fix Windows+L crash
- return false;
+ SendResetRequest();
+ return false;
}
AppSettings& s = AfxGetAppSettings();
@@ -2771,19 +2764,19 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll) if (bTakenLock)
UnlockD3DDevice();
+ /*if (!bWaited)
+ {
+ bWaited = true;
+ WaitForVBlank(bWaited);
+ TRACE("Double VBlank\n");
+ ASSERT(bWaited);
+ if (!bDoVSyncInPresent)
+ {
+ CalculateJitter();
+ OnVBlankFinished(fAll);
+ }
+ }*/
- /* if (!bWaited)
- {
- bWaited = true;
- WaitForVBlank(bWaited);
- TRACE("Double VBlank\n");
- ASSERT(bWaited);
- if (!bDoVSyncInPresent)
- {
- CalculateJitter();
- OnVBlankFinished(fAll);
- }
- }*/
bool fResetDevice = m_bPendingResetDevice;
if(hr == D3DERR_DEVICELOST && m_pD3DDev->TestCooperativeLevel() == D3DERR_DEVICENOTRESET
@@ -2818,21 +2811,9 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll) }
if(fResetDevice)
- {
- if (m_bNeedPendingResetDevice)
- {
- m_bPendingResetDevice = true;
- }
- else
- {
- if (m_MainThreadId && m_MainThreadId == GetCurrentThreadId())
- {
- m_bPendingResetDevice = false;
- ResetDevice();
- }
- else
- m_bPendingResetDevice = true;
- }
+ {
+ m_bPendingResetDevice = true;
+ SendResetRequest();
}
if (m_OrderedPaint)
@@ -2861,8 +2842,19 @@ double CDX9AllocatorPresenter::GetFrameRate() return 10000000.0 / m_rtTimePerFrame;
}
-bool CDX9AllocatorPresenter::ResetDevice()
+void CDX9AllocatorPresenter::SendResetRequest()
+{
+ if (!m_bDeviceResetRequested)
+ {
+ m_bDeviceResetRequested = true;
+ AfxGetApp()->m_pMainWnd->PostMessage(WM_RESET_DEVICE);
+ }
+}
+
+STDMETHODIMP_(bool) CDX9AllocatorPresenter::ResetDevice()
{
+ TRACE("ResetDevice\n");
+ _ASSERT(m_MainThreadId == GetCurrentThreadId());
StopWorkerThreads();
DeleteSurfaces();
HRESULT hr;
@@ -2875,9 +2867,12 @@ bool CDX9AllocatorPresenter::ResetDevice() Error += GetWindowsErrorMessage(hr, NULL);
TRACE("D3D Reset Error\n%ws\n\n", Error.GetBuffer());
#endif
+ m_bDeviceResetRequested = false;
return false;
}
- OnResetDevice();
+ OnResetDevice();
+ m_bDeviceResetRequested = false;
+ m_bPendingResetDevice = false;
return true;
}
diff --git a/src/apps/mplayerc/DX9AllocatorPresenter.h b/src/apps/mplayerc/DX9AllocatorPresenter.h index 8ee3c674d..38d600c78 100644 --- a/src/apps/mplayerc/DX9AllocatorPresenter.h +++ b/src/apps/mplayerc/DX9AllocatorPresenter.h @@ -26,20 +26,6 @@ #include "AllocatorCommon.h"
#include "mplayerc.h"
-// Support ffdshow queueing.
-// This interface is used to check version of Media Player Classic.
-// {A273C7F6-25D4-46b0-B2C8-4F7FADC44E37}
-DEFINE_GUID(IID_IVMRffdshow9,
- 0xa273c7f6, 0x25d4, 0x46b0, 0xb2, 0xc8, 0x4f, 0x7f, 0xad, 0xc4, 0x4e, 0x37);
-
-MIDL_INTERFACE("A273C7F6-25D4-46b0-B2C8-4F7FADC44E37")
-IVMRffdshow9 :
-public IUnknown
-{
-public:
- virtual STDMETHODIMP support_ffdshow(void) = 0;
-};
-
#define VMRBITMAP_UPDATE 0x80000000
#define MAX_PICTURE_SLOTS (60+2) // Last 2 for pixels shader!
@@ -86,9 +72,9 @@ protected: CCritSec m_RenderLock;
CComPtr<IDirectDraw> m_pDirectDraw;
- CComPtr<IDirect3D9Ex> m_pD3DEx;
+ CComPtr<IDirect3D9Ex> m_pD3DEx;
CComPtr<IDirect3D9> m_pD3D;
- CComPtr<IDirect3DDevice9Ex> m_pD3DDevEx;
+ CComPtr<IDirect3DDevice9Ex> m_pD3DDevEx;
void LockD3DDevice()
{
@@ -145,13 +131,13 @@ protected: };
CAtlList<CExternalPixelShader> m_pPixelShaders;
CAtlList<CExternalPixelShader> m_pPixelShadersScreenSpace;
- CComPtr<IDirect3DPixelShader9> m_pResizerPixelShader[4]; // bl, bc1, bc2_1, bc2_2
+ CComPtr<IDirect3DPixelShader9> m_pResizerPixelShader[4]; // bl, bc1, bc2_1, bc2_2
CComPtr<IDirect3DTexture9> m_pScreenSizeTemporaryTexture[2];
D3DFORMAT m_SurfaceType;
D3DFORMAT m_BackbufferType;
D3DFORMAT m_DisplayType;
D3DTEXTUREFILTERTYPE m_filter;
- D3DCAPS9 m_caps;
+ D3DCAPS9 m_caps;
CAutoPtr<CPixelShaderCompiler> m_pPSC;
@@ -222,8 +208,8 @@ protected: void DrawText(const RECT &rc, const CString &strText, int _Priority);
void DrawStats();
HRESULT AlphaBlt(RECT* pSrc, RECT* pDst, CComPtr<IDirect3DTexture9> pTexture);
- virtual void OnResetDevice() {};
- virtual bool ResetDevice();
+ virtual void OnResetDevice() {};
+ void SendResetRequest();
double GetFrameTime();
double GetFrameRate();
@@ -246,9 +232,7 @@ protected: int m_nVMR9Surfaces; // Total number of DX Surfaces
int m_iVMR9Surface;
int m_nCurSurface; // Surface currently displayed
- long m_nUsedBuffer;
- bool m_bNeedPendingResetDevice;
- bool m_bPendingResetDevice;
+ long m_nUsedBuffer;
double m_fAvrFps; // Estimate the real FPS
double m_fJitterStdDev; // Estimate the Jitter std dev
@@ -359,6 +343,7 @@ public: STDMETHODIMP_(bool) Paint(bool fAll);
STDMETHODIMP GetDIB(BYTE* lpDib, DWORD* size);
STDMETHODIMP SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget);
- STDMETHODIMP SetPixelShader2(LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace);
+ STDMETHODIMP SetPixelShader2(LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace);
+ STDMETHODIMP_(bool) ResetDevice();
};
}
diff --git a/src/apps/mplayerc/EVRAllocatorPresenter.cpp b/src/apps/mplayerc/EVRAllocatorPresenter.cpp index af2235a8d..8df90f23f 100644 --- a/src/apps/mplayerc/EVRAllocatorPresenter.cpp +++ b/src/apps/mplayerc/EVRAllocatorPresenter.cpp @@ -315,8 +315,6 @@ CEVRAllocatorPresenter::CEVRAllocatorPresenter(HWND hWnd, HRESULT& hr, CString & m_ModeratedTimeLast = -1;
m_ModeratedClockLast = -1;
- m_bNeedPendingResetDevice = true;
-
if (FAILED (hr))
{
_Error += L"DX9AllocatorPresenter failed\n";
@@ -562,7 +560,6 @@ STDMETHODIMP CEVRAllocatorPresenter::CreateRenderer(IUnknown** ppRenderer) STDMETHODIMP_(bool) CEVRAllocatorPresenter::Paint(bool fAll)
{
-
return __super::Paint (fAll);
}
@@ -1612,6 +1609,7 @@ STDMETHODIMP CEVRAllocatorPresenter::InitializeDevice(AM_MEDIA_TYPE* pMediaType) DWORD WINAPI CEVRAllocatorPresenter::GetMixerThreadStatic(LPVOID lpParam)
{
+ SetThreadName(-1, "CEVRAllocatorPresenter::MixerThread");
CEVRAllocatorPresenter* pThis = (CEVRAllocatorPresenter*) lpParam;
pThis->GetMixerThread();
return 0;
@@ -1620,6 +1618,7 @@ DWORD WINAPI CEVRAllocatorPresenter::GetMixerThreadStatic(LPVOID lpParam) DWORD WINAPI CEVRAllocatorPresenter::PresentThread(LPVOID lpParam)
{
+ SetThreadName(-1, "CEVRAllocatorPresenter::PresentThread");
CEVRAllocatorPresenter* pThis = (CEVRAllocatorPresenter*) lpParam;
pThis->RenderThread();
return 0;
@@ -1972,6 +1971,31 @@ void CEVRAllocatorPresenter::OnVBlankFinished(bool fAll, LONGLONG PerformanceCou }
}
+STDMETHODIMP_(bool) CEVRAllocatorPresenter::ResetDevice()
+{
+ CAutoLock lock(this);
+ CAutoLock lock2(&m_ImageProcessingLock);
+ CAutoLock cRenderLock(&m_RenderLock);
+
+ RemoveAllSamples();
+
+ bool bResult = __super::ResetDevice();
+
+ for(int i = 0; i < m_nNbDXSurface; i++)
+ {
+ CComPtr<IMFSample> pMFSample;
+ HRESULT hr = pfMFCreateVideoSampleFromSurface (m_pVideoSurface[i], &pMFSample);
+
+ if (SUCCEEDED (hr))
+ {
+ pMFSample->SetUINT32 (GUID_SURFACE_INDEX, i);
+ m_FreeSamples.AddTail (pMFSample);
+ }
+ ASSERT (SUCCEEDED (hr));
+ }
+ return bResult;
+}
+
void CEVRAllocatorPresenter::RenderThread()
{
HANDLE hAvrt;
@@ -2035,31 +2059,8 @@ void CEVRAllocatorPresenter::RenderThread() m_bPendingRenegotiate = false;
}
if (m_bPendingResetDevice)
- {
- m_bPendingResetDevice = false;
- CAutoLock lock(this);
- CAutoLock lock2(&m_ImageProcessingLock);
- CAutoLock cRenderLock(&m_RenderLock);
-
+ SendResetRequest();
- RemoveAllSamples();
-
- CDX9AllocatorPresenter::ResetDevice();
-
- for(int i = 0; i < m_nNbDXSurface; i++)
- {
- CComPtr<IMFSample> pMFSample;
- HRESULT hr = pfMFCreateVideoSampleFromSurface (m_pVideoSurface[i], &pMFSample);
-
- if (SUCCEEDED (hr))
- {
- pMFSample->SetUINT32 (GUID_SURFACE_INDEX, i);
- m_FreeSamples.AddTail (pMFSample);
- }
- ASSERT (SUCCEEDED (hr));
- }
-
- }
// Discard timer events if playback stop
// if ((dwObject == WAIT_OBJECT_0 + 3) && (m_nRenderState != Started)) continue;
@@ -2378,8 +2379,6 @@ void CEVRAllocatorPresenter::OnResetDevice() m_pSink->Notify (EC_DISPLAY_CHANGED, 0, 0);
}
-
-
void CEVRAllocatorPresenter::RemoveAllSamples()
{
CAutoLock AutoLock(&m_ImageProcessingLock);
@@ -2389,7 +2388,6 @@ void CEVRAllocatorPresenter::RemoveAllSamples() m_FreeSamples.RemoveAll();
m_LastScheduledSampleTime = -1;
m_LastScheduledUncorrectedSampleTime = -1;
- ASSERT(m_nUsedBuffer == 0);
m_nUsedBuffer = 0;
}
diff --git a/src/apps/mplayerc/EVRAllocatorPresenter.h b/src/apps/mplayerc/EVRAllocatorPresenter.h index 40c31dc85..1f0ee48ea 100644 --- a/src/apps/mplayerc/EVRAllocatorPresenter.h +++ b/src/apps/mplayerc/EVRAllocatorPresenter.h @@ -72,8 +72,8 @@ public: STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
STDMETHODIMP_(bool) Paint(bool fAll);
STDMETHODIMP GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight);
- STDMETHODIMP InitializeDevice(AM_MEDIA_TYPE* pMediaType);
-
+ STDMETHODIMP InitializeDevice(AM_MEDIA_TYPE* pMediaType);
+ STDMETHODIMP_(bool) ResetDevice();
// IMFClockStateSink
STDMETHODIMP OnClockStart(/* [in] */ MFTIME hnsSystemTime, /* [in] */ LONGLONG llClockStartOffset);
@@ -147,8 +147,8 @@ public: STDMETHODIMP DisableImageExport(BOOL bDisable);
// IDirect3DDeviceManager9
- STDMETHODIMP ResetDevice(IDirect3DDevice9 *pDevice,UINT resetToken);
- STDMETHODIMP OpenDeviceHandle(HANDLE *phDevice);
+ STDMETHODIMP ResetDevice(IDirect3DDevice9 *pDevice,UINT resetToken);
+ STDMETHODIMP OpenDeviceHandle(HANDLE *phDevice);
STDMETHODIMP CloseDeviceHandle(HANDLE hDevice);
STDMETHODIMP TestDevice(HANDLE hDevice);
STDMETHODIMP LockDevice(HANDLE hDevice, IDirect3DDevice9 **ppDevice, BOOL fBlock);
diff --git a/src/apps/mplayerc/FGFilter.cpp b/src/apps/mplayerc/FGFilter.cpp index a3e35940c..737fa6824 100644 --- a/src/apps/mplayerc/FGFilter.cpp +++ b/src/apps/mplayerc/FGFilter.cpp @@ -24,7 +24,7 @@ #include "stdafx.h"
#include "FGFilter.h"
#include "../../DSUtil/DSUtil.h"
-#include "DX7AllocatorPresenter.h"
+#include "AllocatorCommon7.h"
#include "AllocatorCommon.h"
#include "SyncAllocatorPresenter.h"
#include <moreuuids.h>
diff --git a/src/apps/mplayerc/FGManager.cpp b/src/apps/mplayerc/FGManager.cpp index 7f6f6afc2..fa5d25fd6 100644 --- a/src/apps/mplayerc/FGManager.cpp +++ b/src/apps/mplayerc/FGManager.cpp @@ -26,7 +26,7 @@ #include "FGManager.h"
#include "../../DSUtil/DSUtil.h"
#include "../../filters/filters.h"
-#include "DX7AllocatorPresenter.h"
+#include "AllocatorCommon7.h"
#include "AllocatorCommon.h"
#include "SyncAllocatorPresenter.h"
#include "DeinterlacerFilter.h"
diff --git a/src/apps/mplayerc/MainFrm.cpp b/src/apps/mplayerc/MainFrm.cpp index bafe3aab5..e17fe9429 100644 --- a/src/apps/mplayerc/MainFrm.cpp +++ b/src/apps/mplayerc/MainFrm.cpp @@ -73,7 +73,7 @@ #include "../../filters/filters.h"
#include "../../filters/PinInfoWnd.h"
-#include "DX7AllocatorPresenter.h"
+#include "AllocatorCommon7.h"
#include "AllocatorCommon.h"
#include "../../subtitles/SSF.h"
@@ -190,6 +190,7 @@ BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) ON_WM_TIMER()
ON_MESSAGE(WM_GRAPHNOTIFY, OnGraphNotify)
+ ON_MESSAGE(WM_RESET_DEVICE, OnResetDevice)
ON_MESSAGE(WM_REARRANGERENDERLESS, OnRepaintRenderLess)
ON_MESSAGE(WM_RESUMEFROMSTATE, OnResumeFromState)
@@ -483,6 +484,79 @@ BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) ON_UPDATE_COMMAND_UI(ID_VIEW_NAVIGATION, OnUpdateViewNavigation)
END_MESSAGE_MAP()
+
+const TCHAR *GetEventString(LONG evCode)
+{
+#define UNPACK_VALUE(VALUE) case VALUE: return _T( #VALUE );
+ switch(evCode)
+ {
+ UNPACK_VALUE(EC_COMPLETE);
+ UNPACK_VALUE(EC_USERABORT);
+ UNPACK_VALUE(EC_ERRORABORT);
+ UNPACK_VALUE(EC_TIME);
+ UNPACK_VALUE(EC_REPAINT);
+ UNPACK_VALUE(EC_STREAM_ERROR_STOPPED);
+ UNPACK_VALUE(EC_STREAM_ERROR_STILLPLAYING);
+ UNPACK_VALUE(EC_ERROR_STILLPLAYING);
+ UNPACK_VALUE(EC_PALETTE_CHANGED);
+ UNPACK_VALUE(EC_VIDEO_SIZE_CHANGED);
+ UNPACK_VALUE(EC_QUALITY_CHANGE);
+ UNPACK_VALUE(EC_SHUTTING_DOWN);
+ UNPACK_VALUE(EC_CLOCK_CHANGED);
+ UNPACK_VALUE(EC_PAUSED);
+ UNPACK_VALUE(EC_OPENING_FILE);
+ UNPACK_VALUE(EC_BUFFERING_DATA);
+ UNPACK_VALUE(EC_FULLSCREEN_LOST);
+ UNPACK_VALUE(EC_ACTIVATE);
+ UNPACK_VALUE(EC_NEED_RESTART);
+ UNPACK_VALUE(EC_WINDOW_DESTROYED);
+ UNPACK_VALUE(EC_DISPLAY_CHANGED);
+ UNPACK_VALUE(EC_STARVATION);
+ UNPACK_VALUE(EC_OLE_EVENT);
+ UNPACK_VALUE(EC_NOTIFY_WINDOW);
+ UNPACK_VALUE(EC_STREAM_CONTROL_STOPPED);
+ UNPACK_VALUE(EC_STREAM_CONTROL_STARTED);
+ UNPACK_VALUE(EC_END_OF_SEGMENT);
+ UNPACK_VALUE(EC_SEGMENT_STARTED);
+ UNPACK_VALUE(EC_LENGTH_CHANGED);
+ UNPACK_VALUE(EC_DEVICE_LOST);
+ UNPACK_VALUE(EC_SAMPLE_NEEDED);
+ UNPACK_VALUE(EC_PROCESSING_LATENCY);
+ UNPACK_VALUE(EC_SAMPLE_LATENCY);
+ UNPACK_VALUE(EC_SCRUB_TIME);
+ UNPACK_VALUE(EC_STEP_COMPLETE);
+ UNPACK_VALUE(EC_TIMECODE_AVAILABLE);
+ UNPACK_VALUE(EC_EXTDEVICE_MODE_CHANGE);
+ UNPACK_VALUE(EC_STATE_CHANGE);
+ UNPACK_VALUE(EC_GRAPH_CHANGED);
+ UNPACK_VALUE(EC_CLOCK_UNSET);
+ UNPACK_VALUE(EC_VMR_RENDERDEVICE_SET);
+ UNPACK_VALUE(EC_VMR_SURFACE_FLIPPED);
+ UNPACK_VALUE(EC_VMR_RECONNECTION_FAILED);
+ UNPACK_VALUE(EC_PREPROCESS_COMPLETE);
+ UNPACK_VALUE(EC_CODECAPI_EVENT);
+ UNPACK_VALUE(EC_WMT_INDEX_EVENT);
+ UNPACK_VALUE(EC_WMT_EVENT);
+ UNPACK_VALUE(EC_BUILT);
+ UNPACK_VALUE(EC_UNBUILT);
+ UNPACK_VALUE(EC_SKIP_FRAMES);
+ UNPACK_VALUE(EC_PLEASE_REOPEN);
+ UNPACK_VALUE(EC_STATUS);
+ UNPACK_VALUE(EC_MARKER_HIT);
+ UNPACK_VALUE(EC_LOADSTATUS);
+ UNPACK_VALUE(EC_FILE_CLOSED);
+ UNPACK_VALUE(EC_ERRORABORTEX);
+ //UNPACK_VALUE(EC_NEW_PIN);
+ //UNPACK_VALUE(EC_RENDER_FINISHED);
+ UNPACK_VALUE(EC_EOS_SOON);
+ UNPACK_VALUE(EC_CONTENTPROPERTY_CHANGED);
+ UNPACK_VALUE(EC_BANDWIDTHCHANGE);
+ UNPACK_VALUE(EC_VIDEOFRAMEREADY);
+ };
+#undef UNPACK_VALUE
+ return _T("UNKNOWN");
+}
+
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
@@ -1554,8 +1628,11 @@ bool g_bExternalSubtitleTime = false; void CMainFrame::OnTimer(UINT_PTR nIDEvent)
{
- if(nIDEvent == TIMER_STREAMPOSPOLLER && m_iMediaLoadState == MLS_LOADED)
+ switch (nIDEvent)
{
+ case TIMER_STREAMPOSPOLLER:
+ if(m_iMediaLoadState == MLS_LOADED)
+ {
REFERENCE_TIME rtNow = 0, rtDur = 0;
if(GetPlaybackMode() == PM_FILE)
@@ -1652,7 +1729,9 @@ void CMainFrame::OnTimer(UINT_PTR nIDEvent) else
g_bExternalSubtitleTime = false;
}
- else if(nIDEvent == TIMER_STREAMPOSPOLLER2 && m_iMediaLoadState == MLS_LOADED)
+ break;
+ case TIMER_STREAMPOSPOLLER2:
+ if (m_iMediaLoadState == MLS_LOADED)
{
__int64 start, stop, pos;
m_wndSeekBar.GetRange(start, stop);
@@ -1689,7 +1768,8 @@ void CMainFrame::OnTimer(UINT_PTR nIDEvent) if(m_pCAP && GetMediaState() == State_Paused)
m_pCAP->Paint(false);
}
- else if(nIDEvent == TIMER_FULLSCREENCONTROLBARHIDER)
+ break;
+ case TIMER_FULLSCREENCONTROLBARHIDER:
{
CPoint p;
GetCursorPos(&p);
@@ -1705,7 +1785,8 @@ void CMainFrame::OnTimer(UINT_PTR nIDEvent) ShowControls(CS_NONE, false);
}
}
- else if(nIDEvent == TIMER_FULLSCREENMOUSEHIDER)
+ break;
+ case TIMER_FULLSCREENMOUSEHIDER:
{
CPoint p;
GetCursorPos(&p);
@@ -1731,7 +1812,8 @@ void CMainFrame::OnTimer(UINT_PTR nIDEvent) }
}
}
- else if(nIDEvent == TIMER_STATS)
+ break;
+ case TIMER_STATS:
{
if(pQP)
{
@@ -2012,11 +2094,14 @@ void CMainFrame::OnTimer(UINT_PTR nIDEvent) SetThreadExecutionState(ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED);
}
}
- else if(nIDEvent == TIMER_STATUSERASER)
+ break;
+ case TIMER_STATUSERASER:
{
KillTimer(TIMER_STATUSERASER);
m_playingmsg.Empty();
}
+ break;
+ }
__super::OnTimer(nIDEvent);
}
@@ -2202,7 +2287,7 @@ LRESULT CMainFrame::OnGraphNotify(WPARAM wParam, LPARAM lParam) LONG_PTR evParam1, evParam2;
while(pME && SUCCEEDED(pME->GetEvent(&evCode, &evParam1, &evParam2, 0)))
{
- TRACE("--> CMainFrame::OnGraphNotify on thread: %d; event: 0x%08x\n", GetCurrentThreadId(), evCode);
+ TRACE("--> CMainFrame::OnGraphNotify on thread: %d; event: 0x%08x (%ws)\n", GetCurrentThreadId(), evCode, GetEventString(evCode));
CString str;
if(m_fCustomGraph)
@@ -2224,17 +2309,10 @@ LRESULT CMainFrame::OnGraphNotify(WPARAM wParam, LPARAM lParam) return hr;
break;
case EC_ERRORABORT:
- {
- TRACE(_T("EC_ERRORABORT, hr = %08x\n"), (HRESULT)evParam1);
- // SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
- // m_closingmsg = _com_error((HRESULT)evParam1).ErrorMessage();
- }
- break;
- case EC_REPAINT:
- TRACE(_T("EC_REPAINT\n"));
+ TRACE(_T("\thr = %08x\n"), (HRESULT)evParam1);
break;
case EC_BUFFERING_DATA:
- TRACE(_T("EC_BUFFERING_DATA, %d, %d\n"), (HRESULT)evParam1, evParam2);
+ TRACE(_T("\t%d, %d\n"), (HRESULT)evParam1, evParam2);
m_fBuffering = ((HRESULT)evParam1 != S_OK);
break;
@@ -2385,7 +2463,7 @@ LRESULT CMainFrame::OnGraphNotify(WPARAM wParam, LPARAM lParam) break;
case EC_DVD_ERROR:
{
- TRACE(_T("EC_DVD_ERROR %d %d\n"), evParam1, evParam2);
+ TRACE(_T("\t%d %d\n"), evParam1, evParam2);
CString err;
@@ -2424,11 +2502,11 @@ LRESULT CMainFrame::OnGraphNotify(WPARAM wParam, LPARAM lParam) }
break;
case EC_DVD_WARNING:
- TRACE(_T("EC_DVD_WARNING %d %d\n"), evParam1, evParam2);
+ TRACE(_T("\t%d %d\n"), evParam1, evParam2);
break;
case EC_VIDEO_SIZE_CHANGED:
{
- TRACE(_T("EC_VIDEO_SIZE_CHANGED %dx%d\n"), CSize(evParam1));
+ TRACE(_T("\t%dx%d\n"), CSize(evParam1));
WINDOWPLACEMENT wp;
wp.length = sizeof(wp);
@@ -2479,15 +2557,24 @@ LRESULT CMainFrame::OnGraphNotify(WPARAM wParam, LPARAM lParam) m_fFullScreen && m_iDVDDomain == DVD_DOMAIN_Title)
AutoChangeMonitorMode();
break;
- default:
- //TRACE(_T("evCode: %d\n"), evCode);
- break;
}
}
return hr;
}
+LRESULT CMainFrame::OnResetDevice( WPARAM wParam, LPARAM lParam )
+{
+ PostMessage(WM_COMMAND, ID_PLAY_PAUSE);
+ CAMEvent e;
+ BOOL bResult = false;
+ m_pGraphThread->PostThreadMessage(CGraphThread::TM_RESET, (WPARAM)&bResult, (LPARAM)&e);
+ e.Wait();
+ if (bResult)
+ PostMessage(WM_COMMAND, ID_PLAY_PLAY); // fix problems with VMR7
+ return S_OK;
+}
+
LRESULT CMainFrame::OnRepaintRenderLess(WPARAM wParam, LPARAM lParam)
{
MoveVideoWindow();
@@ -10530,7 +10617,8 @@ bool CMainFrame::OpenMediaPrivate(CAutoPtr<OpenMediaData> pOMD) while ( pos != NULL )
{
CString path = pOFD->fns.GetNext( pos );
- TRACE(_T("--> CMainFrame::OpenMediaPrivate - pOFD->fns[%d]: %ws\n"), index, path.GetString()); // %ws - wide character string always
+ TRACE(_T("--> CMainFrame::OpenMediaPrivate - pOFD->fns[%d]:\n"), index);
+ TRACE(_T("\t%ws\n"), path.GetString()); // %ws - wide character string always
index++;
}
}
@@ -13065,6 +13153,13 @@ void CMainFrame::OpenMedia(CAutoPtr<OpenMediaData> pOMD) }
}
+bool CMainFrame::ResetDevice()
+{
+ if (m_pCAP)
+ return m_pCAP->ResetDevice();
+ return true;
+}
+
void CMainFrame::CloseMedia()
{
if(m_iMediaLoadState == MLS_CLOSING)
@@ -13173,6 +13268,7 @@ BEGIN_MESSAGE_MAP(CGraphThread, CWinThread) ON_THREAD_MESSAGE(TM_EXIT, OnExit)
ON_THREAD_MESSAGE(TM_OPEN, OnOpen)
ON_THREAD_MESSAGE(TM_CLOSE, OnClose)
+ ON_THREAD_MESSAGE(TM_RESET, OnReset)
ON_THREAD_MESSAGE(TM_TUNER_SCAN, OnTunerScan)
END_MESSAGE_MAP()
@@ -13198,6 +13294,17 @@ void CGraphThread::OnClose(WPARAM wParam, LPARAM lParam) if(CAMEvent* e = (CAMEvent*)lParam) e->Set();
}
+void CGraphThread::OnReset(WPARAM wParam, LPARAM lParam)
+{
+ if(m_pMainFrame)
+ {
+ BOOL* b = (BOOL*)wParam;
+ BOOL bResult = m_pMainFrame->ResetDevice();
+ if (b) *b = bResult;
+ }
+ if(CAMEvent* e = (CAMEvent*)lParam) e->Set();
+}
+
void CGraphThread::OnTunerScan(WPARAM wParam, LPARAM lParam)
{
if(m_pMainFrame)
diff --git a/src/apps/mplayerc/MainFrm.h b/src/apps/mplayerc/MainFrm.h index c45f6e272..ff660ecbd 100644 --- a/src/apps/mplayerc/MainFrm.h +++ b/src/apps/mplayerc/MainFrm.h @@ -140,11 +140,12 @@ public: BOOL InitInstance();
int ExitInstance();
- enum {TM_EXIT=WM_APP, TM_OPEN, TM_CLOSE, TM_TUNER_SCAN};
+ enum {TM_EXIT=WM_APP, TM_OPEN, TM_CLOSE, TM_RESET, TM_TUNER_SCAN};
DECLARE_MESSAGE_MAP()
afx_msg void OnExit(WPARAM wParam, LPARAM lParam);
afx_msg void OnOpen(WPARAM wParam, LPARAM lParam);
- afx_msg void OnClose(WPARAM wParam, LPARAM lParam);
+ afx_msg void OnClose(WPARAM wParam, LPARAM lParam);
+ afx_msg void OnReset(WPARAM wParam, LPARAM lParam);
afx_msg void OnTunerScan(WPARAM wParam, LPARAM lParam);
};
/*
@@ -441,7 +442,8 @@ protected: public:
void OpenCurPlaylistItem(REFERENCE_TIME rtStart = 0);
- void OpenMedia(CAutoPtr<OpenMediaData> pOMD);
+ void OpenMedia(CAutoPtr<OpenMediaData> pOMD);
+ bool ResetDevice();
void CloseMedia();
void StartTunerScan(CAutoPtr<TunerScanData> pTSD);
void StopTunerScan();
@@ -576,7 +578,8 @@ public: afx_msg void OnTimer(UINT_PTR nIDEvent);
- afx_msg LRESULT OnGraphNotify(WPARAM wParam, LPARAM lParam);
+ afx_msg LRESULT OnGraphNotify(WPARAM wParam, LPARAM lParam);
+ afx_msg LRESULT OnResetDevice(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnRepaintRenderLess(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnResumeFromState(WPARAM wParam, LPARAM lParam);
diff --git a/src/apps/mplayerc/QT7AllocatorPresenter.cpp b/src/apps/mplayerc/QT7AllocatorPresenter.cpp new file mode 100644 index 000000000..451c5b2e0 --- /dev/null +++ b/src/apps/mplayerc/QT7AllocatorPresenter.cpp @@ -0,0 +1,160 @@ +/*
+ * $Id: DX7AllocatorPresenter.cpp 1813 2010-04-27 02:03:56Z kinddragon $
+ *
+ * (C) 2003-2006 Gabest
+ * (C) 2006-2010 see AUTHORS
+ *
+ * This file is part of mplayerc.
+ *
+ * Mplayerc is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Mplayerc is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "stdafx.h"
+#include "QT7AllocatorPresenter.h"
+
+using namespace DSObjects;
+
+//
+// CQT7AllocatorPresenter
+//
+
+CQT7AllocatorPresenter::CQT7AllocatorPresenter(HWND hWnd, HRESULT& hr)
+ : CDX7AllocatorPresenter(hWnd, hr)
+{
+}
+
+STDMETHODIMP CQT7AllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
+{
+ CheckPointer(ppv, E_POINTER);
+
+ return
+ QI(IQTVideoSurface)
+ __super::NonDelegatingQueryInterface(riid, ppv);
+}
+
+HRESULT CQT7AllocatorPresenter::AllocSurfaces()
+{
+ CAutoLock cAutoLock(this);
+
+ m_pVideoSurfaceOff = NULL;
+
+ DDSURFACEDESC2 ddsd;
+ INITDDSTRUCT(ddsd);
+ ddsd.dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
+ ddsd.dwWidth = m_NativeVideoSize.cx;
+ ddsd.dwHeight = m_NativeVideoSize.cy;
+ ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
+ ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
+ ddsd.ddpfPixelFormat.dwRGBBitCount = 32;
+ ddsd.ddpfPixelFormat.dwRGBAlphaBitMask = 0xFF000000;
+ ddsd.ddpfPixelFormat.dwRBitMask = 0x00FF0000;
+ ddsd.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
+ ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
+
+ HRESULT hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurfaceOff, NULL);
+ if(FAILED(hr)) return E_FAIL;
+
+ DDBLTFX fx;
+ INITDDSTRUCT(fx);
+ fx.dwFillColor = 0;
+ m_pVideoSurfaceOff->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
+
+ return __super::AllocSurfaces();
+}
+
+void CQT7AllocatorPresenter::DeleteSurfaces()
+{
+ CAutoLock cAutoLock(this);
+
+ m_pVideoSurfaceOff = NULL;
+
+ __super::DeleteSurfaces();
+}
+
+// IQTVideoSurface
+
+STDMETHODIMP CQT7AllocatorPresenter::BeginBlt(const BITMAP& bm)
+{
+ CAutoLock cAutoLock(this);
+
+ DeleteSurfaces();
+
+ m_NativeVideoSize = m_AspectRatio = CSize(bm.bmWidth, abs(bm.bmHeight));
+
+ HRESULT hr;
+ if(FAILED(hr = AllocSurfaces()))
+ return hr;
+
+ return S_OK;
+}
+
+STDMETHODIMP CQT7AllocatorPresenter::DoBlt(const BITMAP& bm)
+{
+ if(!m_pVideoSurface || !m_pVideoSurfaceOff)
+ return E_FAIL;
+
+ bool fOk = false;
+
+ DDSURFACEDESC2 ddsd;
+ INITDDSTRUCT(ddsd);
+ if(FAILED(m_pVideoSurfaceOff->GetSurfaceDesc(&ddsd)))
+ return E_FAIL;
+
+ int w = bm.bmWidth;
+ int h = abs(bm.bmHeight);
+ int bpp = bm.bmBitsPixel;
+
+ if((bpp == 16 || bpp == 24 || bpp == 32) && w == ddsd.dwWidth && h == ddsd.dwHeight)
+ {
+ INITDDSTRUCT(ddsd);
+ if(SUCCEEDED(m_pVideoSurfaceOff->Lock(NULL, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL)))
+ {
+ BitBltFromRGBToRGB(
+ w, h,
+ (BYTE*)ddsd.lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount,
+ (BYTE*)bm.bmBits, bm.bmWidthBytes, bm.bmBitsPixel);
+ m_pVideoSurfaceOff->Unlock(NULL);
+ fOk = true;
+ }
+ }
+
+ if(!fOk)
+ {
+ DDBLTFX fx;
+ INITDDSTRUCT(fx);
+ fx.dwFillColor = 0;
+ m_pVideoSurfaceOff->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
+
+ HDC hDC;
+ if(SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC)))
+ {
+ CString str;
+ str.Format(_T("Sorry, this format is not supported"));
+
+ SetBkColor(hDC, 0);
+ SetTextColor(hDC, 0x404040);
+ TextOut(hDC, 10, 10, str, str.GetLength());
+
+ m_pVideoSurfaceOff->ReleaseDC(hDC);
+ }
+ }
+
+ m_pVideoSurface->Blt(NULL, m_pVideoSurfaceOff, NULL, DDBLT_WAIT, NULL);
+
+ Paint(true);
+
+ return S_OK;
+}
diff --git a/src/apps/mplayerc/QT7AllocatorPresenter.h b/src/apps/mplayerc/QT7AllocatorPresenter.h new file mode 100644 index 000000000..466bc8dcd --- /dev/null +++ b/src/apps/mplayerc/QT7AllocatorPresenter.h @@ -0,0 +1,53 @@ +/*
+ * $Id: DX7AllocatorPresenter.h 1790 2010-04-18 20:29:12Z tetsuo55 $
+ *
+ * (C) 2003-2006 Gabest
+ * (C) 2006-2010 see AUTHORS
+ *
+ * This file is part of mplayerc.
+ *
+ * Mplayerc is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Mplayerc is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#pragma once
+
+#include "DX7AllocatorPresenter.h"
+#include "IQTVideoSurface.h"
+
+namespace DSObjects
+{
+
+ class CQT7AllocatorPresenter
+ : public CDX7AllocatorPresenter
+ , public IQTVideoSurface
+ {
+ CComPtr<IDirectDrawSurface7> m_pVideoSurfaceOff;
+
+ protected:
+ HRESULT AllocSurfaces();
+ void DeleteSurfaces();
+
+ public:
+ CQT7AllocatorPresenter(HWND hWnd, HRESULT& hr);
+
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ // IQTVideoSurface
+ STDMETHODIMP BeginBlt(const BITMAP& bm);
+ STDMETHODIMP DoBlt(const BITMAP& bm);
+ };
+
+}
diff --git a/src/apps/mplayerc/QuicktimeGraph.h b/src/apps/mplayerc/QuicktimeGraph.h index b88d48f1e..a3c37126c 100644 --- a/src/apps/mplayerc/QuicktimeGraph.h +++ b/src/apps/mplayerc/QuicktimeGraph.h @@ -24,8 +24,8 @@ #pragma once
#include "BaseGraph.h"
-#include "DX7AllocatorPresenter.h"
-#include "DX9AllocatorPresenter.h"
+#include "AllocatorCommon7.h"
+#include "AllocatorCommon.h"
namespace DSObjects
{
diff --git a/src/apps/mplayerc/RM7AllocatorPresenter.cpp b/src/apps/mplayerc/RM7AllocatorPresenter.cpp new file mode 100644 index 000000000..272ea2f1f --- /dev/null +++ b/src/apps/mplayerc/RM7AllocatorPresenter.cpp @@ -0,0 +1,275 @@ +/*
+ * $Id: DX7AllocatorPresenter.cpp 1813 2010-04-27 02:03:56Z kinddragon $
+ *
+ * (C) 2003-2006 Gabest
+ * (C) 2006-2010 see AUTHORS
+ *
+ * This file is part of mplayerc.
+ *
+ * Mplayerc is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Mplayerc is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "stdafx.h"
+#include "RM7AllocatorPresenter.h"
+
+using namespace DSObjects;
+
+//
+// CRM7AllocatorPresenter
+//
+
+CRM7AllocatorPresenter::CRM7AllocatorPresenter(HWND hWnd, HRESULT& hr)
+: CDX7AllocatorPresenter(hWnd, hr)
+{
+}
+
+STDMETHODIMP CRM7AllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
+{
+ CheckPointer(ppv, E_POINTER);
+
+ return
+ QI2(IRMAVideoSurface)
+ __super::NonDelegatingQueryInterface(riid, ppv);
+}
+
+HRESULT CRM7AllocatorPresenter::AllocSurfaces()
+{
+ CAutoLock cAutoLock(this);
+
+ m_pVideoSurfaceOff = NULL;
+ m_pVideoSurfaceYUY2 = NULL;
+
+ DDSURFACEDESC2 ddsd;
+ DDBLTFX fx;
+
+ INITDDSTRUCT(ddsd);
+ ddsd.dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
+ ddsd.dwWidth = m_NativeVideoSize.cx;
+ ddsd.dwHeight = m_NativeVideoSize.cy;
+ ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
+ ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
+ ddsd.ddpfPixelFormat.dwRGBBitCount = 32;
+ ddsd.ddpfPixelFormat.dwRGBAlphaBitMask = 0xFF000000;
+ ddsd.ddpfPixelFormat.dwRBitMask = 0x00FF0000;
+ ddsd.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
+ ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
+
+ HRESULT hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurfaceOff, NULL);
+ if(FAILED(hr)) return E_FAIL;
+
+ INITDDSTRUCT(fx);
+ fx.dwFillColor = 0;
+ m_pVideoSurfaceOff->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
+
+ INITDDSTRUCT(ddsd);
+ ddsd.dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
+ ddsd.dwWidth = m_NativeVideoSize.cx;
+ ddsd.dwHeight = m_NativeVideoSize.cy;
+ ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
+ ddsd.ddpfPixelFormat.dwFlags = DDPF_FOURCC;
+ ddsd.ddpfPixelFormat.dwYUVBitCount = 16;
+ ddsd.ddpfPixelFormat.dwFourCC = '2YUY';
+
+ hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurfaceYUY2, NULL);
+
+ if(FAILED(m_pVideoSurfaceOff->Blt(NULL, m_pVideoSurfaceYUY2, NULL, DDBLT_WAIT, NULL)))
+ m_pVideoSurfaceYUY2 = NULL;
+
+ if(m_pVideoSurfaceYUY2)
+ {
+ INITDDSTRUCT(fx);
+ fx.dwFillColor = 0x80108010;
+ m_pVideoSurfaceYUY2->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
+ }
+
+ return __super::AllocSurfaces();
+}
+
+void CRM7AllocatorPresenter::DeleteSurfaces()
+{
+ CAutoLock cAutoLock(this);
+
+ m_pVideoSurfaceOff = NULL;
+ m_pVideoSurfaceYUY2 = NULL;
+
+ __super::DeleteSurfaces();
+}
+
+// IRMAVideoSurface
+
+STDMETHODIMP CRM7AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader* pBitmapInfo, REF(PNxRect) inDestRect, REF(PNxRect) inSrcRect)
+{
+ if(!m_pVideoSurface || !m_pVideoSurfaceOff)
+ return E_FAIL;
+
+ bool fRGB = false;
+ bool fYUY2 = false;
+
+ CRect src((RECT*)&inSrcRect), dst((RECT*)&inDestRect), src2(CPoint(0,0), src.Size());
+ if(src.Width() > dst.Width() || src.Height() > dst.Height())
+ return E_FAIL;
+
+ DDSURFACEDESC2 ddsd;
+
+ if(pBitmapInfo->biCompression == '024I')
+ {
+ DWORD pitch = pBitmapInfo->biWidth;
+ DWORD size = pitch*abs(pBitmapInfo->biHeight);
+
+ BYTE* y = pImageData + src.top*pitch + src.left;
+ BYTE* u = pImageData + size + src.top*(pitch/2) + src.left/2;
+ BYTE* v = pImageData + size + size/4 + src.top*(pitch/2) + src.left/2;
+
+ if(m_pVideoSurfaceYUY2)
+ {
+ INITDDSTRUCT(ddsd);
+ if(SUCCEEDED(m_pVideoSurfaceYUY2->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL)))
+ {
+ BitBltFromI420ToYUY2(src.Width(), src.Height(), (BYTE*)ddsd.lpSurface, ddsd.lPitch, y, u, v, pitch);
+ m_pVideoSurfaceYUY2->Unlock(src2);
+ fYUY2 = true;
+ }
+ }
+ else
+ {
+ INITDDSTRUCT(ddsd);
+ if(SUCCEEDED(m_pVideoSurfaceOff->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL)))
+ {
+ BitBltFromI420ToRGB(src.Width(), src.Height(), (BYTE*)ddsd.lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount, y, u, v, pitch);
+ m_pVideoSurfaceOff->Unlock(src2);
+ fRGB = true;
+ }
+ }
+ }
+ else if(pBitmapInfo->biCompression == '2YUY')
+ {
+ DWORD w = pBitmapInfo->biWidth;
+ DWORD h = abs(pBitmapInfo->biHeight);
+ DWORD pitch = pBitmapInfo->biWidth*2;
+
+ BYTE* yvyu = pImageData + src.top*pitch + src.left*2;
+
+ if(m_pVideoSurfaceYUY2)
+ {
+ INITDDSTRUCT(ddsd);
+ if(SUCCEEDED(m_pVideoSurfaceYUY2->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL)))
+ {
+ BitBltFromYUY2ToYUY2(src.Width(), src.Height(), (BYTE*)ddsd.lpSurface, ddsd.lPitch, yvyu, pitch);
+ m_pVideoSurfaceYUY2->Unlock(src2);
+ fYUY2 = true;
+ }
+ }
+ else
+ {
+ INITDDSTRUCT(ddsd);
+ if(SUCCEEDED(m_pVideoSurfaceOff->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL)))
+ {
+ BitBltFromYUY2ToRGB(src.Width(), src.Height(), (BYTE*)ddsd.lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount, yvyu, pitch);
+ m_pVideoSurfaceOff->Unlock(src2);
+ fRGB = true;
+ }
+ }
+ }
+ else if(pBitmapInfo->biCompression == 0 || pBitmapInfo->biCompression == 3
+ || pBitmapInfo->biCompression == 'BGRA')
+ {
+ DWORD w = pBitmapInfo->biWidth;
+ DWORD h = abs(pBitmapInfo->biHeight);
+ DWORD pitch = pBitmapInfo->biWidth*pBitmapInfo->biBitCount>>3;
+
+ BYTE* rgb = pImageData + src.top*pitch + src.left*(pBitmapInfo->biBitCount>>3);
+
+ INITDDSTRUCT(ddsd);
+ if(SUCCEEDED(m_pVideoSurfaceOff->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL)))
+ {
+ BYTE* lpSurface = (BYTE*)ddsd.lpSurface;
+ if(pBitmapInfo->biHeight > 0)
+ {
+ lpSurface += ddsd.lPitch*(src.Height()-1);
+ ddsd.lPitch = -ddsd.lPitch;
+ }
+ BitBltFromRGBToRGB(src.Width(), src.Height(), lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRGBBitCount, rgb, pitch, pBitmapInfo->biBitCount);
+ fRGB = true;
+ m_pVideoSurfaceOff->Unlock(src2);
+ }
+ }
+
+ if(!fRGB && !fYUY2)
+ {
+ DDBLTFX fx;
+ INITDDSTRUCT(fx);
+ fx.dwFillColor = 0;
+ m_pVideoSurfaceOff->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
+
+ HDC hDC;
+ if(SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC)))
+ {
+ CString str;
+ str.Format(_T("Sorry, this format is not supported"));
+
+ SetBkColor(hDC, 0);
+ SetTextColor(hDC, 0x404040);
+ TextOut(hDC, 10, 10, str, str.GetLength());
+
+ m_pVideoSurfaceOff->ReleaseDC(hDC);
+
+ fRGB = true;
+ }
+ }
+
+
+ HRESULT hr;
+
+ if(fRGB)
+ hr = m_pVideoSurface->Blt(dst, m_pVideoSurfaceOff, src2, DDBLT_WAIT, NULL);
+ if(fYUY2)
+ hr = m_pVideoSurface->Blt(dst, m_pVideoSurfaceYUY2, src2, DDBLT_WAIT, NULL);
+
+ Paint(true);
+
+ return PNR_OK;
+}
+
+STDMETHODIMP CRM7AllocatorPresenter::BeginOptimizedBlt(RMABitmapInfoHeader* pBitmapInfo)
+{
+ CAutoLock cAutoLock(this);
+ DeleteSurfaces();
+ m_NativeVideoSize = m_AspectRatio = CSize(pBitmapInfo->biWidth, abs(pBitmapInfo->biHeight));
+ if(FAILED(AllocSurfaces())) return E_FAIL;
+ return PNR_NOTIMPL;
+}
+
+STDMETHODIMP CRM7AllocatorPresenter::OptimizedBlt(UCHAR* pImageBits, REF(PNxRect) rDestRect, REF(PNxRect) rSrcRect)
+{
+ return PNR_NOTIMPL;
+}
+
+STDMETHODIMP CRM7AllocatorPresenter::EndOptimizedBlt()
+{
+ return PNR_NOTIMPL;
+}
+
+STDMETHODIMP CRM7AllocatorPresenter::GetOptimizedFormat(REF(RMA_COMPRESSION_TYPE) ulType)
+{
+ return PNR_NOTIMPL;
+}
+
+STDMETHODIMP CRM7AllocatorPresenter::GetPreferredFormat(REF(RMA_COMPRESSION_TYPE) ulType)
+{
+ ulType = RMA_I420;
+ return PNR_OK;
+}
diff --git a/src/apps/mplayerc/RM7AllocatorPresenter.h b/src/apps/mplayerc/RM7AllocatorPresenter.h new file mode 100644 index 000000000..ab1d8fe78 --- /dev/null +++ b/src/apps/mplayerc/RM7AllocatorPresenter.h @@ -0,0 +1,64 @@ +/*
+ * $Id: DX7AllocatorPresenter.h 1790 2010-04-18 20:29:12Z tetsuo55 $
+ *
+ * (C) 2003-2006 Gabest
+ * (C) 2006-2010 see AUTHORS
+ *
+ * This file is part of mplayerc.
+ *
+ * Mplayerc is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Mplayerc is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#pragma once
+
+#include "DX7AllocatorPresenter.h"
+#include <RealMedia/pntypes.h>
+#include <RealMedia/pnwintyp.h>
+#include <RealMedia/pncom.h>
+#include <RealMedia/rmavsurf.h>
+
+namespace DSObjects
+{
+
+ class CRM7AllocatorPresenter
+ : public CDX7AllocatorPresenter
+ , public IRMAVideoSurface
+ {
+ CComPtr<IDirectDrawSurface7> m_pVideoSurfaceOff;
+ CComPtr<IDirectDrawSurface7> m_pVideoSurfaceYUY2;
+
+ RMABitmapInfoHeader m_bitmapInfo;
+ RMABitmapInfoHeader m_lastBitmapInfo;
+
+ protected:
+ HRESULT AllocSurfaces();
+ void DeleteSurfaces();
+
+ public:
+ CRM7AllocatorPresenter(HWND hWnd, HRESULT& hr);
+
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ // IRMAVideoSurface
+ STDMETHODIMP Blt(UCHAR* pImageData, RMABitmapInfoHeader* pBitmapInfo, REF(PNxRect) inDestRect, REF(PNxRect) inSrcRect);
+ STDMETHODIMP BeginOptimizedBlt(RMABitmapInfoHeader* pBitmapInfo);
+ STDMETHODIMP OptimizedBlt(UCHAR* pImageBits, REF(PNxRect) rDestRect, REF(PNxRect) rSrcRect);
+ STDMETHODIMP EndOptimizedBlt();
+ STDMETHODIMP GetOptimizedFormat(REF(RMA_COMPRESSION_TYPE) ulType);
+ STDMETHODIMP GetPreferredFormat(REF(RMA_COMPRESSION_TYPE) ulType);
+ };
+
+}
diff --git a/src/apps/mplayerc/RealMediaGraph.h b/src/apps/mplayerc/RealMediaGraph.h index 8b3d0ad49..f8f313996 100644 --- a/src/apps/mplayerc/RealMediaGraph.h +++ b/src/apps/mplayerc/RealMediaGraph.h @@ -25,8 +25,8 @@ #include "BaseGraph.h"
-#include "DX7AllocatorPresenter.h"
-#include "DX9AllocatorPresenter.h"
+#include "AllocatorCommon7.h"
+#include "AllocatorCommon.h"
#include <RealMedia/pntypes.h>
#include <RealMedia/pnwintyp.h>
diff --git a/src/apps/mplayerc/SyncRenderer.cpp b/src/apps/mplayerc/SyncRenderer.cpp index 9324ecde1..a099f00ad 100644 --- a/src/apps/mplayerc/SyncRenderer.cpp +++ b/src/apps/mplayerc/SyncRenderer.cpp @@ -44,6 +44,9 @@ #include "MainFrm.h"
#include "SyncRenderer.h"
+// only for debugging
+//#define DISABLE_USING_D3D9EX
+
using namespace GothSync;
CString GothSyncErrorMessage(HRESULT _Error, HMODULE _Module)
@@ -108,7 +111,9 @@ CString GothSyncErrorMessage(HRESULT _Error, HMODULE _Module) case S_PRESENT_OCCLUDED :
return _T("S_PRESENT_OCCLUDED");
case D3DERR_DEVICEHUNG :
- return _T("D3DERR_DEVICEHUNG");
+ return _T("D3DERR_DEVICEHUNG");
+ case E_UNEXPECTED :
+ return _T("E_UNEXPECTED");
}
CString errmsg;
@@ -134,9 +139,7 @@ CBaseAP::CBaseAP(HWND hWnd, HRESULT& hr, CString &_Error): m_nCurSurface(0),
m_bSnapToVSync(false),
m_bInterlaced(0),
- m_nUsedBuffer(0),
- m_bNeedPendingResetDevice(0),
- m_bPendingResetDevice(0),
+ m_nUsedBuffer(0),
m_TextScale(1.0),
m_dMainThreadId(0),
m_bNeedCheckSample(true),
@@ -200,8 +203,32 @@ CBaseAP::CBaseAP(HWND hWnd, HRESULT& hr, CString &_Error): m_pDirect3DCreate9Ex = NULL;
m_hD3D9 = LoadLibrary(L"d3d9.dll");
- if (m_hD3D9)
- (FARPROC &)m_pDirect3DCreate9Ex = GetProcAddress(m_hD3D9, "Direct3DCreate9Ex");
+#ifndef DISABLE_USING_D3D9EX
+ if (m_hD3D9)
+ (FARPROC &)m_pDirect3DCreate9Ex = GetProcAddress(m_hD3D9, "Direct3DCreate9Ex");
+#endif
+
+ if (m_pDirect3DCreate9Ex)
+ {
+ _tprintf(_T("m_pDirect3DCreate9Ex\n"));
+ m_pDirect3DCreate9Ex(D3D_SDK_VERSION, &m_pD3DEx);
+ if(!m_pD3DEx)
+ {
+ m_pDirect3DCreate9Ex(D3D9b_SDK_VERSION, &m_pD3DEx);
+ }
+ }
+ if(!m_pD3DEx)
+ {
+ m_pD3D.Attach(Direct3DCreate9(D3D_SDK_VERSION));
+ if(!m_pD3D)
+ {
+ m_pD3D.Attach(Direct3DCreate9(D3D9b_SDK_VERSION));
+ }
+ if(m_pD3D)
+ _tprintf(_T("m_pDirect3DCreate9\n"));
+ }
+ else
+ m_pD3D = m_pD3DEx;
ZeroMemory(&m_VMR9AlphaBitmap, sizeof(m_VMR9AlphaBitmap));
@@ -466,8 +493,6 @@ HRESULT CBaseAP::CreateDXDevice(CString &_Error) m_pPSC.Free();
m_pD3DDev = NULL;
m_pD3DDevEx = NULL;
- m_pD3D = NULL;
- m_pD3DEx = NULL;
m_pResizerPixelShader[0] = 0;
m_pResizerPixelShader[1] = 0;
@@ -487,31 +512,11 @@ HRESULT CBaseAP::CreateDXDevice(CString &_Error) Shader.m_pPixelShader = NULL;
}
- if (m_pDirect3DCreate9Ex)
- {
- _tprintf(_T("m_pDirect3DCreate9Ex\n"));
- m_pDirect3DCreate9Ex(D3D_SDK_VERSION, &m_pD3DEx);
- if(!m_pD3DEx)
- {
- m_pDirect3DCreate9Ex(D3D9b_SDK_VERSION, &m_pD3DEx);
- }
- }
- if(!m_pD3DEx)
- {
- m_pD3D.Attach(Direct3DCreate9(D3D_SDK_VERSION));
- if(!m_pD3D)
- {
- m_pD3D.Attach(Direct3DCreate9(D3D9b_SDK_VERSION));
- }
- if(!m_pD3D)
- {
- _Error += L"Failed to create Direct3D device\n";
- return E_UNEXPECTED;
- }
- _tprintf(_T("m_pDirect3DCreate9\n"));
- }
- else
- m_pD3D = m_pD3DEx;
+ if(!m_pD3D)
+ {
+ _Error += L"Failed to create Direct3D device\n";
+ return E_UNEXPECTED;
+ }
D3DDISPLAYMODE d3ddm;
ZeroMemory(&d3ddm, sizeof(d3ddm));
@@ -1672,6 +1677,12 @@ void CBaseAP::UpdateAlphaBitmap() // Present a sample (frame) using DirectX.
STDMETHODIMP_(bool) CBaseAP::Paint(bool fAll)
{
+ if (m_bPendingResetDevice)
+ {
+ SendResetRequest();
+ return false;
+ }
+
AppSettings& s = AfxGetAppSettings();
CMPlayerCApp * pApp = AfxGetMyApp();
D3DRASTER_STATUS rasterStatus;
@@ -1998,35 +2009,37 @@ STDMETHODIMP_(bool) CBaseAP::Paint(bool fAll) }
if(fResetDevice)
- {
- if (m_bNeedPendingResetDevice)
- {
- m_bPendingResetDevice = true;
- }
- else
- {
- if (m_dMainThreadId && m_dMainThreadId == GetCurrentThreadId())
- {
- m_bPendingResetDevice = false;
-
- ResetDevice();
- }
- else
- m_bPendingResetDevice = true;
- }
+ {
+ m_bPendingResetDevice = true;
+ SendResetRequest();
}
return(true);
}
-bool CBaseAP::ResetDevice()
+void CBaseAP::SendResetRequest()
+{
+ if (!m_bDeviceResetRequested)
+ {
+ m_bDeviceResetRequested = true;
+ AfxGetApp()->m_pMainWnd->PostMessage(WM_RESET_DEVICE);
+ }
+}
+
+STDMETHODIMP_(bool) CBaseAP::ResetDevice()
{
DeleteSurfaces();
HRESULT hr;
CString Error;
- if(FAILED(hr = CreateDXDevice(Error)) || FAILED(hr = AllocSurfaces())) return false;
+ if(FAILED(hr = CreateDXDevice(Error)) || FAILED(hr = AllocSurfaces()))
+ {
+ m_bDeviceResetRequested = false;
+ return false;
+ }
m_pGenlock->SetMonitor(GetAdapter(m_pD3D));
m_pGenlock->GetTiming();
- OnResetDevice();
+ OnResetDevice();
+ m_bDeviceResetRequested = false;
+ m_bPendingResetDevice = false;
return true;
}
@@ -2490,13 +2503,12 @@ CSyncAP::CSyncAP(HWND hWnd, HRESULT& hr, CString &_Error): CBaseAP(hWnd, hr, _Er m_nResetToken = 0;
m_hRenderThread = INVALID_HANDLE_VALUE;
m_hMixerThread= INVALID_HANDLE_VALUE;
- m_hEvtFlush = INVALID_HANDLE_VALUE;
- m_hEvtQuit = INVALID_HANDLE_VALUE;
+ m_hEvtFlush = INVALID_HANDLE_VALUE;
+ m_hEvtQuit = INVALID_HANDLE_VALUE;
+ m_hEvtSkip = INVALID_HANDLE_VALUE;
m_bEvtQuit = 0;
m_bEvtFlush = 0;
- m_bNeedPendingResetDevice = true;
-
if (FAILED (hr))
{
_Error += L"SyncAP failed\n";
@@ -3797,28 +3809,12 @@ void CSyncAP::RenderThread() }
if (m_bPendingResetDevice)
- {
- m_bPendingResetDevice = false;
- CAutoLock lock(this);
- CAutoLock lock2(&m_ImageProcessingLock);
- CAutoLock cRenderLock(&m_allocatorLock);
- if (pNewSample) MoveToFreeList(pNewSample, true);
- pNewSample = NULL;
- RemoveAllSamples();
- CBaseAP::ResetDevice();
-
- for(int i = 0; i < m_nDXSurface; i++)
- {
- CComPtr<IMFSample> pMFSample;
- HRESULT hr = pfMFCreateVideoSampleFromSurface (m_pVideoSurface[i], &pMFSample);
- if (SUCCEEDED (hr))
- {
- pMFSample->SetUINT32(GUID_SURFACE_INDEX, i);
- m_FreeSamples.AddTail(pMFSample);
- }
- ASSERT(SUCCEEDED (hr));
- }
- }
+ {
+ if (pNewSample)
+ MoveToFreeList(pNewSample, true);
+ pNewSample = NULL;
+ SendResetRequest();
+ }
else if (m_nStepCount < 0)
{
m_nStepCount = 0;
@@ -3859,13 +3855,37 @@ void CSyncAP::RenderThread() if (pfAvRevertMmThreadCharacteristics) pfAvRevertMmThreadCharacteristics(hAvrt);
}
+STDMETHODIMP_(bool) CSyncAP::ResetDevice()
+{
+ CAutoLock lock(this);
+ CAutoLock lock2(&m_ImageProcessingLock);
+ CAutoLock cRenderLock(&m_allocatorLock);
+ RemoveAllSamples();
+
+ bool bResult = __super::ResetDevice();
+
+ for(int i = 0; i < m_nDXSurface; i++)
+ {
+ CComPtr<IMFSample> pMFSample;
+ HRESULT hr = pfMFCreateVideoSampleFromSurface (m_pVideoSurface[i], &pMFSample);
+ if (SUCCEEDED (hr))
+ {
+ pMFSample->SetUINT32(GUID_SURFACE_INDEX, i);
+ m_FreeSamples.AddTail(pMFSample);
+ }
+ ASSERT(SUCCEEDED (hr));
+ }
+ return bResult;
+}
+
void CSyncAP::OnResetDevice()
{
TRACE("--> CSyncAP::OnResetDevice on thread: %d\n", GetCurrentThreadId());
HRESULT hr;
hr = m_pD3DManager->ResetDevice(m_pD3DDev, m_nResetToken);
if (m_pSink) m_pSink->Notify(EC_DISPLAY_CHANGED, 0, 0);
- if (m_pSink) m_pSink->Notify(EC_VIDEO_SIZE_CHANGED, MAKELPARAM(m_NativeVideoSize.cx, m_NativeVideoSize.cy), 0);
+ CSize videoSize = GetVisibleVideoSize();
+ if (m_pSink) m_pSink->Notify(EC_VIDEO_SIZE_CHANGED, MAKELPARAM(videoSize.cx, videoSize.cy), 0);
}
void CSyncAP::RemoveAllSamples()
@@ -3874,7 +3894,6 @@ void CSyncAP::RemoveAllSamples() FlushSamples();
m_ScheduledSamples.RemoveAll();
m_FreeSamples.RemoveAll();
- ASSERT(m_nUsedBuffer == 0);
m_nUsedBuffer = 0;
}
diff --git a/src/apps/mplayerc/SyncRenderer.h b/src/apps/mplayerc/SyncRenderer.h index 56479448f..d1bb1ed2b 100644 --- a/src/apps/mplayerc/SyncRenderer.h +++ b/src/apps/mplayerc/SyncRenderer.h @@ -159,11 +159,12 @@ protected: D3DCAPS9 m_caps;
D3DPRESENT_PARAMETERS pp;
- bool SettingsNeedResetDevice();
+ bool SettingsNeedResetDevice();
+ void SendResetRequest();
virtual HRESULT CreateDXDevice(CString &_Error);
virtual HRESULT ResetDXDevice(CString &_Error);
virtual HRESULT AllocSurfaces(D3DFORMAT Format = D3DFMT_A8R8G8B8);
- virtual void DeleteSurfaces();
+ virtual void DeleteSurfaces();
HANDLE m_hEvtQuit; // Stop rendering thread event
UINT GetAdapter(IDirect3D9 *pD3D);
@@ -226,7 +227,6 @@ protected: HRESULT AlphaBlt(RECT* pSrc, RECT* pDst, CComPtr<IDirect3DTexture9> pTexture);
virtual void OnResetDevice() {};
- virtual bool ResetDevice();
int m_nTearingPos;
VMR9AlphaBitmap m_VMR9AlphaBitmap;
@@ -243,9 +243,7 @@ protected: int m_nVMR9Surfaces;
int m_iVMR9Surface;
int m_nCurSurface; // Surface currently displayed
- long m_nUsedBuffer;
- bool m_bNeedPendingResetDevice;
- bool m_bPendingResetDevice;
+ long m_nUsedBuffer;
LONG m_lNextSampleWait; // Waiting time for next sample in EVR
bool m_bSnapToVSync; // True if framerate is low enough so that snap to vsync makes sense
@@ -335,7 +333,8 @@ public: STDMETHODIMP_(bool) Paint(bool fAll);
STDMETHODIMP GetDIB(BYTE* lpDib, DWORD* size);
STDMETHODIMP SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget);
- STDMETHODIMP SetPixelShader2(LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace);
+ STDMETHODIMP SetPixelShader2(LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace);
+ STDMETHODIMP_(bool) ResetDevice();
};
class CSyncAP:
@@ -362,7 +361,8 @@ public: STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
STDMETHODIMP_(bool) Paint(bool fAll);
STDMETHODIMP GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight);
- STDMETHODIMP InitializeDevice(AM_MEDIA_TYPE* pMediaType);
+ STDMETHODIMP InitializeDevice(AM_MEDIA_TYPE* pMediaType);
+ STDMETHODIMP_(bool) ResetDevice();
// IMFClockStateSink
STDMETHODIMP OnClockStart(MFTIME hnsSystemTime, LONGLONG llClockStartOffset);
@@ -431,8 +431,8 @@ public: STDMETHODIMP DisableImageExport(BOOL bDisable);
// IDirect3DDeviceManager9
- STDMETHODIMP ResetDevice(IDirect3DDevice9 *pDevice,UINT resetToken);
- STDMETHODIMP OpenDeviceHandle(HANDLE *phDevice);
+ STDMETHODIMP ResetDevice(IDirect3DDevice9 *pDevice,UINT resetToken);
+ STDMETHODIMP OpenDeviceHandle(HANDLE *phDevice);
STDMETHODIMP CloseDeviceHandle(HANDLE hDevice);
STDMETHODIMP TestDevice(HANDLE hDevice);
STDMETHODIMP LockDevice(HANDLE hDevice, IDirect3DDevice9 **ppDevice, BOOL fBlock);
diff --git a/src/apps/mplayerc/VMR7AllocatorPresenter.cpp b/src/apps/mplayerc/VMR7AllocatorPresenter.cpp new file mode 100644 index 000000000..e67451ffb --- /dev/null +++ b/src/apps/mplayerc/VMR7AllocatorPresenter.cpp @@ -0,0 +1,369 @@ +/*
+ * $Id: DX7AllocatorPresenter.cpp 1813 2010-04-27 02:03:56Z kinddragon $
+ *
+ * (C) 2003-2006 Gabest
+ * (C) 2006-2010 see AUTHORS
+ *
+ * This file is part of mplayerc.
+ *
+ * Mplayerc is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Mplayerc is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "stdafx.h"
+#include "mplayerc.h"
+
+#include "VMR7AllocatorPresenter.h"
+#include "IPinHook.h"
+
+extern bool g_bNoDuration; // Defined in MainFrm.cpp
+extern bool g_bExternalSubtitleTime;
+
+using namespace DSObjects;
+
+//
+// CVMR7AllocatorPresenter
+//
+
+#define MY_USER_ID 0x6ABE51
+
+CVMR7AllocatorPresenter::CVMR7AllocatorPresenter(HWND hWnd, HRESULT& hr)
+ : CDX7AllocatorPresenter(hWnd, hr)
+ , m_fUseInternalTimer(false)
+{
+ if(FAILED(hr))
+ return;
+
+ if(FAILED(hr = m_pSA.CoCreateInstance(CLSID_AllocPresenter)))
+ {
+ hr = E_FAIL;
+ return;
+ }
+}
+
+STDMETHODIMP CVMR7AllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
+{
+ CheckPointer(ppv, E_POINTER);
+
+ return
+ QI(IVMRSurfaceAllocator)
+ QI(IVMRImagePresenter)
+ QI(IVMRWindowlessControl)
+ __super::NonDelegatingQueryInterface(riid, ppv);
+}
+
+HRESULT CVMR7AllocatorPresenter::CreateDevice()
+{
+ HRESULT hr = __super::CreateDevice();
+ if(FAILED(hr)) return hr;
+
+ if(m_pIVMRSurfAllocNotify)
+ {
+ HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
+ if(FAILED(hr = m_pIVMRSurfAllocNotify->ChangeDDrawDevice(m_pDD, hMonitor)))
+ return(false);
+ }
+
+ return hr;
+}
+
+void CVMR7AllocatorPresenter::DeleteSurfaces()
+{
+ CAutoLock cAutoLock(this);
+
+ m_pSA->FreeSurface(MY_USER_ID);
+
+ __super::DeleteSurfaces();
+}
+
+// ISubPicAllocatorPresenter
+
+STDMETHODIMP CVMR7AllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
+{
+ CheckPointer(ppRenderer, E_POINTER);
+
+ *ppRenderer = NULL;
+
+ HRESULT hr;
+
+ do
+ {
+ CComPtr<IBaseFilter> pBF;
+
+ if(FAILED(hr = pBF.CoCreateInstance(CLSID_VideoMixingRenderer)))
+ break;
+
+ CComQIPtr<IVMRFilterConfig> pConfig = pBF;
+ if(!pConfig)
+ break;
+
+ if(FAILED(hr = pConfig->SetRenderingMode(VMRMode_Renderless)))
+ break;
+
+ CComQIPtr<IVMRSurfaceAllocatorNotify> pSAN = pBF;
+ if(!pSAN)
+ break;
+
+ if(FAILED(hr = pSAN->AdviseSurfaceAllocator(MY_USER_ID, static_cast<IVMRSurfaceAllocator*>(this)))
+ || FAILED(hr = AdviseNotify(pSAN)))
+ break;
+
+ CComPtr<IPin> pPin = GetFirstPin(pBF);
+ CComQIPtr<IMemInputPin> pMemInputPin = pPin;
+ m_fUseInternalTimer = HookNewSegmentAndReceive((IPinC*)(IPin*)pPin, (IMemInputPinC*)(IMemInputPin*)pMemInputPin);
+
+ *ppRenderer = (IUnknown*)pBF.Detach();
+
+ return S_OK;
+ }
+ while(0);
+
+ return E_FAIL;
+}
+
+STDMETHODIMP_(void) CVMR7AllocatorPresenter::SetTime(REFERENCE_TIME rtNow)
+{
+ __super::SetTime(rtNow);
+// m_fUseInternalTimer = false;
+}
+
+// IVMRSurfaceAllocator
+
+STDMETHODIMP CVMR7AllocatorPresenter::AllocateSurface(DWORD_PTR dwUserID, VMRALLOCATIONINFO* lpAllocInfo, DWORD* lpdwBuffer, LPDIRECTDRAWSURFACE7* lplpSurface)
+{
+ if(!lpAllocInfo || !lpdwBuffer || !lplpSurface)
+ return E_POINTER;
+
+ if(!m_pIVMRSurfAllocNotify)
+ return E_FAIL;
+
+ HRESULT hr;
+
+ DeleteSurfaces();
+
+ // HACK: yv12 will fail to blt onto the backbuffer anyway, but if we first
+ // allocate it and then let our FreeSurface callback call m_pSA->FreeSurface,
+ // then that might stall for about 30 seconds because of some unknown buggy code
+ // behind <ddraw surface>->Release()
+
+ if(lpAllocInfo->lpHdr->biBitCount < 16)
+ return E_FAIL;
+
+ hr = m_pSA->AllocateSurface(dwUserID, lpAllocInfo, lpdwBuffer, lplpSurface);
+ if(FAILED(hr))
+ return hr;
+
+ m_NativeVideoSize = CSize(abs(lpAllocInfo->lpHdr->biWidth), abs(lpAllocInfo->lpHdr->biHeight));
+ m_AspectRatio = m_NativeVideoSize;
+ int arx = lpAllocInfo->szAspectRatio.cx, ary = lpAllocInfo->szAspectRatio.cy;
+ if(arx > 0 && ary > 0) m_AspectRatio.SetSize(arx, ary);
+
+ if(FAILED(hr = AllocSurfaces()))
+ return hr;
+
+ // test if the colorspace is acceptable
+ if(FAILED(hr = m_pVideoSurface->Blt(NULL, *lplpSurface, NULL, DDBLT_WAIT, NULL)))
+ {
+ DeleteSurfaces();
+ return hr;
+ }
+
+ DDBLTFX fx;
+ INITDDSTRUCT(fx);
+ fx.dwFillColor = 0;
+ m_pVideoSurface->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
+
+ return hr;
+}
+
+STDMETHODIMP CVMR7AllocatorPresenter::FreeSurface(DWORD_PTR dwUserID)
+{
+ DeleteSurfaces();
+ return S_OK;
+}
+
+STDMETHODIMP CVMR7AllocatorPresenter::PrepareSurface(DWORD_PTR dwUserID, IDirectDrawSurface7* lpSurface, DWORD dwSurfaceFlags)
+{
+ SetThreadName(-1, "CVMR7AllocatorPresenter");
+
+ if(!lpSurface)
+ return E_POINTER;
+
+ // FIXME: sometimes the msmpeg4/divx3/wmv decoder wants to reuse our
+ // surface (expects it to point to the same mem every time), and to avoid
+ // problems we can't call m_pSA->PrepareSurface (flips? clears?).
+ return S_OK;
+ /*
+ return m_pSA->PrepareSurface(dwUserID, lpSurface, dwSurfaceFlags);
+ */
+}
+
+STDMETHODIMP CVMR7AllocatorPresenter::AdviseNotify(IVMRSurfaceAllocatorNotify* lpIVMRSurfAllocNotify)
+{
+ CAutoLock cAutoLock(this);
+
+ m_pIVMRSurfAllocNotify = lpIVMRSurfAllocNotify;
+
+ HRESULT hr;
+ HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
+ if(FAILED(hr = m_pIVMRSurfAllocNotify->SetDDrawDevice(m_pDD, hMonitor)))
+ return hr;
+
+ return m_pSA->AdviseNotify(lpIVMRSurfAllocNotify);
+}
+
+// IVMRImagePresenter
+
+STDMETHODIMP CVMR7AllocatorPresenter::StartPresenting(DWORD_PTR dwUserID)
+{
+ if (!m_bPendingResetDevice)
+ {
+ ASSERT(m_pD3DDev);
+ }
+
+ CAutoLock cAutoLock(this);
+
+ return m_pD3DDev ? S_OK : E_FAIL;
+}
+
+STDMETHODIMP CVMR7AllocatorPresenter::StopPresenting(DWORD_PTR dwUserID)
+{
+ return S_OK;
+}
+
+STDMETHODIMP CVMR7AllocatorPresenter::PresentImage(DWORD_PTR dwUserID, VMRPRESENTATIONINFO* lpPresInfo)
+{
+ if(!lpPresInfo || !lpPresInfo->lpSurf)
+ return E_POINTER;
+
+ CAutoLock cAutoLock(this);
+
+ if (!m_bPendingResetDevice)
+ m_pVideoSurface->Blt(NULL, lpPresInfo->lpSurf, NULL, DDBLT_WAIT, NULL);
+
+ if(lpPresInfo->rtEnd > lpPresInfo->rtStart)
+ {
+ REFERENCE_TIME rtTimePerFrame = lpPresInfo->rtEnd - lpPresInfo->rtStart;
+ m_fps = 10000000.0 / rtTimePerFrame;
+
+ if(m_pSubPicQueue)
+ {
+ m_pSubPicQueue->SetFPS(m_fps);
+
+ if(m_fUseInternalTimer && !g_bExternalSubtitleTime)
+ {
+ __super::SetTime(g_tSegmentStart + g_tSampleStart);
+ }
+ }
+ }
+
+ CSize VideoSize = m_NativeVideoSize;
+ int arx = lpPresInfo->szAspectRatio.cx, ary = lpPresInfo->szAspectRatio.cy;
+ if(arx > 0 && ary > 0) VideoSize.cx = VideoSize.cy*arx/ary;
+ if(VideoSize != GetVideoSize())
+ {
+ m_AspectRatio.SetSize(arx, ary);
+ AfxGetApp()->m_pMainWnd->PostMessage(WM_REARRANGERENDERLESS);
+ }
+
+ Paint(true);
+
+ return S_OK;
+}
+
+// IVMRWindowlessControl
+//
+// It is only implemented (partially) for the dvd navigator's
+// menu handling, which needs to know a few things about the
+// location of our window.
+
+STDMETHODIMP CVMR7AllocatorPresenter::GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight)
+{
+ CSize vs = m_NativeVideoSize, ar = m_AspectRatio;
+ // DVD Nav. bug workaround fix
+ vs.cx = vs.cy * ar.cx / ar.cy;
+ if(lpWidth) *lpWidth = vs.cx;
+ if(lpHeight) *lpHeight = vs.cy;
+ if(lpARWidth) *lpARWidth = ar.cx;
+ if(lpARHeight) *lpARHeight = ar.cy;
+ return S_OK;
+}
+
+STDMETHODIMP CVMR7AllocatorPresenter::GetMinIdealVideoSize(LONG* lpWidth, LONG* lpHeight)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CVMR7AllocatorPresenter::GetMaxIdealVideoSize(LONG* lpWidth, LONG* lpHeight)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CVMR7AllocatorPresenter::SetVideoPosition(const LPRECT lpSRCRect, const LPRECT lpDSTRect)
+{
+ return E_NOTIMPL; // we have our own method for this
+}
+
+STDMETHODIMP CVMR7AllocatorPresenter::GetVideoPosition(LPRECT lpSRCRect, LPRECT lpDSTRect)
+{
+ CopyRect(lpSRCRect, CRect(CPoint(0, 0), m_NativeVideoSize));
+ CopyRect(lpDSTRect, &m_VideoRect);
+ // DVD Nav. bug workaround fix
+ GetNativeVideoSize(&lpSRCRect->right, &lpSRCRect->bottom, NULL, NULL);
+ return S_OK;
+}
+
+STDMETHODIMP CVMR7AllocatorPresenter::GetAspectRatioMode(DWORD* lpAspectRatioMode)
+{
+ if(lpAspectRatioMode) *lpAspectRatioMode = AM_ARMODE_STRETCHED;
+ return S_OK;
+}
+
+STDMETHODIMP CVMR7AllocatorPresenter::SetAspectRatioMode(DWORD AspectRatioMode)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CVMR7AllocatorPresenter::SetVideoClippingWindow(HWND hwnd)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CVMR7AllocatorPresenter::RepaintVideo(HWND hwnd, HDC hdc)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CVMR7AllocatorPresenter::DisplayModeChanged()
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CVMR7AllocatorPresenter::GetCurrentImage(BYTE** lpDib)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CVMR7AllocatorPresenter::SetBorderColor(COLORREF Clr)
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CVMR7AllocatorPresenter::GetBorderColor(COLORREF* lpClr)
+{
+ if(lpClr) *lpClr = 0;
+ return S_OK;
+}
+
+STDMETHODIMP CVMR7AllocatorPresenter::SetColorKey(COLORREF Clr)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CVMR7AllocatorPresenter::GetColorKey(COLORREF* lpClr)
+{
+ return E_NOTIMPL;
+}
diff --git a/src/apps/mplayerc/VMR7AllocatorPresenter.h b/src/apps/mplayerc/VMR7AllocatorPresenter.h new file mode 100644 index 000000000..6d6716c08 --- /dev/null +++ b/src/apps/mplayerc/VMR7AllocatorPresenter.h @@ -0,0 +1,84 @@ +/*
+ * $Id: DX7AllocatorPresenter.h 1790 2010-04-18 20:29:12Z tetsuo55 $
+ *
+ * (C) 2003-2006 Gabest
+ * (C) 2006-2010 see AUTHORS
+ *
+ * This file is part of mplayerc.
+ *
+ * Mplayerc is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Mplayerc is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#pragma once
+
+#include "DX7AllocatorPresenter.h"
+
+namespace DSObjects
+{
+
+ class CVMR7AllocatorPresenter
+ : public CDX7AllocatorPresenter
+ , public IVMRSurfaceAllocator
+ , public IVMRImagePresenter
+ , public IVMRWindowlessControl
+ {
+ CComPtr<IVMRSurfaceAllocatorNotify> m_pIVMRSurfAllocNotify;
+ CComPtr<IVMRSurfaceAllocator> m_pSA;
+
+ HRESULT CreateDevice();
+ void DeleteSurfaces();
+
+ bool m_fUseInternalTimer;
+
+ public:
+ CVMR7AllocatorPresenter(HWND hWnd, HRESULT& hr);
+
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ // ISubPicAllocatorPresenter
+ STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
+ STDMETHODIMP_(void) SetTime(REFERENCE_TIME rtNow);
+
+ // IVMRSurfaceAllocator
+ STDMETHODIMP AllocateSurface(DWORD_PTR dwUserID, VMRALLOCATIONINFO* lpAllocInfo, DWORD* lpdwBuffer, LPDIRECTDRAWSURFACE7* lplpSurface);
+ STDMETHODIMP FreeSurface(DWORD_PTR dwUserID);
+ STDMETHODIMP PrepareSurface(DWORD_PTR dwUserID, IDirectDrawSurface7* lpSurface, DWORD dwSurfaceFlags);
+ STDMETHODIMP AdviseNotify(IVMRSurfaceAllocatorNotify* lpIVMRSurfAllocNotify);
+
+ // IVMRImagePresenter
+ STDMETHODIMP StartPresenting(DWORD_PTR dwUserID);
+ STDMETHODIMP StopPresenting(DWORD_PTR dwUserID);
+ STDMETHODIMP PresentImage(DWORD_PTR dwUserID, VMRPRESENTATIONINFO* lpPresInfo);
+
+ // IVMRWindowlessControl
+ STDMETHODIMP GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lpARWidth, LONG* lpARHeight);
+ STDMETHODIMP GetMinIdealVideoSize(LONG* lpWidth, LONG* lpHeight);
+ STDMETHODIMP GetMaxIdealVideoSize(LONG* lpWidth, LONG* lpHeight);
+ STDMETHODIMP SetVideoPosition(const LPRECT lpSRCRect, const LPRECT lpDSTRect);
+ STDMETHODIMP GetVideoPosition(LPRECT lpSRCRect, LPRECT lpDSTRect);
+ STDMETHODIMP GetAspectRatioMode(DWORD* lpAspectRatioMode);
+ STDMETHODIMP SetAspectRatioMode(DWORD AspectRatioMode);
+ STDMETHODIMP SetVideoClippingWindow(HWND hwnd);
+ STDMETHODIMP RepaintVideo(HWND hwnd, HDC hdc);
+ STDMETHODIMP DisplayModeChanged();
+ STDMETHODIMP GetCurrentImage(BYTE** lpDib);
+ STDMETHODIMP SetBorderColor(COLORREF Clr);
+ STDMETHODIMP GetBorderColor(COLORREF* lpClr);
+ STDMETHODIMP SetColorKey(COLORREF Clr);
+ STDMETHODIMP GetColorKey(COLORREF* lpClr);
+ };
+
+}
diff --git a/src/apps/mplayerc/VMR9AllocatorPresenter.cpp b/src/apps/mplayerc/VMR9AllocatorPresenter.cpp index 56e3c512a..634b8e088 100644 --- a/src/apps/mplayerc/VMR9AllocatorPresenter.cpp +++ b/src/apps/mplayerc/VMR9AllocatorPresenter.cpp @@ -833,10 +833,13 @@ STDMETHODIMP CVMR9AllocatorPresenter::AdviseNotify(IVMRSurfaceAllocatorNotify9* STDMETHODIMP CVMR9AllocatorPresenter::StartPresenting(DWORD_PTR dwUserID)
{
- CAutoLock cAutoLock(this);
- CAutoLock cRenderLock(&m_RenderLock);
+ if (!m_bPendingResetDevice)
+ {
+ ASSERT(m_pD3DDev);
+ }
- ASSERT(m_pD3DDev);
+ CAutoLock cAutoLock(this);
+ CAutoLock cRenderLock(&m_RenderLock);
return m_pD3DDev ? S_OK : E_FAIL;
}
@@ -852,8 +855,6 @@ STDMETHODIMP CVMR9AllocatorPresenter::PresentImage(DWORD_PTR dwUserID, VMR9Prese SetThreadName(-1, "CVMR9AllocatorPresenter");
CheckPointer(m_pIVMRSurfAllocNotify, E_UNEXPECTED);
- m_MainThreadId = GetCurrentThreadId();
-
if (m_rtTimePerFrame == 0 || m_bNeedCheckSample)
{
m_bNeedCheckSample = false;
@@ -923,65 +924,68 @@ STDMETHODIMP CVMR9AllocatorPresenter::PresentImage(DWORD_PTR dwUserID, VMR9Prese CAutoLock cAutoLock(this);
CAutoLock cRenderLock(&m_RenderLock);
- CComPtr<IDirect3DTexture9> pTexture;
- lpPresInfo->lpSurf->GetContainer(IID_IDirect3DTexture9, (void**)&pTexture);
-
- if(pTexture)
- {
- m_pVideoSurface[m_nCurSurface] = lpPresInfo->lpSurf;
- if(m_pVideoTexture[m_nCurSurface])
- m_pVideoTexture[m_nCurSurface] = pTexture;
- }
- else
- {
- hr = m_pD3DDev->StretchRect(lpPresInfo->lpSurf, NULL, m_pVideoSurface[m_nCurSurface], NULL, D3DTEXF_NONE);
- }
-
- if(lpPresInfo->rtEnd > lpPresInfo->rtStart)
- {
- if(m_pSubPicQueue)
- {
- m_pSubPicQueue->SetFPS(m_fps);
+ if(lpPresInfo->rtEnd > lpPresInfo->rtStart)
+ {
+ if(m_pSubPicQueue)
+ {
+ m_pSubPicQueue->SetFPS(m_fps);
- if(m_fUseInternalTimer && !g_bExternalSubtitleTime)
- {
- __super::SetTime(g_tSegmentStart + g_tSampleStart);
- }
- }
- }
+ if(m_fUseInternalTimer && !g_bExternalSubtitleTime)
+ {
+ __super::SetTime(g_tSegmentStart + g_tSampleStart);
+ }
+ }
+ }
CSize VideoSize = GetVisibleVideoSize();
- int arx = lpPresInfo->szAspectRatio.cx;
- int ary = lpPresInfo->szAspectRatio.cy;
- if(arx > 0 && ary > 0)
- {
+ int arx = lpPresInfo->szAspectRatio.cx;
+ int ary = lpPresInfo->szAspectRatio.cy;
+ if(arx > 0 && ary > 0)
+ {
arx = arx / ((float) m_NativeVideoSize.cx / VideoSize.cx);
ary = ary / ((float) m_NativeVideoSize.cy / VideoSize.cy);
- VideoSize.cx = VideoSize.cy*arx/ary;
- }
- if(VideoSize != GetVideoSize())
- {
- m_AspectRatio.SetSize(arx, ary);
- AfxGetApp()->m_pMainWnd->PostMessage(WM_REARRANGERENDERLESS);
- }
-
- // Tear test bars
- if (AfxGetMyApp()->m_fTearingTest)
- {
- RECT rcTearing;
-
- rcTearing.left = m_nTearingPos;
- rcTearing.top = 0;
- rcTearing.right = rcTearing.left + 4;
- rcTearing.bottom = m_NativeVideoSize.cy;
- m_pD3DDev->ColorFill (m_pVideoSurface[m_nCurSurface], &rcTearing, D3DCOLOR_ARGB (255,255,0,0));
-
- rcTearing.left = (rcTearing.right + 15) % m_NativeVideoSize.cx;
- rcTearing.right = rcTearing.left + 4;
- m_pD3DDev->ColorFill (m_pVideoSurface[m_nCurSurface], &rcTearing, D3DCOLOR_ARGB (255,255,0,0));
-
- m_nTearingPos = (m_nTearingPos + 7) % m_NativeVideoSize.cx;
- }
+ VideoSize.cx = VideoSize.cy*arx/ary;
+ }
+ if(VideoSize != GetVideoSize())
+ {
+ m_AspectRatio.SetSize(arx, ary);
+ AfxGetApp()->m_pMainWnd->PostMessage(WM_REARRANGERENDERLESS);
+ }
+
+ if (!m_bPendingResetDevice)
+ {
+ CComPtr<IDirect3DTexture9> pTexture;
+ lpPresInfo->lpSurf->GetContainer(IID_IDirect3DTexture9, (void**)&pTexture);
+
+ if(pTexture)
+ {
+ m_pVideoSurface[m_nCurSurface] = lpPresInfo->lpSurf;
+ if(m_pVideoTexture[m_nCurSurface])
+ m_pVideoTexture[m_nCurSurface] = pTexture;
+ }
+ else
+ {
+ hr = m_pD3DDev->StretchRect(lpPresInfo->lpSurf, NULL, m_pVideoSurface[m_nCurSurface], NULL, D3DTEXF_NONE);
+ }
+
+ // Tear test bars
+ if (AfxGetMyApp()->m_fTearingTest)
+ {
+ RECT rcTearing;
+
+ rcTearing.left = m_nTearingPos;
+ rcTearing.top = 0;
+ rcTearing.right = rcTearing.left + 4;
+ rcTearing.bottom = m_NativeVideoSize.cy;
+ m_pD3DDev->ColorFill (m_pVideoSurface[m_nCurSurface], &rcTearing, D3DCOLOR_ARGB (255,255,0,0));
+
+ rcTearing.left = (rcTearing.right + 15) % m_NativeVideoSize.cx;
+ rcTearing.right = rcTearing.left + 4;
+ m_pD3DDev->ColorFill (m_pVideoSurface[m_nCurSurface], &rcTearing, D3DCOLOR_ARGB (255,255,0,0));
+
+ m_nTearingPos = (m_nTearingPos + 7) % m_NativeVideoSize.cx;
+ }
+ }
Paint(true);
diff --git a/src/apps/mplayerc/mplayerc.h b/src/apps/mplayerc/mplayerc.h index 4334ef414..690fa953a 100644 --- a/src/apps/mplayerc/mplayerc.h +++ b/src/apps/mplayerc/mplayerc.h @@ -46,6 +46,7 @@ enum WM_GRAPHNOTIFY = WM_APP+1,
WM_REARRANGERENDERLESS,
WM_RESUMEFROMSTATE,
+ WM_RESET_DEVICE,
WM_TUNER_SCAN_PROGRESS,
WM_TUNER_SCAN_END,
WM_TUNER_STATS,
diff --git a/src/apps/mplayerc/mplayerc.vcproj b/src/apps/mplayerc/mplayerc.vcproj index bbc1ffb71..fb96ee54a 100644 --- a/src/apps/mplayerc/mplayerc.vcproj +++ b/src/apps/mplayerc/mplayerc.vcproj @@ -31,7 +31,7 @@ >
<Tool
Name="VCPreBuildEventTool"
- CommandLine="cd ..\..\..\
update_version.bat"
+ CommandLine="cd ..\..\..\
update_version.bat
"
/>
<Tool
Name="VCCustomBuildTool"
@@ -124,7 +124,7 @@ >
<Tool
Name="VCPreBuildEventTool"
- CommandLine="cd ..\..\..\
update_version.bat"
+ CommandLine="cd ..\..\..\
update_version.bat
"
/>
<Tool
Name="VCCustomBuildTool"
@@ -215,7 +215,7 @@ >
<Tool
Name="VCPreBuildEventTool"
- CommandLine="cd ..\..\..\
update_version.bat"
+ CommandLine="cd ..\..\..\
update_version.bat
"
/>
<Tool
Name="VCCustomBuildTool"
@@ -302,7 +302,7 @@ >
<Tool
Name="VCPreBuildEventTool"
- CommandLine="cd ..\..\..\
update_version.bat"
+ CommandLine="cd ..\..\..\
update_version.bat
"
/>
<Tool
Name="VCCustomBuildTool"
@@ -389,6 +389,10 @@ >
</File>
<File
+ RelativePath=".\AllocatorCommon7.cpp"
+ >
+ </File>
+ <File
RelativePath=".\AuthDlg.cpp"
>
</File>
@@ -897,6 +901,10 @@ >
</File>
<File
+ RelativePath=".\QT7AllocatorPresenter.cpp"
+ >
+ </File>
+ <File
RelativePath=".\QT9AllocatorPresenter.cpp"
>
</File>
@@ -933,6 +941,10 @@ >
</File>
<File
+ RelativePath=".\RM7AllocatorPresenter.cpp"
+ >
+ </File>
+ <File
RelativePath=".\RM9AllocatorPresenter.cpp"
>
</File>
@@ -1029,6 +1041,10 @@ >
</File>
<File
+ RelativePath=".\VMR7AllocatorPresenter.cpp"
+ >
+ </File>
+ <File
RelativePath=".\VMR9AllocatorPresenter.cpp"
>
</File>
@@ -1094,6 +1110,10 @@ >
</File>
<File
+ RelativePath=".\AllocatorCommon7.h"
+ >
+ </File>
+ <File
RelativePath=".\AuthDlg.h"
>
</File>
@@ -1486,6 +1506,10 @@ >
</File>
<File
+ RelativePath=".\QT7AllocatorPresenter.h"
+ >
+ </File>
+ <File
RelativePath=".\QT9AllocatorPresenter.h"
>
</File>
@@ -1526,6 +1550,10 @@ >
</File>
<File
+ RelativePath=".\RM7AllocatorPresenter.h"
+ >
+ </File>
+ <File
RelativePath=".\RM9AllocatorPresenter.h"
>
</File>
@@ -1602,6 +1630,10 @@ >
</File>
<File
+ RelativePath=".\VMR7AllocatorPresenter.h"
+ >
+ </File>
+ <File
RelativePath=".\VMR9AllocatorPresenter.h"
>
</File>
@@ -1755,10 +1787,6 @@ >
</File>
<File
- RelativePath=".\res\mpc.png"
- >
- </File>
- <File
RelativePath="res\mpc-hc.exe.manifest"
>
<FileConfiguration
@@ -1777,6 +1805,10 @@ </FileConfiguration>
</File>
<File
+ RelativePath=".\res\mpc.png"
+ >
+ </File>
+ <File
RelativePath=".\res\mplayerc.rc2"
>
<FileConfiguration
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/w32thread.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/w32thread.c index 88e7ef866..554a80655 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/w32thread.c +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/w32thread.c @@ -121,7 +121,7 @@ static int avcodec_thread_execute2(AVCodecContext *s, int (*func)(AVCodecContext int i;
for(i=0; i<s->thread_count; i++)
c[i].func2 = func;
- avcodec_thread_execute(s, NULL, arg, ret, count, 0);
+ return avcodec_thread_execute(s, NULL, arg, ret, count, 0);
}
int avcodec_thread_init(AVCodecContext *s, int thread_count){
|