Add ability to configure quality scaler settings through field trial.

optional<int> min_frames: The minimum number frames to observe to make a
                          scaling decision.
Default: kMinFramesNeededToScale in quality_scaler.cc

optional<double> initial_scale_factor: The sample period scale factor.
Default: kSamplePeriodScaleFactor in quality_scaler.cc

optional<double> scale_factor: Option to use a reduced sampling interval when
                               last check did not result in an adaptation (if
                               unset the initial_scale_factor is used).

Bug: none
Change-Id: I3bb955d1f8d7d7d49bc118361614b5aa59605231
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/135125
Commit-Queue: Åsa Persson <asapersson@webrtc.org>
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27860}
This commit is contained in:
Åsa Persson
2019-05-06 14:17:35 +02:00
committed by Commit Bot
parent cfff652c82
commit 517678cc49
7 changed files with 222 additions and 5 deletions

View File

@ -13,8 +13,8 @@
#include <memory>
#include <utility>
#include "absl/types/optional.h"
#include "rtc_base/checks.h"
#include "rtc_base/experiments/quality_scaler_settings.h"
#include "rtc_base/logging.h"
#include "rtc_base/numerics/exp_filter.h"
#include "rtc_base/task_queue.h"
@ -33,7 +33,7 @@ namespace {
static const int kMeasureMs = 2000;
static const float kSamplePeriodScaleFactor = 2.5;
static const int kFramedropPercentThreshold = 60;
static const int kMinFramesNeededToScale = 2 * 30;
static const size_t kMinFramesNeededToScale = 2 * 30;
} // namespace
@ -87,7 +87,16 @@ QualityScaler::QualityScaler(rtc::TaskQueue* task_queue,
framedrop_percent_media_opt_(5 * 30),
framedrop_percent_all_(5 * 30),
experiment_enabled_(QualityScalingExperiment::Enabled()),
observed_enough_frames_(false) {
observed_enough_frames_(false),
min_frames_needed_(
QualityScalerSettings::ParseFromFieldTrials().MinFrames().value_or(
kMinFramesNeededToScale)),
initial_scale_factor_(QualityScalerSettings::ParseFromFieldTrials()
.InitialScaleFactor()
.value_or(kSamplePeriodScaleFactor)),
scale_factor_(
QualityScalerSettings::ParseFromFieldTrials().ScaleFactor()),
last_adapted_(false) {
RTC_DCHECK_RUN_ON(&task_checker_);
if (experiment_enabled_) {
config_ = QualityScalingExperiment::GetConfig();
@ -118,7 +127,11 @@ int64_t QualityScaler::GetSamplingPeriodMs() const {
// Use half the interval while waiting for enough frames.
return sampling_period_ms_ / 2;
}
return sampling_period_ms_ * kSamplePeriodScaleFactor;
if (scale_factor_ && !last_adapted_) {
// Last check did not result in a AdaptDown/Up, possibly reduce interval.
return sampling_period_ms_ * scale_factor_.value();
}
return sampling_period_ms_ * initial_scale_factor_;
}
void QualityScaler::ReportDroppedFrameByMediaOpt() {
@ -147,13 +160,14 @@ void QualityScaler::CheckQp() {
RTC_DCHECK_RUN_ON(&task_checker_);
// Should be set through InitEncode -> Should be set by now.
RTC_DCHECK_GE(thresholds_.low, 0);
last_adapted_ = false;
// If we have not observed at least this many frames we can't make a good
// scaling decision.
const size_t frames = config_.use_all_drop_reasons
? framedrop_percent_all_.Size()
: framedrop_percent_media_opt_.Size();
if (frames < kMinFramesNeededToScale) {
if (frames < min_frames_needed_) {
observed_enough_frames_ = false;
return;
}
@ -196,6 +210,7 @@ void QualityScaler::ReportQpLow() {
RTC_DCHECK_RUN_ON(&task_checker_);
ClearSamples();
observer_->AdaptUp(AdaptationObserverInterface::AdaptReason::kQuality);
last_adapted_ = true;
}
void QualityScaler::ReportQpHigh() {
@ -206,6 +221,7 @@ void QualityScaler::ReportQpHigh() {
if (fast_rampup_) {
fast_rampup_ = false;
}
last_adapted_ = true;
}
void QualityScaler::ClearSamples() {