#include "modules/audio_processing/agc2/clipping_predictor.h"
#include <cstdint>
#include <limits>
#include <tuple>
#include "rtc_base/checks.h"
#include "test/gmock.h"
#include "test/gtest.h"
namespace webrtc {
namespace {
Eq;
Optional;
ClippingPredictorConfig;
ClippingPredictorMode;
constexpr int kSampleRateHz = …;
constexpr int kNumChannels = …;
constexpr int kSamplesPerChannel = …;
constexpr int kMaxMicLevel = …;
constexpr int kMinMicLevel = …;
constexpr int kDefaultClippedLevelStep = …;
constexpr float kMaxSampleS16 = …;
constexpr float kClippingThresholdDb = …;
void CallAnalyze(int num_calls,
const AudioFrameView<const float>& frame,
ClippingPredictor& predictor) { … }
void AnalyzeNonZeroCrestFactorAudio(int num_calls,
int num_channels,
float peak_ratio,
ClippingPredictor& predictor) { … }
void CheckChannelEstimatesWithValue(int num_channels,
int level,
int default_step,
int min_mic_level,
int max_mic_level,
const ClippingPredictor& predictor,
int expected) { … }
void CheckChannelEstimatesWithoutValue(int num_channels,
int level,
int default_step,
int min_mic_level,
int max_mic_level,
const ClippingPredictor& predictor) { … }
void AnalyzeZeroCrestFactorAudio(int num_calls,
int num_channels,
float peak_ratio,
ClippingPredictor& predictor) { … }
TEST(ClippingPeakPredictorTest, NoPredictorCreated) { … }
TEST(ClippingPeakPredictorTest, ClippingEventPredictionCreated) { … }
TEST(ClippingPeakPredictorTest, AdaptiveStepClippingPeakPredictionCreated) { … }
TEST(ClippingPeakPredictorTest, FixedStepClippingPeakPredictionCreated) { … }
class ClippingPredictorParameterization
: public ::testing::TestWithParam<std::tuple<int, int, int, int>> { … };
TEST_P(ClippingPredictorParameterization,
CheckClippingEventPredictorEstimateAfterCrestFactorDrop) { … }
TEST_P(ClippingPredictorParameterization,
CheckClippingEventPredictorNoEstimateAfterConstantCrestFactor) { … }
TEST_P(ClippingPredictorParameterization,
CheckClippingPeakPredictorEstimateAfterHighCrestFactor) { … }
TEST_P(ClippingPredictorParameterization,
CheckClippingPeakPredictorNoEstimateAfterLowCrestFactor) { … }
INSTANTIATE_TEST_SUITE_P(…);
class ClippingEventPredictorParameterization
: public ::testing::TestWithParam<std::tuple<float, float>> { … };
TEST_P(ClippingEventPredictorParameterization,
CheckEstimateAfterCrestFactorDrop) { … }
INSTANTIATE_TEST_SUITE_P(…);
class ClippingPredictorModeParameterization
: public ::testing::TestWithParam<ClippingPredictorMode> { … };
TEST_P(ClippingPredictorModeParameterization,
CheckEstimateAfterHighCrestFactorWithNoClippingMargin) { … }
TEST_P(ClippingPredictorModeParameterization,
CheckEstimateAfterHighCrestFactorWithClippingMargin) { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST(ClippingEventPredictorTest, CheckEstimateAfterReset) { … }
TEST(ClippingPeakPredictorTest, CheckNoEstimateAfterReset) { … }
TEST(ClippingPeakPredictorTest, CheckAdaptiveStepEstimate) { … }
TEST(ClippingPeakPredictorTest, CheckFixedStepEstimate) { … }
}
}