Bug 1392143 - P2. Disable hardware decoding for small videos. r=mattwoodrow
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 06 Sep 2017 17:02:21 +0200
changeset 429184 bdd70cdbf8f118e1001b2e534c213c17c1fe8240
parent 429183 503df830e5947469778fe8fbc3e10efc29ccde98
child 429185 83c640edfe509971e39ad7d10d1b7994664d7bba
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1392143
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
dom/media/platforms/wmf/WMFVideoMFTManager.cpp
toolkit/components/gfx/SanityTest.js
--- 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) &&