diff --git a/modules/audio_coding/neteq/buffer_level_filter.cc b/modules/audio_coding/neteq/buffer_level_filter.cc index 5d503e9918..8901c01f77 100644 --- a/modules/audio_coding/neteq/buffer_level_filter.cc +++ b/modules/audio_coding/neteq/buffer_level_filter.cc @@ -35,14 +35,13 @@ void BufferLevelFilter::Update(size_t buffer_size_samples, // |level_factor_| and |filtered_current_level_| are in Q8. // |buffer_size_samples| is in Q0. const int64_t filtered_current_level = - ((level_factor_ * int64_t{filtered_current_level_}) >> 8) + - ((256 - level_factor_) * rtc::dchecked_cast(buffer_size_samples)); + (level_factor_ * int64_t{filtered_current_level_} >> 8) + + (256 - level_factor_) * rtc::dchecked_cast(buffer_size_samples); // Account for time-scale operations (accelerate and pre-emptive expand) and // make sure that the filtered value remains non-negative. filtered_current_level_ = rtc::saturated_cast(std::max( - 0, - filtered_current_level - (int64_t{time_stretched_samples} * (1 << 8)))); + 0, filtered_current_level - int64_t{time_stretched_samples} * (1 << 8))); } void BufferLevelFilter::SetFilteredBufferLevel(int buffer_size_samples) { diff --git a/modules/audio_coding/neteq/buffer_level_filter.h b/modules/audio_coding/neteq/buffer_level_filter.h index 89fcaf4612..218a142648 100644 --- a/modules/audio_coding/neteq/buffer_level_filter.h +++ b/modules/audio_coding/neteq/buffer_level_filter.h @@ -12,6 +12,7 @@ #define MODULES_AUDIO_CODING_NETEQ_BUFFER_LEVEL_FILTER_H_ #include +#include #include "rtc_base/constructor_magic.h" @@ -39,7 +40,7 @@ class BufferLevelFilter { // Returns filtered current level in number of samples. virtual int filtered_current_level() const { // Round to nearest whole sample. - return (filtered_current_level_ + (1 << 7)) >> 8; + return (int64_t{filtered_current_level_} + (1 << 7)) >> 8; } private: