summaryrefslogtreecommitdiff
path: root/libavcodec/pthread.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/pthread.c')
-rw-r--r--libavcodec/pthread.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c
index cdf3a391cc..717b865bae 100644
--- a/libavcodec/pthread.c
+++ b/libavcodec/pthread.c
@@ -193,7 +193,7 @@ static int get_logical_cpus(AVCodecContext *avctx)
if (avctx->height)
nb_cpus = FFMIN(nb_cpus, (avctx->height+15)/16);
- return FFMIN(nb_cpus, MAX_AUTO_THREADS);
+ return nb_cpus;
}
@@ -303,9 +303,11 @@ static int thread_init(AVCodecContext *avctx)
if (!thread_count) {
int nb_cpus = get_logical_cpus(avctx);
- // use number of cores + 1 as thread count if there is motre than one
+ // use number of cores + 1 as thread count if there is more than one
if (nb_cpus > 1)
- thread_count = avctx->thread_count = nb_cpus + 1;
+ thread_count = avctx->thread_count = FFMIN(nb_cpus + 1, MAX_AUTO_THREADS);
+ else
+ thread_count = avctx->thread_count = 1;
}
if (thread_count <= 1) {
@@ -783,9 +785,11 @@ static int frame_thread_init(AVCodecContext *avctx)
int nb_cpus = get_logical_cpus(avctx);
if ((avctx->debug & (FF_DEBUG_VIS_QP | FF_DEBUG_VIS_MB_TYPE)) || avctx->debug_mv)
nb_cpus = 1;
- // use number of cores + 1 as thread count if there is motre than one
+ // use number of cores + 1 as thread count if there is more than one
if (nb_cpus > 1)
- thread_count = avctx->thread_count = nb_cpus + 1;
+ thread_count = avctx->thread_count = FFMIN(nb_cpus + 1, MAX_AUTO_THREADS);
+ else
+ thread_count = avctx->thread_count = 1;
}
if (thread_count <= 1) {
@@ -1002,6 +1006,9 @@ static void validate_thread_parameters(AVCodecContext *avctx)
} else if (avctx->codec->capabilities & CODEC_CAP_SLICE_THREADS &&
avctx->thread_type & FF_THREAD_SLICE) {
avctx->active_thread_type = FF_THREAD_SLICE;
+ } else if (!(avctx->codec->capabilities & CODEC_CAP_AUTO_THREADS)) {
+ avctx->thread_count = 1;
+ avctx->active_thread_type = 0;
}
}