// Copyright 2019 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "media/base/frame_rate_estimator.h" #include <array> namespace media { // Number of samples we need before we'll trust the estimate. All samples must // end up in the same bucket, else we won't report an FPS for the window. // kMaxSamples is the maximum that we'll need, if we think that things are // unstable. kMinSamples is the minimum that we'll need to establish a // baseline fps optimistically. static constexpr int kMaxSamples = …; static constexpr int kMinSamples = …; // Size (in FPS) of our buckets, which take on integral multiples of // |BucketSize|. Observed frame rates are rounded to the nearest bucket, so // that 1.75 and 1.25 might both end up in bucket 2. static constexpr int BucketSize = …; namespace { // Convert |duration| into an FPS bucket. int ToBucket(base::TimeDelta duration) { … } } // namespace FrameRateEstimator::FrameRateEstimator() : … { … } FrameRateEstimator::~FrameRateEstimator() = default; void FrameRateEstimator::AddSample(base::TimeDelta frame_duration) { … } std::optional<int> FrameRateEstimator::ComputeFPS() { … } void FrameRateEstimator::Reset() { … } int FrameRateEstimator::GetRequiredSamplesForTesting() const { … } int FrameRateEstimator::GetMinSamplesForTesting() const { … } int FrameRateEstimator::GetMaxSamplesForTesting() const { … } } // namespace media