diff --git a/dom/media/platforms/wmf/DXVA2Manager.cpp b/dom/media/platforms/wmf/DXVA2Manager.cpp index 19b2a6b97e79..466514e666fd 100644 --- a/dom/media/platforms/wmf/DXVA2Manager.cpp +++ b/dom/media/platforms/wmf/DXVA2Manager.cpp @@ -210,19 +210,19 @@ HRESULT ConvertMFTypeToDXVAType(IMFMediaType* pType, DXVA2_VideoDesc* pDesc) { UINT32 fpsNumerator = 0; UINT32 fpsDenominator = 0; - hr = MFGetAttributeRatio(pType, MF_MT_FRAME_RATE, &fpsNumerator, - &fpsDenominator); - NS_ENSURE_TRUE(SUCCEEDED(hr), hr); - pDesc->InputSampleFreq.Numerator = fpsNumerator; - pDesc->InputSampleFreq.Denominator = fpsDenominator; + if (SUCCEEDED(MFGetAttributeRatio(pType, MF_MT_FRAME_RATE, &fpsNumerator, + &fpsDenominator))) { + pDesc->InputSampleFreq.Numerator = fpsNumerator; + pDesc->InputSampleFreq.Denominator = fpsDenominator; - GetDXVA2ExtendedFormatFromMFMediaType(pType, &pDesc->SampleFormat); - pDesc->OutputFrameFreq = pDesc->InputSampleFreq; - if ((pDesc->SampleFormat.SampleFormat == - DXVA2_SampleFieldInterleavedEvenFirst) || - (pDesc->SampleFormat.SampleFormat == - DXVA2_SampleFieldInterleavedOddFirst)) { - pDesc->OutputFrameFreq.Numerator *= 2; + GetDXVA2ExtendedFormatFromMFMediaType(pType, &pDesc->SampleFormat); + pDesc->OutputFrameFreq = pDesc->InputSampleFreq; + if ((pDesc->SampleFormat.SampleFormat == + DXVA2_SampleFieldInterleavedEvenFirst) || + (pDesc->SampleFormat.SampleFormat == + DXVA2_SampleFieldInterleavedOddFirst)) { + pDesc->OutputFrameFreq.Numerator *= 2; + } } return S_OK; @@ -275,9 +275,7 @@ bool D3D9DXVA2Manager::SupportsConfig(IMFMediaType* aInputType, } DXVA2_VideoDesc desc; - // TODO Bug 1764823: ConvertMFTypeToDXVAType should accept the input type - // instead. - hr = ConvertMFTypeToDXVAType(aOutputType, &desc); + hr = ConvertMFTypeToDXVAType(aInputType, &desc); NS_ENSURE_TRUE(SUCCEEDED(hr), false); return CanCreateDecoder(desc, aFramerate); } diff --git a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp index 2c050818a4b3..4739f88a12d2 100644 --- a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp +++ b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp @@ -526,6 +526,12 @@ WMFVideoMFTManager::SetDecoderMediaTypes() { mVideoInfo.ImageRect().height); NS_ENSURE_TRUE(SUCCEEDED(hr), hr); + UINT32 fpsDenominator = 1000; + UINT32 fpsNumerator = static_cast(mFramerate * fpsDenominator); + hr = MFSetAttributeRatio(inputType, MF_MT_FRAME_RATE, fpsNumerator, + fpsDenominator); + NS_ENSURE_TRUE(SUCCEEDED(hr), hr); + RefPtr outputType; hr = wmf::MFCreateMediaType(getter_AddRefs(outputType)); NS_ENSURE_TRUE(SUCCEEDED(hr), hr); @@ -538,6 +544,10 @@ WMFVideoMFTManager::SetDecoderMediaTypes() { mVideoInfo.ImageRect().height); NS_ENSURE_TRUE(SUCCEEDED(hr), hr); + hr = MFSetAttributeRatio(outputType, MF_MT_FRAME_RATE, fpsNumerator, + fpsDenominator); + NS_ENSURE_TRUE(SUCCEEDED(hr), hr); + GUID outputSubType = mUseHwAccel ? MFVideoFormat_NV12 : MFVideoFormat_YV12; hr = outputType->SetGUID(MF_MT_SUBTYPE, outputSubType); NS_ENSURE_TRUE(SUCCEEDED(hr), hr); @@ -990,14 +1000,46 @@ bool WMFVideoMFTManager::IsHardwareAccelerated( nsCString WMFVideoMFTManager::GetDescriptionName() const { nsCString failureReason; bool hw = IsHardwareAccelerated(failureReason); - return nsPrintfCString("wmf %s codec %s video decoder - %s", + + const char* formatName = [&]() { + GUID format = mDecoder->GetOutputMediaSubType(); + if (format == MFVideoFormat_NV12) { + if (!gfx::DeviceManagerDx::Get()->CanUseNV12()) { + return "nv12->argb32"; + } + return "nv12"; + } + if (format == MFVideoFormat_P010) { + if (!gfx::DeviceManagerDx::Get()->CanUseP010()) { + return "p010->argb32"; + } + return "p010"; + } + if (format == MFVideoFormat_P016) { + if (!gfx::DeviceManagerDx::Get()->CanUseP016()) { + return "p016->argb32"; + } + return "p016"; + } + if (format == MFVideoFormat_YV12) { + return "yv12"; + } + return "unknown"; + }(); + + const char* dxvaName = [&]() { + if (!mDXVA2Manager) { + return "no DXVA"; + } + if (mDXVA2Manager->IsD3D11()) { + return "D3D11"; + } + return "D3D9"; + }(); + + return nsPrintfCString("wmf %s codec %s video decoder - %s, %s", WMFDecoderModule::StreamTypeToString(mStreamType), - hw ? "hardware" : "software", - hw ? StaticPrefs::media_wmf_use_nv12_format() && - gfx::DeviceManagerDx::Get()->CanUseNV12() - ? "nv12" - : "rgba32" - : "yuv420"); + hw ? "hardware" : "software", dxvaName, formatName); } } // namespace mozilla