mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2026-01-01 03:12:16 +08:00
Add SSE42 and AVX detect
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
This commit is contained in:
parent
221e602f8a
commit
4ae6b46ce1
@ -1,6 +1,6 @@
|
||||
Name: libyuv
|
||||
URL: http://code.google.com/p/libyuv/
|
||||
Version: 270
|
||||
Version: 271
|
||||
License: BSD
|
||||
License File: LICENSE
|
||||
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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_
|
||||
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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__) || \
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user