Make the extra seturation margin configurable.
The extra saturation margin is a setting for the SaturationProtector in GainController2. The higher it is, the less gain GC2 will apply. In this CL we pipe the setting up to audio_processing.h. Now the setting can be set at a high level. Also in this CL add a few (missing, they should have been there already) tests for the GC2 and GC2 with saturation margin. Bug: webrtc:7494 Change-Id: I1b61f1662e6c6a8817fd5b0e845339694bf8d50d Reviewed-on: https://webrtc-review.googlesource.com/c/109001 Reviewed-by: Sam Zackrisson <saza@webrtc.org> Commit-Queue: Alex Loiko <aleloi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25470}
This commit is contained in:
@ -25,7 +25,7 @@ GainController2::GainController2()
|
||||
: data_dumper_(
|
||||
new ApmDataDumper(rtc::AtomicOps::Increment(&instance_count_))),
|
||||
fixed_gain_controller_(data_dumper_.get()),
|
||||
adaptive_agc_(data_dumper_.get()) {}
|
||||
adaptive_agc_(new AdaptiveAgc(data_dumper_.get())) {}
|
||||
|
||||
GainController2::~GainController2() = default;
|
||||
|
||||
@ -43,14 +43,15 @@ void GainController2::Process(AudioBuffer* audio) {
|
||||
AudioFrameView<float> float_frame(audio->channels_f(), audio->num_channels(),
|
||||
audio->num_frames());
|
||||
if (adaptive_digital_mode_) {
|
||||
adaptive_agc_.Process(float_frame, fixed_gain_controller_.LastAudioLevel());
|
||||
adaptive_agc_->Process(float_frame,
|
||||
fixed_gain_controller_.LastAudioLevel());
|
||||
}
|
||||
fixed_gain_controller_.Process(float_frame);
|
||||
}
|
||||
|
||||
void GainController2::NotifyAnalogLevel(int level) {
|
||||
if (analog_level_ != level && adaptive_digital_mode_) {
|
||||
adaptive_agc_.Reset();
|
||||
adaptive_agc_->Reset();
|
||||
}
|
||||
analog_level_ = level;
|
||||
}
|
||||
@ -61,11 +62,15 @@ void GainController2::ApplyConfig(
|
||||
config_ = config;
|
||||
fixed_gain_controller_.SetGain(config_.fixed_gain_db);
|
||||
adaptive_digital_mode_ = config_.adaptive_digital_mode;
|
||||
adaptive_agc_.reset(
|
||||
new AdaptiveAgc(data_dumper_.get(), config_.extra_saturation_margin_db));
|
||||
}
|
||||
|
||||
bool GainController2::Validate(
|
||||
const AudioProcessing::Config::GainController2& config) {
|
||||
return config.fixed_gain_db >= 0.f;
|
||||
return config.fixed_gain_db >= 0.f &&
|
||||
config.extra_saturation_margin_db >= 0.f &&
|
||||
config.extra_saturation_margin_db <= 100.f;
|
||||
}
|
||||
|
||||
std::string GainController2::ToString(
|
||||
|
||||
Reference in New Issue
Block a user