mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2026-01-01 03:12:16 +08:00
BUG=none TEST=libyuvTest.TestCpuHas Review URL: https://webrtc-codereview.appspot.com/607006 git-svn-id: http://libyuv.googlecode.com/svn/trunk@271 16f28f9a-4ce2-e073-06de-1de4eb20be90
59 lines
1.7 KiB
C++
59 lines
1.7 KiB
C++
/*
|
|
* Copyright (c) 2011 The LibYuv project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#ifndef INCLUDE_LIBYUV_CPU_ID_H_
|
|
#define INCLUDE_LIBYUV_CPU_ID_H_
|
|
|
|
#ifdef __cplusplus
|
|
namespace libyuv {
|
|
extern "C" {
|
|
#endif
|
|
|
|
// Internal flag to indicate cpuid is initialized.
|
|
static const int kCpuInitialized = 1;
|
|
|
|
// These flags are only valid on ARM processors
|
|
static const int kCpuHasARM = 2;
|
|
static const int kCpuHasNEON = 4;
|
|
|
|
// These flags are only valid on x86 processors
|
|
static const int kCpuHasX86 = 8;
|
|
static const int kCpuHasSSE2 = 16;
|
|
static const int kCpuHasSSSE3 = 32;
|
|
static const int kCpuHasSSE41 = 64;
|
|
static const int kCpuHasSSE42 = 128;
|
|
static const int kCpuHasAVX = 256;
|
|
|
|
// Detect CPU has SSE2 etc.
|
|
// Test_flag parameter should be one of kCpuHas constants above.
|
|
// returns non-zero if instruction set is detected
|
|
static __inline int TestCpuFlag(int test_flag) {
|
|
extern int cpu_info_;
|
|
extern int InitCpuFlags();
|
|
return (cpu_info_ ? cpu_info_ : InitCpuFlags()) & test_flag;
|
|
}
|
|
|
|
// For testing, allow CPU flags to be disabled.
|
|
// ie MaskCpuFlags(~kCpuHasSSSE3) to disable SSSE3.
|
|
// MaskCpuFlags(-1) to enable all cpu specific optimizations.
|
|
// MaskCpuFlags(0) to disable all cpu specific optimizations.
|
|
void MaskCpuFlags(int enable_flags);
|
|
|
|
// Low level cpuid for X86. Returns zeros on other CPUs.
|
|
void CpuId(int cpu_info[4], int info_type);
|
|
|
|
#ifdef __cplusplus
|
|
} // extern "C"
|
|
} // namespace libyuv
|
|
#endif
|
|
|
|
#endif // INCLUDE_LIBYUV_CPU_ID_H_
|
|
|