mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1128380: Make AmpleVideoFrames calculation dynamic. r=cpearce
This commit is contained in:
parent
89608a65b8
commit
93b341ddf5
@ -256,6 +256,10 @@ public:
|
||||
// the newer async model.
|
||||
virtual bool IsAsync() const { return false; }
|
||||
|
||||
// Returns true if this decoder reader uses hardware accelerated video
|
||||
// decoding.
|
||||
virtual bool VideoIsHardwareAccelerated() const { return false; }
|
||||
|
||||
protected:
|
||||
virtual ~MediaDecoderReader();
|
||||
|
||||
|
@ -220,7 +220,6 @@ MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder,
|
||||
mVolume(1.0),
|
||||
mPlaybackRate(1.0),
|
||||
mPreservesPitch(true),
|
||||
mAmpleVideoFrames(MIN_VIDEO_QUEUE_SIZE),
|
||||
mLowAudioThresholdUsecs(detail::LOW_AUDIO_USECS),
|
||||
mAmpleAudioThresholdUsecs(detail::AMPLE_AUDIO_USECS),
|
||||
mQuickBufferingLowDataThresholdUsecs(detail::QUICK_BUFFERING_LOW_DATA_USECS),
|
||||
@ -579,7 +578,7 @@ bool MediaDecoderStateMachine::HaveEnoughDecodedVideo()
|
||||
{
|
||||
AssertCurrentThreadInMonitor();
|
||||
|
||||
if (static_cast<uint32_t>(VideoQueue().GetSize()) < mAmpleVideoFrames * mPlaybackRate) {
|
||||
if (static_cast<uint32_t>(VideoQueue().GetSize()) < GetAmpleVideoFrames() * mPlaybackRate) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2241,13 +2240,10 @@ nsresult MediaDecoderStateMachine::DecodeMetadata()
|
||||
mInfo = info;
|
||||
|
||||
if (HasVideo()) {
|
||||
mAmpleVideoFrames = (mReader->IsAsync() && mInfo.mVideo.mIsHardwareAccelerated)
|
||||
? std::max<uint32_t>(sVideoQueueHWAccelSize, MIN_VIDEO_QUEUE_SIZE)
|
||||
: std::max<uint32_t>(sVideoQueueDefaultSize, MIN_VIDEO_QUEUE_SIZE);
|
||||
DECODER_LOG("Video decode isAsync=%d HWAccel=%d videoQueueSize=%d",
|
||||
mReader->IsAsync(),
|
||||
mInfo.mVideo.mIsHardwareAccelerated,
|
||||
mAmpleVideoFrames);
|
||||
mReader->VideoIsHardwareAccelerated(),
|
||||
GetAmpleVideoFrames());
|
||||
}
|
||||
|
||||
mDecoder->StartProgressUpdates();
|
||||
@ -3516,6 +3512,14 @@ void MediaDecoderStateMachine::OnAudioSinkError()
|
||||
DecodeError();
|
||||
}
|
||||
|
||||
uint32_t MediaDecoderStateMachine::GetAmpleVideoFrames() const
|
||||
{
|
||||
AssertCurrentThreadInMonitor();
|
||||
return (mReader->IsAsync() && mReader->VideoIsHardwareAccelerated())
|
||||
? std::max<uint32_t>(sVideoQueueHWAccelSize, MIN_VIDEO_QUEUE_SIZE)
|
||||
: std::max<uint32_t>(sVideoQueueDefaultSize, MIN_VIDEO_QUEUE_SIZE);
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
// avoid redefined macro in unified build
|
||||
|
@ -919,10 +919,11 @@ protected:
|
||||
uint32_t mBufferingWait;
|
||||
int64_t mLowDataThresholdUsecs;
|
||||
|
||||
// If we've got more than mAmpleVideoFrames decoded video frames waiting in
|
||||
// If we've got more than this number of decoded video frames waiting in
|
||||
// the video queue, we will not decode any more video frames until some have
|
||||
// been consumed by the play state machine thread.
|
||||
uint32_t mAmpleVideoFrames;
|
||||
// Must hold monitor.
|
||||
uint32_t GetAmpleVideoFrames() const;
|
||||
|
||||
// Low audio threshold. If we've decoded less than this much audio we
|
||||
// consider our audio decode "behind", and we may skip video decoding
|
||||
@ -961,7 +962,11 @@ protected:
|
||||
MOZ_ASSERT(result <= mAmpleAudioThresholdUsecs, "Prerolling will never finish");
|
||||
return result;
|
||||
}
|
||||
uint32_t VideoPrerollFrames() const { return mScheduler->IsRealTime() ? 0 : mAmpleVideoFrames / 2; }
|
||||
|
||||
uint32_t VideoPrerollFrames() const
|
||||
{
|
||||
return mScheduler->IsRealTime() ? 0 : GetAmpleVideoFrames() / 2;
|
||||
}
|
||||
|
||||
bool DonePrerollingAudio()
|
||||
{
|
||||
|
@ -46,7 +46,6 @@ private:
|
||||
mDisplay = nsIntSize(aWidth, aHeight);
|
||||
mStereoMode = StereoMode::MONO;
|
||||
mHasVideo = aHasVideo;
|
||||
mIsHardwareAccelerated = false;
|
||||
|
||||
// TODO: TrackInfo should be initialized by its specific codec decoder.
|
||||
// This following call should be removed once we have that implemented.
|
||||
@ -76,8 +75,6 @@ public:
|
||||
bool mHasVideo;
|
||||
|
||||
TrackInfo mTrackInfo;
|
||||
|
||||
bool mIsHardwareAccelerated;
|
||||
};
|
||||
|
||||
class AudioInfo {
|
||||
|
@ -497,7 +497,6 @@ MP4Reader::ReadMetadata(MediaInfo* aInfo,
|
||||
NS_ENSURE_TRUE(mVideo.mDecoder != nullptr, NS_ERROR_FAILURE);
|
||||
nsresult rv = mVideo.mDecoder->Init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mInfo.mVideo.mIsHardwareAccelerated = mVideo.mDecoder->IsHardwareAccelerated();
|
||||
|
||||
// Collect telemetry from h264 AVCC SPS.
|
||||
if (!mFoundSPSForTelemetry) {
|
||||
@ -1100,4 +1099,10 @@ MP4Reader::SetSharedDecoderManager(SharedDecoderManager* aManager)
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
MP4Reader::VideoIsHardwareAccelerated() const
|
||||
{
|
||||
return mVideo.mDecoder && mVideo.mDecoder->IsHardwareAccelerated();
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -82,6 +82,8 @@ public:
|
||||
|
||||
virtual bool IsAsync() const MOZ_OVERRIDE { return true; }
|
||||
|
||||
virtual bool VideoIsHardwareAccelerated() const MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
bool InitDemuxer();
|
||||
|
@ -142,10 +142,16 @@ public:
|
||||
#endif
|
||||
|
||||
virtual bool IsAsync() const MOZ_OVERRIDE {
|
||||
ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
|
||||
return (!GetAudioReader() || GetAudioReader()->IsAsync()) &&
|
||||
(!GetVideoReader() || GetVideoReader()->IsAsync());
|
||||
}
|
||||
|
||||
virtual bool VideoIsHardwareAccelerated() const MOZ_OVERRIDE {
|
||||
ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
|
||||
return GetVideoReader() && GetVideoReader()->VideoIsHardwareAccelerated();
|
||||
}
|
||||
|
||||
// Returns true if aReader is a currently active audio or video
|
||||
bool IsActiveReader(MediaDecoderReader* aReader);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user