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-04-15 12:17:40 +0300
committerHendrik Leppkes <h.leppkes@gmail.com>2017-04-15 12:51:49 +0300
commit8c1e205558a8d868f7c036713038796e2c696166 (patch)
tree7abc257a12acf15e49775d95b4c128417c55d204
parent119262ee9ec5b57fd9dd59635caba47064f742f0 (diff)
cuvid: set deinterlace mode to weave (disabled) on progressive streams
In theory the GPU should avoid deinterlacing progressive streams automatically, but it appears at least some device/driver combinations do still attempt to deinterlace progressive streams in some situations, resulting in a degraded image. Based on the report and patch by Lutz Wolter
-rw-r--r--decoder/LAVVideo/decoders/cuvid.cpp15
-rw-r--r--decoder/LAVVideo/decoders/cuvid.h2
2 files changed, 11 insertions, 6 deletions
diff --git a/decoder/LAVVideo/decoders/cuvid.cpp b/decoder/LAVVideo/decoders/cuvid.cpp
index 9c0142b3..9944c5c9 100644
--- a/decoder/LAVVideo/decoders/cuvid.cpp
+++ b/decoder/LAVVideo/decoders/cuvid.cpp
@@ -721,7 +721,7 @@ STDMETHODIMP CDecCuvid::InitDecoder(AVCodecID codec, const CMediaType *pmt)
videoFormatTypeHandler(pmt->Format(), pmt->FormatType(), &bmi);
{
- hr = CreateCUVIDDecoder(cudaCodec, bmi->biWidth, bmi->biHeight);
+ hr = CreateCUVIDDecoder(cudaCodec, bmi->biWidth, bmi->biHeight, !m_bInterlaced);
if (FAILED(hr)) {
DbgLog((LOG_ERROR, 10, L"-> Creating CUVID decoder failed"));
return hr;
@@ -735,7 +735,7 @@ STDMETHODIMP CDecCuvid::InitDecoder(AVCodecID codec, const CMediaType *pmt)
return S_OK;
}
-STDMETHODIMP CDecCuvid::CreateCUVIDDecoder(cudaVideoCodec codec, DWORD dwWidth, DWORD dwHeight)
+STDMETHODIMP CDecCuvid::CreateCUVIDDecoder(cudaVideoCodec codec, DWORD dwWidth, DWORD dwHeight, bool bProgressiveSequence)
{
DbgLog((LOG_TRACE, 10, L"CDecCuvid::CreateCUVIDDecoder(): Creating CUVID decoder instance"));
HRESULT hr = S_OK;
@@ -756,7 +756,7 @@ retry:
dci->CodecType = codec;
dci->ChromaFormat = cudaVideoChromaFormat_420;
dci->OutputFormat = cudaVideoSurfaceFormat_NV12;
- dci->DeinterlaceMode = (cudaVideoDeinterlaceMode)m_pSettings->GetHWAccelDeintMode();
+ dci->DeinterlaceMode = (bProgressiveSequence || (m_pSettings->GetDeinterlacingMode() == DeintMode_Disable)) ? cudaVideoDeinterlaceMode_Weave : (cudaVideoDeinterlaceMode)m_pSettings->GetHWAccelDeintMode();
dci->ulNumOutputSurfaces = 1;
dci->ulTargetWidth = dwWidth;
@@ -817,18 +817,23 @@ int CUDAAPI CDecCuvid::HandleVideoSequence(void *obj, CUVIDEOFORMAT *cuvidfmt)
CUVIDDECODECREATEINFO *dci = &filter->m_VideoDecoderInfo;
+ // Check if we should be deinterlacing
+ bool bShouldDeinterlace = (!cuvidfmt->progressive_sequence && filter->m_pSettings->GetDeinterlacingMode() != DeintMode_Disable && filter->m_pSettings->GetHWAccelDeintMode() != HWDeintMode_Weave);
+
+ // Re-initialize the decoder if needed
if ((cuvidfmt->codec != dci->CodecType)
|| (cuvidfmt->coded_width != dci->ulWidth)
|| (cuvidfmt->coded_height != dci->ulHeight)
|| (cuvidfmt->chroma_format != dci->ChromaFormat)
+ || (bShouldDeinterlace != (dci->DeinterlaceMode != cudaVideoDeinterlaceMode_Weave))
|| filter->m_bForceSequenceUpdate)
{
filter->m_bForceSequenceUpdate = FALSE;
- filter->CreateCUVIDDecoder(cuvidfmt->codec, cuvidfmt->coded_width, cuvidfmt->coded_height);
+ filter->CreateCUVIDDecoder(cuvidfmt->codec, cuvidfmt->coded_width, cuvidfmt->coded_height, cuvidfmt->progressive_sequence);
}
filter->m_bInterlaced = !cuvidfmt->progressive_sequence;
- filter->m_bDoubleRateDeint = filter->m_bInterlaced && (filter->m_pSettings->GetHWAccelDeintOutput() == DeintOutput_FramePerField) && (filter->m_VideoDecoderInfo.DeinterlaceMode != cudaVideoDeinterlaceMode_Weave) && !(filter->m_pSettings->GetDeinterlacingMode() == DeintMode_Disable);
+ filter->m_bDoubleRateDeint = bShouldDeinterlace && (filter->m_pSettings->GetHWAccelDeintOutput() == DeintOutput_FramePerField);
if (filter->m_bInterlaced && cuvidfmt->frame_rate.numerator && cuvidfmt->frame_rate.denominator) {
double dFrameTime = 10000000.0 / ((double)cuvidfmt->frame_rate.numerator / cuvidfmt->frame_rate.denominator);
if (filter->m_bDoubleRateDeint && (int)(dFrameTime / 10000.0) == 41) {
diff --git a/decoder/LAVVideo/decoders/cuvid.h b/decoder/LAVVideo/decoders/cuvid.h
index 0aa4643e..c2c03db2 100644
--- a/decoder/LAVVideo/decoders/cuvid.h
+++ b/decoder/LAVVideo/decoders/cuvid.h
@@ -63,7 +63,7 @@ private:
STDMETHODIMP InitD3D9(int best_device, DWORD requested_device);
- STDMETHODIMP CreateCUVIDDecoder(cudaVideoCodec codec, DWORD dwWidth, DWORD dwHeight);
+ STDMETHODIMP CreateCUVIDDecoder(cudaVideoCodec codec, DWORD dwWidth, DWORD dwHeight, bool bProgressiveSequence);
STDMETHODIMP DecodeSequenceData();
// CUDA Callbacks