summaryrefslogtreecommitdiff
path: root/libavcodec/libvpxenc.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2018-05-19 15:01:56 -0300
committerJames Almer <jamrial@gmail.com>2018-05-21 18:52:31 -0300
commit27df34bf1f7a113086ba5c68d2a58b7c430c301f (patch)
treec9b7fad78c20eeb51cf859e4f7ce360f860ea89e /libavcodec/libvpxenc.c
parentba7d1377e85662f7b4ae728719c10d5427cc6b9b (diff)
avcodec/libvpxenc: fix setting amount of threads used for encoding
The libvpx doxy says that a value of 0 for the g_threads field is equivalent to a value of 1, whereas for avctx->thread_count it means the maximum amount of threads possible for the host system. Use av_cpu_count() to get the correct thread count when auto threads is requested. Reviewed-by: James Zern <jzern@google.com> Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/libvpxenc.c')
-rw-r--r--libavcodec/libvpxenc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index d0bd1e997a..09f7a88452 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -493,7 +493,7 @@ static av_cold int vpx_init(AVCodecContext *avctx,
enccfg.g_h = avctx->height;
enccfg.g_timebase.num = avctx->time_base.num;
enccfg.g_timebase.den = avctx->time_base.den;
- enccfg.g_threads = avctx->thread_count;
+ enccfg.g_threads = avctx->thread_count ? avctx->thread_count : av_cpu_count();
enccfg.g_lag_in_frames= ctx->lag_in_frames;
if (avctx->flags & AV_CODEC_FLAG_PASS1)