diff options
author | Lynne <dev@lynne.ee> | 2024-12-25 19:23:23 +0900 |
---|---|---|
committer | Lynne <dev@lynne.ee> | 2025-01-03 14:53:41 +0900 |
commit | e7b474783c1f6ca11a040e9822358c618070a06b (patch) | |
tree | aaeef016b54a153a48f1477953d5ef0acae10367 | |
parent | d9b773c22f93825fb36d003cbec6e8d1d95540b2 (diff) | |
download | ffmpeg-e7b474783c1f6ca11a040e9822358c618070a06b.tar.gz |
ffv1enc_vulkan: allow setting the number of slices via -slices
Falls back to the exact same code the software encoder uses.
-rw-r--r-- | libavcodec/ffv1enc.c | 4 | ||||
-rw-r--r-- | libavcodec/ffv1enc.h | 1 | ||||
-rw-r--r-- | libavcodec/ffv1enc_vulkan.c | 10 |
3 files changed, 11 insertions, 4 deletions
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index 696823b796..1a0413895a 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -516,7 +516,7 @@ static int sort_stt(FFV1Context *s, uint8_t stt[256]) } -static int encode_determine_slices(AVCodecContext *avctx) +int ff_ffv1_encode_determine_slices(AVCodecContext *avctx) { FFV1Context *s = avctx->priv_data; int plane_count = 1 + 2*s->chroma_planes + s->transparency; @@ -919,7 +919,7 @@ static int encode_init_internal(AVCodecContext *avctx) return ret; if (s->version > 1) { - if ((ret = encode_determine_slices(avctx)) < 0) + if ((ret = ff_ffv1_encode_determine_slices(avctx)) < 0) return ret; if ((ret = ff_ffv1_write_extradata(avctx)) < 0) diff --git a/libavcodec/ffv1enc.h b/libavcodec/ffv1enc.h index 2ecc2d16ec..42d521a747 100644 --- a/libavcodec/ffv1enc.h +++ b/libavcodec/ffv1enc.h @@ -32,6 +32,7 @@ enum { }; av_cold int ff_ffv1_encode_init(AVCodecContext *avctx); +av_cold int ff_ffv1_encode_determine_slices(AVCodecContext *avctx); av_cold int ff_ffv1_write_extradata(AVCodecContext *avctx); av_cold int ff_ffv1_encode_setup_plane_info(AVCodecContext *avctx, enum AVPixelFormat pix_fmt); diff --git a/libavcodec/ffv1enc_vulkan.c b/libavcodec/ffv1enc_vulkan.c index 1874a3f42b..243f472568 100644 --- a/libavcodec/ffv1enc_vulkan.c +++ b/libavcodec/ffv1enc_vulkan.c @@ -1540,8 +1540,14 @@ static av_cold int vulkan_encode_ffv1_init(AVCodecContext *avctx) f->num_v_slices = fv->num_v_slices; if (f->num_h_slices <= 0 && f->num_v_slices <= 0) { - f->num_h_slices = 32; - f->num_v_slices = 32; + if (avctx->slices) { + err = ff_ffv1_encode_determine_slices(avctx); + if (err < 0) + return err; + } else { + f->num_h_slices = 32; + f->num_v_slices = 32; + } } else if (f->num_h_slices && f->num_v_slices <= 0) { f->num_v_slices = 1024 / f->num_h_slices; } else if (f->num_v_slices && f->num_h_slices <= 0) { |