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}
This commit is contained in:
Sam Zackrisson
2019-11-25 08:48:26 +01:00
committed by Commit Bot
parent 2ad66eccb5
commit 31b01c0534
2 changed files with 13 additions and 7 deletions

View File

@ -122,6 +122,7 @@ std::unique_ptr<AudioProcessing> CreateApm(test::FuzzDataHelper* fuzz_data,
#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;

View File

@ -71,12 +71,14 @@ void GenerateFixedFrame(test::FuzzDataHelper* fuzz_data,
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 @@ void FuzzAudioProcessing(test::FuzzDataHelper* fuzz_data,
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 @@ void FuzzAudioProcessing(test::FuzzDataHelper* fuzz_data,
// 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 @@ void FuzzAudioProcessing(test::FuzzDataHelper* fuzz_data,
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) {