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 |
(...skipping 16 matching lines...) Expand all Loading... |
27 // are available to satisfy the request. | 27 // are available to satisfy the request. |
28 class SincResamplerCallback { | 28 class SincResamplerCallback { |
29 public: | 29 public: |
30 virtual ~SincResamplerCallback() {} | 30 virtual ~SincResamplerCallback() {} |
31 virtual void Run(int frames, float* destination) = 0; | 31 virtual void Run(int frames, float* destination) = 0; |
32 }; | 32 }; |
33 | 33 |
34 // SincResampler is a high-quality single-channel sample-rate converter. | 34 // SincResampler is a high-quality single-channel sample-rate converter. |
35 class SincResampler { | 35 class SincResampler { |
36 public: | 36 public: |
37 enum { | 37 // The kernel size can be adjusted for quality (higher is better) at the |
38 // The kernel size can be adjusted for quality (higher is better) at the | 38 // expense of performance. Must be a multiple of 32. |
39 // expense of performance. Must be a multiple of 32. | 39 // TODO(dalecurtis): Test performance to see if we can jack this up to 64+. |
40 // TODO(dalecurtis): Test performance to see if we can jack this up to 64+. | 40 static const int kKernelSize = 32; |
41 kKernelSize = 32, | |
42 | 41 |
43 // Default request size. Affects how often and for how much SincResampler | 42 // Default request size. Affects how often and for how much SincResampler |
44 // calls back for input. Must be greater than kKernelSize. | 43 // calls back for input. Must be greater than kKernelSize. |
45 kDefaultRequestSize = 512, | 44 static const int kDefaultRequestSize = 512; |
46 | 45 |
47 // The kernel offset count is used for interpolation and is the number of | 46 // The kernel offset count is used for interpolation and is the number of |
48 // sub-sample kernel shifts. Can be adjusted for quality (higher is better) | 47 // sub-sample kernel shifts. Can be adjusted for quality (higher is better) |
49 // at the expense of allocating more memory. | 48 // at the expense of allocating more memory. |
50 kKernelOffsetCount = 32, | 49 static const int kKernelOffsetCount = 32; |
51 kKernelStorageSize = kKernelSize * (kKernelOffsetCount + 1), | 50 static const int kKernelStorageSize = kKernelSize * (kKernelOffsetCount + 1); |
52 }; | |
53 | 51 |
54 // Constructs a SincResampler with the specified |read_cb|, which is used to | 52 // Constructs a SincResampler with the specified |read_cb|, which is used to |
55 // acquire audio data for resampling. |io_sample_rate_ratio| is the ratio | 53 // acquire audio data for resampling. |io_sample_rate_ratio| is the ratio |
56 // of input / output sample rates. |request_frames| controls the size in | 54 // of input / output sample rates. |request_frames| controls the size in |
57 // frames of the buffer requested by each |read_cb| call. The value must be | 55 // frames of the buffer requested by each |read_cb| call. The value must be |
58 // greater than kKernelSize. Specify kDefaultRequestSize if there are no | 56 // greater than kKernelSize. Specify kDefaultRequestSize if there are no |
59 // request size constraints. | 57 // request size constraints. |
60 SincResampler(double io_sample_rate_ratio, | 58 SincResampler(double io_sample_rate_ratio, |
61 int request_frames, | 59 int request_frames, |
62 SincResamplerCallback* read_cb); | 60 SincResamplerCallback* read_cb); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 float* const r2_; | 160 float* const r2_; |
163 float* r3_; | 161 float* r3_; |
164 float* r4_; | 162 float* r4_; |
165 | 163 |
166 DISALLOW_COPY_AND_ASSIGN(SincResampler); | 164 DISALLOW_COPY_AND_ASSIGN(SincResampler); |
167 }; | 165 }; |
168 | 166 |
169 } // namespace webrtc | 167 } // namespace webrtc |
170 | 168 |
171 #endif // WEBRTC_COMMON_AUDIO_RESAMPLER_SINC_RESAMPLER_H_ | 169 #endif // WEBRTC_COMMON_AUDIO_RESAMPLER_SINC_RESAMPLER_H_ |
OLD | NEW |