AGC2 size_t -> int
Bug: webrtc:7494
Change-Id: I5ecf242e83b509931c1764a37339d11506c5afc6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/213341
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33600}
diff --git a/modules/audio_processing/agc2/agc2_common.h b/modules/audio_processing/agc2/agc2_common.h
index 5d01100..594a37e 100644
--- a/modules/audio_processing/agc2/agc2_common.h
+++ b/modules/audio_processing/agc2/agc2_common.h
@@ -19,9 +19,9 @@
constexpr float kMaxFloatS16Value = 32767.f;
constexpr float kMaxAbsFloatS16Value = 32768.0f;
-constexpr size_t kFrameDurationMs = 10;
-constexpr size_t kSubFramesInFrame = 20;
-constexpr size_t kMaximalNumberOfSamplesPerChannel = 480;
+constexpr int kFrameDurationMs = 10;
+constexpr int kSubFramesInFrame = 20;
+constexpr int kMaximalNumberOfSamplesPerChannel = 480;
constexpr float kAttackFilterConstant = 0.f;
@@ -38,7 +38,7 @@
constexpr float kVadConfidenceThreshold = 0.9f;
// The amount of 'memory' of the Level Estimator. Decides leak factors.
-constexpr size_t kFullBufferSizeMs = 1200;
+constexpr int kFullBufferSizeMs = 1200;
constexpr float kFullBufferLeakFactor = 1.f - 1.f / kFullBufferSizeMs;
constexpr float kInitialSpeechLevelEstimateDbfs = -30.f;
@@ -51,12 +51,12 @@
constexpr float kDefaultInitialSaturationMarginDb = 20.f;
constexpr float kDefaultExtraSaturationMarginDb = 2.f;
-constexpr size_t kPeakEnveloperSuperFrameLengthMs = 400;
+constexpr int kPeakEnveloperSuperFrameLengthMs = 400;
static_assert(kFullBufferSizeMs % kPeakEnveloperSuperFrameLengthMs == 0,
"Full buffer size should be a multiple of super frame length for "
"optimal Saturation Protector performance.");
-constexpr size_t kPeakEnveloperBufferSize =
+constexpr int kPeakEnveloperBufferSize =
kFullBufferSizeMs / kPeakEnveloperSuperFrameLengthMs + 1;
// This value is 10 ** (-1/20 * frame_size_ms / satproc_attack_ms),
@@ -76,9 +76,9 @@
// Number of interpolation points for each region of the limiter.
// These values have been tuned to limit the interpolated gain curve error given
// the limiter parameters and allowing a maximum error of +/- 32768^-1.
-constexpr size_t kInterpolatedGainCurveKneePoints = 22;
-constexpr size_t kInterpolatedGainCurveBeyondKneePoints = 10;
-constexpr size_t kInterpolatedGainCurveTotalPoints =
+constexpr int kInterpolatedGainCurveKneePoints = 22;
+constexpr int kInterpolatedGainCurveBeyondKneePoints = 10;
+constexpr int kInterpolatedGainCurveTotalPoints =
kInterpolatedGainCurveKneePoints + kInterpolatedGainCurveBeyondKneePoints;
} // namespace webrtc
diff --git a/modules/audio_processing/agc2/fixed_digital_level_estimator.cc b/modules/audio_processing/agc2/fixed_digital_level_estimator.cc
index 971f4f6..9636136 100644
--- a/modules/audio_processing/agc2/fixed_digital_level_estimator.cc
+++ b/modules/audio_processing/agc2/fixed_digital_level_estimator.cc
@@ -25,7 +25,7 @@
} // namespace
FixedDigitalLevelEstimator::FixedDigitalLevelEstimator(
- size_t sample_rate_hz,
+ int sample_rate_hz,
ApmDataDumper* apm_data_dumper)
: apm_data_dumper_(apm_data_dumper),
filter_state_level_(kInitialFilterStateLevel) {
@@ -52,8 +52,8 @@
for (size_t channel_idx = 0; channel_idx < float_frame.num_channels();
++channel_idx) {
const auto channel = float_frame.channel(channel_idx);
- for (size_t sub_frame = 0; sub_frame < kSubFramesInFrame; ++sub_frame) {
- for (size_t sample_in_sub_frame = 0;
+ for (int sub_frame = 0; sub_frame < kSubFramesInFrame; ++sub_frame) {
+ for (int sample_in_sub_frame = 0;
sample_in_sub_frame < samples_in_sub_frame_; ++sample_in_sub_frame) {
envelope[sub_frame] =
std::max(envelope[sub_frame],
@@ -66,14 +66,14 @@
// Make sure envelope increases happen one step earlier so that the
// corresponding *gain decrease* doesn't miss a sudden signal
// increase due to interpolation.
- for (size_t sub_frame = 0; sub_frame < kSubFramesInFrame - 1; ++sub_frame) {
+ for (int sub_frame = 0; sub_frame < kSubFramesInFrame - 1; ++sub_frame) {
if (envelope[sub_frame] < envelope[sub_frame + 1]) {
envelope[sub_frame] = envelope[sub_frame + 1];
}
}
// Add attack / decay smoothing.
- for (size_t sub_frame = 0; sub_frame < kSubFramesInFrame; ++sub_frame) {
+ for (int sub_frame = 0; sub_frame < kSubFramesInFrame; ++sub_frame) {
const float envelope_value = envelope[sub_frame];
if (envelope_value > filter_state_level_) {
envelope[sub_frame] = envelope_value * (1 - kAttackFilterConstant) +
@@ -97,9 +97,9 @@
return envelope;
}
-void FixedDigitalLevelEstimator::SetSampleRate(size_t sample_rate_hz) {
- samples_in_frame_ = rtc::CheckedDivExact(sample_rate_hz * kFrameDurationMs,
- static_cast<size_t>(1000));
+void FixedDigitalLevelEstimator::SetSampleRate(int sample_rate_hz) {
+ samples_in_frame_ =
+ rtc::CheckedDivExact(sample_rate_hz * kFrameDurationMs, 1000);
samples_in_sub_frame_ =
rtc::CheckedDivExact(samples_in_frame_, kSubFramesInFrame);
CheckParameterCombination();
diff --git a/modules/audio_processing/agc2/fixed_digital_level_estimator.h b/modules/audio_processing/agc2/fixed_digital_level_estimator.h
index aa84a2e..d96aeda 100644
--- a/modules/audio_processing/agc2/fixed_digital_level_estimator.h
+++ b/modules/audio_processing/agc2/fixed_digital_level_estimator.h
@@ -31,7 +31,7 @@
// kSubFramesInSample. For kFrameDurationMs=10 and
// kSubFramesInSample=20, this means that sample_rate_hz has to be
// divisible by 2000.
- FixedDigitalLevelEstimator(size_t sample_rate_hz,
+ FixedDigitalLevelEstimator(int sample_rate_hz,
ApmDataDumper* apm_data_dumper);
// The input is assumed to be in FloatS16 format. Scaled input will
@@ -43,7 +43,7 @@
// Rate may be changed at any time (but not concurrently) from the
// value passed to the constructor. The class is not thread safe.
- void SetSampleRate(size_t sample_rate_hz);
+ void SetSampleRate(int sample_rate_hz);
// Resets the level estimator internal state.
void Reset();
@@ -55,8 +55,8 @@
ApmDataDumper* const apm_data_dumper_ = nullptr;
float filter_state_level_;
- size_t samples_in_frame_;
- size_t samples_in_sub_frame_;
+ int samples_in_frame_;
+ int samples_in_sub_frame_;
RTC_DISALLOW_COPY_AND_ASSIGN(FixedDigitalLevelEstimator);
};