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

Side by Side Diff: webrtc/modules/audio_coding/neteq/background_noise.cc

Issue 1315833003: NetEq: Allow negative shift in BackgroundNoise::SaveParameters (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 4 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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 // Never get under 1.0 in average sample energy. 239 // Never get under 1.0 in average sample energy.
240 parameters.energy = std::max(sample_energy, 1); 240 parameters.energy = std::max(sample_energy, 1);
241 parameters.energy_update_threshold = parameters.energy; 241 parameters.energy_update_threshold = parameters.energy;
242 parameters.low_energy_update_threshold = 0; 242 parameters.low_energy_update_threshold = 0;
243 243
244 // Normalize residual_energy to 29 or 30 bits before sqrt. 244 // Normalize residual_energy to 29 or 30 bits before sqrt.
245 int16_t norm_shift = WebRtcSpl_NormW32(residual_energy) - 1; 245 int16_t norm_shift = WebRtcSpl_NormW32(residual_energy) - 1;
246 if (norm_shift & 0x1) { 246 if (norm_shift & 0x1) {
247 norm_shift -= 1; // Even number of shifts required. 247 norm_shift -= 1; // Even number of shifts required.
248 } 248 }
249 assert(norm_shift >= 0); // Should always be positive. 249 residual_energy = WEBRTC_SPL_SHIFT_W32(residual_energy, norm_shift);
250 residual_energy = residual_energy << norm_shift;
251 250
252 // Calculate scale and shift factor. 251 // Calculate scale and shift factor.
253 parameters.scale = static_cast<int16_t>(WebRtcSpl_SqrtFloor(residual_energy)); 252 parameters.scale = static_cast<int16_t>(WebRtcSpl_SqrtFloor(residual_energy));
254 // Add 13 to the |scale_shift_|, since the random numbers table is in 253 // Add 13 to the |scale_shift_|, since the random numbers table is in
255 // Q13. 254 // Q13.
256 // TODO(hlundin): Move the "13" to where the |scale_shift_| is used? 255 // TODO(hlundin): Move the "13" to where the |scale_shift_| is used?
257 parameters.scale_shift = 256 parameters.scale_shift =
258 static_cast<int16_t>(13 + ((kLogResidualLength + norm_shift) / 2)); 257 static_cast<int16_t>(13 + ((kLogResidualLength + norm_shift) / 2));
259 258
260 initialized_ = true; 259 initialized_ = true;
261 } 260 }
262 261
263 } // namespace webrtc 262 } // 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