Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authora_afra <a_afra@users.sourceforge.net>2010-09-09 00:59:22 +0400
committera_afra <a_afra@users.sourceforge.net>2010-09-09 00:59:22 +0400
commit893e45005881bb0a529f8d9ee6851b1beeff9e1a (patch)
tree59e187504612b09720a1c76f2b01c45b46888853 /src/filters/renderer
parent5248c8fe9deeb787dcf6da9dda0043d947ab2478 (diff)
- Fixed threading bug in VMR9
- Added video surface safety checks This commit fixes ticket #698 git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@2509 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/renderer')
-rw-r--r--src/filters/renderer/VideoRenderers/DX9RenderingEngine.cpp43
-rw-r--r--src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.cpp4
2 files changed, 26 insertions, 21 deletions
diff --git a/src/filters/renderer/VideoRenderers/DX9RenderingEngine.cpp b/src/filters/renderer/VideoRenderers/DX9RenderingEngine.cpp
index df2951284..0d3359f2b 100644
--- a/src/filters/renderer/VideoRenderers/DX9RenderingEngine.cpp
+++ b/src/filters/renderer/VideoRenderers/DX9RenderingEngine.cpp
@@ -245,18 +245,13 @@ void CDX9RenderingEngine::CleanupRenderingEngine()
HRESULT CDX9RenderingEngine::CreateVideoSurfaces(D3DFORMAT format)
{
+ HRESULT hr;
CRenderersSettings& settings = GetRenderersSettings();
- for (int i = 0; i < m_nNbDXSurface; i++)
- {
- m_pVideoTexture[i] = NULL;
- m_pVideoSurface[i] = NULL;
- }
+ FreeVideoSurfaces();
m_SurfaceType = format;
- HRESULT hr;
-
if (settings.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D || settings.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D)
{
int nTexturesNeeded = settings.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D ? m_nNbDXSurface : 1;
@@ -312,6 +307,9 @@ void CDX9RenderingEngine::FreeVideoSurfaces()
HRESULT CDX9RenderingEngine::RenderVideo(IDirect3DSurface9* pRenderTarget, const CRect& srcRect, const CRect& destRect)
{
+ if (destRect.IsRectEmpty())
+ return S_OK;
+
if (m_RenderingPath == RENDERING_PATH_DRAW)
return RenderVideoDrawPath(pRenderTarget, srcRect, destRect);
else
@@ -322,6 +320,10 @@ HRESULT CDX9RenderingEngine::RenderVideoDrawPath(IDirect3DSurface9* pRenderTarge
{
HRESULT hr;
+ // Return if the video texture is not initialized
+ if (m_pVideoTexture[m_nCurSurface] == 0)
+ return S_OK;
+
CRenderersSettings& settings = GetRenderersSettings();
// Initialize the processing pipeline
@@ -531,21 +533,22 @@ HRESULT CDX9RenderingEngine::RenderVideoDrawPath(IDirect3DSurface9* pRenderTarge
HRESULT CDX9RenderingEngine::RenderVideoStretchRectPath(IDirect3DSurface9* pRenderTarget, const CRect& srcRect, const CRect& destRect)
{
- HRESULT hr = S_OK;
+ HRESULT hr;
- if (pRenderTarget)
- {
- CRect rSrcVid(srcRect);
- CRect rDstVid(destRect);
+ // Return if the render target or the video surface is not initialized
+ if (pRenderTarget == 0 || m_pVideoSurface[m_nCurSurface] == 0)
+ return S_OK;
- ClipToSurface(pRenderTarget, rSrcVid, rDstVid); // grrr
- // IMPORTANT: rSrcVid has to be aligned on mod2 for yuy2->rgb conversion with StretchRect!!!
- rSrcVid.left &= ~1;
- rSrcVid.right &= ~1;
- rSrcVid.top &= ~1;
- rSrcVid.bottom &= ~1;
- hr = m_pD3DDev->StretchRect(m_pVideoSurface[m_nCurSurface], rSrcVid, pRenderTarget, rDstVid, m_StretchRectFilter);
- }
+ CRect rSrcVid(srcRect);
+ CRect rDstVid(destRect);
+
+ ClipToSurface(pRenderTarget, rSrcVid, rDstVid); // grrr
+ // IMPORTANT: rSrcVid has to be aligned on mod2 for yuy2->rgb conversion with StretchRect!!!
+ rSrcVid.left &= ~1;
+ rSrcVid.right &= ~1;
+ rSrcVid.top &= ~1;
+ rSrcVid.bottom &= ~1;
+ hr = m_pD3DDev->StretchRect(m_pVideoSurface[m_nCurSurface], rSrcVid, pRenderTarget, rDstVid, m_StretchRectFilter);
return hr;
}
diff --git a/src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.cpp
index 7f7fff05a..484f4c517 100644
--- a/src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.cpp
+++ b/src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.cpp
@@ -708,6 +708,9 @@ STDMETHODIMP_(void) CVMR9AllocatorPresenter::SetTime(REFERENCE_TIME rtNow)
STDMETHODIMP CVMR9AllocatorPresenter::InitializeDevice(DWORD_PTR dwUserID, VMR9AllocationInfo* lpAllocInfo, DWORD* lpNumBuffers)
{
+ CAutoLock lock(this);
+ CAutoLock cRenderLock(&m_RenderLock);
+
if(!lpAllocInfo || !lpNumBuffers)
return E_POINTER;
@@ -783,7 +786,6 @@ STDMETHODIMP CVMR9AllocatorPresenter::InitializeDevice(DWORD_PTR dwUserID, VMR9A
STDMETHODIMP CVMR9AllocatorPresenter::TerminateDevice(DWORD_PTR dwUserID)
{
- DeleteSurfaces();
return S_OK;
}