From 8c9de166a11222d6aa38deb12449b30451d2eca5 Mon Sep 17 00:00:00 2001 From: "fbarchard@google.com" Date: Thu, 28 Mar 2013 09:33:26 +0000 Subject: [PATCH] ERMS BUG=none TEST=none Review URL: https://webrtc-codereview.appspot.com/1265004 git-svn-id: http://libyuv.googlecode.com/svn/trunk@625 16f28f9a-4ce2-e073-06de-1de4eb20be90 --- README.chromium | 2 +- include/libyuv/cpu_id.h | 1 + include/libyuv/version.h | 2 +- source/cpu_id.cc | 9 +++++++++ source/row_win.cc | 2 +- unit_test/cpu_test.cc | 2 ++ util/cpuid.c | 2 ++ 7 files changed, 17 insertions(+), 3 deletions(-) diff --git a/README.chromium b/README.chromium index aac3f6621..537249737 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 623 +Version: 624 License: BSD License File: LICENSE diff --git a/include/libyuv/cpu_id.h b/include/libyuv/cpu_id.h index 5f4d8fb8a..8b6d04322 100644 --- a/include/libyuv/cpu_id.h +++ b/include/libyuv/cpu_id.h @@ -34,6 +34,7 @@ static const int kCpuHasSSE41 = 0x80; static const int kCpuHasSSE42 = 0x100; static const int kCpuHasAVX = 0x200; static const int kCpuHasAVX2 = 0x400; +static const int kCpuHasERMS = 0x800; // These flags are only valid on MIPS processors. static const int kCpuHasMIPS = 0x1000; diff --git a/include/libyuv/version.h b/include/libyuv/version.h index f8280d61b..d4144001f 100644 --- a/include/libyuv/version.h +++ b/include/libyuv/version.h @@ -11,6 +11,6 @@ #ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT #define INCLUDE_LIBYUV_VERSION_H_ -#define LIBYUV_VERSION 623 +#define LIBYUV_VERSION 624 #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT diff --git a/source/cpu_id.cc b/source/cpu_id.cc index 4ee9fd69d..235a04ec6 100644 --- a/source/cpu_id.cc +++ b/source/cpu_id.cc @@ -26,6 +26,9 @@ #include "libyuv/basic_types.h" // For CPU_X86 +// TODO(fbarchard): Consider cpu functionality for breakpoints, timer and cache. +// arm - bkpt vs intel int 3 + // TODO(fbarchard): Use cpuid.h when gcc 4.4 is used on OSX and Linux. #if (defined(__pic__) || defined(__APPLE__)) && defined(__i386__) static __inline void __cpuid(int cpu_info[4], int info_type) { @@ -171,6 +174,9 @@ int InitCpuFlags(void) { ((XGetBV(kXCR_XFEATURE_ENABLED_MASK) & 0x06) == 0x06)) { cpu_info_ |= kCpuHasAVX2; } + if (cpu_info[1] & 0x00000200) { + cpu_info_ |= kCpuHasERMS; + } } #endif // Environment variable overrides for testing. @@ -195,6 +201,9 @@ int InitCpuFlags(void) { if (TestEnv("LIBYUV_DISABLE_AVX2")) { cpu_info_ &= ~kCpuHasAVX2; } + if (TestEnv("LIBYUV_DISABLE_ERMS")) { + cpu_info_ &= ~kCpuHasERMS; + } #elif defined(__mips__) && defined(__linux__) // Linux mips parse text file for dsp detect. cpu_info_ = MipsCpuCaps("dsp"); // set kCpuHasMIPS_DSP. diff --git a/source/row_win.cc b/source/row_win.cc index d56ffd717..3d4293551 100644 --- a/source/row_win.cc +++ b/source/row_win.cc @@ -696,7 +696,7 @@ void ARGBToYJRow_SSSE3(const uint8* src_argb, uint8* dst_y, int pix) { lea eax, [eax + 64] phaddw xmm0, xmm1 phaddw xmm2, xmm3 - paddw xmm0, xmm5 + paddw xmm0, xmm5 // Add .5 for rounding. paddw xmm2, xmm5 psrlw xmm0, 7 psrlw xmm2, 7 diff --git a/unit_test/cpu_test.cc b/unit_test/cpu_test.cc index 8dbe245ed..67c489cfc 100644 --- a/unit_test/cpu_test.cc +++ b/unit_test/cpu_test.cc @@ -39,6 +39,8 @@ TEST_F(libyuvTest, TestCpuHas) { printf("Has AVX %x\n", has_avx); int has_avx2 = TestCpuFlag(kCpuHasAVX2); printf("Has AVX2 %x\n", has_avx2); + int has_erms = TestCpuFlag(kCpuHasERMS); + printf("Has ERMS %x\n", has_erms); int has_mips = TestCpuFlag(kCpuHasMIPS); printf("Has MIPS %x\n", has_mips); int has_mips_dsp = TestCpuFlag(kCpuHasMIPS_DSP); diff --git a/util/cpuid.c b/util/cpuid.c index 6f2a1fdac..751405c5e 100644 --- a/util/cpuid.c +++ b/util/cpuid.c @@ -22,6 +22,7 @@ int main(int argc, const char* argv[]) { int has_arm = TestCpuFlag(kCpuHasARM); int has_avx = TestCpuFlag(kCpuHasAVX); int has_avx2 = TestCpuFlag(kCpuHasAVX2); + int has_erms = TestCpuFlag(kCpuHasERMS); int has_mips = TestCpuFlag(kCpuHasMIPS); int has_mips_dsp = TestCpuFlag(kCpuHasMIPS_DSP); int has_mips_dspr2 = TestCpuFlag(kCpuHasMIPS_DSPR2); @@ -70,6 +71,7 @@ int main(int argc, const char* argv[]) { printf("Has ARM %x\n", has_arm); printf("Has AVX %x\n", has_avx); printf("Has AVX2 %x\n", has_avx2); + printf("Has ERMS %x\n", has_erms); printf("Has MIPS %x\n", has_mips); printf("Has MIPS DSP %x\n", has_mips_dsp); printf("Has MIPS DSPR2 %x\n", has_mips_dspr2);