| Index: webrtc/video/vie_encoder.cc
 | 
| diff --git a/webrtc/video/vie_encoder.cc b/webrtc/video/vie_encoder.cc
 | 
| index de6b9a8a636ed91f912f5f50a802d9a15fadc2be..23d899ae34eb3aa4410d006d440ddce10b2d5865 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),
 | 
| @@ -337,8 +339,7 @@ void ViEEncoder::SetSource(
 | 
|          (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]);
 | 
|    });
 | 
|  }
 | 
|  
 | 
| @@ -590,9 +591,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 +701,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 +734,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.
 | 
| 
 |