Fuzzer crash in AGC2.
Gain specified by fuzzer in APM config was too high. Bug: chromium:901661 Change-Id: Id3ea8d23a4284a35c827bb16125902d84e37ca1e Reviewed-on: https://webrtc-review.googlesource.com/c/110604 Commit-Queue: Alex Loiko <aleloi@webrtc.org> Reviewed-by: Jonas Olsson <jonasolsson@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25594}
This commit is contained in:
parent
cfe3b6afd9
commit
20f60f0dc6
@ -62,13 +62,15 @@ void GainController2::NotifyAnalogLevel(int level) {
|
||||
|
||||
void GainController2::ApplyConfig(
|
||||
const AudioProcessing::Config::GainController2& config) {
|
||||
RTC_DCHECK(Validate(config));
|
||||
config_ = config;
|
||||
if (gain_applier_.GetGainFactor() != config_.fixed_gain_db) {
|
||||
RTC_DCHECK(Validate(config))
|
||||
<< " the invalid config was " << ToString(config);
|
||||
|
||||
if (config.fixed_gain_db != config_.fixed_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(
|
||||
@ -77,7 +79,7 @@ void GainController2::ApplyConfig(
|
||||
|
||||
bool GainController2::Validate(
|
||||
const AudioProcessing::Config::GainController2& config) {
|
||||
return config.fixed_gain_db >= 0.f &&
|
||||
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;
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ TEST(GainController2, CreateApplyConfig) {
|
||||
EXPECT_FALSE(GainController2::Validate(config));
|
||||
|
||||
// Check that valid configurations are applied.
|
||||
for (const float& fixed_gain_db : {0.f, 5.f, 10.f, 50.f}) {
|
||||
for (const float& fixed_gain_db : {0.f, 5.f, 10.f, 40.f}) {
|
||||
config.fixed_gain_db = fixed_gain_db;
|
||||
EXPECT_TRUE(GainController2::Validate(config));
|
||||
gain_controller2->ApplyConfig(config);
|
||||
|
||||
@ -89,7 +89,7 @@ std::unique_ptr<AudioProcessing> CreateApm(test::FuzzDataHelper* fuzz_data,
|
||||
|
||||
// Read an int8 value, but don't let it be too large or small.
|
||||
const float gain_controller2_gain_db =
|
||||
rtc::SafeClamp<int>(fuzz_data->ReadOrDefaultValue<int8_t>(0), -50, 50);
|
||||
rtc::SafeClamp<int>(fuzz_data->ReadOrDefaultValue<int8_t>(0), -40, 40);
|
||||
|
||||
constexpr size_t kNumFieldTrials = arraysize(kFieldTrialNames);
|
||||
// Verify that the read data type has enough bits to fuzz the field trials.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user