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}
This commit is contained in:
Per Åhgren 2019-11-26 09:23:45 +01:00 committed by Commit Bot
parent a101a4f186
commit 27bd76bcb2
2 changed files with 14 additions and 5 deletions

View file

@ -375,6 +375,9 @@ int GainControlImpl::enable_limiter(bool enable) {
void GainControlImpl::Initialize(size_t num_proc_channels, int sample_rate_hz) { void GainControlImpl::Initialize(size_t num_proc_channels, int sample_rate_hz) {
data_dumper_->InitiateNewSetOfRecordings(); data_dumper_->InitiateNewSetOfRecordings();
RTC_DCHECK(sample_rate_hz == 16000 || sample_rate_hz == 32000 ||
sample_rate_hz == 48000);
num_proc_channels_ = num_proc_channels; num_proc_channels_ = num_proc_channels;
sample_rate_hz_ = sample_rate_hz; sample_rate_hz_ = sample_rate_hz;

View file

@ -20,7 +20,9 @@
namespace webrtc { namespace webrtc {
namespace { 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(); float* const* channels = buffer->channels_f();
for (size_t i = 0; i < buffer->num_channels(); ++i) { for (size_t i = 0; i < buffer->num_channels(); ++i) {
for (size_t j = 0; j < buffer->num_frames(); ++j) { for (size_t j = 0; j < buffer->num_frames(); ++j) {
@ -28,6 +30,10 @@ void FillAudioBuffer(test::FuzzDataHelper* fuzz_data, AudioBuffer* buffer) {
static_cast<float>(fuzz_data->ReadOrDefaultValue<int16_t>(0)); 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 // This function calls the GainControl functions that are overriden as private
@ -76,8 +82,8 @@ void FuzzGainControllerConfig(test::FuzzDataHelper* fuzz_data,
void FuzzGainController(test::FuzzDataHelper* fuzz_data, GainControlImpl* gci) { void FuzzGainController(test::FuzzDataHelper* fuzz_data, GainControlImpl* gci) {
using Rate = ::webrtc::AudioProcessing::NativeRate; using Rate = ::webrtc::AudioProcessing::NativeRate;
const Rate rate_kinds[] = {Rate::kSampleRate8kHz, Rate::kSampleRate16kHz, const Rate rate_kinds[] = {Rate::kSampleRate16kHz, Rate::kSampleRate32kHz,
Rate::kSampleRate32kHz, Rate::kSampleRate48kHz}; Rate::kSampleRate48kHz};
const auto sample_rate_hz = const auto sample_rate_hz =
static_cast<size_t>(fuzz_data->SelectOneOf(rate_kinds)); static_cast<size_t>(fuzz_data->SelectOneOf(rate_kinds));
@ -94,13 +100,13 @@ void FuzzGainController(test::FuzzDataHelper* fuzz_data, GainControlImpl* gci) {
std::vector<int16_t> packed_render_audio(samples_per_frame); std::vector<int16_t> packed_render_audio(samples_per_frame);
while (fuzz_data->CanReadBytes(1)) { 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); const bool stream_has_echo = fuzz_data->ReadOrDefaultValue(true);
gci->AnalyzeCaptureAudio(audio); gci->AnalyzeCaptureAudio(audio);
gci->ProcessCaptureAudio(&audio, stream_has_echo); gci->ProcessCaptureAudio(&audio, stream_has_echo);
FillAudioBuffer(fuzz_data, &audio); FillAudioBuffer(sample_rate_hz, fuzz_data, &audio);
gci->PackRenderAudioBuffer(audio, &packed_render_audio); gci->PackRenderAudioBuffer(audio, &packed_render_audio);
gci->ProcessRenderAudio(packed_render_audio); gci->ProcessRenderAudio(packed_render_audio);