Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

322 lines
11 KiB
C++
Raw Normal View History

/*
* Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "modules/video_coding/utility/quality_scaler.h"
#include <memory>
#include <utility>
#include "api/field_trials_view.h"
#include "api/units/time_delta.h"
#include "api/video/video_adaptation_reason.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"
Asynchronous QualityScaler: Callback-based CheckQpTask. This CL breaks up the CheckQp() operation into several steps managed by the inner helper class CheckQpTask, making responding to high or low QP an asynchronous operation. Why? Reconfiguring the stream in response to QP overuse will in the future be handled on a separate task queue. See Call-Level Adaptation Processing for more details: https://docs.google.com/document/d/1ZyC26yOCknrrcYa839ZWLxD6o6Gig5A3lVTh4E41074/edit?usp=sharing Instead of "bool AdaptDown()" when high QP is reported, synchronously returning true or false depending on the result of adaptation, this CL introduces void QualityScalerQpUsageHandlerInterface::OnReportQpUsageHigh( rtc::scoped_refptr<QualityScalerQpUsageHandlerCallback>); Where QualityScalerQpUsageHandlerCallback::OnQpUsageHandled( bool clear_qp_samples); Instructs the QualityScaler whether to clear samples before checking QP the next time or to increase the frequency of checking (corresponding to AdaptDown's return value prior to this CL). QualityScaler no longer using AdaptationObserverInterface, this class is renamed and moved to overuse_frame_detector.h. The dependency between CheckQpTasks is made explicit with CheckQpTask::Result and variables like observed_enough_frames_, adapt_called_ and adapt_failed_ are moved there and given more descriptive names. Bug: webrtc:11521 Change-Id: I7faf795aeee5ded18ce75eb1617f88226e337228 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173760 Reviewed-by: Evan Shrubsole <eshr@google.com> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31140}
2020-04-27 17:40:55 +02:00
#include "rtc_base/weak_ptr.h"
namespace webrtc {
namespace {
Reland of Make QualityScaler more responsive to downgrades. (patchset #1 id:1 of https://codereview.webrtc.org/1880103002/ ) Reason for revert: Regressed behavior is actually desirable (go down to 360p instead of producing super-bad 720p). Original issue's description: > Revert of Make QualityScaler more responsive to downgrades. (patchset #3 id:40001 of https://codereview.webrtc.org/1830593003/ ) > > Reason for revert: > Speculative revert: want to see if this causes the regression in https://crbug.com/602621 > > Original issue's description: > > Make QualityScaler more responsive to downgrades. > > > > Permits going from HD to QVGA in 6 seconds instead of 10. Also adds > > windows for going up quickly in the beginning of a call (before any > > downscaling happens due to bad quality). > > > > BUG=webrtc:5678 > > R=glaznev@webrtc.org, stefan@webrtc.org > > > > Committed: https://crrev.com/85829fd90cc4e7a91c9857921b19e8fc126aeb60 > > Cr-Commit-Position: refs/heads/master@{#12219} > > TBR=glaznev@webrtc.org,stefan@webrtc.org,pbos@webrtc.org > # Not skipping CQ checks because original CL landed more than 1 days ago. > BUG=webrtc:5678 > NOTRY=true > > Committed: https://crrev.com/19b4fecf08e3fe215e431a260fb673553c15e569 > Cr-Commit-Position: refs/heads/master@{#12331} TBR=glaznev@webrtc.org,stefan@webrtc.org,phoglund@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=chromium:602621, webrtc:5678 Review URL: https://codereview.webrtc.org/1887493003 Cr-Commit-Position: refs/heads/master@{#12341}
2016-04-13 02:51:02 -07:00
// Threshold constant used until first downscale (to permit fast rampup).
static const int kMeasureMs = 2000;
static const float kSamplePeriodScaleFactor = 2.5;
static const int kFramedropPercentThreshold = 60;
static const size_t kMinFramesNeededToScale = 2 * 30;
} // namespace
class QualityScaler::QpSmoother {
public:
explicit QpSmoother(float alpha)
: alpha_(alpha),
// The initial value of last_sample_ms doesn't matter since the smoother
// will ignore the time delta for the first update.
last_sample_ms_(0),
smoother_(alpha) {}
std::optional<int> GetAvg() const {
float value = smoother_.filtered();
if (value == rtc::ExpFilter::kValueUndefined) {
return std::nullopt;
}
return static_cast<int>(value);
}
void Add(float sample, int64_t time_sent_us) {
int64_t now_ms = time_sent_us / 1000;
smoother_.Apply(static_cast<float>(now_ms - last_sample_ms_), sample);
last_sample_ms_ = now_ms;
}
void Reset() { smoother_.Reset(alpha_); }
private:
const float alpha_;
int64_t last_sample_ms_;
rtc::ExpFilter smoother_;
};
Asynchronous QualityScaler: Callback-based CheckQpTask. This CL breaks up the CheckQp() operation into several steps managed by the inner helper class CheckQpTask, making responding to high or low QP an asynchronous operation. Why? Reconfiguring the stream in response to QP overuse will in the future be handled on a separate task queue. See Call-Level Adaptation Processing for more details: https://docs.google.com/document/d/1ZyC26yOCknrrcYa839ZWLxD6o6Gig5A3lVTh4E41074/edit?usp=sharing Instead of "bool AdaptDown()" when high QP is reported, synchronously returning true or false depending on the result of adaptation, this CL introduces void QualityScalerQpUsageHandlerInterface::OnReportQpUsageHigh( rtc::scoped_refptr<QualityScalerQpUsageHandlerCallback>); Where QualityScalerQpUsageHandlerCallback::OnQpUsageHandled( bool clear_qp_samples); Instructs the QualityScaler whether to clear samples before checking QP the next time or to increase the frequency of checking (corresponding to AdaptDown's return value prior to this CL). QualityScaler no longer using AdaptationObserverInterface, this class is renamed and moved to overuse_frame_detector.h. The dependency between CheckQpTasks is made explicit with CheckQpTask::Result and variables like observed_enough_frames_, adapt_called_ and adapt_failed_ are moved there and given more descriptive names. Bug: webrtc:11521 Change-Id: I7faf795aeee5ded18ce75eb1617f88226e337228 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173760 Reviewed-by: Evan Shrubsole <eshr@google.com> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31140}
2020-04-27 17:40:55 +02:00
// The QualityScaler checks for QP periodically by queuing CheckQpTasks. The
// task will either run to completion and trigger a new task being queued, or it
// will be destroyed because the QualityScaler is destroyed.
//
// When high or low QP is reported, the task will be pending until a callback is
// invoked. This lets the QualityScalerQpUsageHandlerInterface react to QP usage
// asynchronously and prevents checking for QP until the stream has potentially
// been reconfigured.
class QualityScaler::CheckQpTask {
public:
// The result of one CheckQpTask may influence the delay of the next
// CheckQpTask.
struct Result {
bool observed_enough_frames = false;
bool qp_usage_reported = false;
};
CheckQpTask(QualityScaler* quality_scaler, Result previous_task_result)
: quality_scaler_(quality_scaler),
state_(State::kNotStarted),
previous_task_result_(previous_task_result),
weak_ptr_factory_(this) {}
void StartDelayedTask() {
RTC_DCHECK_EQ(state_, State::kNotStarted);
state_ = State::kCheckingQp;
TaskQueueBase::Current()->PostDelayedTask(
[this_weak_ptr = weak_ptr_factory_.GetWeakPtr(), this] {
Asynchronous QualityScaler: Callback-based CheckQpTask. This CL breaks up the CheckQp() operation into several steps managed by the inner helper class CheckQpTask, making responding to high or low QP an asynchronous operation. Why? Reconfiguring the stream in response to QP overuse will in the future be handled on a separate task queue. See Call-Level Adaptation Processing for more details: https://docs.google.com/document/d/1ZyC26yOCknrrcYa839ZWLxD6o6Gig5A3lVTh4E41074/edit?usp=sharing Instead of "bool AdaptDown()" when high QP is reported, synchronously returning true or false depending on the result of adaptation, this CL introduces void QualityScalerQpUsageHandlerInterface::OnReportQpUsageHigh( rtc::scoped_refptr<QualityScalerQpUsageHandlerCallback>); Where QualityScalerQpUsageHandlerCallback::OnQpUsageHandled( bool clear_qp_samples); Instructs the QualityScaler whether to clear samples before checking QP the next time or to increase the frequency of checking (corresponding to AdaptDown's return value prior to this CL). QualityScaler no longer using AdaptationObserverInterface, this class is renamed and moved to overuse_frame_detector.h. The dependency between CheckQpTasks is made explicit with CheckQpTask::Result and variables like observed_enough_frames_, adapt_called_ and adapt_failed_ are moved there and given more descriptive names. Bug: webrtc:11521 Change-Id: I7faf795aeee5ded18ce75eb1617f88226e337228 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173760 Reviewed-by: Evan Shrubsole <eshr@google.com> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31140}
2020-04-27 17:40:55 +02:00
if (!this_weak_ptr) {
// The task has been cancelled through destruction.
return;
}
RTC_DCHECK_EQ(state_, State::kCheckingQp);
RTC_DCHECK_RUN_ON(&quality_scaler_->task_checker_);
switch (quality_scaler_->CheckQp()) {
case QualityScaler::CheckQpResult::kInsufficientSamples: {
result_.observed_enough_frames = false;
// After this line, `this` may be deleted.
break;
Asynchronous QualityScaler: Callback-based CheckQpTask. This CL breaks up the CheckQp() operation into several steps managed by the inner helper class CheckQpTask, making responding to high or low QP an asynchronous operation. Why? Reconfiguring the stream in response to QP overuse will in the future be handled on a separate task queue. See Call-Level Adaptation Processing for more details: https://docs.google.com/document/d/1ZyC26yOCknrrcYa839ZWLxD6o6Gig5A3lVTh4E41074/edit?usp=sharing Instead of "bool AdaptDown()" when high QP is reported, synchronously returning true or false depending on the result of adaptation, this CL introduces void QualityScalerQpUsageHandlerInterface::OnReportQpUsageHigh( rtc::scoped_refptr<QualityScalerQpUsageHandlerCallback>); Where QualityScalerQpUsageHandlerCallback::OnQpUsageHandled( bool clear_qp_samples); Instructs the QualityScaler whether to clear samples before checking QP the next time or to increase the frequency of checking (corresponding to AdaptDown's return value prior to this CL). QualityScaler no longer using AdaptationObserverInterface, this class is renamed and moved to overuse_frame_detector.h. The dependency between CheckQpTasks is made explicit with CheckQpTask::Result and variables like observed_enough_frames_, adapt_called_ and adapt_failed_ are moved there and given more descriptive names. Bug: webrtc:11521 Change-Id: I7faf795aeee5ded18ce75eb1617f88226e337228 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173760 Reviewed-by: Evan Shrubsole <eshr@google.com> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31140}
2020-04-27 17:40:55 +02:00
}
case QualityScaler::CheckQpResult::kNormalQp: {
result_.observed_enough_frames = true;
break;
Asynchronous QualityScaler: Callback-based CheckQpTask. This CL breaks up the CheckQp() operation into several steps managed by the inner helper class CheckQpTask, making responding to high or low QP an asynchronous operation. Why? Reconfiguring the stream in response to QP overuse will in the future be handled on a separate task queue. See Call-Level Adaptation Processing for more details: https://docs.google.com/document/d/1ZyC26yOCknrrcYa839ZWLxD6o6Gig5A3lVTh4E41074/edit?usp=sharing Instead of "bool AdaptDown()" when high QP is reported, synchronously returning true or false depending on the result of adaptation, this CL introduces void QualityScalerQpUsageHandlerInterface::OnReportQpUsageHigh( rtc::scoped_refptr<QualityScalerQpUsageHandlerCallback>); Where QualityScalerQpUsageHandlerCallback::OnQpUsageHandled( bool clear_qp_samples); Instructs the QualityScaler whether to clear samples before checking QP the next time or to increase the frequency of checking (corresponding to AdaptDown's return value prior to this CL). QualityScaler no longer using AdaptationObserverInterface, this class is renamed and moved to overuse_frame_detector.h. The dependency between CheckQpTasks is made explicit with CheckQpTask::Result and variables like observed_enough_frames_, adapt_called_ and adapt_failed_ are moved there and given more descriptive names. Bug: webrtc:11521 Change-Id: I7faf795aeee5ded18ce75eb1617f88226e337228 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173760 Reviewed-by: Evan Shrubsole <eshr@google.com> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31140}
2020-04-27 17:40:55 +02:00
}
case QualityScaler::CheckQpResult::kHighQp: {
result_.observed_enough_frames = true;
result_.qp_usage_reported = true;
quality_scaler_->fast_rampup_ = false;
quality_scaler_->handler_->OnReportQpUsageHigh();
quality_scaler_->ClearSamples();
break;
Asynchronous QualityScaler: Callback-based CheckQpTask. This CL breaks up the CheckQp() operation into several steps managed by the inner helper class CheckQpTask, making responding to high or low QP an asynchronous operation. Why? Reconfiguring the stream in response to QP overuse will in the future be handled on a separate task queue. See Call-Level Adaptation Processing for more details: https://docs.google.com/document/d/1ZyC26yOCknrrcYa839ZWLxD6o6Gig5A3lVTh4E41074/edit?usp=sharing Instead of "bool AdaptDown()" when high QP is reported, synchronously returning true or false depending on the result of adaptation, this CL introduces void QualityScalerQpUsageHandlerInterface::OnReportQpUsageHigh( rtc::scoped_refptr<QualityScalerQpUsageHandlerCallback>); Where QualityScalerQpUsageHandlerCallback::OnQpUsageHandled( bool clear_qp_samples); Instructs the QualityScaler whether to clear samples before checking QP the next time or to increase the frequency of checking (corresponding to AdaptDown's return value prior to this CL). QualityScaler no longer using AdaptationObserverInterface, this class is renamed and moved to overuse_frame_detector.h. The dependency between CheckQpTasks is made explicit with CheckQpTask::Result and variables like observed_enough_frames_, adapt_called_ and adapt_failed_ are moved there and given more descriptive names. Bug: webrtc:11521 Change-Id: I7faf795aeee5ded18ce75eb1617f88226e337228 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173760 Reviewed-by: Evan Shrubsole <eshr@google.com> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31140}
2020-04-27 17:40:55 +02:00
}
case QualityScaler::CheckQpResult::kLowQp: {
result_.observed_enough_frames = true;
result_.qp_usage_reported = true;
quality_scaler_->handler_->OnReportQpUsageLow();
quality_scaler_->ClearSamples();
break;
Asynchronous QualityScaler: Callback-based CheckQpTask. This CL breaks up the CheckQp() operation into several steps managed by the inner helper class CheckQpTask, making responding to high or low QP an asynchronous operation. Why? Reconfiguring the stream in response to QP overuse will in the future be handled on a separate task queue. See Call-Level Adaptation Processing for more details: https://docs.google.com/document/d/1ZyC26yOCknrrcYa839ZWLxD6o6Gig5A3lVTh4E41074/edit?usp=sharing Instead of "bool AdaptDown()" when high QP is reported, synchronously returning true or false depending on the result of adaptation, this CL introduces void QualityScalerQpUsageHandlerInterface::OnReportQpUsageHigh( rtc::scoped_refptr<QualityScalerQpUsageHandlerCallback>); Where QualityScalerQpUsageHandlerCallback::OnQpUsageHandled( bool clear_qp_samples); Instructs the QualityScaler whether to clear samples before checking QP the next time or to increase the frequency of checking (corresponding to AdaptDown's return value prior to this CL). QualityScaler no longer using AdaptationObserverInterface, this class is renamed and moved to overuse_frame_detector.h. The dependency between CheckQpTasks is made explicit with CheckQpTask::Result and variables like observed_enough_frames_, adapt_called_ and adapt_failed_ are moved there and given more descriptive names. Bug: webrtc:11521 Change-Id: I7faf795aeee5ded18ce75eb1617f88226e337228 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173760 Reviewed-by: Evan Shrubsole <eshr@google.com> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31140}
2020-04-27 17:40:55 +02:00
}
}
state_ = State::kCompleted;
// Starting the next task deletes the pending task. After this line,
// `this` has been deleted.
quality_scaler_->StartNextCheckQpTask();
},
TimeDelta::Millis(GetCheckingQpDelayMs()));
Asynchronous QualityScaler: Callback-based CheckQpTask. This CL breaks up the CheckQp() operation into several steps managed by the inner helper class CheckQpTask, making responding to high or low QP an asynchronous operation. Why? Reconfiguring the stream in response to QP overuse will in the future be handled on a separate task queue. See Call-Level Adaptation Processing for more details: https://docs.google.com/document/d/1ZyC26yOCknrrcYa839ZWLxD6o6Gig5A3lVTh4E41074/edit?usp=sharing Instead of "bool AdaptDown()" when high QP is reported, synchronously returning true or false depending on the result of adaptation, this CL introduces void QualityScalerQpUsageHandlerInterface::OnReportQpUsageHigh( rtc::scoped_refptr<QualityScalerQpUsageHandlerCallback>); Where QualityScalerQpUsageHandlerCallback::OnQpUsageHandled( bool clear_qp_samples); Instructs the QualityScaler whether to clear samples before checking QP the next time or to increase the frequency of checking (corresponding to AdaptDown's return value prior to this CL). QualityScaler no longer using AdaptationObserverInterface, this class is renamed and moved to overuse_frame_detector.h. The dependency between CheckQpTasks is made explicit with CheckQpTask::Result and variables like observed_enough_frames_, adapt_called_ and adapt_failed_ are moved there and given more descriptive names. Bug: webrtc:11521 Change-Id: I7faf795aeee5ded18ce75eb1617f88226e337228 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173760 Reviewed-by: Evan Shrubsole <eshr@google.com> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31140}
2020-04-27 17:40:55 +02:00
}
bool HasCompletedTask() const { return state_ == State::kCompleted; }
Result result() const {
RTC_DCHECK(HasCompletedTask());
return result_;
}
private:
enum class State {
kNotStarted,
kCheckingQp,
kCompleted,
};
// Determines the sampling period of CheckQpTasks.
int64_t GetCheckingQpDelayMs() const {
RTC_DCHECK_RUN_ON(&quality_scaler_->task_checker_);
if (quality_scaler_->fast_rampup_) {
return quality_scaler_->sampling_period_ms_;
}
if (quality_scaler_->experiment_enabled_ &&
!previous_task_result_.observed_enough_frames) {
// Use half the interval while waiting for enough frames.
return quality_scaler_->sampling_period_ms_ / 2;
}
if (quality_scaler_->scale_factor_ &&
!previous_task_result_.qp_usage_reported) {
// Last CheckQp did not call AdaptDown/Up, possibly reduce interval.
return quality_scaler_->sampling_period_ms_ *
quality_scaler_->scale_factor_.value();
}
return quality_scaler_->sampling_period_ms_ *
quality_scaler_->initial_scale_factor_;
}
QualityScaler* const quality_scaler_;
State state_;
const Result previous_task_result_;
Result result_;
rtc::WeakPtrFactory<CheckQpTask> weak_ptr_factory_;
};
QualityScaler::QualityScaler(QualityScalerQpUsageHandlerInterface* handler,
VideoEncoder::QpThresholds thresholds,
const FieldTrialsView& field_trials)
: QualityScaler(handler, thresholds, field_trials, kMeasureMs) {}
// Protected ctor, should not be called directly.
Asynchronous QualityScaler: Callback-based CheckQpTask. This CL breaks up the CheckQp() operation into several steps managed by the inner helper class CheckQpTask, making responding to high or low QP an asynchronous operation. Why? Reconfiguring the stream in response to QP overuse will in the future be handled on a separate task queue. See Call-Level Adaptation Processing for more details: https://docs.google.com/document/d/1ZyC26yOCknrrcYa839ZWLxD6o6Gig5A3lVTh4E41074/edit?usp=sharing Instead of "bool AdaptDown()" when high QP is reported, synchronously returning true or false depending on the result of adaptation, this CL introduces void QualityScalerQpUsageHandlerInterface::OnReportQpUsageHigh( rtc::scoped_refptr<QualityScalerQpUsageHandlerCallback>); Where QualityScalerQpUsageHandlerCallback::OnQpUsageHandled( bool clear_qp_samples); Instructs the QualityScaler whether to clear samples before checking QP the next time or to increase the frequency of checking (corresponding to AdaptDown's return value prior to this CL). QualityScaler no longer using AdaptationObserverInterface, this class is renamed and moved to overuse_frame_detector.h. The dependency between CheckQpTasks is made explicit with CheckQpTask::Result and variables like observed_enough_frames_, adapt_called_ and adapt_failed_ are moved there and given more descriptive names. Bug: webrtc:11521 Change-Id: I7faf795aeee5ded18ce75eb1617f88226e337228 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173760 Reviewed-by: Evan Shrubsole <eshr@google.com> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31140}
2020-04-27 17:40:55 +02:00
QualityScaler::QualityScaler(QualityScalerQpUsageHandlerInterface* handler,
VideoEncoder::QpThresholds thresholds,
const FieldTrialsView& field_trials,
int64_t default_sampling_period_ms)
Asynchronous QualityScaler: Callback-based CheckQpTask. This CL breaks up the CheckQp() operation into several steps managed by the inner helper class CheckQpTask, making responding to high or low QP an asynchronous operation. Why? Reconfiguring the stream in response to QP overuse will in the future be handled on a separate task queue. See Call-Level Adaptation Processing for more details: https://docs.google.com/document/d/1ZyC26yOCknrrcYa839ZWLxD6o6Gig5A3lVTh4E41074/edit?usp=sharing Instead of "bool AdaptDown()" when high QP is reported, synchronously returning true or false depending on the result of adaptation, this CL introduces void QualityScalerQpUsageHandlerInterface::OnReportQpUsageHigh( rtc::scoped_refptr<QualityScalerQpUsageHandlerCallback>); Where QualityScalerQpUsageHandlerCallback::OnQpUsageHandled( bool clear_qp_samples); Instructs the QualityScaler whether to clear samples before checking QP the next time or to increase the frequency of checking (corresponding to AdaptDown's return value prior to this CL). QualityScaler no longer using AdaptationObserverInterface, this class is renamed and moved to overuse_frame_detector.h. The dependency between CheckQpTasks is made explicit with CheckQpTask::Result and variables like observed_enough_frames_, adapt_called_ and adapt_failed_ are moved there and given more descriptive names. Bug: webrtc:11521 Change-Id: I7faf795aeee5ded18ce75eb1617f88226e337228 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173760 Reviewed-by: Evan Shrubsole <eshr@google.com> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31140}
2020-04-27 17:40:55 +02:00
: handler_(handler),
thresholds_(thresholds),
sampling_period_ms_(QualityScalerSettings(field_trials)
.SamplingPeriodMs()
.value_or(default_sampling_period_ms)),
fast_rampup_(true),
// Arbitrarily choose size based on 30 fps for 5 seconds.
average_qp_(QualityScalerSettings(field_trials)
.AverageQpWindow()
.value_or(5 * 30)),
framedrop_percent_media_opt_(5 * 30),
framedrop_percent_all_(5 * 30),
experiment_enabled_(QualityScalingExperiment::Enabled(field_trials)),
min_frames_needed_(QualityScalerSettings(field_trials)
.MinFrames()
.value_or(kMinFramesNeededToScale)),
initial_scale_factor_(QualityScalerSettings(field_trials)
.InitialScaleFactor()
.value_or(kSamplePeriodScaleFactor)),
scale_factor_(QualityScalerSettings(field_trials).ScaleFactor()) {
RTC_DCHECK_RUN_ON(&task_checker_);
if (experiment_enabled_) {
config_ = QualityScalingExperiment::GetConfig(field_trials);
qp_smoother_high_.reset(new QpSmoother(config_.alpha_high));
qp_smoother_low_.reset(new QpSmoother(config_.alpha_low));
}
Asynchronous QualityScaler: Callback-based CheckQpTask. This CL breaks up the CheckQp() operation into several steps managed by the inner helper class CheckQpTask, making responding to high or low QP an asynchronous operation. Why? Reconfiguring the stream in response to QP overuse will in the future be handled on a separate task queue. See Call-Level Adaptation Processing for more details: https://docs.google.com/document/d/1ZyC26yOCknrrcYa839ZWLxD6o6Gig5A3lVTh4E41074/edit?usp=sharing Instead of "bool AdaptDown()" when high QP is reported, synchronously returning true or false depending on the result of adaptation, this CL introduces void QualityScalerQpUsageHandlerInterface::OnReportQpUsageHigh( rtc::scoped_refptr<QualityScalerQpUsageHandlerCallback>); Where QualityScalerQpUsageHandlerCallback::OnQpUsageHandled( bool clear_qp_samples); Instructs the QualityScaler whether to clear samples before checking QP the next time or to increase the frequency of checking (corresponding to AdaptDown's return value prior to this CL). QualityScaler no longer using AdaptationObserverInterface, this class is renamed and moved to overuse_frame_detector.h. The dependency between CheckQpTasks is made explicit with CheckQpTask::Result and variables like observed_enough_frames_, adapt_called_ and adapt_failed_ are moved there and given more descriptive names. Bug: webrtc:11521 Change-Id: I7faf795aeee5ded18ce75eb1617f88226e337228 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173760 Reviewed-by: Evan Shrubsole <eshr@google.com> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31140}
2020-04-27 17:40:55 +02:00
RTC_DCHECK(handler_ != nullptr);
StartNextCheckQpTask();
RTC_LOG(LS_INFO) << "QP thresholds: low: " << thresholds_.low
<< ", high: " << thresholds_.high;
}
QualityScaler::~QualityScaler() {
RTC_DCHECK_RUN_ON(&task_checker_);
}
Asynchronous QualityScaler: Callback-based CheckQpTask. This CL breaks up the CheckQp() operation into several steps managed by the inner helper class CheckQpTask, making responding to high or low QP an asynchronous operation. Why? Reconfiguring the stream in response to QP overuse will in the future be handled on a separate task queue. See Call-Level Adaptation Processing for more details: https://docs.google.com/document/d/1ZyC26yOCknrrcYa839ZWLxD6o6Gig5A3lVTh4E41074/edit?usp=sharing Instead of "bool AdaptDown()" when high QP is reported, synchronously returning true or false depending on the result of adaptation, this CL introduces void QualityScalerQpUsageHandlerInterface::OnReportQpUsageHigh( rtc::scoped_refptr<QualityScalerQpUsageHandlerCallback>); Where QualityScalerQpUsageHandlerCallback::OnQpUsageHandled( bool clear_qp_samples); Instructs the QualityScaler whether to clear samples before checking QP the next time or to increase the frequency of checking (corresponding to AdaptDown's return value prior to this CL). QualityScaler no longer using AdaptationObserverInterface, this class is renamed and moved to overuse_frame_detector.h. The dependency between CheckQpTasks is made explicit with CheckQpTask::Result and variables like observed_enough_frames_, adapt_called_ and adapt_failed_ are moved there and given more descriptive names. Bug: webrtc:11521 Change-Id: I7faf795aeee5ded18ce75eb1617f88226e337228 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173760 Reviewed-by: Evan Shrubsole <eshr@google.com> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31140}
2020-04-27 17:40:55 +02:00
void QualityScaler::StartNextCheckQpTask() {
RTC_DCHECK_RUN_ON(&task_checker_);
Asynchronous QualityScaler: Callback-based CheckQpTask. This CL breaks up the CheckQp() operation into several steps managed by the inner helper class CheckQpTask, making responding to high or low QP an asynchronous operation. Why? Reconfiguring the stream in response to QP overuse will in the future be handled on a separate task queue. See Call-Level Adaptation Processing for more details: https://docs.google.com/document/d/1ZyC26yOCknrrcYa839ZWLxD6o6Gig5A3lVTh4E41074/edit?usp=sharing Instead of "bool AdaptDown()" when high QP is reported, synchronously returning true or false depending on the result of adaptation, this CL introduces void QualityScalerQpUsageHandlerInterface::OnReportQpUsageHigh( rtc::scoped_refptr<QualityScalerQpUsageHandlerCallback>); Where QualityScalerQpUsageHandlerCallback::OnQpUsageHandled( bool clear_qp_samples); Instructs the QualityScaler whether to clear samples before checking QP the next time or to increase the frequency of checking (corresponding to AdaptDown's return value prior to this CL). QualityScaler no longer using AdaptationObserverInterface, this class is renamed and moved to overuse_frame_detector.h. The dependency between CheckQpTasks is made explicit with CheckQpTask::Result and variables like observed_enough_frames_, adapt_called_ and adapt_failed_ are moved there and given more descriptive names. Bug: webrtc:11521 Change-Id: I7faf795aeee5ded18ce75eb1617f88226e337228 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173760 Reviewed-by: Evan Shrubsole <eshr@google.com> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31140}
2020-04-27 17:40:55 +02:00
RTC_DCHECK(!pending_qp_task_ || pending_qp_task_->HasCompletedTask())
<< "A previous CheckQpTask has not completed yet!";
CheckQpTask::Result previous_task_result;
if (pending_qp_task_) {
previous_task_result = pending_qp_task_->result();
}
Asynchronous QualityScaler: Callback-based CheckQpTask. This CL breaks up the CheckQp() operation into several steps managed by the inner helper class CheckQpTask, making responding to high or low QP an asynchronous operation. Why? Reconfiguring the stream in response to QP overuse will in the future be handled on a separate task queue. See Call-Level Adaptation Processing for more details: https://docs.google.com/document/d/1ZyC26yOCknrrcYa839ZWLxD6o6Gig5A3lVTh4E41074/edit?usp=sharing Instead of "bool AdaptDown()" when high QP is reported, synchronously returning true or false depending on the result of adaptation, this CL introduces void QualityScalerQpUsageHandlerInterface::OnReportQpUsageHigh( rtc::scoped_refptr<QualityScalerQpUsageHandlerCallback>); Where QualityScalerQpUsageHandlerCallback::OnQpUsageHandled( bool clear_qp_samples); Instructs the QualityScaler whether to clear samples before checking QP the next time or to increase the frequency of checking (corresponding to AdaptDown's return value prior to this CL). QualityScaler no longer using AdaptationObserverInterface, this class is renamed and moved to overuse_frame_detector.h. The dependency between CheckQpTasks is made explicit with CheckQpTask::Result and variables like observed_enough_frames_, adapt_called_ and adapt_failed_ are moved there and given more descriptive names. Bug: webrtc:11521 Change-Id: I7faf795aeee5ded18ce75eb1617f88226e337228 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173760 Reviewed-by: Evan Shrubsole <eshr@google.com> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31140}
2020-04-27 17:40:55 +02:00
pending_qp_task_ = std::make_unique<CheckQpTask>(this, previous_task_result);
pending_qp_task_->StartDelayedTask();
}
void QualityScaler::SetQpThresholds(VideoEncoder::QpThresholds thresholds) {
RTC_DCHECK_RUN_ON(&task_checker_);
thresholds_ = thresholds;
}
void QualityScaler::ReportDroppedFrameByMediaOpt() {
RTC_DCHECK_RUN_ON(&task_checker_);
framedrop_percent_media_opt_.AddSample(100);
framedrop_percent_all_.AddSample(100);
}
void QualityScaler::ReportDroppedFrameByEncoder() {
RTC_DCHECK_RUN_ON(&task_checker_);
framedrop_percent_all_.AddSample(100);
}
void QualityScaler::ReportQp(int qp, int64_t time_sent_us) {
RTC_DCHECK_RUN_ON(&task_checker_);
framedrop_percent_media_opt_.AddSample(0);
framedrop_percent_all_.AddSample(0);
average_qp_.AddSample(qp);
if (qp_smoother_high_)
qp_smoother_high_->Add(qp, time_sent_us);
if (qp_smoother_low_)
qp_smoother_low_->Add(qp, time_sent_us);
}
Asynchronous QualityScaler: Callback-based CheckQpTask. This CL breaks up the CheckQp() operation into several steps managed by the inner helper class CheckQpTask, making responding to high or low QP an asynchronous operation. Why? Reconfiguring the stream in response to QP overuse will in the future be handled on a separate task queue. See Call-Level Adaptation Processing for more details: https://docs.google.com/document/d/1ZyC26yOCknrrcYa839ZWLxD6o6Gig5A3lVTh4E41074/edit?usp=sharing Instead of "bool AdaptDown()" when high QP is reported, synchronously returning true or false depending on the result of adaptation, this CL introduces void QualityScalerQpUsageHandlerInterface::OnReportQpUsageHigh( rtc::scoped_refptr<QualityScalerQpUsageHandlerCallback>); Where QualityScalerQpUsageHandlerCallback::OnQpUsageHandled( bool clear_qp_samples); Instructs the QualityScaler whether to clear samples before checking QP the next time or to increase the frequency of checking (corresponding to AdaptDown's return value prior to this CL). QualityScaler no longer using AdaptationObserverInterface, this class is renamed and moved to overuse_frame_detector.h. The dependency between CheckQpTasks is made explicit with CheckQpTask::Result and variables like observed_enough_frames_, adapt_called_ and adapt_failed_ are moved there and given more descriptive names. Bug: webrtc:11521 Change-Id: I7faf795aeee5ded18ce75eb1617f88226e337228 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173760 Reviewed-by: Evan Shrubsole <eshr@google.com> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31140}
2020-04-27 17:40:55 +02:00
QualityScaler::CheckQpResult QualityScaler::CheckQp() const {
RTC_DCHECK_RUN_ON(&task_checker_);
// Should be set through InitEncode -> Should be set by now.
RTC_DCHECK_GE(thresholds_.low, 0);
// 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 < min_frames_needed_) {
Asynchronous QualityScaler: Callback-based CheckQpTask. This CL breaks up the CheckQp() operation into several steps managed by the inner helper class CheckQpTask, making responding to high or low QP an asynchronous operation. Why? Reconfiguring the stream in response to QP overuse will in the future be handled on a separate task queue. See Call-Level Adaptation Processing for more details: https://docs.google.com/document/d/1ZyC26yOCknrrcYa839ZWLxD6o6Gig5A3lVTh4E41074/edit?usp=sharing Instead of "bool AdaptDown()" when high QP is reported, synchronously returning true or false depending on the result of adaptation, this CL introduces void QualityScalerQpUsageHandlerInterface::OnReportQpUsageHigh( rtc::scoped_refptr<QualityScalerQpUsageHandlerCallback>); Where QualityScalerQpUsageHandlerCallback::OnQpUsageHandled( bool clear_qp_samples); Instructs the QualityScaler whether to clear samples before checking QP the next time or to increase the frequency of checking (corresponding to AdaptDown's return value prior to this CL). QualityScaler no longer using AdaptationObserverInterface, this class is renamed and moved to overuse_frame_detector.h. The dependency between CheckQpTasks is made explicit with CheckQpTask::Result and variables like observed_enough_frames_, adapt_called_ and adapt_failed_ are moved there and given more descriptive names. Bug: webrtc:11521 Change-Id: I7faf795aeee5ded18ce75eb1617f88226e337228 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173760 Reviewed-by: Evan Shrubsole <eshr@google.com> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31140}
2020-04-27 17:40:55 +02:00
return CheckQpResult::kInsufficientSamples;
}
// Check if we should scale down due to high frame drop.
const std::optional<int> drop_rate =
config_.use_all_drop_reasons
? framedrop_percent_all_.GetAverageRoundedDown()
: framedrop_percent_media_opt_.GetAverageRoundedDown();
if (drop_rate && *drop_rate >= kFramedropPercentThreshold) {
RTC_LOG(LS_INFO) << "Reporting high QP, framedrop percent " << *drop_rate;
Asynchronous QualityScaler: Callback-based CheckQpTask. This CL breaks up the CheckQp() operation into several steps managed by the inner helper class CheckQpTask, making responding to high or low QP an asynchronous operation. Why? Reconfiguring the stream in response to QP overuse will in the future be handled on a separate task queue. See Call-Level Adaptation Processing for more details: https://docs.google.com/document/d/1ZyC26yOCknrrcYa839ZWLxD6o6Gig5A3lVTh4E41074/edit?usp=sharing Instead of "bool AdaptDown()" when high QP is reported, synchronously returning true or false depending on the result of adaptation, this CL introduces void QualityScalerQpUsageHandlerInterface::OnReportQpUsageHigh( rtc::scoped_refptr<QualityScalerQpUsageHandlerCallback>); Where QualityScalerQpUsageHandlerCallback::OnQpUsageHandled( bool clear_qp_samples); Instructs the QualityScaler whether to clear samples before checking QP the next time or to increase the frequency of checking (corresponding to AdaptDown's return value prior to this CL). QualityScaler no longer using AdaptationObserverInterface, this class is renamed and moved to overuse_frame_detector.h. The dependency between CheckQpTasks is made explicit with CheckQpTask::Result and variables like observed_enough_frames_, adapt_called_ and adapt_failed_ are moved there and given more descriptive names. Bug: webrtc:11521 Change-Id: I7faf795aeee5ded18ce75eb1617f88226e337228 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173760 Reviewed-by: Evan Shrubsole <eshr@google.com> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31140}
2020-04-27 17:40:55 +02:00
return CheckQpResult::kHighQp;
}
// Check if we should scale up or down based on QP.
const std::optional<int> avg_qp_high =
qp_smoother_high_ ? qp_smoother_high_->GetAvg()
: average_qp_.GetAverageRoundedDown();
const std::optional<int> avg_qp_low =
qp_smoother_low_ ? qp_smoother_low_->GetAvg()
: average_qp_.GetAverageRoundedDown();
if (avg_qp_high && avg_qp_low) {
RTC_LOG(LS_INFO) << "Checking average QP " << *avg_qp_high << " ("
<< *avg_qp_low << ").";
if (*avg_qp_high > thresholds_.high) {
Asynchronous QualityScaler: Callback-based CheckQpTask. This CL breaks up the CheckQp() operation into several steps managed by the inner helper class CheckQpTask, making responding to high or low QP an asynchronous operation. Why? Reconfiguring the stream in response to QP overuse will in the future be handled on a separate task queue. See Call-Level Adaptation Processing for more details: https://docs.google.com/document/d/1ZyC26yOCknrrcYa839ZWLxD6o6Gig5A3lVTh4E41074/edit?usp=sharing Instead of "bool AdaptDown()" when high QP is reported, synchronously returning true or false depending on the result of adaptation, this CL introduces void QualityScalerQpUsageHandlerInterface::OnReportQpUsageHigh( rtc::scoped_refptr<QualityScalerQpUsageHandlerCallback>); Where QualityScalerQpUsageHandlerCallback::OnQpUsageHandled( bool clear_qp_samples); Instructs the QualityScaler whether to clear samples before checking QP the next time or to increase the frequency of checking (corresponding to AdaptDown's return value prior to this CL). QualityScaler no longer using AdaptationObserverInterface, this class is renamed and moved to overuse_frame_detector.h. The dependency between CheckQpTasks is made explicit with CheckQpTask::Result and variables like observed_enough_frames_, adapt_called_ and adapt_failed_ are moved there and given more descriptive names. Bug: webrtc:11521 Change-Id: I7faf795aeee5ded18ce75eb1617f88226e337228 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173760 Reviewed-by: Evan Shrubsole <eshr@google.com> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31140}
2020-04-27 17:40:55 +02:00
return CheckQpResult::kHighQp;
}
if (*avg_qp_low <= thresholds_.low) {
// QP has been low. We want to try a higher resolution.
Asynchronous QualityScaler: Callback-based CheckQpTask. This CL breaks up the CheckQp() operation into several steps managed by the inner helper class CheckQpTask, making responding to high or low QP an asynchronous operation. Why? Reconfiguring the stream in response to QP overuse will in the future be handled on a separate task queue. See Call-Level Adaptation Processing for more details: https://docs.google.com/document/d/1ZyC26yOCknrrcYa839ZWLxD6o6Gig5A3lVTh4E41074/edit?usp=sharing Instead of "bool AdaptDown()" when high QP is reported, synchronously returning true or false depending on the result of adaptation, this CL introduces void QualityScalerQpUsageHandlerInterface::OnReportQpUsageHigh( rtc::scoped_refptr<QualityScalerQpUsageHandlerCallback>); Where QualityScalerQpUsageHandlerCallback::OnQpUsageHandled( bool clear_qp_samples); Instructs the QualityScaler whether to clear samples before checking QP the next time or to increase the frequency of checking (corresponding to AdaptDown's return value prior to this CL). QualityScaler no longer using AdaptationObserverInterface, this class is renamed and moved to overuse_frame_detector.h. The dependency between CheckQpTasks is made explicit with CheckQpTask::Result and variables like observed_enough_frames_, adapt_called_ and adapt_failed_ are moved there and given more descriptive names. Bug: webrtc:11521 Change-Id: I7faf795aeee5ded18ce75eb1617f88226e337228 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173760 Reviewed-by: Evan Shrubsole <eshr@google.com> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31140}
2020-04-27 17:40:55 +02:00
return CheckQpResult::kLowQp;
}
}
Asynchronous QualityScaler: Callback-based CheckQpTask. This CL breaks up the CheckQp() operation into several steps managed by the inner helper class CheckQpTask, making responding to high or low QP an asynchronous operation. Why? Reconfiguring the stream in response to QP overuse will in the future be handled on a separate task queue. See Call-Level Adaptation Processing for more details: https://docs.google.com/document/d/1ZyC26yOCknrrcYa839ZWLxD6o6Gig5A3lVTh4E41074/edit?usp=sharing Instead of "bool AdaptDown()" when high QP is reported, synchronously returning true or false depending on the result of adaptation, this CL introduces void QualityScalerQpUsageHandlerInterface::OnReportQpUsageHigh( rtc::scoped_refptr<QualityScalerQpUsageHandlerCallback>); Where QualityScalerQpUsageHandlerCallback::OnQpUsageHandled( bool clear_qp_samples); Instructs the QualityScaler whether to clear samples before checking QP the next time or to increase the frequency of checking (corresponding to AdaptDown's return value prior to this CL). QualityScaler no longer using AdaptationObserverInterface, this class is renamed and moved to overuse_frame_detector.h. The dependency between CheckQpTasks is made explicit with CheckQpTask::Result and variables like observed_enough_frames_, adapt_called_ and adapt_failed_ are moved there and given more descriptive names. Bug: webrtc:11521 Change-Id: I7faf795aeee5ded18ce75eb1617f88226e337228 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173760 Reviewed-by: Evan Shrubsole <eshr@google.com> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31140}
2020-04-27 17:40:55 +02:00
return CheckQpResult::kNormalQp;
}
void QualityScaler::ClearSamples() {
RTC_DCHECK_RUN_ON(&task_checker_);
framedrop_percent_media_opt_.Reset();
framedrop_percent_all_.Reset();
average_qp_.Reset();
if (qp_smoother_high_)
qp_smoother_high_->Reset();
if (qp_smoother_low_)
qp_smoother_low_->Reset();
Reland of Make QualityScaler more responsive to downgrades. (patchset #1 id:1 of https://codereview.webrtc.org/1880103002/ ) Reason for revert: Regressed behavior is actually desirable (go down to 360p instead of producing super-bad 720p). Original issue's description: > Revert of Make QualityScaler more responsive to downgrades. (patchset #3 id:40001 of https://codereview.webrtc.org/1830593003/ ) > > Reason for revert: > Speculative revert: want to see if this causes the regression in https://crbug.com/602621 > > Original issue's description: > > Make QualityScaler more responsive to downgrades. > > > > Permits going from HD to QVGA in 6 seconds instead of 10. Also adds > > windows for going up quickly in the beginning of a call (before any > > downscaling happens due to bad quality). > > > > BUG=webrtc:5678 > > R=glaznev@webrtc.org, stefan@webrtc.org > > > > Committed: https://crrev.com/85829fd90cc4e7a91c9857921b19e8fc126aeb60 > > Cr-Commit-Position: refs/heads/master@{#12219} > > TBR=glaznev@webrtc.org,stefan@webrtc.org,pbos@webrtc.org > # Not skipping CQ checks because original CL landed more than 1 days ago. > BUG=webrtc:5678 > NOTRY=true > > Committed: https://crrev.com/19b4fecf08e3fe215e431a260fb673553c15e569 > Cr-Commit-Position: refs/heads/master@{#12331} TBR=glaznev@webrtc.org,stefan@webrtc.org,phoglund@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=chromium:602621, webrtc:5678 Review URL: https://codereview.webrtc.org/1887493003 Cr-Commit-Position: refs/heads/master@{#12341}
2016-04-13 02:51:02 -07:00
}
Asynchronous QualityScaler: Callback-based CheckQpTask. This CL breaks up the CheckQp() operation into several steps managed by the inner helper class CheckQpTask, making responding to high or low QP an asynchronous operation. Why? Reconfiguring the stream in response to QP overuse will in the future be handled on a separate task queue. See Call-Level Adaptation Processing for more details: https://docs.google.com/document/d/1ZyC26yOCknrrcYa839ZWLxD6o6Gig5A3lVTh4E41074/edit?usp=sharing Instead of "bool AdaptDown()" when high QP is reported, synchronously returning true or false depending on the result of adaptation, this CL introduces void QualityScalerQpUsageHandlerInterface::OnReportQpUsageHigh( rtc::scoped_refptr<QualityScalerQpUsageHandlerCallback>); Where QualityScalerQpUsageHandlerCallback::OnQpUsageHandled( bool clear_qp_samples); Instructs the QualityScaler whether to clear samples before checking QP the next time or to increase the frequency of checking (corresponding to AdaptDown's return value prior to this CL). QualityScaler no longer using AdaptationObserverInterface, this class is renamed and moved to overuse_frame_detector.h. The dependency between CheckQpTasks is made explicit with CheckQpTask::Result and variables like observed_enough_frames_, adapt_called_ and adapt_failed_ are moved there and given more descriptive names. Bug: webrtc:11521 Change-Id: I7faf795aeee5ded18ce75eb1617f88226e337228 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173760 Reviewed-by: Evan Shrubsole <eshr@google.com> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31140}
2020-04-27 17:40:55 +02:00
QualityScalerQpUsageHandlerInterface::~QualityScalerQpUsageHandlerInterface() {}
} // namespace webrtc