Bug 1764823 - When attempting to hardware decode H264 video, the D3D9 DXVA support check will now correctly use the input media type. r=alwu

Improved the debug description of WMF video decoders to list the DXVA version used as well as the correct output type.

Differential Revision: https://phabricator.services.mozilla.com/D143775
This commit is contained in:
Zaggy1024 2022-04-15 04:21:48 +00:00
parent c40c17bfa2
commit 28b46457ec
2 changed files with 62 additions and 22 deletions

View File

@ -210,19 +210,19 @@ HRESULT ConvertMFTypeToDXVAType(IMFMediaType* pType, DXVA2_VideoDesc* pDesc) {
UINT32 fpsNumerator = 0; UINT32 fpsNumerator = 0;
UINT32 fpsDenominator = 0; UINT32 fpsDenominator = 0;
hr = MFGetAttributeRatio(pType, MF_MT_FRAME_RATE, &fpsNumerator, if (SUCCEEDED(MFGetAttributeRatio(pType, MF_MT_FRAME_RATE, &fpsNumerator,
&fpsDenominator); &fpsDenominator))) {
NS_ENSURE_TRUE(SUCCEEDED(hr), hr); pDesc->InputSampleFreq.Numerator = fpsNumerator;
pDesc->InputSampleFreq.Numerator = fpsNumerator; pDesc->InputSampleFreq.Denominator = fpsDenominator;
pDesc->InputSampleFreq.Denominator = fpsDenominator;
GetDXVA2ExtendedFormatFromMFMediaType(pType, &pDesc->SampleFormat); GetDXVA2ExtendedFormatFromMFMediaType(pType, &pDesc->SampleFormat);
pDesc->OutputFrameFreq = pDesc->InputSampleFreq; pDesc->OutputFrameFreq = pDesc->InputSampleFreq;
if ((pDesc->SampleFormat.SampleFormat == if ((pDesc->SampleFormat.SampleFormat ==
DXVA2_SampleFieldInterleavedEvenFirst) || DXVA2_SampleFieldInterleavedEvenFirst) ||
(pDesc->SampleFormat.SampleFormat == (pDesc->SampleFormat.SampleFormat ==
DXVA2_SampleFieldInterleavedOddFirst)) { DXVA2_SampleFieldInterleavedOddFirst)) {
pDesc->OutputFrameFreq.Numerator *= 2; pDesc->OutputFrameFreq.Numerator *= 2;
}
} }
return S_OK; return S_OK;
@ -275,9 +275,7 @@ bool D3D9DXVA2Manager::SupportsConfig(IMFMediaType* aInputType,
} }
DXVA2_VideoDesc desc; DXVA2_VideoDesc desc;
// TODO Bug 1764823: ConvertMFTypeToDXVAType should accept the input type hr = ConvertMFTypeToDXVAType(aInputType, &desc);
// instead.
hr = ConvertMFTypeToDXVAType(aOutputType, &desc);
NS_ENSURE_TRUE(SUCCEEDED(hr), false); NS_ENSURE_TRUE(SUCCEEDED(hr), false);
return CanCreateDecoder(desc, aFramerate); return CanCreateDecoder(desc, aFramerate);
} }

View File

@ -526,6 +526,12 @@ WMFVideoMFTManager::SetDecoderMediaTypes() {
mVideoInfo.ImageRect().height); mVideoInfo.ImageRect().height);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr); NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
UINT32 fpsDenominator = 1000;
UINT32 fpsNumerator = static_cast<uint32_t>(mFramerate * fpsDenominator);
hr = MFSetAttributeRatio(inputType, MF_MT_FRAME_RATE, fpsNumerator,
fpsDenominator);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
RefPtr<IMFMediaType> outputType; RefPtr<IMFMediaType> outputType;
hr = wmf::MFCreateMediaType(getter_AddRefs(outputType)); hr = wmf::MFCreateMediaType(getter_AddRefs(outputType));
NS_ENSURE_TRUE(SUCCEEDED(hr), hr); NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
@ -538,6 +544,10 @@ WMFVideoMFTManager::SetDecoderMediaTypes() {
mVideoInfo.ImageRect().height); mVideoInfo.ImageRect().height);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr); 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; GUID outputSubType = mUseHwAccel ? MFVideoFormat_NV12 : MFVideoFormat_YV12;
hr = outputType->SetGUID(MF_MT_SUBTYPE, outputSubType); hr = outputType->SetGUID(MF_MT_SUBTYPE, outputSubType);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr); NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
@ -990,14 +1000,46 @@ bool WMFVideoMFTManager::IsHardwareAccelerated(
nsCString WMFVideoMFTManager::GetDescriptionName() const { nsCString WMFVideoMFTManager::GetDescriptionName() const {
nsCString failureReason; nsCString failureReason;
bool hw = IsHardwareAccelerated(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), WMFDecoderModule::StreamTypeToString(mStreamType),
hw ? "hardware" : "software", hw ? "hardware" : "software", dxvaName, formatName);
hw ? StaticPrefs::media_wmf_use_nv12_format() &&
gfx::DeviceManagerDx::Get()->CanUseNV12()
? "nv12"
: "rgba32"
: "yuv420");
} }
} // namespace mozilla } // namespace mozilla