Commit 524be589 authored by Dale Curtis's avatar Dale Curtis Committed by Commit Bot

Make VideoRendererAlgorithm::RemoveExpiredFrames() more aggressive.

There's no need to keep more than 1 frame if none are effective. If any
are effective, there's no reason to keep any of the ones that aren't
effective.

R=eugene

Bug: 1111273
Change-Id: I88bd309f7bc347fbfa84ee5f8a0e40d393a86cc4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2462666
Commit-Queue: Dale Curtis <dalecurtis@chromium.org>
Commit-Queue: Eugene Zemtsov <eugene@chromium.org>
Reviewed-by: default avatarEugene Zemtsov <eugene@chromium.org>
Auto-Submit: Dale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#815901}
parent a2fd175c
...@@ -243,42 +243,32 @@ size_t VideoRendererAlgorithm::RemoveExpiredFrames(base::TimeTicks deadline) { ...@@ -243,42 +243,32 @@ size_t VideoRendererAlgorithm::RemoveExpiredFrames(base::TimeTicks deadline) {
// Even though we may not be able to remove anything due to having only one // Even though we may not be able to remove anything due to having only one
// frame, correct any estimates which may have been set during EnqueueFrame(). // frame, correct any estimates which may have been set during EnqueueFrame().
UpdateFrameStatistics(); UpdateFrameStatistics();
UpdateEffectiveFramesQueued();
// We always leave at least one frame in the queue, so if there's only one // We always leave at least one frame in the queue, so if there's only one
// frame there's nothing we can expire. // frame there's nothing we can expire.
if (frame_queue_.size() == 1) { if (frame_queue_.size() == 1)
UpdateEffectiveFramesQueued();
return 0; return 0;
}
DCHECK_GT(average_frame_duration_, base::TimeDelta()); DCHECK_GT(average_frame_duration_, base::TimeDelta());
// Finds and removes all frames which are too old to be used; I.e., the end of // Finds and removes all frames which are too old to be used.
// their render interval is further than |max_acceptable_drift_| from the
// given |deadline|. We also always expire anything inserted before the last
// rendered frame.
size_t frames_dropped_without_rendering = 0; size_t frames_dropped_without_rendering = 0;
size_t frames_to_expire = 0; size_t frames_to_expire = std::min(
const base::TimeTicks minimum_start_time = frame_queue_.size() - 1, frame_queue_.size() - effective_frames_queued_);
deadline - max_acceptable_drift_ - average_frame_duration_;
for (; frames_to_expire < frame_queue_.size() - 1; ++frames_to_expire) {
const ReadyFrame& frame = frame_queue_[frames_to_expire];
if (frame.start_time >= minimum_start_time)
break;
if (frame.render_count == frame.drop_count)
++frames_dropped_without_rendering;
}
if (!frames_to_expire) { if (!frames_to_expire)
UpdateEffectiveFramesQueued();
return 0; return 0;
for (size_t i = 0; i < frames_to_expire; ++i) {
const ReadyFrame& frame = frame_queue_[i];
if (frame.render_count == frame.drop_count)
++frames_dropped_without_rendering;
} }
cadence_frame_counter_ += frames_to_expire; cadence_frame_counter_ += frames_to_expire;
frame_queue_.erase(frame_queue_.begin(), frame_queue_.erase(frame_queue_.begin(),
frame_queue_.begin() + frames_to_expire); frame_queue_.begin() + frames_to_expire);
UpdateEffectiveFramesQueued();
return frames_dropped_without_rendering; return frames_dropped_without_rendering;
} }
......
...@@ -1245,12 +1245,12 @@ TEST_F(VideoRendererAlgorithmTest, RemoveExpiredFrames) { ...@@ -1245,12 +1245,12 @@ TEST_F(VideoRendererAlgorithmTest, RemoveExpiredFrames) {
tg.step(2); tg.step(2);
// Two frames are removed, one displayed frame (which should not be counted as // Two frames are removed, one displayed frame (which should not be counted as
// dropped) and one undisplayed one. // dropped) and one undisplayed one.
ASSERT_EQ(1u, algorithm_.RemoveExpiredFrames(tg.current())); ASSERT_EQ(2u, algorithm_.RemoveExpiredFrames(tg.current()));
// Since we just removed the last rendered frame, OnLastFrameDropped() should // Since we just removed the last rendered frame, OnLastFrameDropped() should
// be ignored. // be ignored.
algorithm_.OnLastFrameDropped(); algorithm_.OnLastFrameDropped();
frame = RenderAndStep(&tg, &frames_dropped); frame = RenderAndStep(&tg, &frames_dropped);
EXPECT_EQ(1u, frames_dropped); EXPECT_EQ(0u, frames_dropped);
EXPECT_EQ(2u, frames_queued()); EXPECT_EQ(2u, frames_queued());
EXPECT_EQ(1u, EffectiveFramesQueued()); EXPECT_EQ(1u, EffectiveFramesQueued());
ASSERT_TRUE(frame); ASSERT_TRUE(frame);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment