STDMETHODIMP CDecodeThread::CreateDecoderInternal(const CMediaType *pmt, AVCodecID codec) { DbgLog((LOG_TRACE, 10, L"CDecodeThread::CreateDecoderInternal(): Creating new decoder for codec %S", avcodec_get_name(codec))); HRESULT hr = S_OK; BOOL bWMV9 = FALSE; BOOL bHWDecBlackList = _wcsicmp(m_processName.c_str(), L"dllhost.exe") == 0 || _wcsicmp(m_processName.c_str(), L"explorer.exe") == 0 || _wcsicmp(m_processName.c_str(), L"ReClockHelper.dll") == 0; DbgLog((LOG_TRACE, 10, L"-> Process is %s, blacklist: %d", m_processName.c_str(), bHWDecBlackList)); BITMAPINFOHEADER *pBMI = nullptr; videoFormatTypeHandler(*pmt, &pBMI); // Try reusing the current HW decoder if (m_pDecoder && m_bHWDecoder && !m_bHWDecoderFailed && HWFORMAT_ENABLED && HWRESOLUTION_ENABLED) { DbgLog((LOG_TRACE, 10, L"-> Trying to re-use old HW Decoder")); hr = m_pDecoder->InitDecoder(codec, pmt); goto done; } SAFE_DELETE(m_pDecoder); LAVHWAccel hwAccel = m_pLAVVideo->GetHWAccel(); if (!bHWDecBlackList && hwAccel != HWAccel_None && !m_bHWDecoderFailed && HWFORMAT_ENABLED && HWRESOLUTION_ENABLED) { DbgLog((LOG_TRACE, 10, L"-> Trying Hardware Codec %d", hwAccel)); if (hwAccel == HWAccel_CUDA) m_pDecoder = CreateDecoderCUVID(); else if (hwAccel == HWAccel_QuickSync) m_pDecoder = CreateDecoderQuickSync(); else if (hwAccel == HWAccel_DXVA2CopyBack) m_pDecoder = CreateDecoderDXVA2(); else if (hwAccel == HWAccel_DXVA2Native) m_pDecoder = CreateDecoderDXVA2Native(); m_bHWDecoder = TRUE; } softwaredec: // Fallback for software if (!m_pDecoder) { DbgLog((LOG_TRACE, 10, L"-> No HW Codec, using Software")); m_bHWDecoder = FALSE; if (m_pLAVVideo->GetUseMSWMV9Decoder() && (codec == AV_CODEC_ID_VC1 || codec == AV_CODEC_ID_WMV3) && !m_bWMV9Failed) { if (IsWindows7OrNewer()) m_pDecoder = CreateDecoderWMV9MFT(); else m_pDecoder = CreateDecoderWMV9(); bWMV9 = TRUE; } else m_pDecoder = CreateDecoderAVCodec(); } DbgLog((LOG_TRACE, 10, L"-> Created Codec '%s'", m_pDecoder->GetDecoderName())); hr = m_pDecoder->InitInterfaces(static_cast<ILAVVideoSettings *>(m_pLAVVideo), static_cast<ILAVVideoCallback *>(this)); if (FAILED(hr)) { DbgLog((LOG_TRACE, 10, L"-> Init Interfaces failed (hr: 0x%x)", hr)); goto done; } hr = m_pDecoder->InitDecoder(codec, pmt); if (FAILED(hr)) { DbgLog((LOG_TRACE, 10, L"-> Init Decoder failed (hr: 0x%x)", hr)); goto done; } done: if (FAILED(hr)) { SAFE_DELETE(m_pDecoder); if (m_bHWDecoder) { DbgLog((LOG_TRACE, 10, L"-> Hardware decoder failed to initialize, re-trying with software...")); m_bHWDecoderFailed = TRUE; goto softwaredec; } if (bWMV9) { DbgLog((LOG_TRACE, 10, L"-> WMV9 DMO decoder failed, trying avcodec instead...")); m_bWMV9Failed = TRUE; bWMV9 = FALSE; goto softwaredec; } return hr; } m_Codec = codec; m_bSyncToProcess = m_pDecoder->SyncToProcessThread() == S_OK || (m_pLAVVideo->GetDecodeFlags() & LAV_VIDEO_DEC_FLAG_DVD); return hr; }
PlatformInterface::PlatformInterface() : _timestampFrequency( ReadPerformanceFrequency() ) { if( !IsWindows7OrNewer() ) { MessageBoxW( nullptr, L"You are using an unsupported version of Windows. Certain portions of the program may not function correctly or at all. Please update to Windows 7 or newer in order to ensure correct behavior of this program.", L"", MB_OK ); } }