AGC2 remove incorrect field trial parsing functions
The AGC2 params must be exposed via `AudioProcessing::Config::GainController2` and the Finch params must be parsed in blink (see [1]). Note: this CL breaks the chain of 3 CLs titled "AGC2 AdaptiveModeLevelEstimator min consecutive speech frames". [1] https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/modules/mediastream/media_stream_audio_processor.cc;l=593-596?q=HybridAgc&start=11 Bug: webrtc:7494 Change-Id: Ie7bd1bef1d6caf7d2b20600a1626c12171b67c82 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/185044 Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> Reviewed-by: Minyue Li <minyue@webrtc.org> Cr-Commit-Position: refs/heads/master@{#32230}
This commit is contained in:
parent
38b768c588
commit
435f279433
@ -86,16 +86,8 @@ rtc_library("biquad_filter") {
|
||||
]
|
||||
}
|
||||
|
||||
rtc_library("common") {
|
||||
sources = [
|
||||
"agc2_common.cc",
|
||||
"agc2_common.h",
|
||||
]
|
||||
deps = [
|
||||
"../../../rtc_base:rtc_base_approved",
|
||||
"../../../system_wrappers:field_trial",
|
||||
]
|
||||
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
|
||||
rtc_source_set("common") {
|
||||
sources = [ "agc2_common.h" ]
|
||||
}
|
||||
|
||||
rtc_library("fixed_digital") {
|
||||
@ -201,6 +193,7 @@ rtc_library("adaptive_digital_unittests") {
|
||||
"../../../rtc_base:checks",
|
||||
"../../../rtc_base:gunit_helpers",
|
||||
"../../../rtc_base:rtc_base_approved",
|
||||
"../../../test:test_support",
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@ -27,9 +27,9 @@ AdaptiveModeLevelEstimator::AdaptiveModeLevelEstimator(
|
||||
: AdaptiveModeLevelEstimator(
|
||||
apm_data_dumper,
|
||||
AudioProcessing::Config::GainController2::LevelEstimator::kRms,
|
||||
/*use_saturation_protector=*/true,
|
||||
GetInitialSaturationMarginDb(),
|
||||
GetExtraSaturationMarginOffsetDb()) {}
|
||||
kDefaultUseSaturationProtector,
|
||||
kDefaultInitialSaturationMarginDb,
|
||||
kDefaultExtraSaturationMarginDb) {}
|
||||
|
||||
AdaptiveModeLevelEstimator::AdaptiveModeLevelEstimator(
|
||||
ApmDataDumper* apm_data_dumper,
|
||||
@ -39,7 +39,7 @@ AdaptiveModeLevelEstimator::AdaptiveModeLevelEstimator(
|
||||
: AdaptiveModeLevelEstimator(apm_data_dumper,
|
||||
level_estimator,
|
||||
use_saturation_protector,
|
||||
GetInitialSaturationMarginDb(),
|
||||
kDefaultInitialSaturationMarginDb,
|
||||
extra_saturation_margin_db) {}
|
||||
|
||||
AdaptiveModeLevelEstimator::AdaptiveModeLevelEstimator(
|
||||
|
||||
@ -46,8 +46,6 @@ struct TestLevelEstimator {
|
||||
std::unique_ptr<AdaptiveModeLevelEstimator> estimator;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST(AutomaticGainController2AdaptiveModeLevelEstimator,
|
||||
EstimatorShouldNotCrash) {
|
||||
TestLevelEstimator level_estimator;
|
||||
@ -180,4 +178,5 @@ TEST(AutomaticGainController2AdaptiveModeLevelEstimator,
|
||||
kMaxDifferenceDb);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace webrtc
|
||||
|
||||
@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "modules/audio_processing/agc2/agc2_common.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "system_wrappers/include/field_trial.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
float GetInitialSaturationMarginDb() {
|
||||
constexpr char kForceInitialSaturationMarginFieldTrial[] =
|
||||
"WebRTC-Audio-Agc2ForceInitialSaturationMargin";
|
||||
|
||||
const bool use_forced_initial_saturation_margin =
|
||||
webrtc::field_trial::IsEnabled(kForceInitialSaturationMarginFieldTrial);
|
||||
if (use_forced_initial_saturation_margin) {
|
||||
const std::string field_trial_string = webrtc::field_trial::FindFullName(
|
||||
kForceInitialSaturationMarginFieldTrial);
|
||||
float margin_db = -1;
|
||||
if (sscanf(field_trial_string.c_str(), "Enabled-%f", &margin_db) == 1 &&
|
||||
margin_db >= 12.f && margin_db <= 25.f) {
|
||||
return margin_db;
|
||||
}
|
||||
}
|
||||
constexpr float kDefaultInitialSaturationMarginDb = 20.f;
|
||||
return kDefaultInitialSaturationMarginDb;
|
||||
}
|
||||
|
||||
float GetExtraSaturationMarginOffsetDb() {
|
||||
constexpr char kForceExtraSaturationMarginFieldTrial[] =
|
||||
"WebRTC-Audio-Agc2ForceExtraSaturationMargin";
|
||||
|
||||
const bool use_forced_extra_saturation_margin =
|
||||
webrtc::field_trial::IsEnabled(kForceExtraSaturationMarginFieldTrial);
|
||||
if (use_forced_extra_saturation_margin) {
|
||||
const std::string field_trial_string = webrtc::field_trial::FindFullName(
|
||||
kForceExtraSaturationMarginFieldTrial);
|
||||
float margin_db = -1;
|
||||
if (sscanf(field_trial_string.c_str(), "Enabled-%f", &margin_db) == 1 &&
|
||||
margin_db >= 0.f && margin_db <= 10.f) {
|
||||
return margin_db;
|
||||
}
|
||||
}
|
||||
constexpr float kDefaultExtraSaturationMarginDb = 2.f;
|
||||
return kDefaultExtraSaturationMarginDb;
|
||||
}
|
||||
} // namespace webrtc
|
||||
@ -53,8 +53,9 @@ constexpr float kInitialSpeechLevelEstimateDbfs = -30.f;
|
||||
constexpr float kDefaultSmoothedVadProbabilityAttack = 1.f;
|
||||
|
||||
// Saturation Protector settings.
|
||||
float GetInitialSaturationMarginDb();
|
||||
float GetExtraSaturationMarginOffsetDb();
|
||||
constexpr bool kDefaultUseSaturationProtector = true;
|
||||
constexpr float kDefaultInitialSaturationMarginDb = 20.f;
|
||||
constexpr float kDefaultExtraSaturationMarginDb = 2.f;
|
||||
|
||||
constexpr size_t kPeakEnveloperSuperFrameLengthMs = 400;
|
||||
static_assert(kFullBufferSizeMs % kPeakEnveloperSuperFrameLengthMs == 0,
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#include "modules/audio_processing/agc2/agc2_common.h"
|
||||
#include "modules/audio_processing/logging/apm_data_dumper.h"
|
||||
#include "rtc_base/gunit.h"
|
||||
#include "test/gmock.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user