mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2026-02-16 15:19:52 +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
|
Name: libyuv
|
||||||
URL: http://code.google.com/p/libyuv/
|
URL: http://code.google.com/p/libyuv/
|
||||||
Version: 272
|
Version: 273
|
||||||
License: BSD
|
License: BSD
|
||||||
License File: LICENSE
|
License File: LICENSE
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@
|
|||||||
#ifndef INCLUDE_LIBYUV_VERSION_H_
|
#ifndef INCLUDE_LIBYUV_VERSION_H_
|
||||||
#define INCLUDE_LIBYUV_VERSION_H_
|
#define INCLUDE_LIBYUV_VERSION_H_
|
||||||
|
|
||||||
#define LIBYUV_VERSION 272
|
#define LIBYUV_VERSION 273
|
||||||
|
|
||||||
#endif // INCLUDE_LIBYUV_VERSION_H_
|
#endif // INCLUDE_LIBYUV_VERSION_H_
|
||||||
|
|
||||||
|
|||||||
@ -57,14 +57,15 @@ void CpuId(int cpu_info[4], int info_type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// based on libvpx arm_cpudetect.c
|
// based on libvpx arm_cpudetect.c
|
||||||
// For Arm, but testable on any CPU
|
// For Arm, but public to allow testing on any CPU
|
||||||
int ArmCpuCaps(const char* cpuinfoname) {
|
int ArmCpuCaps(const char* cpuinfo_name) {
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
FILE* fin = fopen(cpuinfoname, "r");
|
FILE* fin = fopen(cpuinfo_name, "r");
|
||||||
if (fin) {
|
if (fin) {
|
||||||
char buf[512];
|
char buf[512];
|
||||||
while (fgets(buf, 511, fin)) {
|
while (fgets(buf, 511, fin)) {
|
||||||
if (memcmp(buf, "Features", 8) == 0) {
|
if (memcmp(buf, "Features", 8) == 0) {
|
||||||
|
flags |= kCpuInitialized;
|
||||||
char* p = strstr(buf, " neon");
|
char* p = strstr(buf, " neon");
|
||||||
if (p && (p[5] == ' ' || p[5] == '\n')) {
|
if (p && (p[5] == ' ' || p[5] == '\n')) {
|
||||||
flags |= kCpuHasNEON;
|
flags |= kCpuHasNEON;
|
||||||
@ -81,7 +82,7 @@ int ArmCpuCaps(const char* cpuinfoname) {
|
|||||||
int cpu_info_ = 0;
|
int cpu_info_ = 0;
|
||||||
|
|
||||||
int InitCpuFlags() {
|
int InitCpuFlags() {
|
||||||
#ifdef CPU_X86
|
#if defined(CPU_X86)
|
||||||
int cpu_info[4];
|
int cpu_info[4];
|
||||||
__cpuid(cpu_info, 1);
|
__cpuid(cpu_info, 1);
|
||||||
cpu_info_ = ((cpu_info[3] & 0x04000000) ? kCpuHasSSE2 : 0) |
|
cpu_info_ = ((cpu_info[3] & 0x04000000) ? kCpuHasSSE2 : 0) |
|
||||||
@ -113,15 +114,17 @@ int InitCpuFlags() {
|
|||||||
if (getenv("LIBYUV_DISABLE_ASM")) {
|
if (getenv("LIBYUV_DISABLE_ASM")) {
|
||||||
cpu_info_ = kCpuInitialized;
|
cpu_info_ = kCpuInitialized;
|
||||||
}
|
}
|
||||||
#elif defined(__linux__) && defined(__ARM_NEON__)
|
#elif defined(__arm__)
|
||||||
cpu_info_ = ArmCpuCaps("/proc/cpuinfo") | kCpuInitialized;
|
#if defined(__linux__) && defined(__ARM_NEON__)
|
||||||
|
// linux arm parse text file for neon detect.
|
||||||
|
cpu_info_ = ArmCpuCaps("/proc/cpuinfo");
|
||||||
#elif defined(__ARM_NEON__)
|
#elif defined(__ARM_NEON__)
|
||||||
// gcc -mfpu=neon defines __ARM_NEON__
|
// gcc -mfpu=neon defines __ARM_NEON__
|
||||||
// Enable Neon if you want support for Neon and Arm, and use MaskCpuFlags
|
// Enable Neon if you want support for Neon and Arm, and use MaskCpuFlags
|
||||||
// to disable Neon on devices that do not have it.
|
// to disable Neon on devices that do not have it.
|
||||||
cpu_info_ = kCpuHasNEON | kCpuInitialized | kCpuHasARM;
|
cpu_info_ = kCpuHasNEON;
|
||||||
#else
|
#endif
|
||||||
cpu_info_ = kCpuInitialized | kCpuHasARM;
|
cpu_info_ |= kCpuInitialized | kCpuHasARM;
|
||||||
#endif
|
#endif
|
||||||
return cpu_info_;
|
return cpu_info_;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -89,8 +89,18 @@ TEST_F(libyuvTest, TestCpuId) {
|
|||||||
extern "C" int ArmCpuCaps(const char* cpuinfoname);
|
extern "C" int ArmCpuCaps(const char* cpuinfoname);
|
||||||
|
|
||||||
TEST_F(libyuvTest, TestLinuxNeon) {
|
TEST_F(libyuvTest, TestLinuxNeon) {
|
||||||
EXPECT_EQ(0, ArmCpuCaps("unit_test/testdata/arm_v7.txt"));
|
int testdata = ArmCpuCaps("unit_test/testdata/arm_v7.txt");
|
||||||
EXPECT_EQ(kCpuHasNEON, ArmCpuCaps("unit_test/testdata/tegra3.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
|
} // namespace libyuv
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user