From 4e8baf46a74f853b68f235e5617ed5385b946f37 Mon Sep 17 00:00:00 2001 From: nisse Date: Wed, 5 Oct 2016 23:44:40 -0700 Subject: [PATCH] Delete unused code, cpuinfo.{h,cc}. BUG=webrtc:6424 Review-Url: https://codereview.webrtc.org/2385053004 Cr-Commit-Position: refs/heads/master@{#14538} --- webrtc/media/BUILD.gn | 2 - webrtc/media/base/cpuid.cc | 63 ----------------------------- webrtc/media/base/cpuid.h | 59 --------------------------- webrtc/media/base/cpuid_unittest.cc | 57 -------------------------- webrtc/media/media.gyp | 2 - 5 files changed, 183 deletions(-) delete mode 100644 webrtc/media/base/cpuid.cc delete mode 100644 webrtc/media/base/cpuid.h delete mode 100644 webrtc/media/base/cpuid_unittest.cc diff --git a/webrtc/media/BUILD.gn b/webrtc/media/BUILD.gn index 963c49d126..122c404455 100644 --- a/webrtc/media/BUILD.gn +++ b/webrtc/media/BUILD.gn @@ -52,8 +52,6 @@ rtc_static_library("rtc_media") { "base/audiosource.h", "base/codec.cc", "base/codec.h", - "base/cpuid.cc", - "base/cpuid.h", "base/cryptoparams.h", "base/device.h", "base/hybriddataengine.h", diff --git a/webrtc/media/base/cpuid.cc b/webrtc/media/base/cpuid.cc deleted file mode 100644 index b97a35f476..0000000000 --- a/webrtc/media/base/cpuid.cc +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/media/base/cpuid.h" - -#include "libyuv/cpu_id.h" - -namespace cricket { - -bool CpuInfo::TestCpuFlag(int flag) { - return libyuv::TestCpuFlag(flag) ? true : false; -} - -void CpuInfo::MaskCpuFlagsForTest(int enable_flags) { - libyuv::MaskCpuFlags(enable_flags); -} - -// Detect an Intel Core I5 or better such as 4th generation Macbook Air. -bool IsCoreIOrBetter() { -#if defined(__i386__) || defined(__x86_64__) || \ - defined(_M_IX86) || defined(_M_X64) - uint32_t cpu_info[4]; - libyuv::CpuId(0, 0, &cpu_info[0]); // Function 0: Vendor ID - if (cpu_info[1] == 0x756e6547 && cpu_info[3] == 0x49656e69 && - cpu_info[2] == 0x6c65746e) { // GenuineIntel - // Detect CPU Family and Model - // 3:0 - Stepping - // 7:4 - Model - // 11:8 - Family - // 13:12 - Processor Type - // 19:16 - Extended Model - // 27:20 - Extended Family - libyuv::CpuId(1, 0, &cpu_info[0]); // Function 1: Family and Model - int family = ((cpu_info[0] >> 8) & 0x0f) | ((cpu_info[0] >> 16) & 0xff0); - int model = ((cpu_info[0] >> 4) & 0x0f) | ((cpu_info[0] >> 12) & 0xf0); - // CpuFamily | CpuModel | Name - // 6 | 14 | Yonah -- Core - // 6 | 15 | Merom -- Core 2 - // 6 | 23 | Penryn -- Core 2 (most common) - // 6 | 26 | Nehalem -- Core i* - // 6 | 28 | Atom - // 6 | 30 | Lynnfield -- Core i* - // 6 | 37 | Westmere -- Core i* - const int kAtom = 28; - const int kCore2 = 23; - if (family < 6 || family == 15 || - (family == 6 && (model == kAtom || model <= kCore2))) { - return false; - } - return true; - } -#endif - return false; -} - -} // namespace cricket diff --git a/webrtc/media/base/cpuid.h b/webrtc/media/base/cpuid.h deleted file mode 100644 index 4cc0dcba5e..0000000000 --- a/webrtc/media/base/cpuid.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_MEDIA_BASE_CPUID_H_ -#define WEBRTC_MEDIA_BASE_CPUID_H_ - -#include "webrtc/base/constructormagic.h" - -namespace cricket { - -class CpuInfo { - public: - // The following flags must match libyuv/cpu_id.h values. - // Internal flag to indicate cpuid requires initialization. - static const int kCpuInit = 0x1; - - // These flags are only valid on ARM processors. - static const int kCpuHasARM = 0x2; - static const int kCpuHasNEON = 0x4; - // 0x8 reserved for future ARM flag. - - // These flags are only valid on x86 processors. - static const int kCpuHasX86 = 0x10; - static const int kCpuHasSSE2 = 0x20; - static const int kCpuHasSSSE3 = 0x40; - 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; - static const int kCpuHasMIPS_DSP = 0x2000; - static const int kCpuHasMIPS_DSPR2 = 0x4000; - - // Detect CPU has SSE2 etc. - static bool TestCpuFlag(int flag); - - // For testing, allow CPU flags to be disabled. - static void MaskCpuFlagsForTest(int enable_flags); - - private: - RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(CpuInfo); -}; - -// Detect an Intel Core I5 or better such as 4th generation Macbook Air. -bool IsCoreIOrBetter(); - -} // namespace cricket - -#endif // WEBRTC_MEDIA_BASE_CPUID_H_ diff --git a/webrtc/media/base/cpuid_unittest.cc b/webrtc/media/base/cpuid_unittest.cc deleted file mode 100644 index 6b1873b3a4..0000000000 --- a/webrtc/media/base/cpuid_unittest.cc +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/media/base/cpuid.h" - -#include - -#include "webrtc/base/basictypes.h" -#include "webrtc/base/gunit.h" -#include "webrtc/base/systeminfo.h" - -TEST(CpuInfoTest, CpuId) { - LOG(LS_INFO) << "ARM: " - << cricket::CpuInfo::TestCpuFlag(cricket::CpuInfo::kCpuHasARM); - LOG(LS_INFO) << "NEON: " - << cricket::CpuInfo::TestCpuFlag(cricket::CpuInfo::kCpuHasNEON); - LOG(LS_INFO) << "X86: " - << cricket::CpuInfo::TestCpuFlag(cricket::CpuInfo::kCpuHasX86); - LOG(LS_INFO) << "SSE2: " - << cricket::CpuInfo::TestCpuFlag(cricket::CpuInfo::kCpuHasSSE2); - LOG(LS_INFO) << "SSSE3: " - << cricket::CpuInfo::TestCpuFlag(cricket::CpuInfo::kCpuHasSSSE3); - LOG(LS_INFO) << "SSE41: " - << cricket::CpuInfo::TestCpuFlag(cricket::CpuInfo::kCpuHasSSE41); - LOG(LS_INFO) << "SSE42: " - << cricket::CpuInfo::TestCpuFlag(cricket::CpuInfo::kCpuHasSSE42); - LOG(LS_INFO) << "AVX: " - << cricket::CpuInfo::TestCpuFlag(cricket::CpuInfo::kCpuHasAVX); - bool has_arm = cricket::CpuInfo::TestCpuFlag(cricket::CpuInfo::kCpuHasARM); - bool has_x86 = cricket::CpuInfo::TestCpuFlag(cricket::CpuInfo::kCpuHasX86); - EXPECT_FALSE(has_arm && has_x86); -} - -TEST(CpuInfoTest, IsCoreIOrBetter) { - bool core_i_or_better = cricket::IsCoreIOrBetter(); - // Tests the function is callable. Run on known hardware to confirm. - LOG(LS_INFO) << "IsCoreIOrBetter: " << core_i_or_better; - - // All Core I CPUs have SSE 4.1. - if (core_i_or_better) { - EXPECT_TRUE(cricket::CpuInfo::TestCpuFlag(cricket::CpuInfo::kCpuHasSSE41)); - EXPECT_TRUE(cricket::CpuInfo::TestCpuFlag(cricket::CpuInfo::kCpuHasSSSE3)); - } - - // All CPUs that lack SSE 4.1 are not Core I CPUs. - if (!cricket::CpuInfo::TestCpuFlag(cricket::CpuInfo::kCpuHasSSE41)) { - EXPECT_FALSE(core_i_or_better); - } -} - diff --git a/webrtc/media/media.gyp b/webrtc/media/media.gyp index 24cfcc829e..4325b151cc 100644 --- a/webrtc/media/media.gyp +++ b/webrtc/media/media.gyp @@ -31,8 +31,6 @@ 'base/audiosource.h', 'base/codec.cc', 'base/codec.h', - 'base/cpuid.cc', - 'base/cpuid.h', 'base/cryptoparams.h', 'base/device.h', 'base/hybriddataengine.h',