This CL is partially reverting the effects that
were added in https://codereview.webrtc.org/1773173002.

The reason for the revert is that for some scenarios
that CL causes problems in the coherence estimate used
in the AEC, which in turn causes echo leakage.

The reason for not reverting the actual CL is that
it would cause subsequent CLs to be reverted as well.
Therefore the choice was made to in this CK
instead revert the effects of that CL.

With the changes in this CL, the behavior is bitexact
to what it was before the CL mentioned above.

TBR=aluebs@webrtc.org

BUG=webrtc:5725

Review URL: https://codereview.webrtc.org/1867483003

Cr-Commit-Position: refs/heads/master@{#12259}
diff --git a/data/audio_processing/output_data_fixed.pb b/data/audio_processing/output_data_fixed.pb
index ae5b812..efc9563 100644
--- a/data/audio_processing/output_data_fixed.pb
+++ b/data/audio_processing/output_data_fixed.pb
Binary files differ
diff --git a/data/audio_processing/output_data_float.pb b/data/audio_processing/output_data_float.pb
index 97f8716..f869792 100644
--- a/data/audio_processing/output_data_float.pb
+++ b/data/audio_processing/output_data_float.pb
Binary files differ
diff --git a/data/audio_processing/output_data_mac.pb b/data/audio_processing/output_data_mac.pb
index c05f370..2070170 100644
--- a/data/audio_processing/output_data_mac.pb
+++ b/data/audio_processing/output_data_mac.pb
Binary files differ
diff --git a/webrtc/modules/audio_processing/audio_processing_impl.cc b/webrtc/modules/audio_processing/audio_processing_impl.cc
index 9fd18fc..953b699 100644
--- a/webrtc/modules/audio_processing/audio_processing_impl.cc
+++ b/webrtc/modules/audio_processing/audio_processing_impl.cc
@@ -366,15 +366,18 @@
       formats_.api_format.input_stream().sample_rate_hz(),
       formats_.api_format.output_stream().sample_rate_hz())));
 
-  int rev_proc_rate = ClosestNativeRate(std::min(
-      formats_.api_format.reverse_input_stream().sample_rate_hz(),
-      formats_.api_format.reverse_output_stream().sample_rate_hz()));
-  // If the forward sample rate is 8 kHz, the reverse stream is also processed
-  // at this rate.
+  // We normally process the reverse stream at 16 kHz. Unless...
+  int rev_proc_rate = kSampleRate16kHz;
   if (capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate8kHz) {
+    // ...the forward stream is at 8 kHz.
     rev_proc_rate = kSampleRate8kHz;
   } else {
-    rev_proc_rate = std::max(rev_proc_rate, static_cast<int>(kSampleRate16kHz));
+    if (formats_.api_format.reverse_input_stream().sample_rate_hz() ==
+        kSampleRate32kHz) {
+      // ...or the input is at 32 kHz, in which case we use the splitting
+      // filter rather than the resampler.
+      rev_proc_rate = kSampleRate32kHz;
+    }
   }
 
   // Always downmix the reverse stream to mono for analysis. This has been
@@ -1148,11 +1151,11 @@
 
 bool AudioProcessingImpl::rev_synthesis_needed() const {
   return (is_rev_processed() &&
-          is_multi_band(formats_.rev_proc_format.sample_rate_hz()));
+          formats_.rev_proc_format.sample_rate_hz() == kSampleRate32kHz);
 }
 
 bool AudioProcessingImpl::rev_analysis_needed() const {
-  return is_multi_band(formats_.rev_proc_format.sample_rate_hz()) &&
+  return formats_.rev_proc_format.sample_rate_hz() == kSampleRate32kHz &&
          (is_rev_processed() ||
           public_submodules_->echo_cancellation->is_enabled() ||
           public_submodules_->echo_control_mobile->is_enabled() ||
diff --git a/webrtc/modules/audio_processing/test/audio_processing_unittest.cc b/webrtc/modules/audio_processing/test/audio_processing_unittest.cc
index 12f9735..948c5ef 100644
--- a/webrtc/modules/audio_processing/test/audio_processing_unittest.cc
+++ b/webrtc/modules/audio_processing/test/audio_processing_unittest.cc
@@ -2644,8 +2644,8 @@
     CommonFormats,
     AudioProcessingTest,
     testing::Values(std::tr1::make_tuple(48000, 48000, 48000, 48000, 0, 0),
-                    std::tr1::make_tuple(48000, 48000, 32000, 48000, 35, 30),
-                    std::tr1::make_tuple(48000, 48000, 16000, 48000, 35, 20),
+                    std::tr1::make_tuple(48000, 48000, 32000, 48000, 40, 30),
+                    std::tr1::make_tuple(48000, 48000, 16000, 48000, 40, 20),
                     std::tr1::make_tuple(48000, 44100, 48000, 44100, 20, 20),
                     std::tr1::make_tuple(48000, 44100, 32000, 44100, 20, 15),
                     std::tr1::make_tuple(48000, 44100, 16000, 44100, 20, 15),
@@ -2692,7 +2692,7 @@
                     std::tr1::make_tuple(16000, 32000, 32000, 32000, 25, 0),
                     std::tr1::make_tuple(16000, 32000, 16000, 32000, 25, 20),
                     std::tr1::make_tuple(16000, 16000, 48000, 16000, 40, 20),
-                    std::tr1::make_tuple(16000, 16000, 32000, 16000, 40, 20),
+                    std::tr1::make_tuple(16000, 16000, 32000, 16000, 50, 20),
                     std::tr1::make_tuple(16000, 16000, 16000, 16000, 0, 0)));
 
 #elif defined(WEBRTC_AUDIOPROC_FIXED_PROFILE)
@@ -2748,7 +2748,7 @@
                     std::tr1::make_tuple(16000, 32000, 32000, 32000, 25, 0),
                     std::tr1::make_tuple(16000, 32000, 16000, 32000, 25, 20),
                     std::tr1::make_tuple(16000, 16000, 48000, 16000, 35, 20),
-                    std::tr1::make_tuple(16000, 16000, 32000, 16000, 35, 20),
+                    std::tr1::make_tuple(16000, 16000, 32000, 16000, 40, 20),
                     std::tr1::make_tuple(16000, 16000, 16000, 16000, 0, 0)));
 #endif