[FFmpeg-devel] [PATCH 2/3] ffv1enc_vulkan: allow setting the number of slices via -slices
Lynne
dev at lynne.ee
Wed Jan 1 14:38:41 EET 2025
Falls back to the exact same code the software encoder uses.
---
libavcodec/ffv1enc.c | 4 ++--
libavcodec/ffv1enc.h | 1 +
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) {
--
2.45.2
More information about the ffmpeg-devel
mailing list