author | Matt Woodrow <mwoodrow@mozilla.com> |
Thu, 10 Sep 2015 13:39:02 -0400 | |
changeset 261763 | e7e0427710e1b21ec0db81f47db472de0934e38a |
parent 261762 | 8a7d924a0f3435f0d9626a05449dcbe35c4f0a95 |
child 261764 | f63ec3ee07ed9c74dfddae5feab6545f4584731a |
push id | 64839 |
push user | mwoodrow@mozilla.com |
push date | Thu, 10 Sep 2015 18:21:06 +0000 |
treeherder | mozilla-inbound@e7e0427710e1 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | cpearce |
bugs | 1202296 |
milestone | 43.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
|
dom/media/platforms/wmf/WMFVideoMFTManager.cpp | file | annotate | diff | comparison | revisions | |
dom/media/platforms/wmf/WMFVideoMFTManager.h | file | annotate | diff | comparison | revisions |
--- a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp +++ b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp @@ -148,25 +148,24 @@ public: nsAutoPtr<DXVA2Manager> mDXVA2Manager; LayersBackend mBackend; nsACString& mFailureReason; }; bool WMFVideoMFTManager::InitializeDXVA(bool aForceD3D9) { - MOZ_ASSERT(!mDXVA2Manager); - // If we use DXVA but aren't running with a D3D layer manager then the // readback of decoded video frames from GPU to CPU memory grinds painting // to a halt, and makes playback performance *worse*. if (!mDXVAEnabled) { mDXVAFailureReason.AssignLiteral("Hardware video decoding disabled or blacklisted"); return false; } + MOZ_ASSERT(!mDXVA2Manager); if (mLayersBackend != LayersBackend::LAYERS_D3D9 && mLayersBackend != LayersBackend::LAYERS_D3D11) { mDXVAFailureReason.AssignLiteral("Unsupported layers backend"); return false; } // The DXVA manager must be created on the main thread. nsRefPtr<CreateDXVAManagerEvent> event = @@ -320,67 +319,50 @@ WMFVideoMFTManager::Input(MediaRawData* // // Unfortunately this seems to cause corruption (see bug 1193547) and is // slow because the upload is done into a non-shareable texture and requires // us to copy it. // // This code tests if the given resolution can be supported directly on the GPU, // and makes sure we only ask the MFT for DXVA if it can be supported properly. bool -WMFVideoMFTManager::MaybeToggleDXVA(IMFMediaType* aType) +WMFVideoMFTManager::CanUseDXVA(IMFMediaType* aType) { + MOZ_ASSERT(mDXVA2Manager); // SupportsConfig only checks for valid h264 decoders currently. - if (!mDXVA2Manager || mStreamType != H264) { - return false; + if (mStreamType != H264) { + return true; } // Assume the current samples duration is representative for the // entire video. float framerate = 1000000.0 / mLastDuration; - if (mDXVA2Manager->SupportsConfig(aType, framerate)) { - if (!mUseHwAccel) { - // DXVA disabled, but supported for this resolution - ULONG_PTR manager = ULONG_PTR(mDXVA2Manager->GetDXVADeviceManager()); - HRESULT hr = mDecoder->SendMFTMessage(MFT_MESSAGE_SET_D3D_MANAGER, manager); - if (SUCCEEDED(hr)) { - mUseHwAccel = true; - return true; - } - } - } else if (mUseHwAccel) { - // DXVA enabled, and not supported for this resolution - HRESULT hr = mDecoder->SendMFTMessage(MFT_MESSAGE_SET_D3D_MANAGER, 0); - MOZ_ASSERT(SUCCEEDED(hr), "Attempting to fall back to software failed?"); - mUseHwAccel = false; - return true; - } - - return false; + return mDXVA2Manager->SupportsConfig(aType, framerate); } HRESULT WMFVideoMFTManager::ConfigureVideoFrameGeometry() { RefPtr<IMFMediaType> mediaType; HRESULT hr = mDecoder->GetOutputMediaType(mediaType); NS_ENSURE_TRUE(SUCCEEDED(hr), hr); // If we enabled/disabled DXVA in response to a resolution // change then we need to renegotiate our media types, // and resubmit our previous frame (since the MFT appears // to lose it otherwise). - if (MaybeToggleDXVA(mediaType)) { - hr = SetDecoderMediaTypes(); - NS_ENSURE_TRUE(SUCCEEDED(hr), hr); - - HRESULT hr = mDecoder->GetOutputMediaType(mediaType); - NS_ENSURE_TRUE(SUCCEEDED(hr), hr); + if (mUseHwAccel && !CanUseDXVA(mediaType)) { + mDXVAEnabled = false; + if (!Init()) { + return E_FAIL; + } mDecoder->Input(mLastInput); + return S_OK; } // Verify that the video subtype is what we expect it to be. // When using hardware acceleration/DXVA2 the video format should // be NV12, which is DXVA2's preferred format. For software decoding // we use YV12, as that's easier for us to stick into our rendering // pipeline than NV12. NV12 has interleaved UV samples, whereas YV12 // is a planar format.
--- a/dom/media/platforms/wmf/WMFVideoMFTManager.h +++ b/dom/media/platforms/wmf/WMFVideoMFTManager.h @@ -53,32 +53,32 @@ private: VideoData** aOutVideoData); HRESULT CreateD3DVideoFrame(IMFSample* aSample, int64_t aStreamOffset, VideoData** aOutVideoData); HRESULT SetDecoderMediaTypes(); - bool MaybeToggleDXVA(IMFMediaType* aType); + bool CanUseDXVA(IMFMediaType* aType); // Video frame geometry. VideoInfo mVideoInfo; uint32_t mVideoStride; uint32_t mVideoWidth; uint32_t mVideoHeight; nsIntRect mPictureRegion; RefPtr<layers::ImageContainer> mImageContainer; nsAutoPtr<DXVA2Manager> mDXVA2Manager; RefPtr<IMFSample> mLastInput; float mLastDuration; - const bool mDXVAEnabled; + bool mDXVAEnabled; const layers::LayersBackend mLayersBackend; bool mUseHwAccel; nsCString mDXVAFailureReason; enum StreamType { Unknown, H264,