DCHECKing for deprecated 8kHz support in AGC and changing fuzzer
This CL adds a DCHECK for the deprecated 8 kHz rate in APM.
It also updates the agc fuzzer code to properly do band-split on
the signals, and not send 8 kHz signals into the AGC.
Bug: chromium:1028092,chromium:1028172
Change-Id: I1e7c8d721834310e94b0e21efea07f75da837cab
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160600
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29914}
diff --git a/modules/audio_processing/gain_control_impl.cc b/modules/audio_processing/gain_control_impl.cc
index d3573f8..841d901 100644
--- a/modules/audio_processing/gain_control_impl.cc
+++ b/modules/audio_processing/gain_control_impl.cc
@@ -375,6 +375,9 @@
void GainControlImpl::Initialize(size_t num_proc_channels, int sample_rate_hz) {
data_dumper_->InitiateNewSetOfRecordings();
+ RTC_DCHECK(sample_rate_hz == 16000 || sample_rate_hz == 32000 ||
+ sample_rate_hz == 48000);
+
num_proc_channels_ = num_proc_channels;
sample_rate_hz_ = sample_rate_hz;
diff --git a/test/fuzzers/agc_fuzzer.cc b/test/fuzzers/agc_fuzzer.cc
index 10de3b8..ac3f83b 100644
--- a/test/fuzzers/agc_fuzzer.cc
+++ b/test/fuzzers/agc_fuzzer.cc
@@ -20,7 +20,9 @@
namespace webrtc {
namespace {
-void FillAudioBuffer(test::FuzzDataHelper* fuzz_data, AudioBuffer* buffer) {
+void FillAudioBuffer(size_t sample_rate_hz,
+ test::FuzzDataHelper* fuzz_data,
+ AudioBuffer* buffer) {
float* const* channels = buffer->channels_f();
for (size_t i = 0; i < buffer->num_channels(); ++i) {
for (size_t j = 0; j < buffer->num_frames(); ++j) {
@@ -28,6 +30,10 @@
static_cast<float>(fuzz_data->ReadOrDefaultValue<int16_t>(0));
}
}
+
+ if (sample_rate_hz != 16000) {
+ buffer->SplitIntoFrequencyBands();
+ }
}
// This function calls the GainControl functions that are overriden as private
@@ -76,8 +82,8 @@
void FuzzGainController(test::FuzzDataHelper* fuzz_data, GainControlImpl* gci) {
using Rate = ::webrtc::AudioProcessing::NativeRate;
- const Rate rate_kinds[] = {Rate::kSampleRate8kHz, Rate::kSampleRate16kHz,
- Rate::kSampleRate32kHz, Rate::kSampleRate48kHz};
+ const Rate rate_kinds[] = {Rate::kSampleRate16kHz, Rate::kSampleRate32kHz,
+ Rate::kSampleRate48kHz};
const auto sample_rate_hz =
static_cast<size_t>(fuzz_data->SelectOneOf(rate_kinds));
@@ -94,13 +100,13 @@
std::vector<int16_t> packed_render_audio(samples_per_frame);
while (fuzz_data->CanReadBytes(1)) {
- FillAudioBuffer(fuzz_data, &audio);
+ FillAudioBuffer(sample_rate_hz, fuzz_data, &audio);
const bool stream_has_echo = fuzz_data->ReadOrDefaultValue(true);
gci->AnalyzeCaptureAudio(audio);
gci->ProcessCaptureAudio(&audio, stream_has_echo);
- FillAudioBuffer(fuzz_data, &audio);
+ FillAudioBuffer(sample_rate_hz, fuzz_data, &audio);
gci->PackRenderAudioBuffer(audio, &packed_render_audio);
gci->ProcessRenderAudio(packed_render_audio);