| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license | |
| 5 * that can be found in the LICENSE file in the root of the source | |
| 6 * tree. An additional intellectual property rights grant can be found | |
| 7 * in the file PATENTS. All contributing project authors may | |
| 8 * be found in the AUTHORS file in the root of the source tree. | |
| 9 */ | |
| 10 | |
| 11 #include "webrtc/media/base/cpuid.h" | |
| 12 | |
| 13 #include "libyuv/cpu_id.h" | |
| 14 | |
| 15 namespace cricket { | |
| 16 | |
| 17 bool CpuInfo::TestCpuFlag(int flag) { | |
| 18 return libyuv::TestCpuFlag(flag) ? true : false; | |
| 19 } | |
| 20 | |
| 21 void CpuInfo::MaskCpuFlagsForTest(int enable_flags) { | |
| 22 libyuv::MaskCpuFlags(enable_flags); | |
| 23 } | |
| 24 | |
| 25 // Detect an Intel Core I5 or better such as 4th generation Macbook Air. | |
| 26 bool IsCoreIOrBetter() { | |
| 27 #if defined(__i386__) || defined(__x86_64__) || \ | |
| 28 defined(_M_IX86) || defined(_M_X64) | |
| 29 uint32_t cpu_info[4]; | |
| 30 libyuv::CpuId(0, 0, &cpu_info[0]); // Function 0: Vendor ID | |
| 31 if (cpu_info[1] == 0x756e6547 && cpu_info[3] == 0x49656e69 && | |
| 32 cpu_info[2] == 0x6c65746e) { // GenuineIntel | |
| 33 // Detect CPU Family and Model | |
| 34 // 3:0 - Stepping | |
| 35 // 7:4 - Model | |
| 36 // 11:8 - Family | |
| 37 // 13:12 - Processor Type | |
| 38 // 19:16 - Extended Model | |
| 39 // 27:20 - Extended Family | |
| 40 libyuv::CpuId(1, 0, &cpu_info[0]); // Function 1: Family and Model | |
| 41 int family = ((cpu_info[0] >> 8) & 0x0f) | ((cpu_info[0] >> 16) & 0xff0); | |
| 42 int model = ((cpu_info[0] >> 4) & 0x0f) | ((cpu_info[0] >> 12) & 0xf0); | |
| 43 // CpuFamily | CpuModel | Name | |
| 44 // 6 | 14 | Yonah -- Core | |
| 45 // 6 | 15 | Merom -- Core 2 | |
| 46 // 6 | 23 | Penryn -- Core 2 (most common) | |
| 47 // 6 | 26 | Nehalem -- Core i* | |
| 48 // 6 | 28 | Atom | |
| 49 // 6 | 30 | Lynnfield -- Core i* | |
| 50 // 6 | 37 | Westmere -- Core i* | |
| 51 const int kAtom = 28; | |
| 52 const int kCore2 = 23; | |
| 53 if (family < 6 || family == 15 || | |
| 54 (family == 6 && (model == kAtom || model <= kCore2))) { | |
| 55 return false; | |
| 56 } | |
| 57 return true; | |
| 58 } | |
| 59 #endif | |
| 60 return false; | |
| 61 } | |
| 62 | |
| 63 } // namespace cricket | |
| OLD | NEW |