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

Side by Side 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, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 fiter_output, lpc_coefficients, 94 fiter_output, lpc_coefficients,
95 kMaxLpcOrder + 1, kResidualLength); 95 kMaxLpcOrder + 1, kResidualLength);
96 int32_t residual_energy = WebRtcSpl_DotProductWithScale(fiter_output, 96 int32_t residual_energy = WebRtcSpl_DotProductWithScale(fiter_output,
97 fiter_output, 97 fiter_output,
98 kResidualLength, 98 kResidualLength,
99 0); 99 0);
100 100
101 // Check spectral flatness. 101 // Check spectral flatness.
102 // Comparing the residual variance with the input signal variance tells 102 // Comparing the residual variance with the input signal variance tells
103 // if the spectrum is flat or not. 103 // if the spectrum is flat or not.
104 // If 20 * residual_energy >= sample_energy << 6, the spectrum is flat 104 // If 5 * residual_energy >= 16 * sample_energy, the spectrum is flat
105 // enough. Also ensure that the energy is non-zero. 105 // enough. Also ensure that the energy is non-zero.
106 if ((residual_energy * 20 >= (sample_energy << 6)) && 106 if ((sample_energy > 0) &&
107 (sample_energy > 0)) { 107 (int64_t{5} * residual_energy >= int64_t{16} * sample_energy)) {
kwiberg-webrtc 2017/02/28 12:19:58 Optionally, remove the redundant parentheses.
108 // Spectrum is flat enough; save filter parameters. 108 // Spectrum is flat enough; save filter parameters.
109 // |temp_signal| + |kVecLen| - |kMaxLpcOrder| points at the first of the 109 // |temp_signal| + |kVecLen| - |kMaxLpcOrder| points at the first of the
110 // |kMaxLpcOrder| samples in the residual signal, which will form the 110 // |kMaxLpcOrder| samples in the residual signal, which will form the
111 // filter state for the next noise generation. 111 // filter state for the next noise generation.
112 SaveParameters(channel_ix, lpc_coefficients, 112 SaveParameters(channel_ix, lpc_coefficients,
113 temp_signal + kVecLen - kMaxLpcOrder, sample_energy, 113 temp_signal + kVecLen - kMaxLpcOrder, sample_energy,
114 residual_energy); 114 residual_energy);
115 } 115 }
116 } else { 116 } else {
117 // Will only happen if post-decode VAD is disabled and |sample_energy| is 117 // Will only happen if post-decode VAD is disabled and |sample_energy| is
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 // Add 13 to the |scale_shift_|, since the random numbers table is in 246 // Add 13 to the |scale_shift_|, since the random numbers table is in
247 // Q13. 247 // Q13.
248 // TODO(hlundin): Move the "13" to where the |scale_shift_| is used? 248 // TODO(hlundin): Move the "13" to where the |scale_shift_| is used?
249 parameters.scale_shift = 249 parameters.scale_shift =
250 static_cast<int16_t>(13 + ((kLogResidualLength + norm_shift) / 2)); 250 static_cast<int16_t>(13 + ((kLogResidualLength + norm_shift) / 2));
251 251
252 initialized_ = true; 252 initialized_ = true;
253 } 253 }
254 254
255 } // namespace webrtc 255 } // namespace webrtc
OLDNEW
« 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