diff mbox

[FFmpeg-devel] avcodec/libvpxenc: fix setting amount of threads used for encoding

Message ID 20180519180859.704-1-jamrial@gmail.com
State Accepted
Commit 27df34bf1f7a113086ba5c68d2a58b7c430c301f
Headers show

Commit Message

James Almer May 19, 2018, 6:08 p.m. UTC
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.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavcodec/libvpxenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

James Zern May 21, 2018, 7:16 p.m. UTC | #1
On Sat, May 19, 2018 at 11:16 AM James Almer <jamrial@gmail.com> wrote:

> 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.

> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>   libavcodec/libvpxenc.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)


lgtm, thanks.
James Almer May 21, 2018, 10:51 p.m. UTC | #2
On 5/21/2018 4:16 PM, James Zern wrote:
> On Sat, May 19, 2018 at 11:16 AM James Almer <jamrial@gmail.com> wrote:
> 
>> 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.
> 
>> Signed-off-by: James Almer <jamrial@gmail.com>
>> ---
>>   libavcodec/libvpxenc.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> 
> lgtm, thanks.

Pushed.
diff mbox

Patch

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)