AGC2: renaming GainCurveApplier to Limiter.
Bug: webrtc:7494 Change-Id: I3dcfb864fd63dbf3f3e7345f8f4cac6c86987e8b Reviewed-on: https://webrtc-review.googlesource.com/c/108581 Reviewed-by: Alex Loiko <aleloi@webrtc.org> Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25436}
This commit is contained in:
committed by
Commit Bot
parent
fcc3981633
commit
746d46bec9
@ -98,10 +98,10 @@ rtc_source_set("fixed_digital") {
|
||||
"fixed_digital_level_estimator.h",
|
||||
"fixed_gain_controller.cc",
|
||||
"fixed_gain_controller.h",
|
||||
"gain_curve_applier.cc",
|
||||
"gain_curve_applier.h",
|
||||
"interpolated_gain_curve.cc",
|
||||
"interpolated_gain_curve.h",
|
||||
"limiter.cc",
|
||||
"limiter.h",
|
||||
]
|
||||
|
||||
configs += [ "..:apm_debug_dump" ]
|
||||
@ -218,11 +218,11 @@ rtc_source_set("fixed_digital_unittests") {
|
||||
"compute_interpolated_gain_curve.h",
|
||||
"fixed_digital_level_estimator_unittest.cc",
|
||||
"fixed_gain_controller_unittest.cc",
|
||||
"gain_curve_applier_unittest.cc",
|
||||
"interpolated_gain_curve_unittest.cc",
|
||||
"limiter_db_gain_curve.cc",
|
||||
"limiter_db_gain_curve.h",
|
||||
"limiter_db_gain_curve_unittest.cc",
|
||||
"limiter_unittest.cc",
|
||||
]
|
||||
deps = [
|
||||
":common",
|
||||
|
||||
@ -35,7 +35,7 @@ FixedGainController::FixedGainController(ApmDataDumper* apm_data_dumper)
|
||||
FixedGainController::FixedGainController(ApmDataDumper* apm_data_dumper,
|
||||
std::string histogram_name_prefix)
|
||||
: apm_data_dumper_(apm_data_dumper),
|
||||
gain_curve_applier_(48000, apm_data_dumper_, histogram_name_prefix) {
|
||||
limiter_(48000, apm_data_dumper_, histogram_name_prefix) {
|
||||
// Do update histograms.xml when adding name prefixes.
|
||||
RTC_DCHECK(histogram_name_prefix == "" || histogram_name_prefix == "Test" ||
|
||||
histogram_name_prefix == "AudioMixer" ||
|
||||
@ -57,12 +57,12 @@ void FixedGainController::SetGain(float gain_to_apply_db) {
|
||||
// Reset the gain curve applier to quickly react on abrupt level changes
|
||||
// caused by large changes of the applied gain.
|
||||
if (previous_applied_gained != gain_to_apply_) {
|
||||
gain_curve_applier_.Reset();
|
||||
limiter_.Reset();
|
||||
}
|
||||
}
|
||||
|
||||
void FixedGainController::SetSampleRate(size_t sample_rate_hz) {
|
||||
gain_curve_applier_.SetSampleRate(sample_rate_hz);
|
||||
limiter_.SetSampleRate(sample_rate_hz);
|
||||
}
|
||||
|
||||
void FixedGainController::Process(AudioFrameView<float> signal) {
|
||||
@ -80,7 +80,7 @@ void FixedGainController::Process(AudioFrameView<float> signal) {
|
||||
}
|
||||
|
||||
// Use the limiter.
|
||||
gain_curve_applier_.Process(signal);
|
||||
limiter_.Process(signal);
|
||||
|
||||
// Dump data for debug.
|
||||
const auto channel_view = signal.channel(0);
|
||||
@ -96,6 +96,6 @@ void FixedGainController::Process(AudioFrameView<float> signal) {
|
||||
}
|
||||
|
||||
float FixedGainController::LastAudioLevel() const {
|
||||
return gain_curve_applier_.LastAudioLevel();
|
||||
return limiter_.LastAudioLevel();
|
||||
}
|
||||
} // namespace webrtc
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
#ifndef MODULES_AUDIO_PROCESSING_AGC2_FIXED_GAIN_CONTROLLER_H_
|
||||
#define MODULES_AUDIO_PROCESSING_AGC2_FIXED_GAIN_CONTROLLER_H_
|
||||
|
||||
#include "modules/audio_processing/agc2/gain_curve_applier.h"
|
||||
#include "modules/audio_processing/agc2/limiter.h"
|
||||
#include "modules/audio_processing/include/audio_frame_view.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -34,7 +34,7 @@ class FixedGainController {
|
||||
private:
|
||||
float gain_to_apply_ = 1.f;
|
||||
ApmDataDumper* apm_data_dumper_ = nullptr;
|
||||
GainCurveApplier gain_curve_applier_;
|
||||
Limiter limiter_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "modules/audio_processing/agc2/gain_curve_applier.h"
|
||||
#include "modules/audio_processing/agc2/limiter.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
@ -83,16 +83,16 @@ void ScaleSamples(rtc::ArrayView<const float> per_sample_scaling_factors,
|
||||
|
||||
} // namespace
|
||||
|
||||
GainCurveApplier::GainCurveApplier(size_t sample_rate_hz,
|
||||
ApmDataDumper* apm_data_dumper,
|
||||
std::string histogram_name)
|
||||
Limiter::Limiter(size_t sample_rate_hz,
|
||||
ApmDataDumper* apm_data_dumper,
|
||||
std::string histogram_name)
|
||||
: interp_gain_curve_(apm_data_dumper, histogram_name),
|
||||
level_estimator_(sample_rate_hz, apm_data_dumper),
|
||||
apm_data_dumper_(apm_data_dumper) {}
|
||||
|
||||
GainCurveApplier::~GainCurveApplier() = default;
|
||||
Limiter::~Limiter() = default;
|
||||
|
||||
void GainCurveApplier::Process(AudioFrameView<float> signal) {
|
||||
void Limiter::Process(AudioFrameView<float> signal) {
|
||||
const auto level_estimate = level_estimator_.ComputeLevel(signal);
|
||||
|
||||
RTC_DCHECK_EQ(level_estimate.size() + 1, scaling_factors_.size());
|
||||
@ -119,22 +119,22 @@ void GainCurveApplier::Process(AudioFrameView<float> signal) {
|
||||
per_sample_scaling_factors_.data());
|
||||
}
|
||||
|
||||
InterpolatedGainCurve::Stats GainCurveApplier::GetGainCurveStats() const {
|
||||
InterpolatedGainCurve::Stats Limiter::GetGainCurveStats() const {
|
||||
return interp_gain_curve_.get_stats();
|
||||
}
|
||||
|
||||
void GainCurveApplier::SetSampleRate(size_t sample_rate_hz) {
|
||||
void Limiter::SetSampleRate(size_t sample_rate_hz) {
|
||||
level_estimator_.SetSampleRate(sample_rate_hz);
|
||||
// Check that per_sample_scaling_factors_ is large enough.
|
||||
RTC_DCHECK_LE(sample_rate_hz,
|
||||
kMaximalNumberOfSamplesPerChannel * 1000 / kFrameDurationMs);
|
||||
}
|
||||
|
||||
void GainCurveApplier::Reset() {
|
||||
void Limiter::Reset() {
|
||||
level_estimator_.Reset();
|
||||
}
|
||||
|
||||
float GainCurveApplier::LastAudioLevel() const {
|
||||
float Limiter::LastAudioLevel() const {
|
||||
return level_estimator_.LastAudioLevel();
|
||||
}
|
||||
|
||||
@ -8,9 +8,10 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef MODULES_AUDIO_PROCESSING_AGC2_GAIN_CURVE_APPLIER_H_
|
||||
#define MODULES_AUDIO_PROCESSING_AGC2_GAIN_CURVE_APPLIER_H_
|
||||
#ifndef MODULES_AUDIO_PROCESSING_AGC2_LIMITER_H_
|
||||
#define MODULES_AUDIO_PROCESSING_AGC2_LIMITER_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "modules/audio_processing/agc2/fixed_digital_level_estimator.h"
|
||||
@ -21,13 +22,14 @@
|
||||
namespace webrtc {
|
||||
class ApmDataDumper;
|
||||
|
||||
class GainCurveApplier {
|
||||
class Limiter {
|
||||
public:
|
||||
GainCurveApplier(size_t sample_rate_hz,
|
||||
ApmDataDumper* apm_data_dumper,
|
||||
std::string histogram_name_prefix);
|
||||
|
||||
~GainCurveApplier();
|
||||
Limiter(size_t sample_rate_hz,
|
||||
ApmDataDumper* apm_data_dumper,
|
||||
std::string histogram_name_prefix);
|
||||
Limiter(const Limiter& limiter) = delete;
|
||||
Limiter& operator=(const Limiter& limiter) = delete;
|
||||
~Limiter();
|
||||
|
||||
void Process(AudioFrameView<float> signal);
|
||||
InterpolatedGainCurve::Stats GetGainCurveStats() const;
|
||||
@ -54,10 +56,8 @@ class GainCurveApplier {
|
||||
std::array<float, kMaximalNumberOfSamplesPerChannel>
|
||||
per_sample_scaling_factors_ = {};
|
||||
float last_scaling_factor_ = 1.f;
|
||||
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(GainCurveApplier);
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // MODULES_AUDIO_PROCESSING_AGC2_GAIN_CURVE_APPLIER_H_
|
||||
#endif // MODULES_AUDIO_PROCESSING_AGC2_LIMITER_H_
|
||||
@ -8,7 +8,7 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "modules/audio_processing/agc2/gain_curve_applier.h"
|
||||
#include "modules/audio_processing/agc2/limiter.h"
|
||||
|
||||
#include "common_audio/include/audio_util.h"
|
||||
#include "modules/audio_processing/agc2/agc2_common.h"
|
||||
@ -19,36 +19,36 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
TEST(GainCurveApplier, GainCurveApplierShouldConstructAndRun) {
|
||||
TEST(Limiter, LimiterShouldConstructAndRun) {
|
||||
const int sample_rate_hz = 48000;
|
||||
ApmDataDumper apm_data_dumper(0);
|
||||
|
||||
GainCurveApplier gain_curve_applier(sample_rate_hz, &apm_data_dumper, "");
|
||||
Limiter limiter(sample_rate_hz, &apm_data_dumper, "");
|
||||
|
||||
VectorFloatFrame vectors_with_float_frame(1, sample_rate_hz / 100,
|
||||
kMaxAbsFloatS16Value);
|
||||
gain_curve_applier.Process(vectors_with_float_frame.float_frame_view());
|
||||
limiter.Process(vectors_with_float_frame.float_frame_view());
|
||||
}
|
||||
|
||||
TEST(GainCurveApplier, OutputVolumeAboveThreshold) {
|
||||
TEST(Limiter, OutputVolumeAboveThreshold) {
|
||||
const int sample_rate_hz = 48000;
|
||||
const float input_level =
|
||||
(kMaxAbsFloatS16Value + DbfsToFloatS16(test::kLimiterMaxInputLevelDbFs)) /
|
||||
2.f;
|
||||
ApmDataDumper apm_data_dumper(0);
|
||||
|
||||
GainCurveApplier gain_curve_applier(sample_rate_hz, &apm_data_dumper, "");
|
||||
Limiter limiter(sample_rate_hz, &apm_data_dumper, "");
|
||||
|
||||
// Give the level estimator time to adapt.
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
VectorFloatFrame vectors_with_float_frame(1, sample_rate_hz / 100,
|
||||
input_level);
|
||||
gain_curve_applier.Process(vectors_with_float_frame.float_frame_view());
|
||||
limiter.Process(vectors_with_float_frame.float_frame_view());
|
||||
}
|
||||
|
||||
VectorFloatFrame vectors_with_float_frame(1, sample_rate_hz / 100,
|
||||
input_level);
|
||||
gain_curve_applier.Process(vectors_with_float_frame.float_frame_view());
|
||||
limiter.Process(vectors_with_float_frame.float_frame_view());
|
||||
rtc::ArrayView<const float> channel =
|
||||
vectors_with_float_frame.float_frame_view().channel(0);
|
||||
|
||||
Reference in New Issue
Block a user