diff --git a/common_audio/smoothing_filter.cc b/common_audio/smoothing_filter.cc index e5ce987786..422eaebd14 100644 --- a/common_audio/smoothing_filter.cc +++ b/common_audio/smoothing_filter.cc @@ -10,6 +10,7 @@ #include "common_audio/smoothing_filter.h" +#include #include #include "rtc_base/checks.h" @@ -71,7 +72,7 @@ bool SmoothingFilterImpl::SetTimeConstantMs(int time_constant_ms) { } 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 @@ void SmoothingFilterImpl::ExtrapolateLastSample(int64_t time_ms) { 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 5f6711e53d..caf9943700 100644 --- a/common_audio/smoothing_filter_unittest.cc +++ b/common_audio/smoothing_filter_unittest.cc @@ -122,7 +122,8 @@ TEST(SmoothingFilterTest, InitTimeEqualsOne) { 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 @@ TEST(SmoothingFilterTest, CannotChangeTimeConstantDuringInitialization) { 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()); }