author | Kilik Kuo <kikuo@mozilla.com> |
Wed, 07 Oct 2015 14:52:05 +0800 (2015-10-07) | |
changeset 266867 | 32227d966b607f6635a60026f6d73eee947e4407 |
parent 266866 | eb52856f029c683f7c30fc177b0b6fdbde1ca6c1 |
child 266868 | 793fcff5028b211e3f59710eb6c87c20d7f0861c |
push id | 66316 |
push user | cbook@mozilla.com |
push date | Thu, 08 Oct 2015 17:40:16 +0000 (2015-10-08) |
treeherder | mozilla-inbound@793fcff5028b [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jwwang |
bugs | 1211364 |
milestone | 44.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/MediaDecoderStateMachine.cpp | file | annotate | diff | comparison | revisions | |
dom/media/MediaDecoderStateMachine.h | file | annotate | diff | comparison | revisions |
--- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -844,16 +844,20 @@ MediaDecoderStateMachine::OnVideoDecoded aVideoSample->AdjustForStartTime(StartTime()); mDecodedVideoEndTime = video ? video->GetEndTime() : mDecodedVideoEndTime; SAMPLE_LOG("OnVideoDecoded [%lld,%lld] disc=%d", (video ? video->mTime : -1), (video ? video->GetEndTime() : -1), (video ? video->mDiscontinuity : 0)); + // Check frame validity here for every decoded frame in order to have a + // better chance to make the decision of turning off HW acceleration. + CheckFrameValidity(aVideoSample->As<VideoData>()); + switch (mState) { case DECODER_STATE_BUFFERING: { // If we're buffering, this may be the sample we need to stop buffering. // Save it and schedule the state machine. Push(video, MediaData::VIDEO_DATA); ScheduleStateMachine(); return; } @@ -2443,26 +2447,21 @@ MediaDecoderStateMachine::Reset() mPlaybackOffset = 0; nsCOMPtr<nsIRunnable> resetTask = NS_NewRunnableMethod(mReader, &MediaDecoderReader::ResetDecode); DecodeTaskQueue()->Dispatch(resetTask.forget()); } -bool MediaDecoderStateMachine::CheckFrameValidity(VideoData* aData) +void +MediaDecoderStateMachine::CheckFrameValidity(VideoData* aData) { MOZ_ASSERT(OnTaskQueue()); - // If we've sent this frame before then only return the valid state, - // don't update the statistics. - if (aData->mSentToCompositor) { - return !aData->mImage || aData->mImage->IsValid(); - } - // Update corrupt-frames statistics if (aData->mImage && !aData->mImage->IsValid()) { FrameStatistics& frameStats = mDecoder->GetFrameStatistics(); frameStats.NotifyCorruptFrame(); // If more than 10% of the last 30 frames have been corrupted, then try disabling // hardware acceleration. We use 10 as the corrupt value because RollingMean<> // only supports integer types. mCorruptFrames.insert(10); @@ -2470,20 +2469,18 @@ bool MediaDecoderStateMachine::CheckFram frameStats.GetPresentedFrames() > 60 && mCorruptFrames.mean() >= 2 /* 20% */) { nsCOMPtr<nsIRunnable> task = NS_NewRunnableMethod(mReader, &MediaDecoderReader::DisableHardwareAcceleration); DecodeTaskQueue()->Dispatch(task.forget()); mCorruptFrames.clear(); gfxCriticalNote << "Too many dropped/corrupted frames, disabling DXVA"; } - return false; } else { mCorruptFrames.insert(0); - return true; } } void MediaDecoderStateMachine::RenderVideoFrames(int32_t aMaxFrames, int64_t aClockTime, const TimeStamp& aClockTimeStamp) { MOZ_ASSERT(OnTaskQueue()); @@ -2495,17 +2492,17 @@ void MediaDecoderStateMachine::RenderVid return; } nsAutoTArray<ImageContainer::NonOwningImage,16> images; TimeStamp lastFrameTime; for (uint32_t i = 0; i < frames.Length(); ++i) { VideoData* frame = frames[i]->As<VideoData>(); - bool valid = CheckFrameValidity(frame); + bool valid = !frame->mImage || frame->mImage->IsValid(); frame->mSentToCompositor = true; if (!valid) { continue; } int64_t frameTime = frame->mTime; if (frameTime < 0) {
--- a/dom/media/MediaDecoderStateMachine.h +++ b/dom/media/MediaDecoderStateMachine.h @@ -458,18 +458,19 @@ protected: void SetStartTime(int64_t aStartTimeUsecs); // Update only the state machine's current playback position (and duration, // if unknown). Does not update the playback position on the decoder or // media element -- use UpdatePlaybackPosition for that. Called on the state // machine thread, caller must hold the decoder lock. void UpdatePlaybackPositionInternal(int64_t aTime); - // Decode monitor must be held. - bool CheckFrameValidity(VideoData* aData); + // Decode monitor must be held. To determine if MDSM needs to turn off HW + // acceleration. + void CheckFrameValidity(VideoData* aData); // Sets VideoQueue images into the VideoFrameContainer. Called on the shared // state machine thread. Decode monitor must be held. The first aMaxFrames // (at most) are set. // aClockTime and aClockTimeStamp are used as the baseline for deriving // timestamps for the frames; when omitted, aMaxFrames must be 1 and // a null timestamp is passed to the VideoFrameContainer. // If the VideoQueue is empty, this does nothing.