AGC2: adding level estimation option (RMS or peak-based).
This CL makes possible to choose the level estimation for the adaptive digital GC of AGC2. The options are RMS (default and currently used estimator) and peak-based (already computed, but not used). Besides adding the new AGC2 config param for the level estimator, this CL also refactors the config class by making it more structured. Bug: webrtc:7494 Change-Id: I20eb558ca50f13536aa7bdea08d21de3b630f8bc Reviewed-on: https://webrtc-review.googlesource.com/c/110144 Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> Reviewed-by: Alex Loiko <aleloi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25620}
This commit is contained in:
committed by
Commit Bot
parent
44ca9a392a
commit
1e2542f593
@ -65,30 +65,52 @@ void GainController2::ApplyConfig(
|
||||
RTC_DCHECK(Validate(config))
|
||||
<< " the invalid config was " << ToString(config);
|
||||
|
||||
if (config.fixed_gain_db != config_.fixed_gain_db) {
|
||||
config_ = config;
|
||||
if (config.fixed_digital.gain_db != config_.fixed_digital.gain_db) {
|
||||
// Reset the limiter to quickly react on abrupt level changes caused by
|
||||
// large changes of the fixed gain.
|
||||
limiter_.Reset();
|
||||
}
|
||||
config_ = config;
|
||||
gain_applier_.SetGainFactor(DbToRatio(config_.fixed_gain_db));
|
||||
adaptive_digital_mode_ = config_.adaptive_digital_mode;
|
||||
adaptive_agc_.reset(
|
||||
new AdaptiveAgc(data_dumper_.get(), config_.extra_saturation_margin_db));
|
||||
gain_applier_.SetGainFactor(DbToRatio(config_.fixed_digital.gain_db));
|
||||
adaptive_digital_mode_ = config_.adaptive_digital.enabled;
|
||||
adaptive_agc_.reset(new AdaptiveAgc(data_dumper_.get(), config_));
|
||||
}
|
||||
|
||||
bool GainController2::Validate(
|
||||
const AudioProcessing::Config::GainController2& config) {
|
||||
return config.fixed_gain_db >= 0.f && config.fixed_gain_db < 50.f &&
|
||||
config.extra_saturation_margin_db >= 0.f &&
|
||||
config.extra_saturation_margin_db <= 100.f;
|
||||
return config.fixed_digital.gain_db >= 0.f &&
|
||||
config.fixed_digital.gain_db < 50.f &&
|
||||
config.adaptive_digital.extra_saturation_margin_db >= 0.f &&
|
||||
config.adaptive_digital.extra_saturation_margin_db <= 100.f;
|
||||
}
|
||||
|
||||
std::string GainController2::ToString(
|
||||
const AudioProcessing::Config::GainController2& config) {
|
||||
rtc::StringBuilder ss;
|
||||
ss << "{enabled: " << (config.enabled ? "true" : "false") << ", "
|
||||
<< "fixed_gain_dB: " << config.fixed_gain_db << "}";
|
||||
std::string adaptive_digital_level_estimator;
|
||||
using LevelEstimatorType =
|
||||
AudioProcessing::Config::GainController2::LevelEstimator;
|
||||
switch (config.adaptive_digital.level_estimator) {
|
||||
case LevelEstimatorType::kRms:
|
||||
adaptive_digital_level_estimator = "RMS";
|
||||
break;
|
||||
case LevelEstimatorType::kPeak:
|
||||
adaptive_digital_level_estimator = "peak";
|
||||
break;
|
||||
}
|
||||
// clang-format off
|
||||
// clang formatting doesn't respect custom nested style.
|
||||
ss << "{"
|
||||
<< "enabled: " << (config.enabled ? "true" : "false") << ", "
|
||||
<< "fixed_digital: {gain_db: " << config.fixed_digital.gain_db << "}, "
|
||||
<< "adaptive_digital: {"
|
||||
<< "enabled: "
|
||||
<< (config.adaptive_digital.enabled ? "true" : "false") << ", "
|
||||
<< "level_estimator: " << adaptive_digital_level_estimator << ", "
|
||||
<< "extra_saturation_margin_db:"
|
||||
<< config.adaptive_digital.extra_saturation_margin_db << "}"
|
||||
<< "}";
|
||||
// clang-format on
|
||||
return ss.Release();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user