You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
threads: add sysconf based number of CPUs detection
Can act as fallback and should work on a couple of Unix systems.
This commit is contained in:
2
configure
vendored
2
configure
vendored
@@ -1138,6 +1138,7 @@ HAVE_LIST="
|
|||||||
symver
|
symver
|
||||||
symver_asm_label
|
symver_asm_label
|
||||||
symver_gnu_asm
|
symver_gnu_asm
|
||||||
|
sysconf
|
||||||
sysctl
|
sysctl
|
||||||
sys_mman_h
|
sys_mman_h
|
||||||
sys_param_h
|
sys_param_h
|
||||||
@@ -2858,6 +2859,7 @@ check_func strerror_r
|
|||||||
check_func strptime
|
check_func strptime
|
||||||
check_func strtok_r
|
check_func strtok_r
|
||||||
check_func sched_getaffinity
|
check_func sched_getaffinity
|
||||||
|
check_func sysconf
|
||||||
check_func sysctl
|
check_func sysctl
|
||||||
check_func_headers io.h setmode
|
check_func_headers io.h setmode
|
||||||
check_func_headers lzo/lzo1x.h lzo1x_999_compress
|
check_func_headers lzo/lzo1x.h lzo1x_999_compress
|
||||||
|
@@ -45,6 +45,9 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
#if HAVE_SYSCONF
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
@@ -177,6 +180,10 @@ static int get_logical_cpus(AVCodecContext *avctx)
|
|||||||
ret = sysctl(mib, 2, &nb_cpus, &len, NULL, 0);
|
ret = sysctl(mib, 2, &nb_cpus, &len, NULL, 0);
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
nb_cpus = 0;
|
nb_cpus = 0;
|
||||||
|
#elif HAVE_SYSCONF && defined(_SC_NPROC_ONLN)
|
||||||
|
nb_cpus = sysconf(_SC_NPROC_ONLN);
|
||||||
|
#elif HAVE_SYSCONF && defined(_SC_NPROCESSORS_ONLN)
|
||||||
|
nb_cpus = sysconf(_SC_NPROCESSORS_ONLN);
|
||||||
#endif
|
#endif
|
||||||
av_log(avctx, AV_LOG_DEBUG, "detected %d logical cores\n", nb_cpus);
|
av_log(avctx, AV_LOG_DEBUG, "detected %d logical cores\n", nb_cpus);
|
||||||
return FFMIN(nb_cpus, MAX_AUTO_THREADS);
|
return FFMIN(nb_cpus, MAX_AUTO_THREADS);
|
||||||
|
Reference in New Issue
Block a user