diff options
author | Mirko Bonadei <mbonadei@webrtc.org> | 2019-03-25 09:31:06 +0100 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-03-25 09:28:23 +0000 |
commit | b00dec57fe96d2131256bbe5fab13d232eb97acf (patch) | |
tree | 76a3d1c8a90bff90e42f69af62d408c1a21dfc1e /common_audio | |
parent | 2cdc6117b0c3015a564443af87bf751d224bb370 (diff) | |
download | webrtc-b00dec57fe96d2131256bbe5fab13d232eb97acf.tar.gz |
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}
Diffstat (limited to 'common_audio')
-rw-r--r-- | common_audio/smoothing_filter.cc | 13 | ||||
-rw-r--r-- | common_audio/smoothing_filter_unittest.cc | 11 |
2 files changed, 14 insertions, 10 deletions
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 <math.h> #include <cmath> #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()); } |