AGC2: retuning and large refactoring

- Bug fix: the desired initial gain quickly dropped to 0 dB hence
  starting a call with a too low level
- New tuning to make AGC2 more robust to VAD mistakes
- Smarter max gain increase speed: to deal with an increased threshold
  of adjacent speech frames, the gain applier temporarily allows a
  faster gain increase to deal with a longer time spent waiting for
  enough speech frames in a row to be observed
- Saturation protector isolated from `AdaptiveModeLevelEstimator` to
  simplify the unit tests for the latter (non bit-exact change)
- AGC2 adaptive digital config: unnecessary params deprecated
- Code readability improvements
- Data dumps clean-up and better naming

Bug: webrtc:7494
Change-Id: I4e36059bdf2566cc2a7e1a7e95b7430ba9ae9844
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215140
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Jesus de Vicente Pena <devicentepena@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33736}
diff --git a/modules/audio_processing/include/audio_processing.h b/modules/audio_processing/include/audio_processing.h
index 781b17e..01bb7c3 100644
--- a/modules/audio_processing/include/audio_processing.h
+++ b/modules/audio_processing/include/audio_processing.h
@@ -349,6 +349,7 @@
         return !(*this == rhs);
       }
 
+      // TODO(crbug.com/webrtc/7494): Remove `LevelEstimator`.
       enum LevelEstimator { kRms, kPeak };
       enum NoiseEstimator { kStationaryNoise, kNoiseFloor };
       bool enabled = false;
@@ -359,19 +360,20 @@
         bool enabled = false;
         NoiseEstimator noise_estimator = kNoiseFloor;
         int vad_reset_period_ms = 1500;
-        float vad_probability_attack = 0.9f;
-        LevelEstimator level_estimator = kRms;
-        int level_estimator_adjacent_speech_frames_threshold = 11;
-        // TODO(crbug.com/webrtc/7494): Remove `use_saturation_protector`.
-        bool use_saturation_protector = true;
-        float initial_saturation_margin_db = 20.0f;
-        float extra_saturation_margin_db = 5.0f;
-        int gain_applier_adjacent_speech_frames_threshold = 11;
+        int adjacent_speech_frames_threshold = 12;
         float max_gain_change_db_per_second = 3.0f;
-        float max_output_noise_level_dbfs = -55.0f;
+        float max_output_noise_level_dbfs = -50.0f;
         bool sse2_allowed = true;
         bool avx2_allowed = true;
         bool neon_allowed = true;
+        // TODO(crbug.com/webrtc/7494): Remove deprecated settings below.
+        float vad_probability_attack = 1.0f;
+        LevelEstimator level_estimator = kRms;
+        int level_estimator_adjacent_speech_frames_threshold = 12;
+        bool use_saturation_protector = true;
+        float initial_saturation_margin_db = 25.0f;
+        float extra_saturation_margin_db = 5.0f;
+        int gain_applier_adjacent_speech_frames_threshold = 12;
       } adaptive_digital;
     } gain_controller2;