From 199295882d87072d503ac8b24e293be37b4a4d37 Mon Sep 17 00:00:00 2001 From: Oleh Prypin Date: Tue, 23 Apr 2019 08:50:04 +0200 Subject: [PATCH] Qualify cmath function calls Use the C++-style stdlib headers, add `std::` prefix, in order to avoid implicit casts to double. Bug: None Change-Id: I78d9caaee715be341d2480c6d5e769068966d577 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/133625 Reviewed-by: Karl Wiberg Commit-Queue: Oleh Prypin Cr-Commit-Position: refs/heads/master@{#27905} --- modules/audio_processing/agc2/vad_with_level.cc | 2 +- modules/audio_processing/rms_level.cc | 4 ++-- .../transient/transient_detector.cc | 15 ++++++++------- .../transient/transient_suppressor.cc | 8 ++++---- .../rtp_rtcp/source/receive_statistics_impl.cc | 4 ++-- video/send_statistics_proxy.cc | 2 +- 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/modules/audio_processing/agc2/vad_with_level.cc b/modules/audio_processing/agc2/vad_with_level.cc index 52970dfe67..d4ec2ced98 100644 --- a/modules/audio_processing/agc2/vad_with_level.cc +++ b/modules/audio_processing/agc2/vad_with_level.cc @@ -34,7 +34,7 @@ float ProcessForRms(AudioFrameView frame) { for (const auto& x : frame.channel(0)) { rms += x * x; } - return sqrt(rms / frame.samples_per_channel()); + return std::sqrt(rms / frame.samples_per_channel()); } } // namespace diff --git a/modules/audio_processing/rms_level.cc b/modules/audio_processing/rms_level.cc index 727ecfc9fe..63280d1e67 100644 --- a/modules/audio_processing/rms_level.cc +++ b/modules/audio_processing/rms_level.cc @@ -10,8 +10,8 @@ #include "modules/audio_processing/rms_level.h" -#include #include +#include #include #include "rtc_base/checks.h" @@ -36,7 +36,7 @@ int ComputeRms(float mean_square) { const float mean_square_norm = mean_square / kMaxSquaredLevel; RTC_DCHECK_GT(mean_square_norm, kMinLevel); // 20log_10(x^0.5) = 10log_10(x) - const float rms = 10.f * log10(mean_square_norm); + const float rms = 10.f * std::log10(mean_square_norm); RTC_DCHECK_LE(rms, 0.f); RTC_DCHECK_GT(rms, -RmsLevel::kMinLevelDb); // Return the negated value. diff --git a/modules/audio_processing/transient/transient_detector.cc b/modules/audio_processing/transient/transient_detector.cc index 8997d4c092..b328a0e630 100644 --- a/modules/audio_processing/transient/transient_detector.cc +++ b/modules/audio_processing/transient/transient_detector.cc @@ -11,9 +11,9 @@ #include "modules/audio_processing/transient/transient_detector.h" #include -#include #include #include +#include #include "modules/audio_processing/transient/common.h" #include "modules/audio_processing/transient/daubechies_8_wavelet_coeffs.h" @@ -125,9 +125,9 @@ float TransientDetector::Detect(const float* data, const float kVerticalScaling = 0.5f; const float kVerticalShift = 1.f; - result = - (cos(result * horizontal_scaling + kHorizontalShift) + kVerticalShift) * - kVerticalScaling; + result = (std::cos(result * horizontal_scaling + kHorizontalShift) + + kVerticalShift) * + kVerticalScaling; result *= result; } @@ -161,9 +161,10 @@ float TransientDetector::ReferenceDetectionValue(const float* data, return 1.f; } RTC_DCHECK_NE(0, reference_energy_); - float result = 1.f / (1.f + exp(kReferenceNonLinearity * - (kEnergyRatioThreshold - - reference_energy / reference_energy_))); + float result = + 1.f / (1.f + std::exp(kReferenceNonLinearity * + (kEnergyRatioThreshold - + reference_energy / reference_energy_))); reference_energy_ = kMemory * reference_energy_ + (1.f - kMemory) * reference_energy; diff --git a/modules/audio_processing/transient/transient_suppressor.cc b/modules/audio_processing/transient/transient_suppressor.cc index 1a5ed5669f..58d0df09fa 100644 --- a/modules/audio_processing/transient/transient_suppressor.cc +++ b/modules/audio_processing/transient/transient_suppressor.cc @@ -10,7 +10,6 @@ #include "modules/audio_processing/transient/transient_suppressor.h" -#include #include #include #include @@ -139,9 +138,9 @@ int TransientSuppressor::Initialize(int sample_rate_hz, for (size_t i = 0; i < complex_analysis_length_; ++i) { mean_factor_[i] = kFactorHeight / - (1.f + exp(kLowSlope * static_cast(i - kMinVoiceBin))) + + (1.f + std::exp(kLowSlope * static_cast(i - kMinVoiceBin))) + kFactorHeight / - (1.f + exp(kHighSlope * static_cast(kMaxVoiceBin - i))); + (1.f + std::exp(kHighSlope * static_cast(kMaxVoiceBin - i))); } detector_smoothed_ = 0.f; keypress_counter_ = 0; @@ -352,7 +351,8 @@ void TransientSuppressor::UpdateBuffers(float* data) { // If a restoration takes place, the |magnitudes_| are updated to the new value. void TransientSuppressor::HardRestoration(float* spectral_mean) { const float detector_result = - 1.f - pow(1.f - detector_smoothed_, using_reference_ ? 200.f : 50.f); + 1.f - + std::pow(1.f - detector_smoothed_, using_reference_ ? 200.f : 50.f); // To restore, we get the peaks in the spectrum. If higher than the previous // spectral mean we adjust them. for (size_t i = 0; i < complex_analysis_length_; ++i) { diff --git a/modules/rtp_rtcp/source/receive_statistics_impl.cc b/modules/rtp_rtcp/source/receive_statistics_impl.cc index b696daacf6..a224b1e010 100644 --- a/modules/rtp_rtcp/source/receive_statistics_impl.cc +++ b/modules/rtp_rtcp/source/receive_statistics_impl.cc @@ -10,7 +10,7 @@ #include "modules/rtp_rtcp/source/receive_statistics_impl.h" -#include +#include #include #include #include @@ -329,7 +329,7 @@ bool StreamStatisticianImpl::IsRetransmitOfOldPacket( int64_t max_delay_ms = 0; // Jitter standard deviation in samples. - float jitter_std = sqrt(static_cast(jitter_q4_ >> 4)); + float jitter_std = std::sqrt(static_cast(jitter_q4_ >> 4)); // 2 times the standard deviation => 95% confidence. // And transform to milliseconds by dividing by the frequency in kHz. diff --git a/video/send_statistics_proxy.cc b/video/send_statistics_proxy.cc index 0b165374e9..638bb64f63 100644 --- a/video/send_statistics_proxy.cc +++ b/video/send_statistics_proxy.cc @@ -678,7 +678,7 @@ void SendStatisticsProxy::OnEncodedFrameTimeMeasured(int encode_time_ms, rtc::CritScope lock(&crit_); uma_container_->encode_time_counter_.Add(encode_time_ms); encode_time_.Apply(1.0f, encode_time_ms); - stats_.avg_encode_time_ms = round(encode_time_.filtered()); + stats_.avg_encode_time_ms = std::round(encode_time_.filtered()); stats_.total_encode_time_ms += encode_time_ms; stats_.encode_usage_percent = encode_usage_percent; }