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

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

Issue 1179953003: Revert "Upconvert various types to int." (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 5 years, 6 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
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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 int16_t ratio = WebRtcSpl_DivW32W16(bgn_energy, energy_scaled); 103 int16_t ratio = WebRtcSpl_DivW32W16(bgn_energy, energy_scaled);
104 mute_factor = WebRtcSpl_SqrtFloor(static_cast<int32_t>(ratio) << 14); 104 mute_factor = WebRtcSpl_SqrtFloor(static_cast<int32_t>(ratio) << 14);
105 } else { 105 } else {
106 mute_factor = 16384; // 1.0 in Q14. 106 mute_factor = 16384; // 1.0 in Q14.
107 } 107 }
108 if (mute_factor > external_mute_factor_array[channel_ix]) { 108 if (mute_factor > external_mute_factor_array[channel_ix]) {
109 external_mute_factor_array[channel_ix] = std::min(mute_factor, 16384); 109 external_mute_factor_array[channel_ix] = std::min(mute_factor, 16384);
110 } 110 }
111 111
112 // If muted increase by 0.64 for every 20 ms (NB/WB 0.0040/0.0020 in Q14). 112 // If muted increase by 0.64 for every 20 ms (NB/WB 0.0040/0.0020 in Q14).
113 int increment = static_cast<int>(64 / fs_mult); 113 int16_t increment = 64 / fs_mult;
114 for (size_t i = 0; i < length_per_channel; i++) { 114 for (size_t i = 0; i < length_per_channel; i++) {
115 // Scale with mute factor. 115 // Scale with mute factor.
116 assert(channel_ix < output->Channels()); 116 assert(channel_ix < output->Channels());
117 assert(i < output->Size()); 117 assert(i < output->Size());
118 int32_t scaled_signal = (*output)[channel_ix][i] * 118 int32_t scaled_signal = (*output)[channel_ix][i] *
119 external_mute_factor_array[channel_ix]; 119 external_mute_factor_array[channel_ix];
120 // Shift 14 with proper rounding. 120 // Shift 14 with proper rounding.
121 (*output)[channel_ix][i] = (scaled_signal + 8192) >> 14; 121 (*output)[channel_ix][i] = (scaled_signal + 8192) >> 14;
122 // Increase mute_factor towards 16384. 122 // Increase mute_factor towards 16384.
123 external_mute_factor_array[channel_ix] = 123 external_mute_factor_array[channel_ix] =
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 // TODO(hlundin): Add 16 instead of 8 for correct rounding. Keeping 8 now 169 // TODO(hlundin): Add 16 instead of 8 for correct rounding. Keeping 8 now
170 // for legacy bit-exactness. 170 // for legacy bit-exactness.
171 signal[i] = 171 signal[i] =
172 (fraction * signal[i] + (32 - fraction) * cng_output[i] + 8) >> 5; 172 (fraction * signal[i] + (32 - fraction) * cng_output[i] + 8) >> 5;
173 fraction += increment; 173 fraction += increment;
174 } 174 }
175 } else if (external_mute_factor_array[0] < 16384) { 175 } else if (external_mute_factor_array[0] < 16384) {
176 // Previous was neither of Expand, FadeToBGN or RFC3389_CNG, but we are 176 // Previous was neither of Expand, FadeToBGN or RFC3389_CNG, but we are
177 // still ramping up from previous muting. 177 // still ramping up from previous muting.
178 // If muted increase by 0.64 for every 20 ms (NB/WB 0.0040/0.0020 in Q14). 178 // If muted increase by 0.64 for every 20 ms (NB/WB 0.0040/0.0020 in Q14).
179 int increment = static_cast<int>(64 / fs_mult); 179 int16_t increment = 64 / fs_mult;
180 size_t length_per_channel = length / output->Channels(); 180 size_t length_per_channel = length / output->Channels();
181 for (size_t i = 0; i < length_per_channel; i++) { 181 for (size_t i = 0; i < length_per_channel; i++) {
182 for (size_t channel_ix = 0; channel_ix < output->Channels(); 182 for (size_t channel_ix = 0; channel_ix < output->Channels();
183 ++channel_ix) { 183 ++channel_ix) {
184 // Scale with mute factor. 184 // Scale with mute factor.
185 assert(channel_ix < output->Channels()); 185 assert(channel_ix < output->Channels());
186 assert(i < output->Size()); 186 assert(i < output->Size());
187 int32_t scaled_signal = (*output)[channel_ix][i] * 187 int32_t scaled_signal = (*output)[channel_ix][i] *
188 external_mute_factor_array[channel_ix]; 188 external_mute_factor_array[channel_ix];
189 // Shift 14 with proper rounding. 189 // Shift 14 with proper rounding.
190 (*output)[channel_ix][i] = (scaled_signal + 8192) >> 14; 190 (*output)[channel_ix][i] = (scaled_signal + 8192) >> 14;
191 // Increase mute_factor towards 16384. 191 // Increase mute_factor towards 16384.
192 external_mute_factor_array[channel_ix] = 192 external_mute_factor_array[channel_ix] =
193 std::min(16384, external_mute_factor_array[channel_ix] + increment); 193 std::min(16384, external_mute_factor_array[channel_ix] + increment);
194 } 194 }
195 } 195 }
196 } 196 }
197 197
198 return static_cast<int>(length); 198 return static_cast<int>(length);
199 } 199 }
200 200
201 } // namespace webrtc 201 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/neteq_impl.cc ('k') | webrtc/modules/audio_coding/neteq/test/RTPencode.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698