1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

avcodec/magicyuvenc: Fix setting nb_slices

Do not derive it via av_cpu_count() in case AVCodecContext.slices
is unset. Instead default to AVCodecContext.thread_num instead
(which is one in case frame-threading is used and gives the actual
number of slice threads for slice threading).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt
2025-04-11 22:46:57 +02:00
parent 853e66a072
commit 685f658524

View File

@ -201,7 +201,7 @@ static av_cold int magy_encode_init(AVCodecContext *avctx)
s->planes = av_pix_fmt_count_planes(avctx->pix_fmt); s->planes = av_pix_fmt_count_planes(avctx->pix_fmt);
s->nb_slices = (avctx->slices <= 0) ? av_cpu_count() : avctx->slices; s->nb_slices = avctx->slices > 0 ? avctx->slices : avctx->thread_count;
s->nb_slices = FFMIN(s->nb_slices, avctx->height >> s->vshift[1]); s->nb_slices = FFMIN(s->nb_slices, avctx->height >> s->vshift[1]);
s->nb_slices = FFMAX(1, s->nb_slices); s->nb_slices = FFMAX(1, s->nb_slices);
s->slice_height = FFALIGN((avctx->height + s->nb_slices - 1) / s->nb_slices, 1 << s->vshift[1]); s->slice_height = FFALIGN((avctx->height + s->nb_slices - 1) / s->nb_slices, 1 << s->vshift[1]);