Clean up CPU detection defines in SincResampler a little.

R=aluebs@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/9159004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@5615 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
andrew@webrtc.org 2014-02-27 04:12:34 +00:00
parent 0231e801d6
commit 00073aafa8
3 changed files with 12 additions and 20 deletions

View File

@ -114,13 +114,12 @@ static double SincScaleFactor(double io_ratio) {
}
// If we know the minimum architecture at compile time, avoid CPU detection.
// iOS lies about its architecture, so we also need to exclude it here.
#if defined(WEBRTC_ARCH_X86_FAMILY) && !defined(WEBRTC_IOS)
#if defined(__SSE__)
#if defined(WEBRTC_ARCH_X86_FAMILY)
#if defined(__SSE2__)
#define CONVOLVE_FUNC Convolve_SSE
void SincResampler::InitializeCPUSpecificFeatures() {}
#else
// X86 CPU detection required. Function will be set by
// x86 CPU detection required. Function will be set by
// InitializeCPUSpecificFeatures().
// TODO(dalecurtis): Once Chrome moves to an SSE baseline this can be removed.
#define CONVOLVE_FUNC convolve_proc_
@ -134,7 +133,7 @@ void SincResampler::InitializeCPUSpecificFeatures() {
#define CONVOLVE_FUNC Convolve_NEON
void SincResampler::InitializeCPUSpecificFeatures() {}
#else
// NEON CPU detection required. Function will be set by
// ARM CPU detection required. Function will be set by
// InitializeCPUSpecificFeatures().
#define CONVOLVE_FUNC convolve_proc_
@ -165,12 +164,12 @@ SincResampler::SincResampler(double io_sample_rate_ratio,
AlignedMalloc(sizeof(float) * kKernelStorageSize, 16))),
input_buffer_(static_cast<float*>(
AlignedMalloc(sizeof(float) * input_buffer_size_, 16))),
#if defined(WEBRTC_RESAMPLER_CPU_DETECTION)
#if defined(WEBRTC_CPU_DETECTION)
convolve_proc_(NULL),
#endif
r1_(input_buffer_.get()),
r2_(input_buffer_.get() + kKernelSize / 2) {
#if defined(WEBRTC_RESAMPLER_CPU_DETECTION)
#if defined(WEBRTC_CPU_DETECTION)
InitializeCPUSpecificFeatures();
assert(convolve_proc_);
#endif

View File

@ -20,13 +20,6 @@
#include "webrtc/test/testsupport/gtest_prod_util.h"
#include "webrtc/typedefs.h"
#if (defined(WEBRTC_ARCH_X86_FAMILY) && !defined(WEBRTC_IOS) && \
!defined(__SSE__)) || \
(defined(WEBRTC_ARCH_ARM_V7) && !defined(WEBRTC_ARCH_ARM_NEON))
// Convenience define.
#define WEBRTC_RESAMPLER_CPU_DETECTION
#endif
namespace webrtc {
// Callback class for providing more data into the resampler. Expects |frames|
@ -106,9 +99,8 @@ class SincResampler {
void InitializeCPUSpecificFeatures();
// Compute convolution of |k1| and |k2| over |input_ptr|, resultant sums are
// linearly interpolated using |kernel_interpolation_factor|. On x86, the
// underlying implementation is chosen at run time based on SSE support. On
// ARM, NEON support is chosen at compile time based on compilation flags.
// linearly interpolated using |kernel_interpolation_factor|. On x86 and ARM
// the underlying implementation is chosen at run time.
static float Convolve_C(const float* input_ptr, const float* k1,
const float* k2, double kernel_interpolation_factor);
#if defined(WEBRTC_ARCH_X86_FAMILY)
@ -157,7 +149,7 @@ class SincResampler {
// TODO(ajm): Move to using a global static which must only be initialized
// once by the user. We're not doing this initially, because we don't have
// e.g. a LazyInstance helper in webrtc.
#if defined(WEBRTC_RESAMPLER_CPU_DETECTION)
#if defined(WEBRTC_CPU_DETECTION)
typedef float (*ConvolveProc)(const float*, const float*, const float*,
double);
ConvolveProc convolve_proc_;

View File

@ -60,8 +60,9 @@
#error Define either WEBRTC_ARCH_LITTLE_ENDIAN or WEBRTC_ARCH_BIG_ENDIAN
#endif
#if defined(__SSE2__) || defined(_MSC_VER)
#define WEBRTC_USE_SSE2
#if (defined(WEBRTC_ARCH_X86_FAMILY) && !defined(__SSE2__)) || \
(defined(WEBRTC_ARCH_ARM_V7) && !defined(WEBRTC_ARCH_ARM_NEON))
#define WEBRTC_CPU_DETECTION
#endif
#if !defined(_MSC_VER)