diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-08-04 04:05:25 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-08-04 04:05:36 +0200 |
commit | 7fd7aa6b2b8471eaaf712b6a3839f7304f13cabd (patch) | |
tree | 09b87c38d6e56b3b88ed37a0d4b7db509399aa46 /libavutil | |
parent | 01fc6533aa4175bad4b926361d017801aff9c53c (diff) | |
parent | caf5ef852bf71984d3322bbeaf48cfb04ac8255f (diff) | |
download | ffmpeg-7fd7aa6b2b8471eaaf712b6a3839f7304f13cabd.tar.gz |
Merge commit 'caf5ef852bf71984d3322bbeaf48cfb04ac8255f'
* commit 'caf5ef852bf71984d3322bbeaf48cfb04ac8255f':
cpu-test: test av_cpu_count
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/cpu.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/libavutil/cpu.c b/libavutil/cpu.c index 62611878b2..1192619b70 100644 --- a/libavutil/cpu.c +++ b/libavutil/cpu.c @@ -278,6 +278,7 @@ int av_cpu_count(void) #ifdef TEST #include <stdio.h> +#include "avstring.h" #if !HAVE_GETOPT #include "compat/getopt.c" @@ -343,12 +344,14 @@ int main(int argc, char **argv) { int cpu_flags_raw = av_get_cpu_flags(); int cpu_flags_eff; + int cpu_count = av_cpu_count(); + char threads[5] = "auto"; if (cpu_flags_raw < 0) return 1; for (;;) { - int c = getopt(argc, argv, "c:"); + int c = getopt(argc, argv, "c:t:"); if (c == -1) break; switch (c) { @@ -360,6 +363,14 @@ int main(int argc, char **argv) av_set_cpu_flags_mask(cpuflags); break; } + case 't': + { + int len = av_strlcpy(threads, optarg, sizeof(threads)); + if (len >= sizeof(threads)) { + fprintf(stderr, "Invalid thread count '%s'\n", optarg); + return 2; + } + } } } @@ -370,6 +381,7 @@ int main(int argc, char **argv) print_cpu_flags(cpu_flags_raw, "raw"); print_cpu_flags(cpu_flags_eff, "effective"); + fprintf(stderr, "threads = %s (cpu_count = %d)\n", threads, cpu_count); return 0; } |