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

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

Issue 2562423002: Fix for negative shift value in NetEq. (Closed)
Patch Set: Created 4 years 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 } else { 91 } else {
92 energy = 0; 92 energy = 0;
93 } 93 }
94 94
95 int mute_factor; 95 int mute_factor;
96 if ((energy != 0) && 96 if ((energy != 0) &&
97 (energy > background_noise_.Energy(channel_ix))) { 97 (energy > background_noise_.Energy(channel_ix))) {
98 // Normalize new frame energy to 15 bits. 98 // Normalize new frame energy to 15 bits.
99 scaling = WebRtcSpl_NormW32(energy) - 16; 99 scaling = WebRtcSpl_NormW32(energy) - 16;
100 // We want background_noise_.energy() / energy in Q14. 100 // We want background_noise_.energy() / energy in Q14.
101 int32_t bgn_energy = 101 int32_t bgn_energy = WEBRTC_SPL_SHIFT_W32(
102 background_noise_.Energy(channel_ix) << (scaling+14); 102 background_noise_.Energy(channel_ix), scaling + 14);
103 int16_t energy_scaled = 103 int16_t energy_scaled =
104 static_cast<int16_t>(WEBRTC_SPL_SHIFT_W32(energy, scaling)); 104 static_cast<int16_t>(WEBRTC_SPL_SHIFT_W32(energy, scaling));
105 int32_t ratio = WebRtcSpl_DivW32W16(bgn_energy, energy_scaled); 105 int32_t ratio = WebRtcSpl_DivW32W16(bgn_energy, energy_scaled);
106 mute_factor = WebRtcSpl_SqrtFloor(ratio << 14); 106 mute_factor = WebRtcSpl_SqrtFloor(ratio << 14);
107 } else { 107 } else {
108 mute_factor = 16384; // 1.0 in Q14. 108 mute_factor = 16384; // 1.0 in Q14.
109 } 109 }
110 if (mute_factor > external_mute_factor_array[channel_ix]) { 110 if (mute_factor > external_mute_factor_array[channel_ix]) {
111 external_mute_factor_array[channel_ix] = 111 external_mute_factor_array[channel_ix] =
112 static_cast<int16_t>(std::min(mute_factor, 16384)); 112 static_cast<int16_t>(std::min(mute_factor, 16384));
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 external_mute_factor_array[channel_ix] = static_cast<int16_t>(std::min( 202 external_mute_factor_array[channel_ix] = static_cast<int16_t>(std::min(
203 16384, external_mute_factor_array[channel_ix] + increment)); 203 16384, external_mute_factor_array[channel_ix] + increment));
204 } 204 }
205 } 205 }
206 } 206 }
207 207
208 return static_cast<int>(length); 208 return static_cast<int>(length);
209 } 209 }
210 210
211 } // namespace webrtc 211 } // 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