| Index: media/filters/video_cadence_estimator.cc
|
| diff --git a/media/filters/video_cadence_estimator.cc b/media/filters/video_cadence_estimator.cc
|
| index 8804bf2d63a92edac0379b9ad6e6f697f2ea165c..ac2beb133ee3120790db99d753297f8a7d6b3bb6 100644
|
| --- a/media/filters/video_cadence_estimator.cc
|
| +++ b/media/filters/video_cadence_estimator.cc
|
| @@ -18,6 +18,15 @@ namespace media {
|
| // require some time to elapse before a cadence switch is accepted.
|
| const int kMinimumCadenceDurationMs = 100;
|
|
|
| +// The numbers are used to decide whether the current video is variable FPS or
|
| +// constant FPS. If ratio of the sample deviation and the render length is
|
| +// above |kVariableFPSFactor|, then it is recognized as a variable FPS, and if
|
| +// the ratio is below |kConstantFPSFactor|, then it is recognized as a constant
|
| +// FPS, and if the ratio is in between the two factors, then we do not change
|
| +// previous recognition.
|
| +const double kVariableFPSFactor = 0.55;
|
| +const double kConstantFPSFactor = 0.45;
|
| +
|
| // Records the number of cadence changes to UMA.
|
| static void HistogramCadenceChangeCount(int cadence_changes) {
|
| const int kCadenceChangeMax = 10;
|
| @@ -66,7 +75,8 @@ VideoCadenceEstimator::VideoCadenceEstimator(
|
| base::TimeDelta minimum_time_until_max_drift)
|
| : cadence_hysteresis_threshold_(
|
| base::TimeDelta::FromMilliseconds(kMinimumCadenceDurationMs)),
|
| - minimum_time_until_max_drift_(minimum_time_until_max_drift) {
|
| + minimum_time_until_max_drift_(minimum_time_until_max_drift),
|
| + is_variable_frame_rate_(false) {
|
| Reset();
|
| }
|
|
|
| @@ -83,10 +93,27 @@ void VideoCadenceEstimator::Reset() {
|
| bool VideoCadenceEstimator::UpdateCadenceEstimate(
|
| base::TimeDelta render_interval,
|
| base::TimeDelta frame_duration,
|
| + base::TimeDelta frame_duration_deviation,
|
| base::TimeDelta max_acceptable_drift) {
|
| DCHECK_GT(render_interval, base::TimeDelta());
|
| DCHECK_GT(frame_duration, base::TimeDelta());
|
|
|
| + if (frame_duration_deviation > kVariableFPSFactor * render_interval) {
|
| + is_variable_frame_rate_ = true;
|
| + } else if (frame_duration_deviation < kConstantFPSFactor * render_interval) {
|
| + is_variable_frame_rate_ = false;
|
| + }
|
| +
|
| + // Variable FPS detected, turn off Cadence by force.
|
| + if (is_variable_frame_rate_) {
|
| + render_intervals_cadence_held_ = 0;
|
| + if (!cadence_.empty()) {
|
| + cadence_.clear();
|
| + return true;
|
| + }
|
| + return false;
|
| + }
|
| +
|
| base::TimeDelta time_until_max_drift;
|
|
|
| // See if we can find a cadence which fits the data.
|
|
|