23 #define CORE_FLAG(f) \
24 (AV_CPU_FLAG_ ## f * (HAVE_ ## f ## _EXTERNAL || HAVE_ ## f ## _INLINE))
26 #define CORE_CPU_FLAGS \
27 (CORE_FLAG(ARMV5TE) | \
29 CORE_FLAG(ARMV6T2) | \
34 #if defined __linux__ || defined __ANDROID__
44 #define HWCAP_VFP (1 << 6)
45 #define HWCAP_EDSP (1 << 7)
46 #define HWCAP_THUMBEE (1 << 11)
47 #define HWCAP_NEON (1 << 12)
48 #define HWCAP_VFPv3 (1 << 13)
49 #define HWCAP_TLS (1 << 15)
51 static int get_hwcap(uint32_t *hwcap)
53 struct { uint32_t a_type; uint32_t a_val; } auxv;
54 FILE *
f = fopen(
"/proc/self/auxv",
"r");
60 while (fread(&auxv,
sizeof(auxv), 1, f) > 0) {
61 if (auxv.a_type == AT_HWCAP) {
72 static int get_cpuinfo(uint32_t *hwcap)
74 FILE *
f = fopen(
"/proc/cpuinfo",
"r");
81 while (fgets(buf,
sizeof(buf), f)) {
83 if (strstr(buf,
" edsp "))
85 if (strstr(buf,
" tls "))
87 if (strstr(buf,
" thumbee "))
88 *hwcap |= HWCAP_THUMBEE;
89 if (strstr(buf,
" vfp "))
91 if (strstr(buf,
" vfpv3 "))
92 *hwcap |= HWCAP_VFPv3;
93 if (strstr(buf,
" neon ") || strstr(buf,
" asimd "))
95 if (strstr(buf,
" fp "))
96 *hwcap |= HWCAP_VFP | HWCAP_VFPv3;
109 if (get_hwcap(&hwcap) < 0)
110 if (get_cpuinfo(&hwcap) < 0)
113 #define check_cap(cap, flag) do { \
114 if (hwcap & HWCAP_ ## cap) \
115 flags |= AV_CPU_FLAG_ ## flag; \
120 check_cap(EDSP, ARMV5TE);
121 check_cap(TLS, ARMV6);
122 check_cap(THUMBEE, ARMV6T2);
124 check_cap(VFPv3, VFPV3);
125 check_cap(NEON, NEON);
153 AV_CPU_FLAG_ARMV6T2 * HAVE_ARMV6T2 |
154 AV_CPU_FLAG_VFP * HAVE_VFP |
#define AV_CPU_FLAG_ARMV6T2
#define AV_CPU_FLAG_VFP_VM
VFPv2 vector mode, deprecated in ARMv7-A and unavailable in various CPUs implementations.
#define AV_CPU_FLAG_ARMV5TE
#define AV_CPU_FLAG_VFPV3
#define AV_CPU_FLAG_ARMV6
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
#define flags(name, subs,...)
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
int ff_get_cpu_flags_arm(void)
#define AV_CPU_FLAG_SETEND
size_t ff_get_cpu_max_align_arm(void)