Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Unified Diff: webrtc/modules/audio_coding/neteq/background_noise.cc

Issue 2722533002: Fixing an overflow issue in NetEq::BackgroundNoise (Closed)
Patch Set: Alternative solution Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/audio_coding/neteq/background_noise.cc
diff --git a/webrtc/modules/audio_coding/neteq/background_noise.cc b/webrtc/modules/audio_coding/neteq/background_noise.cc
index 9cfd6cb40ed7c25951ec118e78e431a6df56dafe..cf77ec57e9f4a98f5f321e38106c0bb1eda6d34b 100644
--- a/webrtc/modules/audio_coding/neteq/background_noise.cc
+++ b/webrtc/modules/audio_coding/neteq/background_noise.cc
@@ -101,10 +101,10 @@ void BackgroundNoise::Update(const AudioMultiVector& input,
// Check spectral flatness.
// Comparing the residual variance with the input signal variance tells
// if the spectrum is flat or not.
- // If 20 * residual_energy >= sample_energy << 6, the spectrum is flat
+ // If 5 * residual_energy >= 16 * sample_energy, the spectrum is flat
// enough. Also ensure that the energy is non-zero.
- if ((residual_energy * 20 >= (sample_energy << 6)) &&
- (sample_energy > 0)) {
+ if ((sample_energy > 0) &&
+ (int64_t{5} * residual_energy >= int64_t{16} * sample_energy)) {
kwiberg-webrtc 2017/02/28 12:19:58 Optionally, remove the redundant parentheses.
// Spectrum is flat enough; save filter parameters.
// |temp_signal| + |kVecLen| - |kMaxLpcOrder| points at the first of the
// |kMaxLpcOrder| samples in the residual signal, which will form the
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698