Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(581)

Unified Diff: media/filters/video_renderer_algorithm.cc

Issue 1153433003: Merge to M44: "Drop frames less than a millisecond apart in media time." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2403
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | media/filters/video_renderer_algorithm_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/video_renderer_algorithm.cc
diff --git a/media/filters/video_renderer_algorithm.cc b/media/filters/video_renderer_algorithm.cc
index 8df9e5c90fe91b0b4af65961b26eb16012e4f496..59b6d51be5322e62b1ecc0ba6d127ad5ad513eaf 100644
--- a/media/filters/video_renderer_algorithm.cc
+++ b/media/filters/video_renderer_algorithm.cc
@@ -363,25 +363,30 @@ void VideoRendererAlgorithm::EnqueueFrame(
frame_queue_.end(), frame);
DCHECK_GE(it - frame_queue_.begin(), 0);
- // If a frame was inserted before the first frame, update the index. On the
- // next call to Render() it will be dropped.
+ // Drop any frames inserted before or at the last rendered frame if we've
+ // already rendered any frames.
const size_t new_frame_index = it - frame_queue_.begin();
if (new_frame_index <= last_frame_index_ && have_rendered_frames_) {
- if (new_frame_index == last_frame_index_ &&
- frame->timestamp() ==
- frame_queue_[last_frame_index_].frame->timestamp()) {
- DVLOG(2) << "Ignoring frame with the same timestamp as the most recently "
- "rendered frame.";
- ++frames_dropped_during_enqueue_;
- return;
- }
- ++last_frame_index_;
- } else if (new_frame_index < frame_queue_.size() &&
- frame->timestamp() ==
- frame_queue_[new_frame_index].frame->timestamp()) {
- DVLOG(2) << "Replacing existing frame with the same timestamp with most "
- << "recently received frame.";
- frame_queue_[new_frame_index].frame = frame;
+ DVLOG(2) << "Dropping frame inserted before the last rendered frame.";
+ ++frames_dropped_during_enqueue_;
+ return;
+ }
+
+ // Drop any frames which are less than a millisecond apart in media time (even
+ // those with timestamps matching an already enqueued frame), there's no way
+ // we can reasonably render these frames; it's effectively a 1000fps limit.
+ const base::TimeDelta delta =
+ std::min(new_frame_index < frame_queue_.size()
+ ? frame_queue_[new_frame_index].frame->timestamp() -
+ frame->timestamp()
+ : base::TimeDelta::Max(),
+ new_frame_index > 0
+ ? frame->timestamp() -
+ frame_queue_[new_frame_index - 1].frame->timestamp()
+ : base::TimeDelta::Max());
+ if (delta < base::TimeDelta::FromMilliseconds(1)) {
+ DVLOG(2) << "Dropping frame too close to an already enqueued frame: "
+ << delta.InMicroseconds() << " us";
++frames_dropped_during_enqueue_;
return;
}
« no previous file with comments | « no previous file | media/filters/video_renderer_algorithm_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698