11b362b15af34006e6a11974088a46d42b903418eJohann/* 21b362b15af34006e6a11974088a46d42b903418eJohann * Copyright (c) 2011 The LibYuv project authors. All Rights Reserved. 31b362b15af34006e6a11974088a46d42b903418eJohann * 41b362b15af34006e6a11974088a46d42b903418eJohann * Use of this source code is governed by a BSD-style license 51b362b15af34006e6a11974088a46d42b903418eJohann * that can be found in the LICENSE file in the root of the source 61b362b15af34006e6a11974088a46d42b903418eJohann * tree. An additional intellectual property rights grant can be found 71b362b15af34006e6a11974088a46d42b903418eJohann * in the file PATENTS. All contributing project authors may 81b362b15af34006e6a11974088a46d42b903418eJohann * be found in the AUTHORS file in the root of the source tree. 91b362b15af34006e6a11974088a46d42b903418eJohann */ 101b362b15af34006e6a11974088a46d42b903418eJohann 111b362b15af34006e6a11974088a46d42b903418eJohann#ifndef INCLUDE_LIBYUV_CPU_ID_H_ 121b362b15af34006e6a11974088a46d42b903418eJohann#define INCLUDE_LIBYUV_CPU_ID_H_ 131b362b15af34006e6a11974088a46d42b903418eJohann 141b362b15af34006e6a11974088a46d42b903418eJohann#ifdef __cplusplus 151b362b15af34006e6a11974088a46d42b903418eJohannnamespace libyuv { 161b362b15af34006e6a11974088a46d42b903418eJohannextern "C" { 171b362b15af34006e6a11974088a46d42b903418eJohann#endif 181b362b15af34006e6a11974088a46d42b903418eJohann 191b362b15af34006e6a11974088a46d42b903418eJohann// These flags are only valid on x86 processors 201b362b15af34006e6a11974088a46d42b903418eJohannstatic const int kCpuHasSSE2 = 1; 211b362b15af34006e6a11974088a46d42b903418eJohannstatic const int kCpuHasSSSE3 = 2; 221b362b15af34006e6a11974088a46d42b903418eJohann 231b362b15af34006e6a11974088a46d42b903418eJohann// These flags are only valid on ARM processors 241b362b15af34006e6a11974088a46d42b903418eJohannstatic const int kCpuHasNEON = 4; 251b362b15af34006e6a11974088a46d42b903418eJohann 261b362b15af34006e6a11974088a46d42b903418eJohann// Internal flag to indicate cpuid is initialized. 271b362b15af34006e6a11974088a46d42b903418eJohannstatic const int kCpuInitialized = 8; 281b362b15af34006e6a11974088a46d42b903418eJohann 291b362b15af34006e6a11974088a46d42b903418eJohann// Detect CPU has SSE2 etc. 301b362b15af34006e6a11974088a46d42b903418eJohann// test_flag parameter should be one of kCpuHas constants above 311b362b15af34006e6a11974088a46d42b903418eJohann// returns non-zero if instruction set is detected 321b362b15af34006e6a11974088a46d42b903418eJohannstatic __inline int TestCpuFlag(int test_flag) { 331b362b15af34006e6a11974088a46d42b903418eJohann extern int cpu_info_; 341b362b15af34006e6a11974088a46d42b903418eJohann extern int InitCpuFlags(); 351b362b15af34006e6a11974088a46d42b903418eJohann return (cpu_info_ ? cpu_info_ : InitCpuFlags()) & test_flag; 361b362b15af34006e6a11974088a46d42b903418eJohann} 371b362b15af34006e6a11974088a46d42b903418eJohann 381b362b15af34006e6a11974088a46d42b903418eJohann// For testing, allow CPU flags to be disabled. 391b362b15af34006e6a11974088a46d42b903418eJohann// ie MaskCpuFlags(~kCpuHasSSSE3) to disable SSSE3. 401b362b15af34006e6a11974088a46d42b903418eJohann// -1 to enable all cpu specific optimizations. 411b362b15af34006e6a11974088a46d42b903418eJohann// 0 to disable all cpu specific optimizations. 421b362b15af34006e6a11974088a46d42b903418eJohannvoid MaskCpuFlags(int enable_flags); 431b362b15af34006e6a11974088a46d42b903418eJohann 441b362b15af34006e6a11974088a46d42b903418eJohann#ifdef __cplusplus 451b362b15af34006e6a11974088a46d42b903418eJohann} // extern "C" 461b362b15af34006e6a11974088a46d42b903418eJohann} // namespace libyuv 471b362b15af34006e6a11974088a46d42b903418eJohann#endif 481b362b15af34006e6a11974088a46d42b903418eJohann 491b362b15af34006e6a11974088a46d42b903418eJohann#endif // INCLUDE_LIBYUV_CPU_ID_H_ 50