OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 // Modified from the Chromium original here: | 11 // Modified from the Chromium original here: |
12 // src/media/base/sinc_resampler.h | 12 // src/media/base/sinc_resampler.h |
13 | 13 |
14 #ifndef WEBRTC_COMMON_AUDIO_RESAMPLER_SINC_RESAMPLER_H_ | 14 #ifndef WEBRTC_COMMON_AUDIO_RESAMPLER_SINC_RESAMPLER_H_ |
15 #define WEBRTC_COMMON_AUDIO_RESAMPLER_SINC_RESAMPLER_H_ | 15 #define WEBRTC_COMMON_AUDIO_RESAMPLER_SINC_RESAMPLER_H_ |
16 | 16 |
| 17 #include <memory> |
| 18 |
17 #include "webrtc/base/constructormagic.h" | 19 #include "webrtc/base/constructormagic.h" |
18 #include "webrtc/base/gtest_prod_util.h" | 20 #include "webrtc/base/gtest_prod_util.h" |
19 #include "webrtc/base/scoped_ptr.h" | |
20 #include "webrtc/system_wrappers/include/aligned_malloc.h" | 21 #include "webrtc/system_wrappers/include/aligned_malloc.h" |
21 #include "webrtc/typedefs.h" | 22 #include "webrtc/typedefs.h" |
22 | 23 |
23 namespace webrtc { | 24 namespace webrtc { |
24 | 25 |
25 // Callback class for providing more data into the resampler. Expects |frames| | 26 // Callback class for providing more data into the resampler. Expects |frames| |
26 // of data to be rendered into |destination|; zero padded if not enough frames | 27 // of data to be rendered into |destination|; zero padded if not enough frames |
27 // are available to satisfy the request. | 28 // are available to satisfy the request. |
28 class SincResamplerCallback { | 29 class SincResamplerCallback { |
29 public: | 30 public: |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 131 |
131 // The number of source frames processed per pass. | 132 // The number of source frames processed per pass. |
132 size_t block_size_; | 133 size_t block_size_; |
133 | 134 |
134 // The size (in samples) of the internal buffer used by the resampler. | 135 // The size (in samples) of the internal buffer used by the resampler. |
135 const size_t input_buffer_size_; | 136 const size_t input_buffer_size_; |
136 | 137 |
137 // Contains kKernelOffsetCount kernels back-to-back, each of size kKernelSize. | 138 // Contains kKernelOffsetCount kernels back-to-back, each of size kKernelSize. |
138 // The kernel offsets are sub-sample shifts of a windowed sinc shifted from | 139 // The kernel offsets are sub-sample shifts of a windowed sinc shifted from |
139 // 0.0 to 1.0 sample. | 140 // 0.0 to 1.0 sample. |
140 rtc::scoped_ptr<float[], AlignedFreeDeleter> kernel_storage_; | 141 std::unique_ptr<float[], AlignedFreeDeleter> kernel_storage_; |
141 rtc::scoped_ptr<float[], AlignedFreeDeleter> kernel_pre_sinc_storage_; | 142 std::unique_ptr<float[], AlignedFreeDeleter> kernel_pre_sinc_storage_; |
142 rtc::scoped_ptr<float[], AlignedFreeDeleter> kernel_window_storage_; | 143 std::unique_ptr<float[], AlignedFreeDeleter> kernel_window_storage_; |
143 | 144 |
144 // Data from the source is copied into this buffer for each processing pass. | 145 // Data from the source is copied into this buffer for each processing pass. |
145 rtc::scoped_ptr<float[], AlignedFreeDeleter> input_buffer_; | 146 std::unique_ptr<float[], AlignedFreeDeleter> input_buffer_; |
146 | 147 |
147 // Stores the runtime selection of which Convolve function to use. | 148 // Stores the runtime selection of which Convolve function to use. |
148 // TODO(ajm): Move to using a global static which must only be initialized | 149 // TODO(ajm): Move to using a global static which must only be initialized |
149 // once by the user. We're not doing this initially, because we don't have | 150 // once by the user. We're not doing this initially, because we don't have |
150 // e.g. a LazyInstance helper in webrtc. | 151 // e.g. a LazyInstance helper in webrtc. |
151 #if defined(WEBRTC_CPU_DETECTION) | 152 #if defined(WEBRTC_CPU_DETECTION) |
152 typedef float (*ConvolveProc)(const float*, const float*, const float*, | 153 typedef float (*ConvolveProc)(const float*, const float*, const float*, |
153 double); | 154 double); |
154 ConvolveProc convolve_proc_; | 155 ConvolveProc convolve_proc_; |
155 #endif | 156 #endif |
156 | 157 |
157 // Pointers to the various regions inside |input_buffer_|. See the diagram at | 158 // Pointers to the various regions inside |input_buffer_|. See the diagram at |
158 // the top of the .cc file for more information. | 159 // the top of the .cc file for more information. |
159 float* r0_; | 160 float* r0_; |
160 float* const r1_; | 161 float* const r1_; |
161 float* const r2_; | 162 float* const r2_; |
162 float* r3_; | 163 float* r3_; |
163 float* r4_; | 164 float* r4_; |
164 | 165 |
165 RTC_DISALLOW_COPY_AND_ASSIGN(SincResampler); | 166 RTC_DISALLOW_COPY_AND_ASSIGN(SincResampler); |
166 }; | 167 }; |
167 | 168 |
168 } // namespace webrtc | 169 } // namespace webrtc |
169 | 170 |
170 #endif // WEBRTC_COMMON_AUDIO_RESAMPLER_SINC_RESAMPLER_H_ | 171 #endif // WEBRTC_COMMON_AUDIO_RESAMPLER_SINC_RESAMPLER_H_ |
OLD | NEW |