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

Side by Side Diff: media/filters/video_renderer_algorithm.cc

Issue 2502093002: Adjust VideoRendererAlgorithm for |frame_dropping_disabled_| (Closed)
Patch Set: Style fixes, new unit test Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/filters/video_renderer_algorithm.h" 5 #include "media/filters/video_renderer_algorithm.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 namespace media { 10 namespace media {
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 return base::TimeDelta(); 678 return base::TimeDelta();
679 } 679 }
680 680
681 void VideoRendererAlgorithm::UpdateEffectiveFramesQueued() { 681 void VideoRendererAlgorithm::UpdateEffectiveFramesQueued() {
682 if (frame_queue_.empty() || average_frame_duration_.is_zero() || 682 if (frame_queue_.empty() || average_frame_duration_.is_zero() ||
683 last_deadline_max_.is_null()) { 683 last_deadline_max_.is_null()) {
684 effective_frames_queued_ = frame_queue_.size(); 684 effective_frames_queued_ = frame_queue_.size();
685 return; 685 return;
686 } 686 }
687 687
688 // Determine the lower bound of the number of effective queues first.
689 // Normally, this is 0.
690 size_t min_frames_queued = 0;
691
692 // If frame dropping is disabled, the lower bound is the number of frames
693 // that were not rendered yet.
694 if (frame_dropping_disabled_) {
695 min_frames_queued = std::count_if(
696 frame_queue_.cbegin(), frame_queue_.cend(),
697 [](const ReadyFrame& frame) { return frame.render_count == 0; });
698 }
699
700 // Next, see if can report more frames as queued.
701 effective_frames_queued_ =
702 std::max(min_frames_queued, CountEffectiveFramesQueued());
703 }
704
705 size_t VideoRendererAlgorithm::CountEffectiveFramesQueued() const {
688 // If we don't have cadence, subtract off any frames which are before 706 // If we don't have cadence, subtract off any frames which are before
689 // the last rendered frame or are past their expected rendering time. 707 // the last rendered frame or are past their expected rendering time.
690 if (!cadence_estimator_.has_cadence()) { 708 if (!cadence_estimator_.has_cadence()) {
691 size_t expired_frames = 0; 709 size_t expired_frames = 0;
692 for (; expired_frames < frame_queue_.size(); ++expired_frames) { 710 for (; expired_frames < frame_queue_.size(); ++expired_frames) {
693 const ReadyFrame& frame = frame_queue_[expired_frames]; 711 const ReadyFrame& frame = frame_queue_[expired_frames];
694 if (frame.end_time.is_null() || frame.end_time > last_deadline_max_) 712 if (frame.end_time.is_null() || frame.end_time > last_deadline_max_)
695 break; 713 break;
696 } 714 }
697 effective_frames_queued_ = frame_queue_.size() - expired_frames; 715 return frame_queue_.size() - expired_frames;
698 return;
699 } 716 }
700 717
701 // Find the first usable frame to start counting from. 718 // Find the first usable frame to start counting from.
702 const int start_index = FindBestFrameByCadence(nullptr); 719 const int start_index = FindBestFrameByCadence(nullptr);
703 if (start_index < 0) { 720 if (start_index < 0)
704 effective_frames_queued_ = 0; 721 return 0;
705 return;
706 }
707 722
708 const base::TimeTicks minimum_start_time = 723 const base::TimeTicks minimum_start_time =
709 last_deadline_max_ - max_acceptable_drift_; 724 last_deadline_max_ - max_acceptable_drift_;
710 size_t renderable_frame_count = 0; 725 size_t renderable_frame_count = 0;
711 for (size_t i = start_index; i < frame_queue_.size(); ++i) { 726 for (size_t i = start_index; i < frame_queue_.size(); ++i) {
712 const ReadyFrame& frame = frame_queue_[i]; 727 const ReadyFrame& frame = frame_queue_[i];
713 if (frame.render_count < frame.ideal_render_count && 728 if (frame.render_count < frame.ideal_render_count &&
714 (frame.end_time.is_null() || frame.end_time > minimum_start_time)) { 729 (frame.end_time.is_null() || frame.end_time > minimum_start_time)) {
715 ++renderable_frame_count; 730 ++renderable_frame_count;
716 } 731 }
717 } 732 }
718 733 return renderable_frame_count;
719 effective_frames_queued_ = renderable_frame_count;
720 } 734 }
721 735
722 } // namespace media 736 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/video_renderer_algorithm.h ('k') | media/filters/video_renderer_algorithm_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698