aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-02-12 12:40:57 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-02-12 12:41:09 +0100
commit3ccda2b02ba643df35bf76988cfecba0c5034bb1 (patch)
treee2c413f713d553319bea713930e5e86389a3af84
parent7ff1a4b10f2d7f9a4ae1c72e1259b4ed7d13e316 (diff)
parent375ef6528c9dd2db7f9881e232cb0ec3aa16970d (diff)
downloadffmpeg-3ccda2b02ba643df35bf76988cfecba0c5034bb1.tar.gz
Merge commit '375ef6528c9dd2db7f9881e232cb0ec3aa16970d'
* commit '375ef6528c9dd2db7f9881e232cb0ec3aa16970d': libfdk-aacenc: Actually check for upper bounds of cutoff arm: Fall back to runtime cpu feature detection via /proc/cpuinfo Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavutil/arm/cpu.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/libavutil/arm/cpu.c b/libavutil/arm/cpu.c
index 041afc985a..b4aabc375e 100644
--- a/libavutil/arm/cpu.c
+++ b/libavutil/arm/cpu.c
@@ -34,6 +34,8 @@
#include <stdint.h>
#include <stdio.h>
+#include <string.h>
+#include "libavutil/avstring.h"
#define AT_HWCAP 16
@@ -66,13 +68,44 @@ static int get_hwcap(uint32_t *hwcap)
return err;
}
+static int get_cpuinfo(uint32_t *hwcap)
+{
+ FILE *f = fopen("/proc/cpuinfo", "r");
+ char buf[200];
+
+ if (!f)
+ return -1;
+
+ *hwcap = 0;
+ while (fgets(buf, sizeof(buf), f)) {
+ if (av_strstart(buf, "Features", NULL)) {
+ if (strstr(buf, " edsp "))
+ *hwcap |= HWCAP_EDSP;
+ if (strstr(buf, " tls "))
+ *hwcap |= HWCAP_TLS;
+ if (strstr(buf, " thumbee "))
+ *hwcap |= HWCAP_THUMBEE;
+ if (strstr(buf, " vfp "))
+ *hwcap |= HWCAP_VFP;
+ if (strstr(buf, " vfpv3 "))
+ *hwcap |= HWCAP_VFPv3;
+ if (strstr(buf, " neon "))
+ *hwcap |= HWCAP_NEON;
+ break;
+ }
+ }
+ fclose(f);
+ return 0;
+}
+
int ff_get_cpu_flags_arm(void)
{
int flags = CORE_CPU_FLAGS;
uint32_t hwcap;
if (get_hwcap(&hwcap) < 0)
- return flags;
+ if (get_cpuinfo(&hwcap) < 0)
+ return flags;
#define check_cap(cap, flag) do { \
if (hwcap & HWCAP_ ## cap) \