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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 // | 79 // |
80 // 8) Else, if we're not on the second load, goto (4). | 80 // 8) Else, if we're not on the second load, goto (4). |
81 // | 81 // |
82 // Note: we're glossing over how the sub-sample handling works with | 82 // Note: we're glossing over how the sub-sample handling works with |
83 // |virtual_source_idx_|, etc. | 83 // |virtual_source_idx_|, etc. |
84 | 84 |
85 // MSVC++ requires this to be set before any other includes to get M_PI. | 85 // MSVC++ requires this to be set before any other includes to get M_PI. |
86 #define _USE_MATH_DEFINES | 86 #define _USE_MATH_DEFINES |
87 | 87 |
88 #include "webrtc/common_audio/resampler/sinc_resampler.h" | 88 #include "webrtc/common_audio/resampler/sinc_resampler.h" |
89 #include "webrtc/system_wrappers/interface/cpu_features_wrapper.h" | |
90 #include "webrtc/typedefs.h" | |
91 | 89 |
92 #include <assert.h> | 90 #include <assert.h> |
93 #include <math.h> | 91 #include <math.h> |
94 #include <string.h> | 92 #include <string.h> |
95 | 93 |
96 #include <limits> | 94 #include <limits> |
97 | 95 |
| 96 #include "webrtc/system_wrappers/interface/cpu_features_wrapper.h" |
| 97 #include "webrtc/typedefs.h" |
| 98 |
98 namespace webrtc { | 99 namespace webrtc { |
| 100 namespace { |
99 | 101 |
100 static double SincScaleFactor(double io_ratio) { | 102 double SincScaleFactor(double io_ratio) { |
101 // |sinc_scale_factor| is basically the normalized cutoff frequency of the | 103 // |sinc_scale_factor| is basically the normalized cutoff frequency of the |
102 // low-pass filter. | 104 // low-pass filter. |
103 double sinc_scale_factor = io_ratio > 1.0 ? 1.0 / io_ratio : 1.0; | 105 double sinc_scale_factor = io_ratio > 1.0 ? 1.0 / io_ratio : 1.0; |
104 | 106 |
105 // The sinc function is an idealized brick-wall filter, but since we're | 107 // The sinc function is an idealized brick-wall filter, but since we're |
106 // windowing it the transition from pass to stop does not happen right away. | 108 // windowing it the transition from pass to stop does not happen right away. |
107 // So we should adjust the low pass filter cutoff slightly downward to avoid | 109 // So we should adjust the low pass filter cutoff slightly downward to avoid |
108 // some aliasing at the very high-end. | 110 // some aliasing at the very high-end. |
109 // TODO(crogers): this value is empirical and to be more exact should vary | 111 // TODO(crogers): this value is empirical and to be more exact should vary |
110 // depending on kKernelSize. | 112 // depending on kKernelSize. |
111 sinc_scale_factor *= 0.9; | 113 sinc_scale_factor *= 0.9; |
112 | 114 |
113 return sinc_scale_factor; | 115 return sinc_scale_factor; |
114 } | 116 } |
115 | 117 |
| 118 } // namespace |
| 119 |
116 // If we know the minimum architecture at compile time, avoid CPU detection. | 120 // If we know the minimum architecture at compile time, avoid CPU detection. |
117 #if defined(WEBRTC_ARCH_X86_FAMILY) | 121 #if defined(WEBRTC_ARCH_X86_FAMILY) |
118 #if defined(__SSE2__) | 122 #if defined(__SSE2__) |
119 #define CONVOLVE_FUNC Convolve_SSE | 123 #define CONVOLVE_FUNC Convolve_SSE |
120 void SincResampler::InitializeCPUSpecificFeatures() {} | 124 void SincResampler::InitializeCPUSpecificFeatures() {} |
121 #else | 125 #else |
122 // x86 CPU detection required. Function will be set by | 126 // x86 CPU detection required. Function will be set by |
123 // InitializeCPUSpecificFeatures(). | 127 // InitializeCPUSpecificFeatures(). |
124 // TODO(dalecurtis): Once Chrome moves to an SSE baseline this can be removed. | 128 // TODO(dalecurtis): Once Chrome moves to an SSE baseline this can be removed. |
125 #define CONVOLVE_FUNC convolve_proc_ | 129 #define CONVOLVE_FUNC convolve_proc_ |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 sum1 += *input_ptr * *k1++; | 367 sum1 += *input_ptr * *k1++; |
364 sum2 += *input_ptr++ * *k2++; | 368 sum2 += *input_ptr++ * *k2++; |
365 } | 369 } |
366 | 370 |
367 // Linearly interpolate the two "convolutions". | 371 // Linearly interpolate the two "convolutions". |
368 return static_cast<float>((1.0 - kernel_interpolation_factor) * sum1 + | 372 return static_cast<float>((1.0 - kernel_interpolation_factor) * sum1 + |
369 kernel_interpolation_factor * sum2); | 373 kernel_interpolation_factor * sum2); |
370 } | 374 } |
371 | 375 |
372 } // namespace webrtc | 376 } // namespace webrtc |
OLD | NEW |