2016-03-17 18:13:17 +00:00
|
|
|
/*
|
2016-05-11 18:10:10 +00:00
|
|
|
* This file is part of FFmpeg.
|
2016-03-17 18:13:17 +00:00
|
|
|
*
|
2016-05-11 18:10:10 +00:00
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
2016-03-17 18:13:17 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
2016-05-11 18:10:10 +00:00
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
2016-03-17 18:13:17 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2016-05-11 18:10:10 +00:00
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
2016-03-17 18:13:17 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2016-05-11 18:10:10 +00:00
|
|
|
#include <stdio.h>
|
2016-05-11 20:03:21 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
2016-03-17 18:13:17 +00:00
|
|
|
|
2016-06-22 11:44:29 +00:00
|
|
|
#include "libavutil/cpu.h"
|
|
|
|
#include "libavutil/avstring.h"
|
2016-03-17 18:13:17 +00:00
|
|
|
|
2016-05-11 20:03:21 +00:00
|
|
|
#if HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
2016-05-11 18:10:10 +00:00
|
|
|
#if !HAVE_GETOPT
|
2016-03-17 18:13:17 +00:00
|
|
|
#include "compat/getopt.c"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static const struct {
|
|
|
|
int flag;
|
|
|
|
const char *name;
|
|
|
|
} cpu_flag_tab[] = {
|
|
|
|
#if ARCH_AARCH64
|
|
|
|
{ AV_CPU_FLAG_ARMV8, "armv8" },
|
|
|
|
{ AV_CPU_FLAG_NEON, "neon" },
|
|
|
|
{ AV_CPU_FLAG_VFP, "vfp" },
|
2023-05-25 12:29:02 +00:00
|
|
|
{ AV_CPU_FLAG_DOTPROD, "dotprod" },
|
|
|
|
{ AV_CPU_FLAG_I8MM, "i8mm" },
|
2016-03-17 18:13:17 +00:00
|
|
|
#elif ARCH_ARM
|
|
|
|
{ AV_CPU_FLAG_ARMV5TE, "armv5te" },
|
|
|
|
{ AV_CPU_FLAG_ARMV6, "armv6" },
|
|
|
|
{ AV_CPU_FLAG_ARMV6T2, "armv6t2" },
|
|
|
|
{ AV_CPU_FLAG_VFP, "vfp" },
|
|
|
|
{ AV_CPU_FLAG_VFP_VM, "vfp_vm" },
|
|
|
|
{ AV_CPU_FLAG_VFPV3, "vfpv3" },
|
|
|
|
{ AV_CPU_FLAG_NEON, "neon" },
|
2016-05-11 18:10:10 +00:00
|
|
|
{ AV_CPU_FLAG_SETEND, "setend" },
|
2016-03-17 18:13:17 +00:00
|
|
|
#elif ARCH_PPC
|
|
|
|
{ AV_CPU_FLAG_ALTIVEC, "altivec" },
|
2020-07-18 15:35:39 +00:00
|
|
|
#elif ARCH_MIPS
|
|
|
|
{ AV_CPU_FLAG_MMI, "mmi" },
|
|
|
|
{ AV_CPU_FLAG_MSA, "msa" },
|
2016-03-17 18:13:17 +00:00
|
|
|
#elif ARCH_X86
|
|
|
|
{ AV_CPU_FLAG_MMX, "mmx" },
|
|
|
|
{ AV_CPU_FLAG_MMXEXT, "mmxext" },
|
|
|
|
{ AV_CPU_FLAG_SSE, "sse" },
|
|
|
|
{ AV_CPU_FLAG_SSE2, "sse2" },
|
2016-05-11 18:10:10 +00:00
|
|
|
{ AV_CPU_FLAG_SSE2SLOW, "sse2slow" },
|
2016-03-17 18:13:17 +00:00
|
|
|
{ AV_CPU_FLAG_SSE3, "sse3" },
|
2016-05-11 18:10:10 +00:00
|
|
|
{ AV_CPU_FLAG_SSE3SLOW, "sse3slow" },
|
2016-03-17 18:13:17 +00:00
|
|
|
{ AV_CPU_FLAG_SSSE3, "ssse3" },
|
|
|
|
{ AV_CPU_FLAG_ATOM, "atom" },
|
|
|
|
{ AV_CPU_FLAG_SSE4, "sse4.1" },
|
|
|
|
{ AV_CPU_FLAG_SSE42, "sse4.2" },
|
|
|
|
{ AV_CPU_FLAG_AVX, "avx" },
|
|
|
|
{ AV_CPU_FLAG_AVXSLOW, "avxslow" },
|
|
|
|
{ AV_CPU_FLAG_XOP, "xop" },
|
|
|
|
{ AV_CPU_FLAG_FMA3, "fma3" },
|
|
|
|
{ AV_CPU_FLAG_FMA4, "fma4" },
|
|
|
|
{ AV_CPU_FLAG_3DNOW, "3dnow" },
|
|
|
|
{ AV_CPU_FLAG_3DNOWEXT, "3dnowext" },
|
|
|
|
{ AV_CPU_FLAG_CMOV, "cmov" },
|
|
|
|
{ AV_CPU_FLAG_AVX2, "avx2" },
|
|
|
|
{ AV_CPU_FLAG_BMI1, "bmi1" },
|
|
|
|
{ AV_CPU_FLAG_BMI2, "bmi2" },
|
2016-05-11 18:10:10 +00:00
|
|
|
{ AV_CPU_FLAG_AESNI, "aesni" },
|
2017-10-26 17:48:26 +00:00
|
|
|
{ AV_CPU_FLAG_AVX512, "avx512" },
|
2022-10-26 15:40:03 +00:00
|
|
|
{ AV_CPU_FLAG_AVX512ICL, "avx512icl" },
|
2021-12-21 20:52:09 +00:00
|
|
|
{ AV_CPU_FLAG_SLOW_GATHER, "slowgather" },
|
2021-12-15 03:51:04 +00:00
|
|
|
#elif ARCH_LOONGARCH
|
|
|
|
{ AV_CPU_FLAG_LSX, "lsx" },
|
|
|
|
{ AV_CPU_FLAG_LASX, "lasx" },
|
2023-12-14 12:45:27 +00:00
|
|
|
#elif ARCH_RISCV
|
|
|
|
{ AV_CPU_FLAG_RVI, "rvi" },
|
|
|
|
{ AV_CPU_FLAG_RVF, "rvf" },
|
|
|
|
{ AV_CPU_FLAG_RVD, "rvd" },
|
|
|
|
{ AV_CPU_FLAG_RVB_ADDR, "zba" },
|
|
|
|
{ AV_CPU_FLAG_RVB_BASIC, "zbb" },
|
|
|
|
{ AV_CPU_FLAG_RVV_I32, "zve32x" },
|
|
|
|
{ AV_CPU_FLAG_RVV_F32, "zve32f" },
|
|
|
|
{ AV_CPU_FLAG_RVV_I64, "zve64x" },
|
|
|
|
{ AV_CPU_FLAG_RVV_F64, "zve64d" },
|
2016-03-17 18:13:17 +00:00
|
|
|
#endif
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static void print_cpu_flags(int cpu_flags, const char *type)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2016-05-11 18:10:10 +00:00
|
|
|
printf("cpu_flags(%s) = 0x%08X\n", type, cpu_flags);
|
|
|
|
printf("cpu_flags_str(%s) =", type);
|
2016-03-17 18:13:17 +00:00
|
|
|
for (i = 0; cpu_flag_tab[i].flag; i++)
|
|
|
|
if (cpu_flags & cpu_flag_tab[i].flag)
|
2016-05-11 18:10:10 +00:00
|
|
|
printf(" %s", cpu_flag_tab[i].name);
|
|
|
|
printf("\n");
|
2016-03-17 18:13:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
int cpu_flags_raw = av_get_cpu_flags();
|
|
|
|
int cpu_flags_eff;
|
|
|
|
int cpu_count = av_cpu_count();
|
2023-06-22 16:33:06 +00:00
|
|
|
const char *threads = "auto";
|
2016-05-11 18:10:10 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i = 0; cpu_flag_tab[i].flag; i++) {
|
|
|
|
unsigned tmp = 0;
|
|
|
|
if (av_parse_cpu_caps(&tmp, cpu_flag_tab[i].name) < 0) {
|
|
|
|
fprintf(stderr, "Table missing %s\n", cpu_flag_tab[i].name);
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
}
|
2016-03-17 18:13:17 +00:00
|
|
|
|
|
|
|
if (cpu_flags_raw < 0)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
int c = getopt(argc, argv, "c:t:");
|
|
|
|
if (c == -1)
|
|
|
|
break;
|
|
|
|
switch (c) {
|
|
|
|
case 'c':
|
|
|
|
{
|
2016-05-11 18:10:10 +00:00
|
|
|
unsigned flags = av_get_cpu_flags();
|
|
|
|
if (av_parse_cpu_caps(&flags, optarg) < 0)
|
2016-03-17 18:13:17 +00:00
|
|
|
return 2;
|
2016-05-11 18:10:10 +00:00
|
|
|
|
|
|
|
av_force_cpu_flags(flags);
|
2016-03-17 18:13:17 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 't':
|
|
|
|
{
|
2023-06-22 16:33:06 +00:00
|
|
|
threads = optarg;
|
2016-03-17 18:13:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cpu_flags_eff = av_get_cpu_flags();
|
|
|
|
|
|
|
|
if (cpu_flags_eff < 0)
|
|
|
|
return 3;
|
|
|
|
|
|
|
|
print_cpu_flags(cpu_flags_raw, "raw");
|
|
|
|
print_cpu_flags(cpu_flags_eff, "effective");
|
2016-05-11 18:10:10 +00:00
|
|
|
printf("threads = %s (cpu_count = %d)\n", threads, cpu_count);
|
2016-03-17 18:13:17 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|