Bug 1392143 - P2. Disable hardware decoding for small videos. r=mattwoodrow draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 06 Sep 2017 17:02:21 +0200
changeset 661373 dcfb26420f2aa2b3b8972f2a9ad35a141b37e74a
parent 661372 841fe4eff706d78ac4267679a21902c9b9c1b07a
child 661374 b0266bcb46c82d5cee18157a3d66712c5744bf0c
push id78726
push userbmo:jyavenard@mozilla.com
push dateFri, 08 Sep 2017 09:59:08 +0000
reviewersmattwoodrow
bugs1392143
milestone57.0a1
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) &&