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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 assert(channel_ix < output->Channels()); | 138 assert(channel_ix < output->Channels()); |
139 assert(i < output->Size()); | 139 assert(i < output->Size()); |
140 (*output)[channel_ix][i] = | 140 (*output)[channel_ix][i] = |
141 static_cast<int16_t>((fraction * (*output)[channel_ix][i] + | 141 static_cast<int16_t>((fraction * (*output)[channel_ix][i] + |
142 (32 - fraction) * expanded[channel_ix][i] + 8) >> 5); | 142 (32 - fraction) * expanded[channel_ix][i] + 8) >> 5); |
143 fraction += increment; | 143 fraction += increment; |
144 } | 144 } |
145 } | 145 } |
146 } else if (last_mode == kModeRfc3389Cng) { | 146 } else if (last_mode == kModeRfc3389Cng) { |
147 assert(output->Channels() == 1); // Not adapted for multi-channel yet. | 147 assert(output->Channels() == 1); // Not adapted for multi-channel yet. |
148 static const size_t kCngLength = 32; | 148 static const size_t kCngLength = 48; |
| 149 RTC_DCHECK_LE(static_cast<size_t>(8 * fs_mult), kCngLength); |
149 int16_t cng_output[kCngLength]; | 150 int16_t cng_output[kCngLength]; |
150 // Reset mute factor and start up fresh. | 151 // Reset mute factor and start up fresh. |
151 external_mute_factor_array[0] = 16384; | 152 external_mute_factor_array[0] = 16384; |
152 ComfortNoiseDecoder* cng_decoder = decoder_database_->GetActiveCngDecoder(); | 153 ComfortNoiseDecoder* cng_decoder = decoder_database_->GetActiveCngDecoder(); |
153 | 154 |
154 if (cng_decoder) { | 155 if (cng_decoder) { |
155 // Generate long enough for 32kHz. | 156 // Generate long enough for 48kHz. |
156 if (!cng_decoder->Generate(cng_output, 0)) { | 157 if (!cng_decoder->Generate(cng_output, 0)) { |
157 // Error returned; set return vector to all zeros. | 158 // Error returned; set return vector to all zeros. |
158 memset(cng_output, 0, sizeof(cng_output)); | 159 memset(cng_output, 0, sizeof(cng_output)); |
159 } | 160 } |
160 } else { | 161 } else { |
161 // If no CNG instance is defined, just copy from the decoded data. | 162 // If no CNG instance is defined, just copy from the decoded data. |
162 // (This will result in interpolating the decoded with itself.) | 163 // (This will result in interpolating the decoded with itself.) |
163 (*output)[0].CopyTo(fs_mult * 8, 0, cng_output); | 164 (*output)[0].CopyTo(fs_mult * 8, 0, cng_output); |
164 } | 165 } |
165 // Interpolate the CNG into the new vector. | 166 // Interpolate the CNG into the new vector. |
(...skipping 29 matching lines...) Expand all 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 |