Bug 1496529 - P9. Enable low latency decoding on Windows. r=bryce
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 09 Oct 2018 16:59:32 +0000
changeset 496093 ea2cd3e66c564ab1f64c33b3ea8ce5924b3b6a79
parent 496092 357d4762fa8fda3470020886958c300aae51cb22
child 496094 b3a1baa85807cc175fd2d2b49d21408ea55e5e21
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbryce
bugs1496529
milestone64.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 1496529 - P9. Enable low latency decoding on Windows. r=bryce Depends on D7908 Differential Revision: https://phabricator.services.mozilla.com/D7909
dom/media/platforms/wmf/WMFDecoderModule.cpp
dom/media/platforms/wmf/WMFVideoMFTManager.cpp
dom/media/platforms/wmf/WMFVideoMFTManager.h
--- a/dom/media/platforms/wmf/WMFDecoderModule.cpp
+++ b/dom/media/platforms/wmf/WMFDecoderModule.cpp
@@ -89,29 +89,23 @@ WMFDecoderModule::Startup()
 {
   mWMFInitialized = SUCCEEDED(wmf::MFStartup());
   return mWMFInitialized ? NS_OK : NS_ERROR_FAILURE;
 }
 
 already_AddRefed<MediaDataDecoder>
 WMFDecoderModule::CreateVideoDecoder(const CreateDecoderParams& aParams)
 {
-  if (aParams.mOptions.contains(CreateDecoderParams::Option::LowLatency)) {
-    // Latency on Windows is bad. Let's not attempt to decode with WMF decoders
-    // when low latency is required.
-    return nullptr;
-  }
-
   nsAutoPtr<WMFVideoMFTManager> manager(new WMFVideoMFTManager(
     aParams.VideoConfig(),
     aParams.mKnowsCompositor,
     aParams.mImageContainer,
     aParams.mRate.mValue,
-    sDXVAEnabled && !aParams.mOptions.contains(
-                      CreateDecoderParams::Option::HardwareDecoderNotAllowed)));
+    aParams.mOptions,
+    sDXVAEnabled));
 
   MediaResult result = manager->Init();
   if (NS_FAILED(result)) {
     if (aParams.mError) {
       *aParams.mError = result;
     }
     return nullptr;
   }
--- a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
+++ b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
@@ -141,26 +141,30 @@ GetCompositorBackendType(layers::KnowsCo
   return LayersBackend::LAYERS_NONE;
 }
 
 WMFVideoMFTManager::WMFVideoMFTManager(
   const VideoInfo& aConfig,
   layers::KnowsCompositor* aKnowsCompositor,
   layers::ImageContainer* aImageContainer,
   float aFramerate,
+  const CreateDecoderParams::OptionSet& aOptions,
   bool aDXVAEnabled)
   : mVideoInfo(aConfig)
   , mImageSize(aConfig.mImage)
   , mDecodedImageSize(aConfig.mImage)
   , mVideoStride(0)
   , mYUVColorSpace(YUVColorSpace::BT601)
   , mImageContainer(aImageContainer)
   , mKnowsCompositor(aKnowsCompositor)
-  , mDXVAEnabled(aDXVAEnabled)
+  , mDXVAEnabled(aDXVAEnabled &&
+                 !aOptions.contains(
+                   CreateDecoderParams::Option::HardwareDecoderNotAllowed))
   , mFramerate(aFramerate)
+  , mLowLatency(aOptions.contains(CreateDecoderParams::Option::LowLatency))
   // mVideoStride, mVideoWidth, mVideoHeight, mUseHwAccel are initialized in
   // Init().
 {
   MOZ_COUNT_CTOR(WMFVideoMFTManager);
 
   // Need additional checks/params to check vp8/vp9
   if (MP4Decoder::IsH264(aConfig.mMimeType)) {
     mStreamType = H264;
@@ -611,17 +615,17 @@ WMFVideoMFTManager::InitInternal()
                              RESULT_DETAIL("Can't create the MFT decoder.")));
 
   RefPtr<IMFAttributes> attr(decoder->GetAttributes());
   UINT32 aware = 0;
   if (attr) {
     attr->GetUINT32(MF_SA_D3D_AWARE, &aware);
     attr->SetUINT32(CODECAPI_AVDecNumWorkerThreads,
       WMFDecoderModule::GetNumDecoderThreads());
-    if (gfxPrefs::PDMWMFLowLatencyEnabled()) {
+    if (mLowLatency || gfxPrefs::PDMWMFLowLatencyEnabled()) {
       hr = attr->SetUINT32(CODECAPI_AVLowLatencyMode, TRUE);
       if (SUCCEEDED(hr)) {
         LOG("Enabling Low Latency Mode");
       } else {
         LOG("Couldn't enable Low Latency Mode");
       }
     }
   }
--- a/dom/media/platforms/wmf/WMFVideoMFTManager.h
+++ b/dom/media/platforms/wmf/WMFVideoMFTManager.h
@@ -22,16 +22,17 @@ class DXVA2Manager;
 
 class WMFVideoMFTManager : public MFTManager
 {
 public:
   WMFVideoMFTManager(const VideoInfo& aConfig,
                      layers::KnowsCompositor* aKnowsCompositor,
                      layers::ImageContainer* aImageContainer,
                      float aFramerate,
+                     const CreateDecoderParams::OptionSet& aOptions,
                      bool aDXVAEnabled);
   ~WMFVideoMFTManager();
 
   MediaResult Init();
 
   HRESULT Input(MediaRawData* aSample) override;
 
   HRESULT Output(int64_t aStreamOffset, RefPtr<MediaData>& aOutput) override;
@@ -118,13 +119,14 @@ private:
   const GUID& GetMediaSubtypeGUID();
 
   uint32_t mNullOutputCount = 0;
   bool mGotValidOutputAfterNullOutput = false;
   bool mGotExcessiveNullOutput = false;
   bool mIsValid = true;
   bool mIMFUsable = false;
   const float mFramerate;
+  const bool mLowLatency;
 };
 
 } // namespace mozilla
 
 #endif // WMFVideoMFTManager_h_