#include "modules/audio_processing/agc2/adaptive_digital_gain_controller.h"
#include <algorithm>
#include <memory>
#include "api/audio/audio_processing.h"
#include "common_audio/include/audio_util.h"
#include "modules/audio_processing/agc2/agc2_common.h"
#include "modules/audio_processing/agc2/vector_float_frame.h"
#include "modules/audio_processing/logging/apm_data_dumper.h"
#include "rtc_base/gunit.h"
namespace webrtc {
namespace {
constexpr int kMono = …;
constexpr int kStereo = …;
constexpr int kFrameLen10ms8kHz = …;
constexpr int kFrameLen10ms48kHz = …;
constexpr float kMaxSpeechProbability = …;
constexpr float kNoNoiseDbfs = …;
constexpr float kWithNoiseDbfs = …;
constexpr int kNumExtraFrames = …;
constexpr float GetMaxGainChangePerFrameDb(
float max_gain_change_db_per_second) { … }
AdaptiveDigitalConfig;
constexpr AdaptiveDigitalConfig kDefaultConfig{ … };
struct GainApplierHelper { … };
AdaptiveDigitalGainController::FrameInfo GetFrameInfoToNotAdapt(
const AdaptiveDigitalConfig& config) { … }
TEST(GainController2AdaptiveDigitalGainControllerTest,
GainApplierShouldNotCrash) { … }
TEST(GainController2AdaptiveDigitalGainControllerTest, MaxGainApplied) { … }
TEST(GainController2AdaptiveDigitalGainControllerTest, GainDoesNotChangeFast) { … }
TEST(GainController2AdaptiveDigitalGainControllerTest, GainIsRampedInAFrame) { … }
TEST(GainController2AdaptiveDigitalGainControllerTest, NoiseLimitsGain) { … }
TEST(GainController2AdaptiveDigitalGainControllerTest,
CanHandlePositiveSpeechLevels) { … }
TEST(GainController2AdaptiveDigitalGainControllerTest, AudioLevelLimitsGain) { … }
class AdaptiveDigitalGainControllerParametrizedTest
: public ::testing::TestWithParam<int> { … };
TEST_P(AdaptiveDigitalGainControllerParametrizedTest,
DoNotIncreaseGainWithTooFewSpeechFrames) { … }
TEST_P(AdaptiveDigitalGainControllerParametrizedTest,
IncreaseGainWithEnoughSpeechFrames) { … }
INSTANTIATE_TEST_SUITE_P(…);
}
}