mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2026-01-01 03:12:16 +08:00
For cpu's with Neon, set arm as well. Make unittest allow testdata unaccessable but try proc/cpuinfo
BUG=none TEST=none Review URL: https://webrtc-codereview.appspot.com/610005 git-svn-id: http://libyuv.googlecode.com/svn/trunk@273 16f28f9a-4ce2-e073-06de-1de4eb20be90
This commit is contained in:
parent
ab41581844
commit
7afffcc4d0
@ -1,6 +1,6 @@
|
||||
Name: libyuv
|
||||
URL: http://code.google.com/p/libyuv/
|
||||
Version: 272
|
||||
Version: 273
|
||||
License: BSD
|
||||
License File: LICENSE
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
#ifndef INCLUDE_LIBYUV_VERSION_H_
|
||||
#define INCLUDE_LIBYUV_VERSION_H_
|
||||
|
||||
#define LIBYUV_VERSION 272
|
||||
#define LIBYUV_VERSION 273
|
||||
|
||||
#endif // INCLUDE_LIBYUV_VERSION_H_
|
||||
|
||||
|
||||
@ -57,14 +57,15 @@ void CpuId(int cpu_info[4], int info_type) {
|
||||
}
|
||||
|
||||
// based on libvpx arm_cpudetect.c
|
||||
// For Arm, but testable on any CPU
|
||||
int ArmCpuCaps(const char* cpuinfoname) {
|
||||
// For Arm, but public to allow testing on any CPU
|
||||
int ArmCpuCaps(const char* cpuinfo_name) {
|
||||
int flags = 0;
|
||||
FILE* fin = fopen(cpuinfoname, "r");
|
||||
FILE* fin = fopen(cpuinfo_name, "r");
|
||||
if (fin) {
|
||||
char buf[512];
|
||||
while (fgets(buf, 511, fin)) {
|
||||
if (memcmp(buf, "Features", 8) == 0) {
|
||||
flags |= kCpuInitialized;
|
||||
char* p = strstr(buf, " neon");
|
||||
if (p && (p[5] == ' ' || p[5] == '\n')) {
|
||||
flags |= kCpuHasNEON;
|
||||
@ -81,7 +82,7 @@ int ArmCpuCaps(const char* cpuinfoname) {
|
||||
int cpu_info_ = 0;
|
||||
|
||||
int InitCpuFlags() {
|
||||
#ifdef CPU_X86
|
||||
#if defined(CPU_X86)
|
||||
int cpu_info[4];
|
||||
__cpuid(cpu_info, 1);
|
||||
cpu_info_ = ((cpu_info[3] & 0x04000000) ? kCpuHasSSE2 : 0) |
|
||||
@ -113,15 +114,17 @@ int InitCpuFlags() {
|
||||
if (getenv("LIBYUV_DISABLE_ASM")) {
|
||||
cpu_info_ = kCpuInitialized;
|
||||
}
|
||||
#elif defined(__linux__) && defined(__ARM_NEON__)
|
||||
cpu_info_ = ArmCpuCaps("/proc/cpuinfo") | kCpuInitialized;
|
||||
#elif defined(__arm__)
|
||||
#if defined(__linux__) && defined(__ARM_NEON__)
|
||||
// linux arm parse text file for neon detect.
|
||||
cpu_info_ = ArmCpuCaps("/proc/cpuinfo");
|
||||
#elif defined(__ARM_NEON__)
|
||||
// gcc -mfpu=neon defines __ARM_NEON__
|
||||
// Enable Neon if you want support for Neon and Arm, and use MaskCpuFlags
|
||||
// to disable Neon on devices that do not have it.
|
||||
cpu_info_ = kCpuHasNEON | kCpuInitialized | kCpuHasARM;
|
||||
#else
|
||||
cpu_info_ = kCpuInitialized | kCpuHasARM;
|
||||
cpu_info_ = kCpuHasNEON;
|
||||
#endif
|
||||
cpu_info_ |= kCpuInitialized | kCpuHasARM;
|
||||
#endif
|
||||
return cpu_info_;
|
||||
}
|
||||
|
||||
@ -89,8 +89,18 @@ TEST_F(libyuvTest, TestCpuId) {
|
||||
extern "C" int ArmCpuCaps(const char* cpuinfoname);
|
||||
|
||||
TEST_F(libyuvTest, TestLinuxNeon) {
|
||||
EXPECT_EQ(0, ArmCpuCaps("unit_test/testdata/arm_v7.txt"));
|
||||
EXPECT_EQ(kCpuHasNEON, ArmCpuCaps("unit_test/testdata/tegra3.txt"));
|
||||
int testdata = ArmCpuCaps("unit_test/testdata/arm_v7.txt");
|
||||
if (testdata) {
|
||||
EXPECT_EQ(kCpuInitialized,
|
||||
ArmCpuCaps("unit_test/testdata/arm_v7.txt"));
|
||||
EXPECT_EQ((kCpuInitialized | kCpuHasNEON),
|
||||
ArmCpuCaps("unit_test/testdata/tegra3.txt"));
|
||||
} else {
|
||||
printf("WARNING: unable to load \"unit_test/testdata/arm_v7.txt\"\n");
|
||||
}
|
||||
#if defined(__linux__) && defined(__ARM_NEON__)
|
||||
EXPECT_NE(0, ArmCpuCaps("/proc/cpuinfo"));
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace libyuv
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user