Fuzz APM float interface with up to 8 channels
Bug: webrtc:10859
Change-Id: Ie50b5fc102296bd71917852674cd2289e690ad78
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160305
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29891}
diff --git a/test/fuzzers/audio_processing_configs_fuzzer.cc b/test/fuzzers/audio_processing_configs_fuzzer.cc
index 8dd0e29..57699dd 100644
--- a/test/fuzzers/audio_processing_configs_fuzzer.cc
+++ b/test/fuzzers/audio_processing_configs_fuzzer.cc
@@ -122,6 +122,7 @@
#endif
webrtc::AudioProcessing::Config apm_config;
+ apm_config.pipeline.experimental_multi_channel = true;
apm_config.echo_canceller.enabled = use_aec || use_aecm;
apm_config.echo_canceller.mobile_mode = use_aecm;
apm_config.residual_echo_detector.enabled = red;
diff --git a/test/fuzzers/audio_processing_fuzzer_helper.cc b/test/fuzzers/audio_processing_fuzzer_helper.cc
index 5d7ea4c..eb2e0e8 100644
--- a/test/fuzzers/audio_processing_fuzzer_helper.cc
+++ b/test/fuzzers/audio_processing_fuzzer_helper.cc
@@ -71,12 +71,14 @@
void FuzzAudioProcessing(test::FuzzDataHelper* fuzz_data,
std::unique_ptr<AudioProcessing> apm) {
AudioFrame fixed_frame;
- std::array<float, 480> float_frame1;
- std::array<float, 480> float_frame2;
- std::array<float* const, 2> float_frame_ptrs = {
- &float_frame1[0],
- &float_frame2[0],
- };
+ // Normal usage is up to 8 channels. Allowing to fuzz one beyond this allows
+ // us to catch implicit assumptions about normal usage.
+ constexpr int kMaxNumChannels = 9;
+ std::array<std::array<float, 480>, kMaxNumChannels> float_frames;
+ std::array<float*, kMaxNumChannels> float_frame_ptrs;
+ for (int i = 0; i < kMaxNumChannels; ++i) {
+ float_frame_ptrs[i] = float_frames[i].data();
+ }
float* const* ptr_to_float_frames = &float_frame_ptrs[0];
using Rate = AudioProcessing::NativeRate;
@@ -94,7 +96,6 @@
const auto output_rate =
static_cast<size_t>(fuzz_data->SelectOneOf(rate_kinds));
- const int num_channels = fuzz_data->ReadOrDefaultValue(true) ? 2 : 1;
const uint8_t stream_delay = fuzz_data->ReadOrDefaultValue<uint8_t>(0);
// API call needed for AEC-2 and AEC-m to run.
@@ -110,6 +111,9 @@
// Fill the arrays with audio samples from the data.
int apm_return_code = AudioProcessing::Error::kNoError;
if (is_float) {
+ const int num_channels =
+ fuzz_data->ReadOrDefaultValue<uint8_t>(1) % kMaxNumChannels;
+
GenerateFloatFrame(fuzz_data, input_rate, num_channels,
ptr_to_float_frames);
if (is_capture) {
@@ -122,6 +126,7 @@
StreamConfig(output_rate, 1), ptr_to_float_frames);
}
} else {
+ const int num_channels = fuzz_data->ReadOrDefaultValue(true) ? 2 : 1;
GenerateFixedFrame(fuzz_data, input_rate, num_channels, &fixed_frame);
if (is_capture) {