Revert "Reland Process 8 kHz audio as 16 kHz internally of the audio processing module"
This reverts commit b7b8e30cb44c41f51dbbefb9a9160e6dfe869c5b.
Reason for revert: Broke ApmTest.Process test in internal iOS waterfall
Original change's description:
> Reland Process 8 kHz audio as 16 kHz internally of the audio processing module
>
> This CL relands the code from the CL "Process 8 kHz audio as 16 kHz internally
> of the audio processing module" which by mistake was reverted via a rebase in
> another CL.
>
> The CL changes the behavior of APM for 8 kHz so that it is internally
> processed as 16 kHz.
>
> Bug: webrtc:10863
> Change-Id: I32a57b2d279c2134125667c19b09cfda381a33c3
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/150221
> Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
> Commit-Queue: Per Ã…hgren <peah@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#28944}
TBR=gustaf@webrtc.org,peah@webrtc.org
Change-Id: Ia49e07b0c25c49da646917516e317f1d57cc4e84
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:10863
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/150326
Reviewed-by: Artem Titarenko <artit@webrtc.org>
Commit-Queue: Artem Titarenko <artit@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28948}
diff --git a/modules/audio_processing/audio_processing_impl.cc b/modules/audio_processing/audio_processing_impl.cc
index 97babf9..464c61b 100644
--- a/modules/audio_processing/audio_processing_impl.cc
+++ b/modules/audio_processing/audio_processing_impl.cc
@@ -84,17 +84,22 @@
sample_rate_hz == AudioProcessing::kSampleRate48kHz;
}
-// Identify the native processing rate that best handles a sample rate.
-int SuitableProcessRate(int minimum_rate, bool band_splitting_required) {
+int FindNativeProcessRateToUse(int minimum_rate, bool band_splitting_required) {
#ifdef WEBRTC_ARCH_ARM_FAMILY
- constexpr int kMaxSplittingRate = 32000;
+ constexpr int kMaxSplittingNativeProcessRate =
+ AudioProcessing::kSampleRate32kHz;
#else
- constexpr int kMaxSplittingRate = 48000;
+ constexpr int kMaxSplittingNativeProcessRate =
+ AudioProcessing::kSampleRate48kHz;
#endif
- static_assert(kMaxSplittingRate <= 48000, "");
- const int uppermost_native_rate =
- band_splitting_required ? kMaxSplittingRate : 48000;
- for (auto rate : {16000, 32000, 48000}) {
+ static_assert(
+ kMaxSplittingNativeProcessRate <= AudioProcessing::kMaxNativeSampleRateHz,
+ "");
+ const int uppermost_native_rate = band_splitting_required
+ ? kMaxSplittingNativeProcessRate
+ : AudioProcessing::kSampleRate48kHz;
+
+ for (auto rate : AudioProcessing::kNativeSampleRatesHz) {
if (rate >= uppermost_native_rate) {
return uppermost_native_rate;
}
@@ -590,19 +595,18 @@
formats_.api_format = config;
- int capture_processing_rate = SuitableProcessRate(
+ int capture_processing_rate = FindNativeProcessRateToUse(
std::min(formats_.api_format.input_stream().sample_rate_hz(),
formats_.api_format.output_stream().sample_rate_hz()),
submodule_states_.CaptureMultiBandSubModulesActive() ||
submodule_states_.RenderMultiBandSubModulesActive());
- RTC_DCHECK_NE(8000, capture_processing_rate);
capture_nonlocked_.capture_processing_format =
StreamConfig(capture_processing_rate);
int render_processing_rate;
if (!capture_nonlocked_.echo_controller_enabled) {
- render_processing_rate = SuitableProcessRate(
+ render_processing_rate = FindNativeProcessRateToUse(
std::min(formats_.api_format.reverse_input_stream().sample_rate_hz(),
formats_.api_format.reverse_output_stream().sample_rate_hz()),
submodule_states_.CaptureMultiBandSubModulesActive() ||
@@ -630,8 +634,6 @@
std::max(render_processing_rate, static_cast<int>(kSampleRate16kHz));
}
- RTC_DCHECK_NE(8000, render_processing_rate);
-
// Always downmix the render stream to mono for analysis. This has been
// demonstrated to work well for AEC in most practical scenarios.
if (submodule_states_.RenderMultiBandSubModulesActive()) {
diff --git a/modules/audio_processing/audio_processing_unittest.cc b/modules/audio_processing/audio_processing_unittest.cc
index 7fa6845..831799f 100644
--- a/modules/audio_processing/audio_processing_unittest.cc
+++ b/modules/audio_processing/audio_processing_unittest.cc
@@ -65,7 +65,7 @@
// When false, this will compare the output data with the results stored to
// file. This is the typical case. When the file should be updated, it can
// be set to true with the command-line switch --write_ref_data.
-bool write_ref_data = true;
+bool write_ref_data = false;
const int32_t kChannels[] = {1, 2};
const int kSampleRates[] = {8000, 16000, 32000, 48000};
@@ -1200,8 +1200,8 @@
TEST_F(ApmTest, NoProcessingWhenAllComponentsDisabledFloat) {
// Test that ProcessStream copies input to output even with no processing.
- const size_t kSamples = 160;
- const int sample_rate = 16000;
+ const size_t kSamples = 80;
+ const int sample_rate = 8000;
const float src[kSamples] = {-1.0f, 0.0f, 1.0f};
float dest[kSamples] = {};
diff --git a/modules/audio_processing/include/audio_processing.h b/modules/audio_processing/include/audio_processing.h
index fb62f77..eb12a66 100644
--- a/modules/audio_processing/include/audio_processing.h
+++ b/modules/audio_processing/include/audio_processing.h
@@ -698,7 +698,6 @@
kBadStreamParameterWarning = -13
};
- // Native rates supported by the AudioFrame interfaces.
enum NativeRate {
kSampleRate8kHz = 8000,
kSampleRate16kHz = 16000,
diff --git a/resources/audio_processing/output_data_fixed.pb.sha1 b/resources/audio_processing/output_data_fixed.pb.sha1
index e4444a9..072dc4f 100644
--- a/resources/audio_processing/output_data_fixed.pb.sha1
+++ b/resources/audio_processing/output_data_fixed.pb.sha1
@@ -1 +1 @@
-91f6018874f4cbce414918d053e1d6c36d3e51c4
\ No newline at end of file
+7481cf57b2ade2f600d91e8bc77fd9780a56b62e
\ No newline at end of file
diff --git a/resources/audio_processing/output_data_float.pb.sha1 b/resources/audio_processing/output_data_float.pb.sha1
index a8b35f8..c1b6f1a 100644
--- a/resources/audio_processing/output_data_float.pb.sha1
+++ b/resources/audio_processing/output_data_float.pb.sha1
@@ -1 +1 @@
-4794107799631a85c4aa4671979c6fa7edbef08b
\ No newline at end of file
+d67b879f3b4a31b3c4f3587bd4418be5f9df5105
\ No newline at end of file