Bug 1392143 - P2. Disable hardware decoding for small videos. r=mattwoodrow
As the H264 SanityTest uses a 132x132 videos to determine if the hardware decoder is working, we always use the software decoder for smaller videos.
MozReview-Commit-ID: 8VbZTiJO9mA
--- a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
+++ b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
@@ -598,18 +598,26 @@ WMFVideoMFTManager::Init()
}
return success;
}
bool
WMFVideoMFTManager::InitInternal()
{
+ // The H264 SanityTest uses a 132x132 videos to determine if DXVA can be used.
+ // so we want to use the software decoder for videos with lower resolutions.
+ static const int MIN_H264_HW_WIDTH = 132;
+ static const int MIN_H264_HW_HEIGHT = 132;
+
mUseHwAccel = false; // default value; changed if D3D setup succeeds.
- bool useDxva = InitializeDXVA();
+ bool useDxva = (mStreamType != H264 ||
+ (mVideoInfo.ImageRect().width > MIN_H264_HW_WIDTH &&
+ mVideoInfo.ImageRect().height > MIN_H264_HW_HEIGHT)) &&
+ InitializeDXVA();
RefPtr<MFTDecoder> decoder;
HRESULT hr;
if (mStreamType == VP9 && useDxva && mCheckForAMDDecoder &&
gfxPrefs::PDMWMFAMDVP9DecoderEnabled()) {
if ((decoder = LoadAMDVP9Decoder())) {
mAMDVP9InUse = true;
--- a/toolkit/components/gfx/SanityTest.js
+++ b/toolkit/components/gfx/SanityTest.js
@@ -101,16 +101,18 @@ function takeWindowSnapshot(win, ctx) {
// Verify that all the 4 coloured squares of the video
// render as expected (with a tolerance of 64 to allow for
// yuv->rgb differences between platforms).
//
// The video is 132*132, and is split into quadrants of
// different colours. The top left of the video is 8,72
// and we test a pixel 33,33 into each quadrant to avoid
// blending differences at the edges.
+// If those values are ever changed, make sure to update
+// WMFVideoMFTManager::CanUseDXVA accordingly.
//
// We allow massive amounts of fuzz for the colours since
// it can depend hugely on the yuv -> rgb conversion, and
// we don't want to fail unnecessarily.
function verifyVideoRendering(ctx) {
return testPixel(ctx, 41, 105, 255, 255, 255, 255, 64) &&
testPixel(ctx, 107, 105, 0, 255, 0, 255, 64) &&
testPixel(ctx, 41, 171, 0, 0, 255, 255, 64) &&