| Index: webrtc/video/vie_encoder.cc
|
| diff --git a/webrtc/video/vie_encoder.cc b/webrtc/video/vie_encoder.cc
|
| index de6b9a8a636ed91f912f5f50a802d9a15fadc2be..be6b76bfbd1a6ed512b149c30c62bcd461c621ac 100644
|
| --- a/webrtc/video/vie_encoder.cc
|
| +++ b/webrtc/video/vie_encoder.cc
|
| @@ -15,6 +15,7 @@
|
| #include <utility>
|
|
|
| #include "webrtc/modules/video_coding/include/video_codec_initializer.h"
|
| +#include "webrtc/base/arraysize.h"
|
| #include "webrtc/base/checks.h"
|
| #include "webrtc/base/logging.h"
|
| #include "webrtc/base/trace_event.h"
|
| @@ -262,6 +263,7 @@ ViEEncoder::ViEEncoder(uint32_t number_of_cores,
|
| has_received_rpsi_(false),
|
| picture_id_rpsi_(0),
|
| clock_(Clock::GetRealTimeClock()),
|
| + scale_counter_(kScaleReasonSize, 0),
|
| last_frame_width_(0),
|
| last_frame_height_(0),
|
| last_captured_timestamp_(0),
|
| @@ -333,12 +335,10 @@ void ViEEncoder::SetSource(
|
| source_proxy_->SetSource(source, degradation_preference);
|
| encoder_queue_.PostTask([this, degradation_preference] {
|
| RTC_DCHECK_RUN_ON(&encoder_queue_);
|
| - scaling_enabled_ =
|
| - (degradation_preference !=
|
| + scaling_enabled_ = (degradation_preference !=
|
| VideoSendStream::DegradationPreference::kMaintainResolution);
|
| stats_proxy_->SetResolutionRestrictionStats(
|
| - scaling_enabled_ && scale_counter_[kQuality] > 0,
|
| - scaling_enabled_ && scale_counter_[kCpu] > 0);
|
| + scaling_enabled_, scale_counter_[kCpu] > 0, scale_counter_[kQuality]);
|
| });
|
| }
|
|
|
| @@ -434,7 +434,7 @@ void ViEEncoder::ReconfigureEncoder() {
|
| std::move(streams), encoder_config_.min_transmit_bitrate_bps);
|
|
|
| const auto scaling_settings = settings_.encoder->GetScalingSettings();
|
| - if (scaling_settings.enabled && scaling_enabled_) {
|
| + if (scaling_enabled_ && scaling_settings.enabled) {
|
| if (scaling_settings.thresholds) {
|
| quality_scaler_.reset(
|
| new QualityScaler(this, *(scaling_settings.thresholds)));
|
| @@ -443,6 +443,8 @@ void ViEEncoder::ReconfigureEncoder() {
|
| }
|
| } else {
|
| quality_scaler_.reset(nullptr);
|
| + stats_proxy_->SetResolutionRestrictionStats(
|
| + false, scale_counter_[kCpu] > 0, scale_counter_[kQuality]);
|
| }
|
| }
|
|
|
| @@ -590,9 +592,8 @@ EncodedImageCallback::Result ViEEncoder::OnEncodedImage(
|
| // Encoded is called on whatever thread the real encoder implementation run
|
| // on. In the case of hardware encoders, there might be several encoders
|
| // running in parallel on different threads.
|
| - if (stats_proxy_) {
|
| + if (stats_proxy_)
|
| stats_proxy_->OnSendEncodedImage(encoded_image, codec_specific_info);
|
| - }
|
|
|
| EncodedImageCallback::Result result =
|
| sink_->OnEncodedImage(encoded_image, codec_specific_info, fragmentation);
|
| @@ -701,7 +702,8 @@ void ViEEncoder::ScaleDown(ScaleReason reason) {
|
| return;
|
| switch (reason) {
|
| case kQuality:
|
| - stats_proxy_->OnQualityRestrictedResolutionChanged(true);
|
| + stats_proxy_->OnQualityRestrictedResolutionChanged(
|
| + scale_counter_[reason] + 1);
|
| break;
|
| case kCpu:
|
| if (scale_counter_[reason] >= kMaxCpuDowngrades)
|
| @@ -733,7 +735,7 @@ void ViEEncoder::ScaleUp(ScaleReason reason) {
|
| switch (reason) {
|
| case kQuality:
|
| stats_proxy_->OnQualityRestrictedResolutionChanged(
|
| - scale_counter_[reason] > 1);
|
| + scale_counter_[reason] - 1);
|
| break;
|
| case kCpu:
|
| // Update stats accordingly.
|
|
|