BalancedDegradationSettings: add option to configure a min framerate diff.
If a framerate reduction (input fps - restricted fps) is less than the configured diff, shorten interval to next qp check. Bug: none Change-Id: Ia0b9e0638e5ba75cdc20a1bb45bfcb7d858c5f89 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/149040 Commit-Queue: Åsa Persson <asapersson@webrtc.org> Reviewed-by: Magnus Flodman <mflodman@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28880}
This commit is contained in:
@ -96,7 +96,8 @@ QualityScaler::QualityScaler(rtc::TaskQueue* task_queue,
|
||||
.value_or(kSamplePeriodScaleFactor)),
|
||||
scale_factor_(
|
||||
QualityScalerSettings::ParseFromFieldTrials().ScaleFactor()),
|
||||
last_adapted_(false) {
|
||||
adapt_called_(false),
|
||||
adapt_failed_(false) {
|
||||
RTC_DCHECK_RUN_ON(&task_checker_);
|
||||
if (experiment_enabled_) {
|
||||
config_ = QualityScalingExperiment::GetConfig();
|
||||
@ -127,8 +128,12 @@ int64_t QualityScaler::GetSamplingPeriodMs() const {
|
||||
// Use half the interval while waiting for enough frames.
|
||||
return sampling_period_ms_ / 2;
|
||||
}
|
||||
if (scale_factor_ && !last_adapted_) {
|
||||
// Last check did not result in a AdaptDown/Up, possibly reduce interval.
|
||||
if (adapt_failed_) {
|
||||
// Check shortly again.
|
||||
return sampling_period_ms_ / 8;
|
||||
}
|
||||
if (scale_factor_ && !adapt_called_) {
|
||||
// Last CheckQp did not call AdaptDown/Up, possibly reduce interval.
|
||||
return sampling_period_ms_ * scale_factor_.value();
|
||||
}
|
||||
return sampling_period_ms_ * initial_scale_factor_;
|
||||
@ -165,7 +170,8 @@ 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;
|
||||
adapt_failed_ = false;
|
||||
adapt_called_ = false;
|
||||
|
||||
// If we have not observed at least this many frames we can't make a good
|
||||
// scaling decision.
|
||||
@ -215,18 +221,24 @@ void QualityScaler::ReportQpLow() {
|
||||
RTC_DCHECK_RUN_ON(&task_checker_);
|
||||
ClearSamples();
|
||||
observer_->AdaptUp(AdaptationObserverInterface::AdaptReason::kQuality);
|
||||
last_adapted_ = true;
|
||||
adapt_called_ = true;
|
||||
}
|
||||
|
||||
void QualityScaler::ReportQpHigh() {
|
||||
RTC_DCHECK_RUN_ON(&task_checker_);
|
||||
ClearSamples();
|
||||
observer_->AdaptDown(AdaptationObserverInterface::AdaptReason::kQuality);
|
||||
|
||||
if (observer_->AdaptDown(
|
||||
AdaptationObserverInterface::AdaptReason::kQuality)) {
|
||||
ClearSamples();
|
||||
} else {
|
||||
adapt_failed_ = true;
|
||||
}
|
||||
|
||||
// If we've scaled down, wait longer before scaling up again.
|
||||
if (fast_rampup_) {
|
||||
fast_rampup_ = false;
|
||||
}
|
||||
last_adapted_ = true;
|
||||
adapt_called_ = true;
|
||||
}
|
||||
|
||||
void QualityScaler::ClearSamples() {
|
||||
|
||||
@ -37,7 +37,9 @@ class AdaptationObserverInterface {
|
||||
// Called to signal that we can handle larger or more frequent frames.
|
||||
virtual void AdaptUp(AdaptReason reason) = 0;
|
||||
// Called to signal that the source should reduce the resolution or framerate.
|
||||
virtual void AdaptDown(AdaptReason reason) = 0;
|
||||
// Returns false if a downgrade was requested but the request did not result
|
||||
// in a new limiting resolution or fps.
|
||||
virtual bool AdaptDown(AdaptReason reason) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~AdaptationObserverInterface() {}
|
||||
@ -101,7 +103,8 @@ class QualityScaler {
|
||||
const size_t min_frames_needed_;
|
||||
const double initial_scale_factor_;
|
||||
const absl::optional<double> scale_factor_;
|
||||
bool last_adapted_ RTC_GUARDED_BY(&task_checker_);
|
||||
bool adapt_called_ RTC_GUARDED_BY(&task_checker_);
|
||||
bool adapt_failed_ RTC_GUARDED_BY(&task_checker_);
|
||||
};
|
||||
} // namespace webrtc
|
||||
|
||||
|
||||
@ -36,9 +36,10 @@ class MockAdaptationObserver : public AdaptationObserverInterface {
|
||||
adapt_up_events_++;
|
||||
event.Set();
|
||||
}
|
||||
void AdaptDown(AdaptReason r) override {
|
||||
bool AdaptDown(AdaptReason r) override {
|
||||
adapt_down_events_++;
|
||||
event.Set();
|
||||
return true;
|
||||
}
|
||||
|
||||
rtc::Event event;
|
||||
|
||||
Reference in New Issue
Block a user