diff options
author | Hendrik Leppkes <h.leppkes@gmail.com> | 2017-08-21 15:00:46 +0300 |
---|---|---|
committer | Hendrik Leppkes <h.leppkes@gmail.com> | 2017-08-21 15:00:46 +0300 |
commit | 999b2c5f328c0480de09c22ce83c3b9642ef85ef (patch) | |
tree | f40e513c7ab12f82766d541a9df2cffdfbce60c4 /decoder/LAVVideo | |
parent | 76dd7fb2513453d3a190f2cbd12df2f9ba980d0a (diff) |
Move the maximum buffers into the decoder implementation
Diffstat (limited to 'decoder/LAVVideo')
-rw-r--r-- | decoder/LAVVideo/DecodeManager.h | 2 | ||||
-rw-r--r-- | decoder/LAVVideo/LAVVideo.cpp | 8 | ||||
-rw-r--r-- | decoder/LAVVideo/decoders/DecBase.h | 2 | ||||
-rw-r--r-- | decoder/LAVVideo/decoders/ILAVDecoder.h | 2 | ||||
-rw-r--r-- | decoder/LAVVideo/decoders/d3d11va.cpp | 9 | ||||
-rw-r--r-- | decoder/LAVVideo/decoders/d3d11va.h | 2 | ||||
-rw-r--r-- | decoder/LAVVideo/decoders/dxva2dec.cpp | 9 | ||||
-rw-r--r-- | decoder/LAVVideo/decoders/dxva2dec.h | 2 |
8 files changed, 26 insertions, 10 deletions
diff --git a/decoder/LAVVideo/DecodeManager.h b/decoder/LAVVideo/DecodeManager.h index cec6ec92..81162bcc 100644 --- a/decoder/LAVVideo/DecodeManager.h +++ b/decoder/LAVVideo/DecodeManager.h @@ -51,7 +51,7 @@ public: // ILAVDecoder (partial) STDMETHODIMP_(const WCHAR*) GetDecoderName() { return m_pDecoder ? m_pDecoder->GetDecoderName() : nullptr; } - STDMETHODIMP_(long) GetBufferCount() { return m_pDecoder ? m_pDecoder->GetBufferCount() : 4; } + STDMETHODIMP_(long) GetBufferCount(long *pMaxBuffers) { return m_pDecoder ? m_pDecoder->GetBufferCount(pMaxBuffers) : 4; } STDMETHODIMP_(BOOL) IsInterlaced(BOOL bAllowGuess) { return m_pDecoder ? m_pDecoder->IsInterlaced(bAllowGuess) : TRUE; } STDMETHODIMP GetPixelFormat(LAVPixelFormat *pPix, int *pBpp) { ASSERT(m_pDecoder); return m_pDecoder->GetPixelFormat(pPix, pBpp); } STDMETHODIMP_(REFERENCE_TIME) GetFrameDuration() { ASSERT(m_pDecoder); return m_pDecoder->GetFrameDuration(); } diff --git a/decoder/LAVVideo/LAVVideo.cpp b/decoder/LAVVideo/LAVVideo.cpp index 0bf4d79e..dbea52cc 100644 --- a/decoder/LAVVideo/LAVVideo.cpp +++ b/decoder/LAVVideo/LAVVideo.cpp @@ -526,14 +526,16 @@ HRESULT CLAVVideo::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERT CMediaType &mtOut = m_pOutput->CurrentMediaType(); videoFormatTypeHandler(mtOut, &pBIH); - // try to honor the requested number of downstream buffers, but cap at 127, because the amount needs to fit into 7-bit for DXVA decoding + // try to honor the requested number of downstream buffers, but cap at the decoders maximum + long decoderBuffersMax = LONG_MAX; + long decoderBuffs = m_Decoder.GetBufferCount(&decoderBuffersMax); long downstreamBuffers = pProperties->cBuffers; - pProperties->cBuffers = min(max(pProperties->cBuffers, 2) + m_Decoder.GetBufferCount(), 127); + pProperties->cBuffers = min(max(pProperties->cBuffers, 2) + decoderBuffs, decoderBuffersMax); pProperties->cbBuffer = pBIH ? pBIH->biSizeImage : 3110400; pProperties->cbAlign = 1; pProperties->cbPrefix = 0; - DbgLog((LOG_TRACE, 10, L" -> Downstream wants %d buffers, decoder wants %d, for a total of: %d", downstreamBuffers, m_Decoder.GetBufferCount(), pProperties->cBuffers)); + DbgLog((LOG_TRACE, 10, L" -> Downstream wants %d buffers, decoder wants %d, for a total of: %d", downstreamBuffers, decoderBuffs, pProperties->cBuffers)); HRESULT hr; ALLOCATOR_PROPERTIES Actual; diff --git a/decoder/LAVVideo/decoders/DecBase.h b/decoder/LAVVideo/decoders/DecBase.h index 0da35bdf..fb535b21 100644 --- a/decoder/LAVVideo/decoders/DecBase.h +++ b/decoder/LAVVideo/decoders/DecBase.h @@ -38,7 +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_(long) GetBufferCount() { return 2; } + 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 0e539e7e..9e6bcca0 100644 --- a/decoder/LAVVideo/decoders/ILAVDecoder.h +++ b/decoder/LAVVideo/decoders/ILAVDecoder.h @@ -388,7 +388,7 @@ interface ILAVDecoder /** * Get the number of sample buffers optimal for this decoder */ - STDMETHOD_(long, GetBufferCount)() PURE; + STDMETHOD_(long, GetBufferCount)(long *pMaxBuffers = nullptr) PURE; /** * Get the name of the decoder diff --git a/decoder/LAVVideo/decoders/d3d11va.cpp b/decoder/LAVVideo/decoders/d3d11va.cpp index 263ba0ca..6e524bcc 100644 --- a/decoder/LAVVideo/decoders/d3d11va.cpp +++ b/decoder/LAVVideo/decoders/d3d11va.cpp @@ -508,7 +508,7 @@ STDMETHODIMP CDecD3D11::FillHWContext(AVD3D11VAContext *ctx) return S_OK; } -STDMETHODIMP_(long) CDecD3D11::GetBufferCount() +STDMETHODIMP_(long) CDecD3D11::GetBufferCount(long *pMaxBuffers) { long buffers = 0; @@ -533,6 +533,13 @@ STDMETHODIMP_(long) CDecD3D11::GetBufferCount() if (m_pCallback->GetDecodeFlags() & LAV_VIDEO_DEC_FLAG_DVD) { buffers += 4; } + + if (pMaxBuffers) + { + // cap at 127, because it needs to fit into the 7-bit DXVA structs + *pMaxBuffers = 127; + } + return buffers; } diff --git a/decoder/LAVVideo/decoders/d3d11va.h b/decoder/LAVVideo/decoders/d3d11va.h index a0fb1d85..82b67ef9 100644 --- a/decoder/LAVVideo/decoders/d3d11va.h +++ b/decoder/LAVVideo/decoders/d3d11va.h @@ -51,7 +51,7 @@ public: STDMETHODIMP InitAllocator(IMemAllocator **ppAlloc); STDMETHODIMP PostConnect(IPin *pPin); - STDMETHODIMP_(long) GetBufferCount(); + 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; } STDMETHODIMP SetDirectOutput(BOOL bDirect) { m_bDirect = bDirect; return S_OK; } diff --git a/decoder/LAVVideo/decoders/dxva2dec.cpp b/decoder/LAVVideo/decoders/dxva2dec.cpp index 60e64611..dcb5ba39 100644 --- a/decoder/LAVVideo/decoders/dxva2dec.cpp +++ b/decoder/LAVVideo/decoders/dxva2dec.cpp @@ -969,7 +969,7 @@ STDMETHODIMP CDecDXVA2::InitDecoder(AVCodecID codec, const CMediaType *pmt) return S_OK; } -STDMETHODIMP_(long) CDecDXVA2::GetBufferCount() +STDMETHODIMP_(long) CDecDXVA2::GetBufferCount(long *pMaxBuffers) { long buffers = 0; @@ -993,6 +993,13 @@ STDMETHODIMP_(long) CDecDXVA2::GetBufferCount() if (m_pCallback->GetDecodeFlags() & LAV_VIDEO_DEC_FLAG_DVD) { buffers += 4; } + + if (pMaxBuffers) + { + // cap at 127, because it needs to fit into the 7-bit DXVA structs + *pMaxBuffers = 127; + } + return buffers; } diff --git a/decoder/LAVVideo/decoders/dxva2dec.h b/decoder/LAVVideo/decoders/dxva2dec.h index a2d3fed8..669ab5af 100644 --- a/decoder/LAVVideo/decoders/dxva2dec.h +++ b/decoder/LAVVideo/decoders/dxva2dec.h @@ -51,7 +51,7 @@ public: STDMETHODIMP InitAllocator(IMemAllocator **ppAlloc); STDMETHODIMP PostConnect(IPin *pPin); - STDMETHODIMP_(long) GetBufferCount(); + STDMETHODIMP_(long) GetBufferCount(long *pMaxBuffers = nullptr); STDMETHODIMP_(const WCHAR*) GetDecoderName() { return m_bNative ? L"dxva2n" : (m_bDirect ? L"dxva2cb direct" : L"dxva2cb"); } STDMETHODIMP HasThreadSafeBuffers() { return m_bNative ? S_FALSE : S_OK; } STDMETHODIMP SetDirectOutput(BOOL bDirect) { m_bDirect = bDirect; return S_OK; } |