Commit 27df34bf authored by James Almer's avatar James Almer

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: 's avatarJames Zern <jzern@google.com>
Signed-off-by: 's avatarJames Almer <jamrial@gmail.com>
parent ba7d1377
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment