2 * This file is part of FFmpeg.
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #include "libavutil/cpu.h"
24 #include "libavutil/avstring.h"
30 #include "compat/getopt.c"
38 { AV_CPU_FLAG_ARMV8, "armv8" },
39 { AV_CPU_FLAG_NEON, "neon" },
40 { AV_CPU_FLAG_VFP, "vfp" },
42 { AV_CPU_FLAG_ARMV5TE, "armv5te" },
43 { AV_CPU_FLAG_ARMV6, "armv6" },
44 { AV_CPU_FLAG_ARMV6T2, "armv6t2" },
45 { AV_CPU_FLAG_VFP, "vfp" },
46 { AV_CPU_FLAG_VFP_VM, "vfp_vm" },
47 { AV_CPU_FLAG_VFPV3, "vfpv3" },
48 { AV_CPU_FLAG_NEON, "neon" },
49 { AV_CPU_FLAG_SETEND, "setend" },
51 { AV_CPU_FLAG_ALTIVEC, "altivec" },
53 { AV_CPU_FLAG_MMI, "mmi" },
54 { AV_CPU_FLAG_MSA, "msa" },
56 { AV_CPU_FLAG_MMX, "mmx" },
57 { AV_CPU_FLAG_MMXEXT, "mmxext" },
58 { AV_CPU_FLAG_SSE, "sse" },
59 { AV_CPU_FLAG_SSE2, "sse2" },
60 { AV_CPU_FLAG_SSE2SLOW, "sse2slow" },
61 { AV_CPU_FLAG_SSE3, "sse3" },
62 { AV_CPU_FLAG_SSE3SLOW, "sse3slow" },
63 { AV_CPU_FLAG_SSSE3, "ssse3" },
64 { AV_CPU_FLAG_ATOM, "atom" },
65 { AV_CPU_FLAG_SSE4, "sse4.1" },
66 { AV_CPU_FLAG_SSE42, "sse4.2" },
67 { AV_CPU_FLAG_AVX, "avx" },
68 { AV_CPU_FLAG_AVXSLOW, "avxslow" },
69 { AV_CPU_FLAG_XOP, "xop" },
70 { AV_CPU_FLAG_FMA3, "fma3" },
71 { AV_CPU_FLAG_FMA4, "fma4" },
72 { AV_CPU_FLAG_3DNOW, "3dnow" },
73 { AV_CPU_FLAG_3DNOWEXT, "3dnowext" },
74 { AV_CPU_FLAG_CMOV, "cmov" },
75 { AV_CPU_FLAG_AVX2, "avx2" },
76 { AV_CPU_FLAG_BMI1, "bmi1" },
77 { AV_CPU_FLAG_BMI2, "bmi2" },
78 { AV_CPU_FLAG_AESNI, "aesni" },
79 { AV_CPU_FLAG_AVX512, "avx512" },
84 static void print_cpu_flags(int cpu_flags, const char *type)
88 printf("cpu_flags(%s) = 0x%08X\n", type, cpu_flags);
89 printf("cpu_flags_str(%s) =", type);
90 for (i = 0; cpu_flag_tab[i].flag; i++)
91 if (cpu_flags & cpu_flag_tab[i].flag)
92 printf(" %s", cpu_flag_tab[i].name);
97 int main(int argc, char **argv)
99 int cpu_flags_raw = av_get_cpu_flags();
101 int cpu_count = av_cpu_count();
102 char threads[5] = "auto";
105 for(i = 0; cpu_flag_tab[i].flag; i++) {
107 if (av_parse_cpu_caps(&tmp, cpu_flag_tab[i].name) < 0) {
108 fprintf(stderr, "Table missing %s\n", cpu_flag_tab[i].name);
113 if (cpu_flags_raw < 0)
117 int c = getopt(argc, argv, "c:t:");
123 unsigned flags = av_get_cpu_flags();
124 if (av_parse_cpu_caps(&flags, optarg) < 0)
127 av_force_cpu_flags(flags);
132 int len = av_strlcpy(threads, optarg, sizeof(threads));
133 if (len >= sizeof(threads)) {
134 fprintf(stderr, "Invalid thread count '%s'\n", optarg);
141 cpu_flags_eff = av_get_cpu_flags();
143 if (cpu_flags_eff < 0)
146 print_cpu_flags(cpu_flags_raw, "raw");
147 print_cpu_flags(cpu_flags_eff, "effective");
148 printf("threads = %s (cpu_count = %d)\n", threads, cpu_count);