Correcting the AGC saturation detection for multichannel input
This CL changes the AGC saturation detection so that saturations only in one mic channel is counted equally bad as saturations in more than one channel. Bug: webrtc:10859 Change-Id: I3cf9fce17c2dd51a70365cc408fe6276944b4b19 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/159021 Reviewed-by: Sam Zackrisson <saza@webrtc.org> Commit-Queue: Per Åhgren <peah@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29731}
This commit is contained in:
@ -146,17 +146,19 @@ int InitializeGainControl(GainControl* gain_control,
|
||||
float ComputeClippedRatio(const float* const* audio,
|
||||
size_t num_channels,
|
||||
size_t samples_per_channel) {
|
||||
RTC_DCHECK_GT(num_channels * samples_per_channel, 0);
|
||||
RTC_DCHECK_GT(samples_per_channel, 0);
|
||||
int num_clipped = 0;
|
||||
for (size_t ch = 0; ch < num_channels; ++ch) {
|
||||
int num_clipped_in_ch = 0;
|
||||
for (size_t i = 0; i < samples_per_channel; ++i) {
|
||||
RTC_DCHECK(audio[ch]);
|
||||
if (audio[ch][i] >= 32767.f || audio[ch][i] <= -32768.f) {
|
||||
++num_clipped;
|
||||
++num_clipped_in_ch;
|
||||
}
|
||||
}
|
||||
num_clipped = std::max(num_clipped, num_clipped_in_ch);
|
||||
}
|
||||
return static_cast<float>(num_clipped) / (num_channels * samples_per_channel);
|
||||
return static_cast<float>(num_clipped) / (samples_per_channel);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@ -113,8 +113,13 @@ class AgcManagerDirectTest : public ::testing::Test {
|
||||
|
||||
void CallPreProc(int num_calls, float clipped_ratio) {
|
||||
RTC_DCHECK_GE(1.f, clipped_ratio);
|
||||
int num_clipped = kNumChannels * kSamplesPerChannel * clipped_ratio;
|
||||
std::fill(audio_data.begin(), audio_data.begin() + num_clipped, 32767.f);
|
||||
const int num_clipped = kSamplesPerChannel * clipped_ratio;
|
||||
std::fill(audio_data.begin(), audio_data.end(), 0.f);
|
||||
for (size_t ch = 0; ch < kNumChannels; ++ch) {
|
||||
for (int k = 0; k < num_clipped; ++k) {
|
||||
audio[ch][k] = 32767.f;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < num_calls; ++i) {
|
||||
manager_.AnalyzePreProcess(audio.data(), kNumChannels,
|
||||
|
||||
Reference in New Issue
Block a user