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

github.com/mpc-hc/LAVFilters.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHendrik Leppkes <h.leppkes@gmail.com>2017-08-22 15:39:02 +0300
committerHendrik Leppkes <h.leppkes@gmail.com>2017-08-22 15:39:02 +0300
commit67f5aefae8fa2f154677e5001f1f7bed8e490521 (patch)
tree09afd617b19b18c2823cc185d99b6368a1a743b6
parentf7abe27be3ec8345af8e02eb9a267f1f1dc3170d (diff)
d3d11: return all surfaces to the allocator when breaking the renderer connection
-rw-r--r--decoder/LAVVideo/DecodeManager.cpp10
-rw-r--r--decoder/LAVVideo/DecodeManager.h1
-rw-r--r--decoder/LAVVideo/LAVVideo.cpp4
-rw-r--r--decoder/LAVVideo/decoders/DecBase.h1
-rw-r--r--decoder/LAVVideo/decoders/ILAVDecoder.h5
-rw-r--r--decoder/LAVVideo/decoders/d3d11va.cpp15
-rw-r--r--decoder/LAVVideo/decoders/d3d11va.h1
7 files changed, 37 insertions, 0 deletions
diff --git a/decoder/LAVVideo/DecodeManager.cpp b/decoder/LAVVideo/DecodeManager.cpp
index 4ea51b0b..1178742e 100644
--- a/decoder/LAVVideo/DecodeManager.cpp
+++ b/decoder/LAVVideo/DecodeManager.cpp
@@ -237,3 +237,13 @@ STDMETHODIMP CDecodeManager::PostConnect(IPin *pPin)
}
return hr;
}
+
+STDMETHODIMP CDecodeManager::BreakConnect()
+{
+ CAutoLock decoderLock(this);
+
+ if (!m_pDecoder)
+ return E_UNEXPECTED;
+
+ return m_pDecoder->BreakConnect();
+}
diff --git a/decoder/LAVVideo/DecodeManager.h b/decoder/LAVVideo/DecodeManager.h
index 81162bcc..06aeb257 100644
--- a/decoder/LAVVideo/DecodeManager.h
+++ b/decoder/LAVVideo/DecodeManager.h
@@ -44,6 +44,7 @@ public:
// Allocator/memory management
STDMETHODIMP InitAllocator(IMemAllocator **ppAlloc);
STDMETHODIMP PostConnect(IPin *pPin);
+ STDMETHODIMP BreakConnect();
// HWAccel Query
STDMETHODIMP_(BOOL) IsHWDecoderActive() { return m_bHWDecoder; }
diff --git a/decoder/LAVVideo/LAVVideo.cpp b/decoder/LAVVideo/LAVVideo.cpp
index dbea52cc..d7f84c15 100644
--- a/decoder/LAVVideo/LAVVideo.cpp
+++ b/decoder/LAVVideo/LAVVideo.cpp
@@ -907,6 +907,10 @@ HRESULT CLAVVideo::BreakConnect(PIN_DIRECTION dir)
if (m_pFilterGraph)
avfilter_graph_free(&m_pFilterGraph);
}
+ else if (dir == PINDIR_OUTPUT)
+ {
+ m_Decoder.BreakConnect();
+ }
return __super::BreakConnect(dir);
}
diff --git a/decoder/LAVVideo/decoders/DecBase.h b/decoder/LAVVideo/decoders/DecBase.h
index fb535b21..2ef16125 100644
--- a/decoder/LAVVideo/decoders/DecBase.h
+++ b/decoder/LAVVideo/decoders/DecBase.h
@@ -38,6 +38,7 @@ public:
STDMETHODIMP_(BOOL) IsInterlaced(BOOL bAllowGuess) { return TRUE; }
STDMETHODIMP InitAllocator(IMemAllocator **ppAlloc) { return E_NOTIMPL; }
STDMETHODIMP PostConnect(IPin *pPin) { return S_FALSE; }
+ STDMETHODIMP BreakConnect() { return S_FALSE; }
STDMETHODIMP_(long) GetBufferCount(long *pMaxBuffers = nullptr) { return 2; }
STDMETHODIMP HasThreadSafeBuffers() { return S_FALSE; }
diff --git a/decoder/LAVVideo/decoders/ILAVDecoder.h b/decoder/LAVVideo/decoders/ILAVDecoder.h
index 9e6bcca0..17f36c67 100644
--- a/decoder/LAVVideo/decoders/ILAVDecoder.h
+++ b/decoder/LAVVideo/decoders/ILAVDecoder.h
@@ -386,6 +386,11 @@ interface ILAVDecoder
STDMETHOD(PostConnect)(IPin *pPin) PURE;
/**
+ * Notify the decoder the output connection was broken
+ */
+ STDMETHOD(BreakConnect)() PURE;
+
+ /**
* Get the number of sample buffers optimal for this decoder
*/
STDMETHOD_(long, GetBufferCount)(long *pMaxBuffers = nullptr) PURE;
diff --git a/decoder/LAVVideo/decoders/d3d11va.cpp b/decoder/LAVVideo/decoders/d3d11va.cpp
index 27f939b0..f0c08251 100644
--- a/decoder/LAVVideo/decoders/d3d11va.cpp
+++ b/decoder/LAVVideo/decoders/d3d11va.cpp
@@ -426,6 +426,21 @@ fail:
return E_FAIL;
}
+STDMETHODIMP CDecD3D11::BreakConnect()
+{
+ if (m_bReadBackFallback)
+ return S_FALSE;
+
+ // release any resources held by the core
+ m_pCallback->ReleaseAllDXVAResources();
+
+ // flush all buffers out of the decoder to ensure the allocator can be properly de-allocated
+ if (m_pAVCtx && avcodec_is_open(m_pAVCtx))
+ avcodec_flush_buffers(m_pAVCtx);
+
+ return S_OK;
+}
+
STDMETHODIMP CDecD3D11::InitDecoder(AVCodecID codec, const CMediaType *pmt)
{
HRESULT hr = S_OK;
diff --git a/decoder/LAVVideo/decoders/d3d11va.h b/decoder/LAVVideo/decoders/d3d11va.h
index 82b67ef9..75e4914c 100644
--- a/decoder/LAVVideo/decoders/d3d11va.h
+++ b/decoder/LAVVideo/decoders/d3d11va.h
@@ -51,6 +51,7 @@ public:
STDMETHODIMP InitAllocator(IMemAllocator **ppAlloc);
STDMETHODIMP PostConnect(IPin *pPin);
+ STDMETHODIMP BreakConnect();
STDMETHODIMP_(long) GetBufferCount(long *pMaxBuffers = nullptr);
STDMETHODIMP_(const WCHAR*) GetDecoderName() { return m_bReadBackFallback ? (m_bDirect ? L"d3d11 cb direct" : L"d3d11 cb") : L"d3d11 native"; }
STDMETHODIMP HasThreadSafeBuffers() { return S_FALSE; }