Exclude initial adapt downs in stats for quality adapt changes per minute.

Make WebRTC.Video.AdaptChangesPerMinute.Quality stats only based on changes during a call.

Discard initial quality adapt changes due to bitrate (MaximumFrameSizeForBitrate).
Makes stats only based on changes determined by the quality scaler.

Bug: none
Change-Id: I461b65e65634565ade87b1336cf5206aa14926ff
Reviewed-on: https://webrtc-review.googlesource.com/37660
Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
Commit-Queue: Åsa Persson <asapersson@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21585}
diff --git a/video/send_statistics_proxy.h b/video/send_statistics_proxy.h
index c90f88a..1aa836e 100644
--- a/video/send_statistics_proxy.h
+++ b/video/send_statistics_proxy.h
@@ -74,6 +74,7 @@
       const VideoStreamEncoder::AdaptCounts& cpu_counts,
       const VideoStreamEncoder::AdaptCounts& quality_counts);
   void OnMinPixelLimitReached();
+  void OnInitialQualityResolutionAdaptDown();
 
   void OnSuspendChange(bool is_suspended);
   void OnInactiveSsrc(uint32_t ssrc);
@@ -181,6 +182,10 @@
     SampleCounter vp9;   // QP range: 0-255.
     SampleCounter h264;  // QP range: 0-51.
   };
+  struct AdaptChanges {
+    int down = 0;
+    int up = 0;
+  };
 
   // Map holding encoded frames (mapped by timestamp).
   // If simulcast layers are encoded on different threads, there is no guarantee
@@ -217,6 +222,9 @@
       const VideoStreamEncoder::AdaptCounts& cpu_counts,
       const VideoStreamEncoder::AdaptCounts& quality_counts)
       RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
+  void TryUpdateInitialQualityResolutionAdaptUp(
+      const VideoStreamEncoder::AdaptCounts& quality_counts)
+      RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
 
   void UpdateEncoderFallbackStats(const CodecSpecificInfo* codec_info,
                                   int pixels)
@@ -298,6 +306,7 @@
     size_t num_streams_;  // Number of configured streams to encoder.
     size_t num_pixels_highest_stream_;
     EncodedFrameMap encoded_frames_;
+    AdaptChanges initial_quality_changes_;
 
     std::map<int, QpCounters>
         qp_counters_;  // QP counters mapped by spatial idx.