| Index: webrtc/video/quality_threshold.cc
|
| diff --git a/webrtc/video/quality_threshold.cc b/webrtc/video/quality_threshold.cc
|
| index 3f2d835e80b2b7e3332cc5501ec214c3ef689a5a..c1d3b101ebc7018926f9eb9189ef93a317190175 100644
|
| --- a/webrtc/video/quality_threshold.cc
|
| +++ b/webrtc/video/quality_threshold.cc
|
| @@ -28,7 +28,9 @@ QualityThreshold::QualityThreshold(int low_threshold,
|
| next_index_(0),
|
| sum_(0),
|
| count_low_(0),
|
| - count_high_(0) {
|
| + count_high_(0),
|
| + num_high_states_(0),
|
| + num_certain_states_(0) {
|
| RTC_CHECK_GT(fraction, 0.5f);
|
| RTC_CHECK_GT(max_measurements, 1);
|
| RTC_CHECK_LT(low_threshold, high_threshold);
|
| @@ -64,6 +66,12 @@ void QualityThreshold::AddMeasurement(int measurement) {
|
|
|
| if (until_full_ > 0)
|
| --until_full_;
|
| +
|
| + if (is_high_) {
|
| + if (*is_high_)
|
| + ++num_high_states_;
|
| + ++num_certain_states_;
|
| + }
|
| }
|
|
|
| rtc::Optional<bool> QualityThreshold::IsHigh() const {
|
| @@ -83,4 +91,14 @@ rtc::Optional<double> QualityThreshold::CalculateVariance() const {
|
| return rtc::Optional<double>(variance / (max_measurements_ - 1));
|
| }
|
|
|
| +rtc::Optional<double> QualityThreshold::FractionHigh(
|
| + int min_required_samples) const {
|
| + RTC_DCHECK_GT(min_required_samples, 0);
|
| + if (num_certain_states_ < min_required_samples)
|
| + return rtc::Optional<double>();
|
| +
|
| + return rtc::Optional<double>(static_cast<double>(num_high_states_) /
|
| + num_certain_states_);
|
| +}
|
| +
|
| } // namespace webrtc
|
|
|