Skip to content

Commit

Permalink
vcomp/lavc: thr_cnt=0 for other threads implicitly
Browse files Browse the repository at this point in the history
Set automatic number (== 0) of threads if codec advertises
AV_CODEC_CAP_OTHER_THREAD implicitily, with exceptions:
1. AOM AV1, rav1e - seems not to set the number automatically
2. libx26* - allow setting but enables frame threading internally
(which is undesirable)

the current setting applies not just to libvpx* but also to
eg. libopenh264.
  • Loading branch information
MartinPulec committed Jun 3, 2024
1 parent 3801f6e commit 63b524c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/video_compress/libavcodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1562,11 +1562,12 @@ static void set_codec_thread_mode(AVCodecContext *codec_ctx, struct setparam_par
codec_ctx->thread_count = req_thread_count;
} else if ((codec_ctx->codec->capabilities & AV_CODEC_CAP_OTHER_THREADS) != 0) {
// do not enable MT for eg. libx265 - libx265 uses frame threads
if (strncmp(codec_ctx->codec->name, "libvpx", 6) == 0) {
codec_ctx->thread_count = 0;
} else if (strcmp(codec_ctx->codec->name, "libaom-av1") == 0 ||
if (strcmp(codec_ctx->codec->name, "libaom-av1") == 0 ||
strcmp(codec_ctx->codec->name, "librav1e") == 0) {
codec_ctx->thread_count = thread::hardware_concurrency();
} else if (strstr(codec_ctx->codec->name, "libx26") !=
codec_ctx->codec->name) {
codec_ctx->thread_count = 0;
}
} else if (codec_ctx->thread_type != 0) {
codec_ctx->thread_count = thread::hardware_concurrency();
Expand Down

0 comments on commit 63b524c

Please sign in to comment.