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/time_stretch.h" | 11 #include "webrtc/modules/audio_coding/neteq/time_stretch.h" |
12 | 12 |
13 #include <algorithm> // min, max | 13 #include <algorithm> // min, max |
| 14 #include <memory> |
14 | 15 |
15 #include "webrtc/base/safe_conversions.h" | 16 #include "webrtc/base/safe_conversions.h" |
16 #include "webrtc/base/scoped_ptr.h" | |
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/neteq/background_noise.h" | 18 #include "webrtc/modules/audio_coding/neteq/background_noise.h" |
19 #include "webrtc/modules/audio_coding/neteq/dsp_helper.h" | 19 #include "webrtc/modules/audio_coding/neteq/dsp_helper.h" |
20 | 20 |
21 namespace webrtc { | 21 namespace webrtc { |
22 | 22 |
23 TimeStretch::ReturnCodes TimeStretch::Process(const int16_t* input, | 23 TimeStretch::ReturnCodes TimeStretch::Process(const int16_t* input, |
24 size_t input_len, | 24 size_t input_len, |
25 bool fast_mode, | 25 bool fast_mode, |
26 AudioMultiVector* output, | 26 AudioMultiVector* output, |
27 size_t* length_change_samples) { | 27 size_t* length_change_samples) { |
28 // Pre-calculate common multiplication with |fs_mult_|. | 28 // Pre-calculate common multiplication with |fs_mult_|. |
29 size_t fs_mult_120 = | 29 size_t fs_mult_120 = |
30 static_cast<size_t>(fs_mult_ * 120); // Corresponds to 15 ms. | 30 static_cast<size_t>(fs_mult_ * 120); // Corresponds to 15 ms. |
31 | 31 |
32 const int16_t* signal; | 32 const int16_t* signal; |
33 rtc::scoped_ptr<int16_t[]> signal_array; | 33 std::unique_ptr<int16_t[]> signal_array; |
34 size_t signal_len; | 34 size_t signal_len; |
35 if (num_channels_ == 1) { | 35 if (num_channels_ == 1) { |
36 signal = input; | 36 signal = input; |
37 signal_len = input_len; | 37 signal_len = input_len; |
38 } else { | 38 } else { |
39 // We want |signal| to be only the first channel of |input|, which is | 39 // We want |signal| to be only the first channel of |input|, which is |
40 // interleaved. Thus, we take the first sample, skip forward |num_channels| | 40 // interleaved. Thus, we take the first sample, skip forward |num_channels| |
41 // samples, and continue like that. | 41 // samples, and continue like that. |
42 signal_len = input_len / num_channels_; | 42 signal_len = input_len / num_channels_; |
43 signal_array.reset(new int16_t[signal_len]); | 43 signal_array.reset(new int16_t[signal_len]); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 int temp_scale = WebRtcSpl_NormW32(left_side); | 208 int temp_scale = WebRtcSpl_NormW32(left_side); |
209 left_side = left_side << temp_scale; | 209 left_side = left_side << temp_scale; |
210 right_side = right_side >> (2 * scaling - temp_scale); | 210 right_side = right_side >> (2 * scaling - temp_scale); |
211 } else { | 211 } else { |
212 left_side = left_side << 2 * scaling; | 212 left_side = left_side << 2 * scaling; |
213 } | 213 } |
214 return left_side > right_side; | 214 return left_side > right_side; |
215 } | 215 } |
216 | 216 |
217 } // namespace webrtc | 217 } // namespace webrtc |
OLD | NEW |