chromium/third_party/webrtc/modules/audio_processing/agc2/clipping_predictor_unittest.cc

/*
 *  Copyright (c) 2021 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/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 =;

// Threshold in dB corresponding to a signal with an amplitude equal to 99% of
// the dynamic range - i.e., computed as `20*log10(0.99)`.
constexpr float kClippingThresholdDb =;

void CallAnalyze(int num_calls,
                 const AudioFrameView<const float>& frame,
                 ClippingPredictor& predictor) {}

// Creates and analyzes an audio frame with a non-zero (approx. 4.15dB) crest
// factor.
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) {}

// Creates and analyzes an audio frame with a zero crest factor.
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) {}

}  // namespace
}  // namespace webrtc