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:

committed by
Commit Bot

parent
2ad66eccb5
commit
31b01c0534
@ -122,6 +122,7 @@ std::unique_ptr<AudioProcessing> CreateApm(test::FuzzDataHelper* fuzz_data,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
webrtc::AudioProcessing::Config apm_config;
|
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.enabled = use_aec || use_aecm;
|
||||||
apm_config.echo_canceller.mobile_mode = use_aecm;
|
apm_config.echo_canceller.mobile_mode = use_aecm;
|
||||||
apm_config.residual_echo_detector.enabled = red;
|
apm_config.residual_echo_detector.enabled = red;
|
||||||
|
@ -71,12 +71,14 @@ void GenerateFixedFrame(test::FuzzDataHelper* fuzz_data,
|
|||||||
void FuzzAudioProcessing(test::FuzzDataHelper* fuzz_data,
|
void FuzzAudioProcessing(test::FuzzDataHelper* fuzz_data,
|
||||||
std::unique_ptr<AudioProcessing> apm) {
|
std::unique_ptr<AudioProcessing> apm) {
|
||||||
AudioFrame fixed_frame;
|
AudioFrame fixed_frame;
|
||||||
std::array<float, 480> float_frame1;
|
// Normal usage is up to 8 channels. Allowing to fuzz one beyond this allows
|
||||||
std::array<float, 480> float_frame2;
|
// us to catch implicit assumptions about normal usage.
|
||||||
std::array<float* const, 2> float_frame_ptrs = {
|
constexpr int kMaxNumChannels = 9;
|
||||||
&float_frame1[0],
|
std::array<std::array<float, 480>, kMaxNumChannels> float_frames;
|
||||||
&float_frame2[0],
|
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];
|
float* const* ptr_to_float_frames = &float_frame_ptrs[0];
|
||||||
|
|
||||||
using Rate = AudioProcessing::NativeRate;
|
using Rate = AudioProcessing::NativeRate;
|
||||||
@ -94,7 +96,6 @@ void FuzzAudioProcessing(test::FuzzDataHelper* fuzz_data,
|
|||||||
const auto output_rate =
|
const auto output_rate =
|
||||||
static_cast<size_t>(fuzz_data->SelectOneOf(rate_kinds));
|
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);
|
const uint8_t stream_delay = fuzz_data->ReadOrDefaultValue<uint8_t>(0);
|
||||||
|
|
||||||
// API call needed for AEC-2 and AEC-m to run.
|
// 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.
|
// Fill the arrays with audio samples from the data.
|
||||||
int apm_return_code = AudioProcessing::Error::kNoError;
|
int apm_return_code = AudioProcessing::Error::kNoError;
|
||||||
if (is_float) {
|
if (is_float) {
|
||||||
|
const int num_channels =
|
||||||
|
fuzz_data->ReadOrDefaultValue<uint8_t>(1) % kMaxNumChannels;
|
||||||
|
|
||||||
GenerateFloatFrame(fuzz_data, input_rate, num_channels,
|
GenerateFloatFrame(fuzz_data, input_rate, num_channels,
|
||||||
ptr_to_float_frames);
|
ptr_to_float_frames);
|
||||||
if (is_capture) {
|
if (is_capture) {
|
||||||
@ -122,6 +126,7 @@ void FuzzAudioProcessing(test::FuzzDataHelper* fuzz_data,
|
|||||||
StreamConfig(output_rate, 1), ptr_to_float_frames);
|
StreamConfig(output_rate, 1), ptr_to_float_frames);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
const int num_channels = fuzz_data->ReadOrDefaultValue(true) ? 2 : 1;
|
||||||
GenerateFixedFrame(fuzz_data, input_rate, num_channels, &fixed_frame);
|
GenerateFixedFrame(fuzz_data, input_rate, num_channels, &fixed_frame);
|
||||||
|
|
||||||
if (is_capture) {
|
if (is_capture) {
|
||||||
|
Reference in New Issue
Block a user