Commit cb3344ae authored by fbarchard@google.com's avatar fbarchard@google.com

If libyuv built with Neon, assume Neon is present on CPU.

BUG=315
TESTED=untested
R=nfullagar@chromium.org

Review URL: https://webrtc-codereview.appspot.com/9589004

git-svn-id: http://libyuv.googlecode.com/svn/trunk@980 16f28f9a-4ce2-e073-06de-1de4eb20be90
parent 4b3428e7
Name: libyuv Name: libyuv
URL: http://code.google.com/p/libyuv/ URL: http://code.google.com/p/libyuv/
Version: 979 Version: 980
License: BSD License: BSD
License File: LICENSE License File: LICENSE
......
...@@ -11,6 +11,6 @@ ...@@ -11,6 +11,6 @@
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT #ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
#define INCLUDE_LIBYUV_VERSION_H_ #define INCLUDE_LIBYUV_VERSION_H_
#define LIBYUV_VERSION 979 #define LIBYUV_VERSION 980
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
...@@ -121,19 +121,20 @@ void CpuId(uint32 eax, uint32 ecx, uint32* cpu_info) { ...@@ -121,19 +121,20 @@ void CpuId(uint32 eax, uint32 ecx, uint32* cpu_info) {
LIBYUV_API SAFEBUFFERS LIBYUV_API SAFEBUFFERS
int ArmCpuCaps(const char* cpuinfo_name) { int ArmCpuCaps(const char* cpuinfo_name) {
FILE* f = fopen(cpuinfo_name, "r"); FILE* f = fopen(cpuinfo_name, "r");
if (f) { if (!f) {
char cpuinfo_line[512]; return kCpuHasNEON; // Assume Neon if /proc/cpuinfo is unavailable.
while (fgets(cpuinfo_line, sizeof(cpuinfo_line) - 1, f)) { }
if (memcmp(cpuinfo_line, "Features", 8) == 0) { char cpuinfo_line[512];
char* p = strstr(cpuinfo_line, " neon"); while (fgets(cpuinfo_line, sizeof(cpuinfo_line) - 1, f)) {
if (p && (p[5] == ' ' || p[5] == '\n')) { if (memcmp(cpuinfo_line, "Features", 8) == 0) {
fclose(f); char* p = strstr(cpuinfo_line, " neon");
return kCpuHasNEON; if (p && (p[5] == ' ' || p[5] == '\n')) {
} fclose(f);
return kCpuHasNEON;
} }
} }
fclose(f);
} }
fclose(f);
return 0; return 0;
} }
...@@ -247,15 +248,14 @@ int InitCpuFlags(void) { ...@@ -247,15 +248,14 @@ int InitCpuFlags(void) {
cpu_info_ &= ~kCpuHasMIPS_DSPR2; cpu_info_ &= ~kCpuHasMIPS_DSPR2;
} }
#elif defined(__arm__) #elif defined(__arm__)
#if defined(__linux__) && (defined(__ARM_NEON__) || defined(LIBYUV_NEON)) && \ #if defined(__ARM_NEON__) || defined(__native_client__) || !defined(__linux__)
!defined(__native_client__)
// Linux arm parse text file for neon detect.
cpu_info_ = ArmCpuCaps("/proc/cpuinfo");
#elif defined(__ARM_NEON__) || defined(__native_client__)
// 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; cpu_info_ = kCpuHasNEON;
#else
// Linux arm parse text file for neon detect.
cpu_info_ = ArmCpuCaps("/proc/cpuinfo");
#endif #endif
cpu_info_ |= kCpuHasARM; cpu_info_ |= kCpuHasARM;
if (TestEnv("LIBYUV_DISABLE_NEON")) { if (TestEnv("LIBYUV_DISABLE_NEON")) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment