Bug 1692881 - part2 : keep decoded video has at least same amount of duration as decoded audio data. r=bryce

MDSM will stop decoding video when it reaches the certain amount of frames, but that will not work well if the video decoding is way too slow than the audio decoding.

In that situation, video should keep decoding as much as possible, in order to catch up with the audio decoding.

But we also don't need to decode video without any constraint, set the duration of decoded video to at least as the same as the decoded audio seems fair and enough.

Differential Revision: https://phabricator.services.mozilla.com/D117243
This commit is contained in:
alwu 2021-06-14 22:31:51 +00:00
Родитель a342363d48
Коммит 97b2a661fb
1 изменённых файлов: 12 добавлений и 1 удалений

Просмотреть файл

@ -2895,7 +2895,18 @@ bool MediaDecoderStateMachine::HaveEnoughDecodedAudio() {
bool MediaDecoderStateMachine::HaveEnoughDecodedVideo() {
MOZ_ASSERT(OnTaskQueue());
return VideoQueue().GetSize() >= GetAmpleVideoFrames() * mPlaybackRate + 1;
// If the media has audio, then we should also consider audio decoding speed.
// Typically, video decoding is slower than audio decoding. In extreme
// situations (e.g. 4k+ video without hardware acceleration), the video
// decoding will be much slower than audio. In order to reduce frame drops,
// this check tries to keep the decoded video buffered as much as audio.
bool isVideoEnoughComparedWithAudio = true;
if (HasAudio()) {
isVideoEnoughComparedWithAudio =
VideoQueue().Duration() >= AudioQueue().Duration();
}
return VideoQueue().GetSize() >= GetAmpleVideoFrames() * mPlaybackRate + 1 &&
isVideoEnoughComparedWithAudio;
}
void MediaDecoderStateMachine::PushAudio(AudioData* aSample) {