Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2022-09-05 15:17:56 +0300
committerMartin Storsjö <martin@martin.st>2022-09-06 18:46:44 +0300
commitda5f7799a03aa53d0ffd25572aa9c65ba8279e57 (patch)
treef0a42076656bc69db090778166c7a57670a12219 /libavutil/slicethread.c
parente4759fa951311d7b02a26756af63f7e5b499c7fc (diff)
slicethread: Limit the automatic number of threads to 16
This matches a similar cap on the number of automatic threads in libavcodec/pthread_slice.c. On systems with lots of cores, this fixes a couple fate failures in 32 bit mode on such machines (where spawning a huge number of threads runs out of address space). Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavutil/slicethread.c')
-rw-r--r--libavutil/slicethread.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libavutil/slicethread.c b/libavutil/slicethread.c
index ea1c9c8311..115b099736 100644
--- a/libavutil/slicethread.c
+++ b/libavutil/slicethread.c
@@ -24,6 +24,8 @@
#include "thread.h"
#include "avassert.h"
+#define MAX_AUTO_THREADS 16
+
#if HAVE_PTHREADS || HAVE_W32THREADS || HAVE_OS2THREADS
typedef struct WorkerContext {
@@ -105,7 +107,7 @@ int avpriv_slicethread_create(AVSliceThread **pctx, void *priv,
if (!nb_threads) {
int nb_cpus = av_cpu_count();
if (nb_cpus > 1)
- nb_threads = nb_cpus + 1;
+ nb_threads = FFMIN(nb_cpus + 1, MAX_AUTO_THREADS);
else
nb_threads = 1;
}