OLD | NEW |
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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 } | 92 } |
93 | 93 |
94 int mute_factor; | 94 int mute_factor; |
95 if ((energy != 0) && | 95 if ((energy != 0) && |
96 (energy > background_noise_.Energy(channel_ix))) { | 96 (energy > background_noise_.Energy(channel_ix))) { |
97 // Normalize new frame energy to 15 bits. | 97 // Normalize new frame energy to 15 bits. |
98 scaling = WebRtcSpl_NormW32(energy) - 16; | 98 scaling = WebRtcSpl_NormW32(energy) - 16; |
99 // We want background_noise_.energy() / energy in Q14. | 99 // We want background_noise_.energy() / energy in Q14. |
100 int32_t bgn_energy = | 100 int32_t bgn_energy = |
101 background_noise_.Energy(channel_ix) << (scaling+14); | 101 background_noise_.Energy(channel_ix) << (scaling+14); |
102 int16_t energy_scaled = static_cast<int16_t>(energy << scaling); | 102 int16_t energy_scaled = |
| 103 static_cast<int16_t>(WEBRTC_SPL_SHIFT_W32(energy, scaling)); |
103 int32_t ratio = WebRtcSpl_DivW32W16(bgn_energy, energy_scaled); | 104 int32_t ratio = WebRtcSpl_DivW32W16(bgn_energy, energy_scaled); |
104 mute_factor = WebRtcSpl_SqrtFloor(ratio << 14); | 105 mute_factor = WebRtcSpl_SqrtFloor(ratio << 14); |
105 } else { | 106 } else { |
106 mute_factor = 16384; // 1.0 in Q14. | 107 mute_factor = 16384; // 1.0 in Q14. |
107 } | 108 } |
108 if (mute_factor > external_mute_factor_array[channel_ix]) { | 109 if (mute_factor > external_mute_factor_array[channel_ix]) { |
109 external_mute_factor_array[channel_ix] = | 110 external_mute_factor_array[channel_ix] = |
110 static_cast<int16_t>(std::min(mute_factor, 16384)); | 111 static_cast<int16_t>(std::min(mute_factor, 16384)); |
111 } | 112 } |
112 | 113 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 external_mute_factor_array[channel_ix] = static_cast<int16_t>(std::min( | 196 external_mute_factor_array[channel_ix] = static_cast<int16_t>(std::min( |
196 16384, external_mute_factor_array[channel_ix] + increment)); | 197 16384, external_mute_factor_array[channel_ix] + increment)); |
197 } | 198 } |
198 } | 199 } |
199 } | 200 } |
200 | 201 |
201 return static_cast<int>(length); | 202 return static_cast<int>(length); |
202 } | 203 } |
203 | 204 |
204 } // namespace webrtc | 205 } // namespace webrtc |
OLD | NEW |