Improve NetEq network adaptation in the beginning of the call.

Change the way the forget factor converge to the steady state so that we don't overemphasize the first packets received.

The logic is controlled by the delay histogram field trial which has an added parameter to control if emphasis should be even (c=1, default) or put on later packets (c>1) until we reach our steady state forget factor.

Bug: webrtc:10411
Change-Id: Ia5d46c22d1a4a66994652f71c8cde664362bfacb
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/137050
Reviewed-by: Minyue Li <minyue@webrtc.org>
Reviewed-by: Chen Xing <chxg@google.com>
Commit-Queue: Jakob Ivarsson‎ <jakobi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28039}
diff --git a/modules/audio_coding/neteq/histogram.h b/modules/audio_coding/neteq/histogram.h
index fc8f612..7eb90d9 100644
--- a/modules/audio_coding/neteq/histogram.h
+++ b/modules/audio_coding/neteq/histogram.h
@@ -15,12 +15,16 @@
 
 #include <vector>
 
+#include "absl/types/optional.h"
+
 namespace webrtc {
 
 class Histogram {
  public:
   // Creates histogram with capacity |num_buckets| and |forget_factor| in Q15.
-  Histogram(size_t num_buckets, int forget_factor);
+  Histogram(size_t num_buckets,
+            int forget_factor,
+            absl::optional<double> start_forget_weight = absl::nullopt);
 
   virtual ~Histogram();
 
@@ -43,17 +47,24 @@
   // Returns the probability for each bucket in Q30.
   std::vector<int> buckets() const { return buckets_; }
 
-  int forget_factor() const { return base_forget_factor_; }
-
   // Made public for testing.
   static std::vector<int> ScaleBuckets(const std::vector<int>& buckets,
                                        int old_bucket_width,
                                        int new_bucket_width);
 
+  // Accessors only intended for testing purposes.
+  int base_forget_factor_for_testing() const { return base_forget_factor_; }
+  int forget_factor_for_testing() const { return forget_factor_; }
+  absl::optional<double> start_forget_weight_for_testing() const {
+    return start_forget_weight_;
+  }
+
  private:
   std::vector<int> buckets_;
   int forget_factor_;  // Q15
   const int base_forget_factor_;
+  int add_count_;
+  const absl::optional<double> start_forget_weight_;
 };
 
 }  // namespace webrtc