History

ffv1enc: do not hardcode 1024 slices

Instead use a field where possible and the defined constant when not. Tested by using 4096 slices.

Lynne committed 1 year ago

Commit ab37c7e1 parent 75960ac1 file · +21 −12Browse files

Unified · Split

libavcodec/ffv1enc_vulkan.c+21−12
@@ -1012,6 +1012,7 @@ static int init_rct_search_shader(AVCodecContext *avctx, FFVkSPIRVCompiler *spv) · 1011 unmodified lines
10121012 {
10131013 int err;
10141014 VulkanEncodeFFv1Context *fv = avctx->priv_data;
1015+ FFV1Context *f = &fv->ctx;
10151016 FFVulkanShader *shd = &fv->rct_search;
10161017 FFVulkanDescriptorSetBinding *desc_set;
10171018
@@ -1075,7 +1076,8 @@ static int init_rct_search_shader(AVCodecContext *avctx, FFVkSPIRVCompiler *spv) · 57 unmodified lines
10751076 .name = "slice_data_buf",
10761077 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
10771078 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1078− .buf_content = "SliceContext slice_ctx[1024];",
1079+ .buf_content = "SliceContext slice_ctx",
1080+ .buf_elems = f->max_slice_count,
10791081 },
10801082 {
10811083 .name = "src",
@@ -1109,6 +1111,7 @@ static int init_setup_shader(AVCodecContext *avctx, FFVkSPIRVCompiler *spv) · 27 unmodified lines
11091111 {
11101112 int err;
11111113 VulkanEncodeFFv1Context *fv = avctx->priv_data;
1114+ FFV1Context *f = &fv->ctx;
11121115 FFVulkanShader *shd = &fv->setup;
11131116 FFVulkanDescriptorSetBinding *desc_set;
11141117
@@ -1158,7 +1161,8 @@ static int init_setup_shader(AVCodecContext *avctx, FFVkSPIRVCompiler *spv) · 43 unmodified lines
11581161 .name = "slice_data_buf",
11591162 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
11601163 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1161− .buf_content = "SliceContext slice_ctx[1024];",
1164+ .buf_content = "SliceContext slice_ctx",
1165+ .buf_elems = f->max_slice_count,
11621166 },
11631167 {
11641168 .name = "src",
@@ -1192,6 +1196,7 @@ static int init_reset_shader(AVCodecContext *avctx, FFVkSPIRVCompiler *spv) · 27 unmodified lines
11921196 {
11931197 int err;
11941198 VulkanEncodeFFv1Context *fv = avctx->priv_data;
1199+ FFV1Context *f = &fv->ctx;
11951200 FFVulkanShader *shd = &fv->reset;
11961201 FFVulkanDescriptorSetBinding *desc_set;
11971202
@@ -1254,7 +1259,8 @@ static int init_reset_shader(AVCodecContext *avctx, FFVkSPIRVCompiler *spv) · 56 unmodified lines
12541259 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
12551260 .mem_quali = "readonly",
12561261 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1257− .buf_content = "SliceContext slice_ctx[1024];",
1262+ .buf_content = "SliceContext slice_ctx",
1263+ .buf_elems = f->max_slice_count,
12581264 },
12591265 };
12601266 RET(ff_vk_shader_add_descriptor_set(&fv->s, shd, desc_set, 1, 0, 0));
@@ -1278,6 +1284,7 @@ static int init_encode_shader(AVCodecContext *avctx, FFVkSPIRVCompiler *spv) · 17 unmodified lines
12781284 {
12791285 int err;
12801286 VulkanEncodeFFv1Context *fv = avctx->priv_data;
1287+ FFV1Context *f = &fv->ctx;
12811288 FFVulkanShader *shd = &fv->enc;
12821289 FFVulkanDescriptorSetBinding *desc_set;
12831290
@@ -1339,7 +1346,8 @@ static int init_encode_shader(AVCodecContext *avctx, FFVkSPIRVCompiler *spv) · 55 unmodified lines
13391346 .name = "slice_data_buf",
13401347 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
13411348 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1342− .buf_content = "SliceContext slice_ctx[1024];",
1349+ .buf_content = "SliceContext slice_ctx",
1350+ .buf_elems = f->max_slice_count,
13431351 },
13441352 {
13451353 .name = "src",
@@ -1483,22 +1491,24 @@ static av_cold int vulkan_encode_ffv1_init(AVCodecContext *avctx) · 137 unmodified lines
14831491 f->num_v_slices = 32;
14841492 }
14851493 } else if (f->num_h_slices && f->num_v_slices <= 0) {
1486− f->num_v_slices = 1024 / f->num_h_slices;
1494+ f->num_v_slices = MAX_SLICES / f->num_h_slices;
14871495 } else if (f->num_v_slices && f->num_h_slices <= 0) {
1488− f->num_h_slices = 1024 / f->num_v_slices;
1496+ f->num_h_slices = MAX_SLICES / f->num_v_slices;
14891497 }
14901498
14911499 f->num_h_slices = FFMIN(f->num_h_slices, avctx->width);
14921500 f->num_v_slices = FFMIN(f->num_v_slices, avctx->height);
14931501
1494− if (f->num_h_slices * f->num_v_slices > 1024) {
1502+ if (f->num_h_slices * f->num_v_slices > MAX_SLICES) {
14951503 av_log(avctx, AV_LOG_ERROR, "Too many slices (%i), maximum supported "
1496− "by the standard is 1024\n",
1497− f->num_h_slices * f->num_v_slices);
1504+ "by the standard is %i\n",
1505+ f->num_h_slices * f->num_v_slices, MAX_SLICES);
14981506 return AVERROR_PATCHWELCOME;
14991507 }
15001508 }
15011509
1510+ f->max_slice_count = f->num_h_slices * f->num_v_slices;
1511+
15021512 if ((err = ff_ffv1_write_extradata(avctx)) < 0)
15031513 return err;
15041514
@@ -1707,7 +1717,6 @@ static av_cold int vulkan_encode_ffv1_init(AVCodecContext *avctx) · 202 unmodified lines
17071717 for (int i = 0; i < fv->async_depth; i++)
17081718 fv->exec_pool.contexts[i].opaque = &fv->exec_ctx_info[i];
17091719
1710− f->max_slice_count = f->num_h_slices * f->num_v_slices;
17111720 fv->buf_regions = av_malloc_array(f->max_slice_count, sizeof(*fv->buf_regions));
17121721 if (!fv->buf_regions)
17131722 return AVERROR(ENOMEM);
@@ -1783,9 +1792,9 @@ static const AVOption vulkan_encode_ffv1_options[] = { · 69 unmodified lines
17831792 { .i64 = QTABLE_GT8BIT }, INT_MIN, INT_MAX, VE, .unit = "qtable" },
17841793
17851794 { "slices_h", "Number of horizontal slices", OFFSET(num_h_slices), AV_OPT_TYPE_INT,
1786− { .i64 = -1 }, -1, 1024, VE },
1795+ { .i64 = -1 }, -1, MAX_SLICES, VE },
17871796 { "slices_v", "Number of vertical slices", OFFSET(num_v_slices), AV_OPT_TYPE_INT,
1788− { .i64 = -1 }, -1, 1024, VE },
1797+ { .i64 = -1 }, -1, MAX_SLICES, VE },
17891798
17901799 { "force_pcm", "Code all slices with no prediction", OFFSET(force_pcm), AV_OPT_TYPE_BOOL,
17911800 { .i64 = 0 }, 0, 1, VE },

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t