MCPcopy Create free account
hub / github.com/Nevcairiel/LAVFilters / InitDecoder

Method InitDecoder

decoder/LAVVideo/decoders/cuvid.cpp:630–836  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

628}
629
630STDMETHODIMP CDecCuvid::InitDecoder(AVCodecID codec, const CMediaType *pmt, const MediaSideDataFFMpeg *pSideData)
631{
632 DbgLog((LOG_TRACE, 10, L"CDecCuvid::InitDecoder(): Initializing CUVID decoder"));
633 HRESULT hr = S_OK;
634
635 if (!m_cudaContext)
636 {
637 DbgLog((LOG_TRACE, 10, L"-> InitDecoder called without a cuda context"));
638 return E_FAIL;
639 }
640
641 // Free old device
642 DestroyDecoder(false);
643
644 // Flush Display Queue
645 memset(&m_DisplayQueue, 0, sizeof(m_DisplayQueue));
646 for (int i = 0; i < DISPLAY_DELAY; i++)
647 m_DisplayQueue[i].picture_index = -1;
648 m_DisplayPos = 0;
649
650 m_DisplayDelay = DISPLAY_DELAY;
651
652 // Reduce display delay for DVD decoding for lower decode latency
653 if (m_pCallback->GetDecodeFlags() & LAV_VIDEO_DEC_FLAG_DVD)
654 m_DisplayDelay /= 2;
655
656 cudaVideoCodec cudaCodec = (cudaVideoCodec)-1;
657 for (int i = 0; i < countof(cuda_codecs); i++)
658 {
659 if (cuda_codecs[i].ffcodec == codec)
660 {
661 cudaCodec = cuda_codecs[i].cudaCodec;
662 break;
663 }
664 }
665
666 if (cudaCodec == -1)
667 {
668 DbgLog((LOG_TRACE, 10, L"-> Codec id %d does not map to a CUVID codec", codec));
669 return E_FAIL;
670 }
671
672 if (cudaCodec == cudaVideoCodec_MPEG4 && !m_bVDPAULevelC)
673 {
674 DbgLog((LOG_TRACE, 10, L"-> Device is not capable to decode this format (not >= Level C)"));
675 return E_FAIL;
676 }
677
678 m_bUseTimestampQueue = (m_pCallback->GetDecodeFlags() & LAV_VIDEO_DEC_FLAG_ONLY_DTS) ||
679 (cudaCodec == cudaVideoCodec_MPEG4 && pmt->formattype != FORMAT_MPEG2Video) ||
680 (cudaCodec == cudaVideoCodec_VP9);
681 m_bWaitForKeyframe = m_bUseTimestampQueue;
682 m_bInterlaced = TRUE;
683 m_bFormatIncompatible = FALSE;
684 m_bTFF = TRUE;
685 m_rtPrevDiff = AV_NOPTS_VALUE;
686 m_bARPresent = TRUE;
687

Callers 1

CreateDecoderMethod · 0.45

Calls 7

getExtraDataFunction · 0.85
videoFormatTypeHandlerFunction · 0.85
FormatMethod · 0.80
SetNALUSizeMethod · 0.80
ConvertHEVCExtradataMethod · 0.80
FormatTypeMethod · 0.80
ConvertMethod · 0.45

Tested by

no test coverage detected