Skip to content

Commit 9b80a61

Browse files
committed
lavc: do not enable MT with CAP_OTHER_THREADS
Only enable for libvpx*. Codecs must be individually evaluated - for libx265, it increases latency because it uses frame threading parallelism internally. For libsvt_hevc and libx264, the performance boost is not noticeable.
1 parent a578d84 commit 9b80a61

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/video_compress/libavcodec.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,8 +1692,10 @@ static void set_codec_thread_mode(AVCodecContext *codec_ctx, struct setparam_par
16921692
if (req_thread_count != -1) {
16931693
codec_ctx->thread_count = req_thread_count;
16941694
} else if ((codec_ctx->codec->capabilities & AV_CODEC_CAP_OTHER_THREADS) != 0) {
1695-
// mainly for libvpx-vp9, libx264 has thread_count set implicitly to 0 (auto)
1696-
codec_ctx->thread_count = 0;
1695+
// do not enable MT for eg. libx265 - libx265 uses frame threads
1696+
if (strncmp(codec_ctx->codec->name, "libvpx", 6)) {
1697+
codec_ctx->thread_count = 0;
1698+
}
16971699
} else if (codec_ctx->thread_type != 0) {
16981700
codec_ctx->thread_count = thread::hardware_concurrency();
16991701
}

0 commit comments

Comments
 (0)