Chromium Code Reviews| Index: media/filters/video_renderer_algorithm.cc |
| diff --git a/media/filters/video_renderer_algorithm.cc b/media/filters/video_renderer_algorithm.cc |
| index 71783cf8ca9d80ba76aa1c1e107dcee03e9a4c0f..5505e844481f34d67f38ebcf25730793bccf4771 100644 |
| --- a/media/filters/video_renderer_algorithm.cc |
| +++ b/media/filters/video_renderer_algorithm.cc |
| @@ -685,6 +685,24 @@ void VideoRendererAlgorithm::UpdateEffectiveFramesQueued() { |
| return; |
| } |
| + // Determine the lower bound of the number of effective queues first. |
| + // Normally, this is 0. |
| + size_t min_frames_queued = 0; |
| + // If frame dropping is disabled, the lower bound is the number of frames |
|
DaleCurtis
2016/11/16 22:03:44
Add line between these.
DaleCurtis
2016/11/16 22:03:44
Add line between these.
wdzierzanowski
2016/11/23 09:54:06
Done.
|
| + // that were not rendered yet. |
| + if (frame_dropping_disabled_) { |
| + min_frames_queued = std::count_if( |
| + frame_queue_.cbegin(), frame_queue_.cend(), |
| + [](const ReadyFrame& frame) { return frame.render_count == 0; }); |
| + } |
| + |
| + // Next, see if can report more frames as queued. |
| + const size_t frames_queued = CountEffectiveFramesQueued(); |
|
DaleCurtis
2016/11/16 22:03:44
Just inline this into the std::max.
wdzierzanowski
2016/11/23 09:54:06
Done.
|
| + |
| + effective_frames_queued_ = std::max(min_frames_queued, frames_queued); |
| +} |
| + |
| +size_t VideoRendererAlgorithm::CountEffectiveFramesQueued() const { |
| // If we don't have cadence, subtract off any frames which are before |
| // the last rendered frame or are past their expected rendering time. |
| if (!cadence_estimator_.has_cadence()) { |
| @@ -694,16 +712,13 @@ void VideoRendererAlgorithm::UpdateEffectiveFramesQueued() { |
| if (frame.end_time.is_null() || frame.end_time > last_deadline_max_) |
| break; |
| } |
| - effective_frames_queued_ = frame_queue_.size() - expired_frames; |
| - return; |
| + return frame_queue_.size() - expired_frames; |
| } |
| // Find the first usable frame to start counting from. |
| const int start_index = FindBestFrameByCadence(nullptr); |
| - if (start_index < 0) { |
| - effective_frames_queued_ = 0; |
| - return; |
| - } |
| + if (start_index < 0) |
| + return 0; |
| const base::TimeTicks minimum_start_time = |
| last_deadline_max_ - max_acceptable_drift_; |
| @@ -715,8 +730,7 @@ void VideoRendererAlgorithm::UpdateEffectiveFramesQueued() { |
| ++renderable_frame_count; |
| } |
| } |
| - |
| - effective_frames_queued_ = renderable_frame_count; |
| + return renderable_frame_count; |
| } |
| } // namespace media |