[FFmpeg-devel] [PATCH] ffv1enc_vulkan: remove arbitrary limitation of the number of slices
Lynne
dev at lynne.ee
Thu Nov 21 21:02:19 EET 2024
---
libavcodec/ffv1enc_vulkan.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/libavcodec/ffv1enc_vulkan.c b/libavcodec/ffv1enc_vulkan.c
index a3c10524fe..b37c24484f 100644
--- a/libavcodec/ffv1enc_vulkan.c
+++ b/libavcodec/ffv1enc_vulkan.c
@@ -1437,13 +1437,24 @@ static av_cold int vulkan_encode_ffv1_init(AVCodecContext *avctx)
f->num_h_slices = fv->num_h_slices;
f->num_v_slices = fv->num_v_slices;
- if (f->num_h_slices <= 0)
+ f->num_h_slices = FFMIN(f->num_h_slices, avctx->width);
+ f->num_v_slices = FFMIN(f->num_v_slices, avctx->height);
+
+ if (f->num_h_slices <= 0 && f->num_v_slices <= 0) {
f->num_h_slices = 32;
- if (f->num_v_slices <= 0)
f->num_v_slices = 32;
+ } else if (f->num_h_slices) {
+ f->num_v_slices = 1024 / f->num_h_slices;
+ } else if (f->num_v_slices) {
+ f->num_h_slices = 1024 / f->num_v_slices;
+ }
- f->num_h_slices = FFMIN(f->num_h_slices, avctx->width);
- f->num_v_slices = FFMIN(f->num_v_slices, avctx->height);
+ if (f->num_h_slices * f->num_v_slices > 1024) {
+ av_log(avctx, AV_LOG_ERROR, "Too many slices (%i), maximum supported "
+ "by the standard is 1024\n",
+ f->num_h_slices * f->num_v_slices);
+ return AVERROR_PATCHWELCOME;
+ }
}
if ((err = ff_ffv1_write_extradata(avctx)) < 0)
@@ -1611,9 +1622,9 @@ static const AVOption vulkan_encode_ffv1_options[] = {
{ .i64 = -1 }, -1, 2, VE },
{ "slices_h", "Number of horizontal slices", OFFSET(num_h_slices), AV_OPT_TYPE_INT,
- { .i64 = -1 }, -1, 32, VE },
+ { .i64 = -1 }, -1, 1024, VE },
{ "slices_v", "Number of vertical slices", OFFSET(num_v_slices), AV_OPT_TYPE_INT,
- { .i64 = -1 }, -1, 32, VE },
+ { .i64 = -1 }, -1, 1024, VE },
{ "force_pcm", "Code all slices with no prediction", OFFSET(force_pcm), AV_OPT_TYPE_BOOL,
{ .i64 = 0 }, 0, 1, VE },
--
2.45.2.753.g447d99e1c3b
More information about the ffmpeg-devel
mailing list