Commit: b790b57fe170d094d9b809ae5d93b85c3312e9bf Author: Sergey Sharybin Date: Wed Aug 19 15:39:00 2020 +0200 Branches: sculpt-dev https://developer.blender.org/rBb790b57fe170d094d9b809ae5d93b85c3312e9bf
FFmpeg: Improve multi-threading settings Allow use all system threads for frame encoding/decoding. This is very straightforward: the value of zero basically disables threading. Change threading policy to slice when decoding frames. The reason for this is because decoding happens frame-by-frame, so inter-frame threading policy will not bring any speedup. The change for threading policy to slice is less obvious and is based on benchmark of the demo files from T78986. This gives best performance so far. Rendering the following file went down from 190sec down to 160sec. https://storage.googleapis.com/institute-storage/vse_simplified_example.zip This change makes both reading and writing faster. The animation render is just easiest to get actual time metrics. Differential Revision: https://developer.blender.org/D8627 =================================================================== M source/blender/blenkernel/intern/writeffmpeg.c M source/blender/imbuf/intern/anim_movie.c =================================================================== diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index e6adad765c3..0991d804882 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -37,6 +37,7 @@ # endif # include "BLI_math_base.h" +# include "BLI_threads.h" # include "BLI_utildefines.h" # include "BKE_global.h" @@ -566,8 +567,8 @@ static AVStream *alloc_video_stream(FFMpegContext *context, /* Set up the codec context */ c = st->codec; - c->thread_count = 0; - c->thread_type = FF_THREAD_FRAME; + c->thread_count = BLI_system_thread_count(); + c->thread_type = FF_THREAD_SLICE; c->codec_id = codec_id; c->codec_type = AVMEDIA_TYPE_VIDEO; @@ -780,8 +781,8 @@ static AVStream *alloc_audio_stream(FFMpegContext *context, st->id = 1; c = st->codec; - c->thread_count = 0; - c->thread_type = FF_THREAD_FRAME; + c->thread_count = BLI_system_thread_count(); + c->thread_type = FF_THREAD_SLICE; c->codec_id = codec_id; c->codec_type = AVMEDIA_TYPE_AUDIO; diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index 3a7570cd320..28bf26aa343 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -55,6 +55,7 @@ #include "BLI_path_util.h" #include "BLI_string.h" +#include "BLI_threads.h" #include "BLI_utildefines.h" #include "MEM_guardedalloc.h" @@ -573,6 +574,9 @@ static int startffmpeg(struct anim *anim) pCodecCtx->workaround_bugs = 1; + pCodecCtx->thread_count = BLI_system_thread_count(); + pCodecCtx->thread_type = FF_THREAD_SLICE; + if (avcodec_open2(pCodecCtx, pCodec, NULL) < 0) { avformat_close_input(&pFormatCtx); return -1; _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs