OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_BASE_SINC_RESAMPLER_H_ | 5 #ifndef MEDIA_BASE_SINC_RESAMPLER_H_ |
6 #define MEDIA_BASE_SINC_RESAMPLER_H_ | 6 #define MEDIA_BASE_SINC_RESAMPLER_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
10 #include "base/memory/aligned_memory.h" | 10 #include "base/memory/aligned_memory.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
66 private: | 66 private: |
67 FRIEND_TEST_ALL_PREFIXES(SincResamplerTest, Convolve); | 67 FRIEND_TEST_ALL_PREFIXES(SincResamplerTest, Convolve); |
68 FRIEND_TEST_ALL_PREFIXES(SincResamplerTest, ConvolveBenchmark); | 68 FRIEND_TEST_ALL_PREFIXES(SincResamplerTest, ConvolveBenchmark); |
69 | 69 |
70 void InitializeKernel(); | 70 void InitializeKernel(); |
71 | 71 |
72 // Compute convolution of |k1| and |k2| over |input_ptr|, resultant sums are | 72 // Compute convolution of |k1| and |k2| over |input_ptr|, resultant sums are |
73 // linearly interpolated using |kernel_interpolation_factor|. On x86, the | 73 // linearly interpolated using |kernel_interpolation_factor|. On x86, the |
74 // underlying implementation is chosen at run time based on SSE support. On | 74 // underlying implementation is chosen at run time based on SSE support. On |
75 // ARM, NEON support is chosen at compile time based on compilation flags. | 75 // ARM, NEON support is chosen at compile time based on compilation flags. |
76 static float Convolve(const float* input_ptr, const float* k1, | |
77 const float* k2, double kernel_interpolation_factor); | |
78 static float Convolve_C(const float* input_ptr, const float* k1, | 76 static float Convolve_C(const float* input_ptr, const float* k1, |
79 const float* k2, double kernel_interpolation_factor); | 77 const float* k2, double kernel_interpolation_factor); |
80 #if defined(ARCH_CPU_X86_FAMILY) | 78 #if defined(ARCH_CPU_X86_FAMILY) |
81 static float Convolve_SSE(const float* input_ptr, const float* k1, | 79 static float Convolve_SSE(const float* input_ptr, const float* k1, |
82 const float* k2, | 80 const float* k2, |
83 double kernel_interpolation_factor); | 81 double kernel_interpolation_factor); |
84 #elif defined(ARCH_CPU_ARM_FAMILY) && defined(USE_NEON) | 82 #elif defined(ARCH_CPU_ARM_FAMILY) && defined(USE_NEON) |
85 static float Convolve_NEON(const float* input_ptr, const float* k1, | 83 static float Convolve_NEON(const float* input_ptr, const float* k1, |
86 const float* k2, | 84 const float* k2, |
87 double kernel_interpolation_factor); | 85 double kernel_interpolation_factor); |
(...skipping 13 matching lines...) Expand all Loading... | |
101 ReadCB read_cb_; | 99 ReadCB read_cb_; |
102 | 100 |
103 // Contains kKernelOffsetCount kernels back-to-back, each of size kKernelSize. | 101 // Contains kKernelOffsetCount kernels back-to-back, each of size kKernelSize. |
104 // The kernel offsets are sub-sample shifts of a windowed sinc shifted from | 102 // The kernel offsets are sub-sample shifts of a windowed sinc shifted from |
105 // 0.0 to 1.0 sample. | 103 // 0.0 to 1.0 sample. |
106 scoped_ptr_malloc<float, base::ScopedPtrAlignedFree> kernel_storage_; | 104 scoped_ptr_malloc<float, base::ScopedPtrAlignedFree> kernel_storage_; |
107 | 105 |
108 // Data from the source is copied into this buffer for each processing pass. | 106 // Data from the source is copied into this buffer for each processing pass. |
109 scoped_ptr_malloc<float, base::ScopedPtrAlignedFree> input_buffer_; | 107 scoped_ptr_malloc<float, base::ScopedPtrAlignedFree> input_buffer_; |
110 | 108 |
109 // Stores the runtime selection of which Convolve function to use. | |
110 #if defined(ARCH_CPU_X86_FAMILY) && !defined(__SSE__) | |
111 typedef float (*ConvolveProc)(const float* src, const float* k1, | |
scherkus (not reviewing)
2013/03/08 02:33:08
nit: you don't need arg names here
DaleCurtis
2013/03/12 00:28:28
Done.
| |
112 const float* k2, | |
113 double kernel_interpolation_factor); | |
114 const ConvolveProc convolve_proc_; | |
115 #endif | |
116 | |
111 // Pointers to the various regions inside |input_buffer_|. See the diagram at | 117 // Pointers to the various regions inside |input_buffer_|. See the diagram at |
112 // the top of the .cc file for more information. | 118 // the top of the .cc file for more information. |
113 float* const r0_; | 119 float* const r0_; |
114 float* const r1_; | 120 float* const r1_; |
115 float* const r2_; | 121 float* const r2_; |
116 float* const r3_; | 122 float* const r3_; |
117 float* const r4_; | 123 float* const r4_; |
118 float* const r5_; | 124 float* const r5_; |
119 | 125 |
120 DISALLOW_COPY_AND_ASSIGN(SincResampler); | 126 DISALLOW_COPY_AND_ASSIGN(SincResampler); |
121 }; | 127 }; |
122 | 128 |
123 } // namespace media | 129 } // namespace media |
124 | 130 |
125 #endif // MEDIA_BASE_SINC_RESAMPLER_H_ | 131 #endif // MEDIA_BASE_SINC_RESAMPLER_H_ |
OLD | NEW |