]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/libaom: fix setting amount of threads
authorJames Almer <jamrial@gmail.com>
Thu, 13 Sep 2018 16:26:00 +0000 (13:26 -0300)
committerJames Almer <jamrial@gmail.com>
Thu, 13 Sep 2018 16:44:45 +0000 (13:44 -0300)
The libaom doxy says that a value of 0 for the threads fields 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: Jan Ekström <jeebjp@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
libavcodec/libaomdec.c
libavcodec/libaomenc.c

index 6a2de6d47a760431982e02818454c302de22d502..2530c9f76b4ada03fc1325b81c588467e211f340 100644 (file)
@@ -43,7 +43,7 @@ static av_cold int aom_init(AVCodecContext *avctx,
     AV1DecodeContext *ctx           = avctx->priv_data;
     struct aom_codec_dec_cfg deccfg = {
         /* token partitions+1 would be a decent choice */
-        .threads = FFMIN(avctx->thread_count, 16)
+        .threads = FFMIN(avctx->thread_count ? avctx->thread_count : av_cpu_count(), 16)
     };
 
     av_log(avctx, AV_LOG_INFO, "%s\n", aom_codec_version_str());
index bbf4cf8b6429edf6888a82c08898d764844712d1..6a79d9b873869d41d88a575efaf4cfe9ade5dcb9 100644 (file)
@@ -319,7 +319,7 @@ static av_cold int aom_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();
 
     if (ctx->lag_in_frames >= 0)
         enccfg.g_lag_in_frames = ctx->lag_in_frames;