Removing the intelligibility enhancer.

The intelligibility enhancer is always disabled and it is the only non-test
target using the lapped transform in common_audio (which we planned to remove).

Bug: webrtc:9689, webrtc:5298
Change-Id: Ida65d3aa11ac366471e7e5cbc053108b376c67d8
Reviewed-on: https://webrtc-review.googlesource.com/96460
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Per Ã…hgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24504}
diff --git a/modules/audio_processing/audio_processing_impl.cc b/modules/audio_processing/audio_processing_impl.cc
index 4a1a86c..8848b73 100644
--- a/modules/audio_processing/audio_processing_impl.cc
+++ b/modules/audio_processing/audio_processing_impl.cc
@@ -38,9 +38,6 @@
 #include "rtc_base/system/arch.h"
 #include "rtc_base/timeutils.h"
 #include "rtc_base/trace_event.h"
-#if WEBRTC_INTELLIGIBILITY_ENHANCER
-#include "modules/audio_processing/intelligibility/intelligibility_enhancer.h"
-#endif
 #include "modules/audio_processing/level_estimator_impl.h"
 #include "modules/audio_processing/low_cut_filter.h"
 #include "modules/audio_processing/noise_suppression_impl.h"
@@ -50,14 +47,6 @@
 #include "rtc_base/atomicops.h"
 #include "system_wrappers/include/metrics.h"
 
-// Check to verify that the define for the intelligibility enhancer is properly
-// set.
-#if !defined(WEBRTC_INTELLIGIBILITY_ENHANCER) || \
-    (WEBRTC_INTELLIGIBILITY_ENHANCER != 0 &&     \
-     WEBRTC_INTELLIGIBILITY_ENHANCER != 1)
-#error "Set WEBRTC_INTELLIGIBILITY_ENHANCER to either 0 or 1"
-#endif
-
 #define RETURN_ON_ERR(expr) \
   do {                      \
     int err = (expr);       \
@@ -170,7 +159,6 @@
     bool mobile_echo_controller_enabled,
     bool residual_echo_detector_enabled,
     bool noise_suppressor_enabled,
-    bool intelligibility_enhancer_enabled,
     bool adaptive_gain_controller_enabled,
     bool gain_controller2_enabled,
     bool pre_amplifier_enabled,
@@ -187,8 +175,6 @@
       (residual_echo_detector_enabled != residual_echo_detector_enabled_);
   changed |= (noise_suppressor_enabled != noise_suppressor_enabled_);
   changed |=
-      (intelligibility_enhancer_enabled != intelligibility_enhancer_enabled_);
-  changed |=
       (adaptive_gain_controller_enabled != adaptive_gain_controller_enabled_);
   changed |=
       (gain_controller2_enabled != gain_controller2_enabled_);
@@ -204,7 +190,6 @@
     mobile_echo_controller_enabled_ = mobile_echo_controller_enabled;
     residual_echo_detector_enabled_ = residual_echo_detector_enabled;
     noise_suppressor_enabled_ = noise_suppressor_enabled;
-    intelligibility_enhancer_enabled_ = intelligibility_enhancer_enabled;
     adaptive_gain_controller_enabled_ = adaptive_gain_controller_enabled;
     gain_controller2_enabled_ = gain_controller2_enabled;
     pre_amplifier_enabled_ = pre_amplifier_enabled;
@@ -221,12 +206,7 @@
 
 bool AudioProcessingImpl::ApmSubmoduleStates::CaptureMultiBandSubModulesActive()
     const {
-#if WEBRTC_INTELLIGIBILITY_ENHANCER
-  return CaptureMultiBandProcessingActive() ||
-         intelligibility_enhancer_enabled_ || voice_activity_detector_enabled_;
-#else
   return CaptureMultiBandProcessingActive() || voice_activity_detector_enabled_;
-#endif
 }
 
 bool AudioProcessingImpl::ApmSubmoduleStates::CaptureMultiBandProcessingActive()
@@ -260,11 +240,7 @@
 
 bool AudioProcessingImpl::ApmSubmoduleStates::RenderMultiBandProcessingActive()
     const {
-#if WEBRTC_INTELLIGIBILITY_ENHANCER
-  return intelligibility_enhancer_enabled_;
-#else
   return false;
-#endif
 }
 
 struct AudioProcessingImpl::ApmPublicSubmodules {
@@ -283,9 +259,6 @@
 
   // Accessed internally from both render and capture.
   std::unique_ptr<TransientSuppressor> transient_suppressor;
-#if WEBRTC_INTELLIGIBILITY_ENHANCER
-  std::unique_ptr<IntelligibilityEnhancer> intelligibility_enhancer;
-#endif
 };
 
 struct AudioProcessingImpl::ApmPrivateSubmodules {
@@ -405,7 +378,7 @@
 #else
       capture_(config.Get<ExperimentalNs>().enabled),
 #endif
-      capture_nonlocked_(config.Get<Intelligibility>().enabled) {
+      capture_nonlocked_() {
   {
     rtc::CritScope cs_render(&crit_render_);
     rtc::CritScope cs_capture(&crit_capture_);
@@ -589,9 +562,6 @@
     public_submodules_->gain_control_for_experimental_agc->Initialize();
   }
   InitializeTransient();
-#if WEBRTC_INTELLIGIBILITY_ENHANCER
-  InitializeIntelligibility();
-#endif
   InitializeLowCutFilter();
   public_submodules_->noise_suppression->Initialize(num_proc_channels(),
                                                     proc_sample_rate_hz());
@@ -742,15 +712,6 @@
         config.Get<ExperimentalNs>().enabled;
     InitializeTransient();
   }
-
-#if WEBRTC_INTELLIGIBILITY_ENHANCER
-  if (capture_nonlocked_.intelligibility_enabled !=
-     config.Get<Intelligibility>().enabled) {
-    capture_nonlocked_.intelligibility_enabled =
-        config.Get<Intelligibility>().enabled;
-    InitializeIntelligibility();
-  }
-#endif
 }
 
 int AudioProcessingImpl::proc_sample_rate_hz() const {
@@ -1306,18 +1267,6 @@
     capture_buffer->CopyLowPassToReference();
   }
   public_submodules_->noise_suppression->ProcessCaptureAudio(capture_buffer);
-#if WEBRTC_INTELLIGIBILITY_ENHANCER
-  if (capture_nonlocked_.intelligibility_enabled) {
-    RTC_DCHECK(public_submodules_->noise_suppression->is_enabled());
-    const int gain_db =
-        public_submodules_->gain_control->is_enabled()
-            ? public_submodules_->gain_control->compression_gain_db()
-            : 0;
-    const float gain = DbToRatio(gain_db);
-    public_submodules_->intelligibility_enhancer->SetCaptureNoiseEstimate(
-        public_submodules_->noise_suppression->NoiseEstimate(), gain);
-  }
-#endif
 
   // Ensure that the stream delay was set before the call to the
   // AECM ProcessCaptureAudio function.
@@ -1540,13 +1489,6 @@
     render_buffer->SplitIntoFrequencyBands();
   }
 
-#if WEBRTC_INTELLIGIBILITY_ENHANCER
-  if (capture_nonlocked_.intelligibility_enabled) {
-    public_submodules_->intelligibility_enhancer->ProcessRenderAudio(
-        render_buffer);
-  }
-#endif
-
   if (submodule_states_.RenderMultiBandSubModulesActive()) {
     QueueBandedRenderAudio(render_buffer);
   }
@@ -1809,7 +1751,6 @@
       public_submodules_->echo_control_mobile->is_enabled(),
       config_.residual_echo_detector.enabled,
       public_submodules_->noise_suppression->is_enabled(),
-      capture_nonlocked_.intelligibility_enabled,
       public_submodules_->gain_control->is_enabled(),
       config_.gain_controller2.enabled, config_.pre_amplifier.enabled,
       capture_nonlocked_.echo_controller_enabled,
@@ -1830,18 +1771,6 @@
   }
 }
 
-void AudioProcessingImpl::InitializeIntelligibility() {
-#if WEBRTC_INTELLIGIBILITY_ENHANCER
-  if (capture_nonlocked_.intelligibility_enabled) {
-    public_submodules_->intelligibility_enhancer.reset(
-        new IntelligibilityEnhancer(capture_nonlocked_.split_rate,
-                                    render_.render_audio->num_channels(),
-                                    render_.render_audio->num_bands(),
-                                    NoiseSuppressionImpl::num_noise_bins()));
-  }
-#endif
-}
-
 void AudioProcessingImpl::InitializeLowCutFilter() {
   if (config_.high_pass_filter.enabled) {
     private_submodules_->low_cut_filter.reset(
@@ -2029,8 +1958,6 @@
 
   apm_config.transient_suppression_enabled =
       capture_.transient_suppressor_enabled;
-  apm_config.intelligibility_enhancer_enabled =
-      capture_nonlocked_.intelligibility_enabled;
   apm_config.experiments_description = experiments_description;
   apm_config.pre_amplifier_enabled = config_.pre_amplifier.enabled;
   apm_config.pre_amplifier_fixed_gain_factor =