Qualify cmath function calls.
Bug: webrtc:10433
Change-Id: I5c31010a99be8ae93b3a85c3bce09292268007cd
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/128612
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Minyue Li <minyue@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27262}
diff --git a/common_audio/smoothing_filter.cc b/common_audio/smoothing_filter.cc
index e5ce987..422eaeb 100644
--- a/common_audio/smoothing_filter.cc
+++ b/common_audio/smoothing_filter.cc
@@ -10,6 +10,7 @@
#include "common_audio/smoothing_filter.h"
+#include <math.h>
#include <cmath>
#include "rtc_base/checks.h"
@@ -71,7 +72,7 @@
}
void SmoothingFilterImpl::UpdateAlpha(int time_constant_ms) {
- alpha_ = time_constant_ms == 0 ? 0.0f : exp(-1.0f / time_constant_ms);
+ alpha_ = time_constant_ms == 0 ? 0.0f : std::exp(-1.0f / time_constant_ms);
}
void SmoothingFilterImpl::ExtrapolateLastSample(int64_t time_ms) {
@@ -93,12 +94,12 @@
multiplier = 0.0f;
} else if (init_time_ms_ == 1) {
// This means |init_factor_| = 1.
- multiplier = exp(last_state_time_ms_ - time_ms);
+ multiplier = std::exp(last_state_time_ms_ - time_ms);
} else {
- multiplier =
- exp(-(powf(init_factor_, last_state_time_ms_ - *init_end_time_ms_) -
- powf(init_factor_, time_ms - *init_end_time_ms_)) /
- init_const_);
+ multiplier = std::exp(
+ -(powf(init_factor_, last_state_time_ms_ - *init_end_time_ms_) -
+ powf(init_factor_, time_ms - *init_end_time_ms_)) /
+ init_const_);
}
} else {
if (last_state_time_ms_ < *init_end_time_ms_) {
diff --git a/common_audio/smoothing_filter_unittest.cc b/common_audio/smoothing_filter_unittest.cc
index 5f6711e..caf9943 100644
--- a/common_audio/smoothing_filter_unittest.cc
+++ b/common_audio/smoothing_filter_unittest.cc
@@ -122,7 +122,8 @@
constexpr int kInitTimeMs = 1;
SmoothingFilterStates states(kInitTimeMs);
CheckOutput(&states, 1.0f, 1, 1.0f);
- CheckOutput(&states, 0.5f, 1, 1.0f * exp(-1.0f) + (1.0f - exp(-1.0f)) * 0.5f);
+ CheckOutput(&states, 0.5f, 1,
+ 1.0f * std::exp(-1.0f) + (1.0f - std::exp(-1.0f)) * 0.5f);
}
TEST(SmoothingFilterTest, GetAverageOutputsEmptyBeforeFirstSample) {
@@ -144,17 +145,19 @@
states.smoothing_filter.AddSample(0.0);
EXPECT_FALSE(states.smoothing_filter.SetTimeConstantMs(kInitTimeMs * 2));
- EXPECT_NE(exp(-1.0f / (kInitTimeMs * 2)), states.smoothing_filter.alpha());
+ EXPECT_NE(std::exp(-1.0f / (kInitTimeMs * 2)),
+ states.smoothing_filter.alpha());
states.fake_clock.AdvanceTime(TimeDelta::ms(1));
states.smoothing_filter.AddSample(0.0);
// When initialization finishes, the time constant should be come
// |kInitTimeConstantMs|.
- EXPECT_FLOAT_EQ(exp(-1.0f / kInitTimeMs), states.smoothing_filter.alpha());
+ EXPECT_FLOAT_EQ(std::exp(-1.0f / kInitTimeMs),
+ states.smoothing_filter.alpha());
// After initialization, |SetTimeConstantMs| takes effect.
EXPECT_TRUE(states.smoothing_filter.SetTimeConstantMs(kInitTimeMs * 2));
- EXPECT_FLOAT_EQ(exp(-1.0f / (kInitTimeMs * 2)),
+ EXPECT_FLOAT_EQ(std::exp(-1.0f / (kInitTimeMs * 2)),
states.smoothing_filter.alpha());
}