| 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 |
| 11 #include "webrtc/modules/audio_coding/neteq/normal.h" | 11 #include "webrtc/modules/audio_coding/neteq/normal.h" |
| 12 | 12 |
| 13 #include <string.h> // memset, memcpy | 13 #include <string.h> // memset, memcpy |
| 14 | 14 |
| 15 #include <algorithm> // min | 15 #include <algorithm> // min |
| 16 | 16 |
| 17 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" | 17 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" |
| 18 #include "webrtc/modules/audio_coding/codecs/audio_decoder.h" | 18 #include "webrtc/modules/audio_coding/codecs/audio_decoder.h" |
| 19 #include "webrtc/modules/audio_coding/codecs/cng/webrtc_cng.h" | |
| 20 #include "webrtc/modules/audio_coding/neteq/audio_multi_vector.h" | 19 #include "webrtc/modules/audio_coding/neteq/audio_multi_vector.h" |
| 21 #include "webrtc/modules/audio_coding/neteq/background_noise.h" | 20 #include "webrtc/modules/audio_coding/neteq/background_noise.h" |
| 22 #include "webrtc/modules/audio_coding/neteq/decoder_database.h" | 21 #include "webrtc/modules/audio_coding/neteq/decoder_database.h" |
| 23 #include "webrtc/modules/audio_coding/neteq/expand.h" | 22 #include "webrtc/modules/audio_coding/neteq/expand.h" |
| 24 | 23 |
| 25 namespace webrtc { | 24 namespace webrtc { |
| 26 | 25 |
| 27 int Normal::Process(const int16_t* input, | 26 int Normal::Process(const int16_t* input, |
| 28 size_t length, | 27 size_t length, |
| 29 Modes last_mode, | 28 Modes last_mode, |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 (32 - fraction) * expanded[channel_ix][i] + 8) >> 5); | 141 (32 - fraction) * expanded[channel_ix][i] + 8) >> 5); |
| 143 fraction += increment; | 142 fraction += increment; |
| 144 } | 143 } |
| 145 } | 144 } |
| 146 } else if (last_mode == kModeRfc3389Cng) { | 145 } else if (last_mode == kModeRfc3389Cng) { |
| 147 assert(output->Channels() == 1); // Not adapted for multi-channel yet. | 146 assert(output->Channels() == 1); // Not adapted for multi-channel yet. |
| 148 static const size_t kCngLength = 32; | 147 static const size_t kCngLength = 32; |
| 149 int16_t cng_output[kCngLength]; | 148 int16_t cng_output[kCngLength]; |
| 150 // Reset mute factor and start up fresh. | 149 // Reset mute factor and start up fresh. |
| 151 external_mute_factor_array[0] = 16384; | 150 external_mute_factor_array[0] = 16384; |
| 152 AudioDecoder* cng_decoder = decoder_database_->GetActiveCngDecoder(); | 151 ComfortNoiseDecoder* cng_decoder = decoder_database_->GetActiveCngDecoder(); |
| 153 | 152 |
| 154 if (cng_decoder) { | 153 if (cng_decoder) { |
| 155 // Generate long enough for 32kHz. | 154 // Generate long enough for 32kHz. |
| 156 if (WebRtcCng_Generate(cng_decoder->CngDecoderInstance(), cng_output, | 155 if (!cng_decoder->Generate(cng_output, 0)) { |
| 157 kCngLength, 0) < 0) { | |
| 158 // Error returned; set return vector to all zeros. | 156 // Error returned; set return vector to all zeros. |
| 159 memset(cng_output, 0, sizeof(cng_output)); | 157 memset(cng_output, 0, sizeof(cng_output)); |
| 160 } | 158 } |
| 161 } else { | 159 } else { |
| 162 // If no CNG instance is defined, just copy from the decoded data. | 160 // If no CNG instance is defined, just copy from the decoded data. |
| 163 // (This will result in interpolating the decoded with itself.) | 161 // (This will result in interpolating the decoded with itself.) |
| 164 memcpy(cng_output, signal, fs_mult * 8 * sizeof(int16_t)); | 162 memcpy(cng_output, signal, fs_mult * 8 * sizeof(int16_t)); |
| 165 } | 163 } |
| 166 // Interpolate the CNG into the new vector. | 164 // Interpolate the CNG into the new vector. |
| 167 // (NB/WB/SWB32/SWB48 8/16/32/48 samples.) | 165 // (NB/WB/SWB32/SWB48 8/16/32/48 samples.) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 196 external_mute_factor_array[channel_ix] = static_cast<int16_t>(std::min( | 194 external_mute_factor_array[channel_ix] = static_cast<int16_t>(std::min( |
| 197 16384, external_mute_factor_array[channel_ix] + increment)); | 195 16384, external_mute_factor_array[channel_ix] + increment)); |
| 198 } | 196 } |
| 199 } | 197 } |
| 200 } | 198 } |
| 201 | 199 |
| 202 return static_cast<int>(length); | 200 return static_cast<int>(length); |
| 203 } | 201 } |
| 204 | 202 |
| 205 } // namespace webrtc | 203 } // namespace webrtc |
| OLD | NEW |