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 { |
99 | 100 |
Andrew MacDonald
2015/06/10 06:23:56
I prefer to drop the vertical line between nested
Peter Kasting
2015/06/11 04:31:41
Done.
| |
100 static double SincScaleFactor(double io_ratio) { | 101 namespace { |
102 | |
103 double SincScaleFactor(double io_ratio) { | |
101 // |sinc_scale_factor| is basically the normalized cutoff frequency of the | 104 // |sinc_scale_factor| is basically the normalized cutoff frequency of the |
102 // low-pass filter. | 105 // low-pass filter. |
103 double sinc_scale_factor = io_ratio > 1.0 ? 1.0 / io_ratio : 1.0; | 106 double sinc_scale_factor = io_ratio > 1.0 ? 1.0 / io_ratio : 1.0; |
104 | 107 |
105 // The sinc function is an idealized brick-wall filter, but since we're | 108 // 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. | 109 // 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 | 110 // So we should adjust the low pass filter cutoff slightly downward to avoid |
108 // some aliasing at the very high-end. | 111 // some aliasing at the very high-end. |
109 // TODO(crogers): this value is empirical and to be more exact should vary | 112 // TODO(crogers): this value is empirical and to be more exact should vary |
110 // depending on kKernelSize. | 113 // depending on kKernelSize. |
111 sinc_scale_factor *= 0.9; | 114 sinc_scale_factor *= 0.9; |
112 | 115 |
113 return sinc_scale_factor; | 116 return sinc_scale_factor; |
114 } | 117 } |
115 | 118 |
119 } // namespace | |
120 | |
116 // If we know the minimum architecture at compile time, avoid CPU detection. | 121 // If we know the minimum architecture at compile time, avoid CPU detection. |
117 #if defined(WEBRTC_ARCH_X86_FAMILY) | 122 #if defined(WEBRTC_ARCH_X86_FAMILY) |
118 #if defined(__SSE2__) | 123 #if defined(__SSE2__) |
119 #define CONVOLVE_FUNC Convolve_SSE | 124 #define CONVOLVE_FUNC Convolve_SSE |
120 void SincResampler::InitializeCPUSpecificFeatures() {} | 125 void SincResampler::InitializeCPUSpecificFeatures() {} |
121 #else | 126 #else |
122 // x86 CPU detection required. Function will be set by | 127 // x86 CPU detection required. Function will be set by |
123 // InitializeCPUSpecificFeatures(). | 128 // InitializeCPUSpecificFeatures(). |
124 // TODO(dalecurtis): Once Chrome moves to an SSE baseline this can be removed. | 129 // TODO(dalecurtis): Once Chrome moves to an SSE baseline this can be removed. |
125 #define CONVOLVE_FUNC convolve_proc_ | 130 #define CONVOLVE_FUNC convolve_proc_ |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
363 sum1 += *input_ptr * *k1++; | 368 sum1 += *input_ptr * *k1++; |
364 sum2 += *input_ptr++ * *k2++; | 369 sum2 += *input_ptr++ * *k2++; |
365 } | 370 } |
366 | 371 |
367 // Linearly interpolate the two "convolutions". | 372 // Linearly interpolate the two "convolutions". |
368 return static_cast<float>((1.0 - kernel_interpolation_factor) * sum1 + | 373 return static_cast<float>((1.0 - kernel_interpolation_factor) * sum1 + |
369 kernel_interpolation_factor * sum2); | 374 kernel_interpolation_factor * sum2); |
370 } | 375 } |
371 | 376 |
372 } // namespace webrtc | 377 } // namespace webrtc |
OLD | NEW |