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.
This commit is contained in:
Martin Pulec
2022-11-29 16:12:01 +01:00
parent a578d84b90
commit 9b80a61d9f

View File

@@ -1692,8 +1692,10 @@ static void set_codec_thread_mode(AVCodecContext *codec_ctx, struct setparam_par
if (req_thread_count != -1) {
codec_ctx->thread_count = req_thread_count;
} else if ((codec_ctx->codec->capabilities & AV_CODEC_CAP_OTHER_THREADS) != 0) {
// mainly for libvpx-vp9, libx264 has thread_count set implicitly to 0 (auto)
codec_ctx->thread_count = 0;
// do not enable MT for eg. libx265 - libx265 uses frame threads
if (strncmp(codec_ctx->codec->name, "libvpx", 6)) {
codec_ctx->thread_count = 0;
}
} else if (codec_ctx->thread_type != 0) {
codec_ctx->thread_count = thread::hardware_concurrency();
}