| 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/accelerate.h" | 11 #include "webrtc/modules/audio_coding/neteq/accelerate.h" |
| 12 | 12 |
| 13 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" | 13 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" |
| 14 | 14 |
| 15 namespace webrtc { | 15 namespace webrtc { |
| 16 | 16 |
| 17 Accelerate::ReturnCodes Accelerate::Process(const int16_t* input, | 17 Accelerate::ReturnCodes Accelerate::Process(const int16_t* input, |
| 18 size_t input_length, | 18 size_t input_length, |
| 19 bool fast_accelerate, | 19 bool fast_accelerate, |
| 20 AudioMultiVector* output, | 20 AudioMultiVector* output, |
| 21 int16_t* length_change_samples) { | 21 size_t* length_change_samples) { |
| 22 // Input length must be (almost) 30 ms. | 22 // Input length must be (almost) 30 ms. |
| 23 static const int k15ms = 120; // 15 ms = 120 samples at 8 kHz sample rate. | 23 static const int k15ms = 120; // 15 ms = 120 samples at 8 kHz sample rate. |
| 24 if (num_channels_ == 0 || static_cast<int>(input_length) / num_channels_ < | 24 if (num_channels_ == 0 || static_cast<int>(input_length) / num_channels_ < |
| 25 (2 * k15ms - 1) * fs_mult_) { | 25 (2 * k15ms - 1) * fs_mult_) { |
| 26 // Length of input data too short to do accelerate. Simply move all data | 26 // Length of input data too short to do accelerate. Simply move all data |
| 27 // from input to output. | 27 // from input to output. |
| 28 output->PushBackInterleaved(input, input_length); | 28 output->PushBackInterleaved(input, input_length); |
| 29 return kError; | 29 return kError; |
| 30 } | 30 } |
| 31 return TimeStretch::Process(input, input_length, fast_accelerate, output, | 31 return TimeStretch::Process(input, input_length, fast_accelerate, output, |
| 32 length_change_samples); | 32 length_change_samples); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void Accelerate::SetParametersForPassiveSpeech(size_t /*len*/, | 35 void Accelerate::SetParametersForPassiveSpeech(size_t /*len*/, |
| 36 int16_t* best_correlation, | 36 int16_t* best_correlation, |
| 37 int* /*peak_index*/) const { | 37 size_t* /*peak_index*/) const { |
| 38 // When the signal does not contain any active speech, the correlation does | 38 // When the signal does not contain any active speech, the correlation does |
| 39 // not matter. Simply set it to zero. | 39 // not matter. Simply set it to zero. |
| 40 *best_correlation = 0; | 40 *best_correlation = 0; |
| 41 } | 41 } |
| 42 | 42 |
| 43 Accelerate::ReturnCodes Accelerate::CheckCriteriaAndStretch( | 43 Accelerate::ReturnCodes Accelerate::CheckCriteriaAndStretch( |
| 44 const int16_t* input, | 44 const int16_t* input, |
| 45 size_t input_length, | 45 size_t input_length, |
| 46 size_t peak_index, | 46 size_t peak_index, |
| 47 int16_t best_correlation, | 47 int16_t best_correlation, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 } | 92 } |
| 93 | 93 |
| 94 Accelerate* AccelerateFactory::Create( | 94 Accelerate* AccelerateFactory::Create( |
| 95 int sample_rate_hz, | 95 int sample_rate_hz, |
| 96 size_t num_channels, | 96 size_t num_channels, |
| 97 const BackgroundNoise& background_noise) const { | 97 const BackgroundNoise& background_noise) const { |
| 98 return new Accelerate(sample_rate_hz, num_channels, background_noise); | 98 return new Accelerate(sample_rate_hz, num_channels, background_noise); |
| 99 } | 99 } |
| 100 | 100 |
| 101 } // namespace webrtc | 101 } // namespace webrtc |
| OLD | NEW |