1 /* 2 * Copyright (c) 2011 The LibYuv project authors. All Rights Reserved. 3 * 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 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef INCLUDE_LIBYUV_CPU_ID_H_ 12 #define INCLUDE_LIBYUV_CPU_ID_H_ 13 14 #ifdef __cplusplus 15 namespace libyuv { 16 extern "C" { 17 #endif 18 19 // These flags are only valid on x86 processors 20 static const int kCpuHasSSE2 = 1; 21 static const int kCpuHasSSSE3 = 2; 22 23 // These flags are only valid on ARM processors 24 static const int kCpuHasNEON = 4; 25 26 // Internal flag to indicate cpuid is initialized. 27 static const int kCpuInitialized = 8; 28 29 // Detect CPU has SSE2 etc. 30 // test_flag parameter should be one of kCpuHas constants above 31 // returns non-zero if instruction set is detected TestCpuFlag(int test_flag)32static __inline int TestCpuFlag(int test_flag) { 33 extern int cpu_info_; 34 extern int InitCpuFlags(); 35 return (cpu_info_ ? cpu_info_ : InitCpuFlags()) & test_flag; 36 } 37 38 // For testing, allow CPU flags to be disabled. 39 // ie MaskCpuFlags(~kCpuHasSSSE3) to disable SSSE3. 40 // -1 to enable all cpu specific optimizations. 41 // 0 to disable all cpu specific optimizations. 42 void MaskCpuFlags(int enable_flags); 43 44 #ifdef __cplusplus 45 } // extern "C" 46 } // namespace libyuv 47 #endif 48 49 #endif // INCLUDE_LIBYUV_CPU_ID_H_ 50