diff --git a/README.chromium b/README.chromium index 9499fb09b..b507acaa5 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 270 +Version: 271 License: BSD License File: LICENSE diff --git a/include/libyuv/cpu_id.h b/include/libyuv/cpu_id.h index cfa9ec15a..354919bdb 100644 --- a/include/libyuv/cpu_id.h +++ b/include/libyuv/cpu_id.h @@ -16,18 +16,20 @@ namespace libyuv { extern "C" { #endif -// These flags are only valid on x86 processors -static const int kCpuHasX86 = 1; -static const int kCpuHasSSE2 = 2; -static const int kCpuHasSSSE3 = 4; -static const int kCpuHasSSE41 = 8; +// Internal flag to indicate cpuid is initialized. +static const int kCpuInitialized = 1; // These flags are only valid on ARM processors -static const int kCpuHasARM = 16; -static const int kCpuHasNEON = 32; +static const int kCpuHasARM = 2; +static const int kCpuHasNEON = 4; -// Internal flag to indicate cpuid is initialized. -static const int kCpuInitialized = 64; +// 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. diff --git a/include/libyuv/version.h b/include/libyuv/version.h index efe352d24..d398bc2b8 100644 --- a/include/libyuv/version.h +++ b/include/libyuv/version.h @@ -11,7 +11,7 @@ #ifndef INCLUDE_LIBYUV_VERSION_H_ #define INCLUDE_LIBYUV_VERSION_H_ -#define LIBYUV_VERSION 270 +#define LIBYUV_VERSION 271 #endif // INCLUDE_LIBYUV_VERSION_H_ diff --git a/source/cpu_id.cc b/source/cpu_id.cc index 9832e0d8c..54bce3cc6 100644 --- a/source/cpu_id.cc +++ b/source/cpu_id.cc @@ -84,9 +84,11 @@ int InitCpuFlags() { #ifdef CPU_X86 int cpu_info[4]; __cpuid(cpu_info, 1); - cpu_info_ = (cpu_info[3] & 0x04000000 ? kCpuHasSSE2 : 0) | - (cpu_info[2] & 0x00000200 ? kCpuHasSSSE3 : 0) | - (cpu_info[2] & 0x00080000 ? kCpuHasSSE41 : 0) | + cpu_info_ = ((cpu_info[3] & 0x04000000) ? kCpuHasSSE2 : 0) | + ((cpu_info[2] & 0x00000200) ? kCpuHasSSSE3 : 0) | + ((cpu_info[2] & 0x00080000) ? kCpuHasSSE41 : 0) | + ((cpu_info[2] & 0x00100000) ? kCpuHasSSE42 : 0) | + (((cpu_info[2] & 0x18000000) == 0x18000000) ? kCpuHasAVX : 0) | kCpuInitialized | kCpuHasX86; // environment variable overrides for testing. diff --git a/unit_test/cpu_test.cc b/unit_test/cpu_test.cc index a1d75dc52..393c72b6a 100644 --- a/unit_test/cpu_test.cc +++ b/unit_test/cpu_test.cc @@ -19,10 +19,16 @@ namespace libyuv { TEST_F(libyuvTest, TestVersion) { - EXPECT_GE(LIBYUV_VERSION, 169); + EXPECT_GE(LIBYUV_VERSION, 169); // 169 is first version to support version. } TEST_F(libyuvTest, TestCpuHas) { + int cpu_flags = TestCpuFlag(~kCpuInitialized); + printf("Cpu Flags %x\n", cpu_flags); + int has_arm = TestCpuFlag(kCpuHasARM); + printf("Has ARM %d\n", has_arm); + int has_neon = TestCpuFlag(kCpuHasNEON); + printf("Has NEON %d\n", has_neon); int has_x86 = TestCpuFlag(kCpuHasX86); printf("Has X86 %d\n", has_x86); int has_sse2 = TestCpuFlag(kCpuHasSSE2); @@ -31,10 +37,10 @@ TEST_F(libyuvTest, TestCpuHas) { printf("Has SSSE3 %d\n", has_ssse3); int has_sse41 = TestCpuFlag(kCpuHasSSE41); printf("Has SSE4.1 %d\n", has_sse41); - int has_arm = TestCpuFlag(kCpuHasARM); - printf("Has ARM %d\n", has_arm); - int has_neon = TestCpuFlag(kCpuHasNEON); - printf("Has NEON %d\n", has_neon); + int has_sse42 = TestCpuFlag(kCpuHasSSE42); + printf("Has SSE4.2 %d\n", has_sse42); + int has_avx = TestCpuFlag(kCpuHasAVX); + printf("Has AVX %d\n", has_avx); } #if defined(__i386__) || defined(__x86_64__) || \