Imported Upstream version 5.1.2
[platform/upstream/ffmpeg.git] / libavfilter / vf_scale_vulkan.c
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18
19 #include "libavutil/random_seed.h"
20 #include "libavutil/opt.h"
21 #include "vulkan_filter.h"
22 #include "scale_eval.h"
23 #include "internal.h"
24 #include "colorspace.h"
25
26 #define CGROUPS (int [3]){ 32, 32, 1 }
27
28 enum ScalerFunc {
29     F_BILINEAR = 0,
30     F_NEAREST,
31
32     F_NB,
33 };
34
35 typedef struct ScaleVulkanContext {
36     FFVulkanContext vkctx;
37
38     FFVkQueueFamilyCtx qf;
39     FFVkExecContext *exec;
40     FFVulkanPipeline *pl;
41     FFVkBuffer params_buf;
42
43     /* Shader updators, must be in the main filter struct */
44     VkDescriptorImageInfo input_images[3];
45     VkDescriptorImageInfo output_images[3];
46     VkDescriptorBufferInfo params_desc;
47
48     char *out_format_string;
49     char *w_expr;
50     char *h_expr;
51
52     enum ScalerFunc scaler;
53     enum AVColorRange out_range;
54
55     int initialized;
56 } ScaleVulkanContext;
57
58 static const char scale_bilinear[] = {
59     C(0, vec4 scale_bilinear(int idx, ivec2 pos, vec2 crop_range, vec2 crop_off))
60     C(0, {                                                                      )
61     C(1,     vec2 npos = (vec2(pos) + 0.5f) / imageSize(output_img[idx]);       )
62     C(1,     npos *= crop_range;    /* Reduce the range */                      )
63     C(1,     npos += crop_off;      /* Offset the start */                      )
64     C(1,     return texture(input_img[idx], npos);                              )
65     C(0, }                                                                      )
66 };
67
68 static const char rgb2yuv[] = {
69     C(0, vec4 rgb2yuv(vec4 src, int fullrange)                                  )
70     C(0, {                                                                      )
71     C(1,     src *= yuv_matrix;                                                 )
72     C(1,     if (fullrange == 1) {                                              )
73     C(2,         src += vec4(0.0, 0.5, 0.5, 0.0);                               )
74     C(1,     } else {                                                           )
75     C(2,         src *= vec4(219.0 / 255.0, 224.0 / 255.0, 224.0 / 255.0, 1.0); )
76     C(2,         src += vec4(16.0 / 255.0, 128.0 / 255.0, 128.0 / 255.0, 0.0);  )
77     C(1,     }                                                                  )
78     C(1,     return src;                                                        )
79     C(0, }                                                                      )
80 };
81
82 static const char write_nv12[] = {
83     C(0, void write_nv12(vec4 src, ivec2 pos)                                   )
84     C(0, {                                                                      )
85     C(1,     imageStore(output_img[0], pos, vec4(src.r, 0.0, 0.0, 0.0));        )
86     C(1,     pos /= ivec2(2);                                                   )
87     C(1,     imageStore(output_img[1], pos, vec4(src.g, src.b, 0.0, 0.0));      )
88     C(0, }                                                                      )
89 };
90
91 static const char write_420[] = {
92     C(0, void write_420(vec4 src, ivec2 pos)                                    )
93     C(0, {                                                                      )
94     C(1,     imageStore(output_img[0], pos, vec4(src.r, 0.0, 0.0, 0.0));        )
95     C(1,     pos /= ivec2(2);                                                   )
96     C(1,     imageStore(output_img[1], pos, vec4(src.g, 0.0, 0.0, 0.0));        )
97     C(1,     imageStore(output_img[2], pos, vec4(src.b, 0.0, 0.0, 0.0));        )
98     C(0, }                                                                      )
99 };
100
101 static const char write_444[] = {
102     C(0, void write_444(vec4 src, ivec2 pos)                                    )
103     C(0, {                                                                      )
104     C(1,     imageStore(output_img[0], pos, vec4(src.r, 0.0, 0.0, 0.0));        )
105     C(1,     imageStore(output_img[1], pos, vec4(src.g, 0.0, 0.0, 0.0));        )
106     C(1,     imageStore(output_img[2], pos, vec4(src.b, 0.0, 0.0, 0.0));        )
107     C(0, }                                                                      )
108 };
109
110 static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
111 {
112     int err;
113     FFVkSampler *sampler;
114     VkFilter sampler_mode;
115     ScaleVulkanContext *s = ctx->priv;
116     FFVulkanContext *vkctx = &s->vkctx;
117
118     int crop_x = in->crop_left;
119     int crop_y = in->crop_top;
120     int crop_w = in->width - (in->crop_left + in->crop_right);
121     int crop_h = in->height - (in->crop_top + in->crop_bottom);
122     int in_planes = av_pix_fmt_count_planes(s->vkctx.input_format);
123
124     ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT, 0);
125
126     switch (s->scaler) {
127     case F_NEAREST:
128         sampler_mode = VK_FILTER_NEAREST;
129         break;
130     case F_BILINEAR:
131         sampler_mode = VK_FILTER_LINEAR;
132         break;
133     };
134
135     /* Create a sampler */
136     sampler = ff_vk_init_sampler(vkctx, 0, sampler_mode);
137     if (!sampler)
138         return AVERROR_EXTERNAL;
139
140     s->pl = ff_vk_create_pipeline(vkctx, &s->qf);
141     if (!s->pl)
142         return AVERROR(ENOMEM);
143
144     { /* Create the shader */
145         FFVulkanDescriptorSetBinding desc_i[2] = {
146             {
147                 .name       = "input_img",
148                 .type       = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
149                 .dimensions = 2,
150                 .elems      = in_planes,
151                 .stages     = VK_SHADER_STAGE_COMPUTE_BIT,
152                 .updater    = s->input_images,
153                 .sampler    = sampler,
154             },
155             {
156                 .name       = "output_img",
157                 .type       = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
158                 .mem_layout = ff_vk_shader_rep_fmt(s->vkctx.output_format),
159                 .mem_quali  = "writeonly",
160                 .dimensions = 2,
161                 .elems      = av_pix_fmt_count_planes(s->vkctx.output_format),
162                 .stages     = VK_SHADER_STAGE_COMPUTE_BIT,
163                 .updater    = s->output_images,
164             },
165         };
166
167         FFVulkanDescriptorSetBinding desc_b = {
168             .name        = "params",
169             .type        = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
170             .mem_quali   = "readonly",
171             .mem_layout  = "std430",
172             .stages      = VK_SHADER_STAGE_COMPUTE_BIT,
173             .updater     = &s->params_desc,
174             .buf_content = "mat4 yuv_matrix;",
175         };
176
177         FFVkSPIRVShader *shd = ff_vk_init_shader(s->pl, "scale_compute",
178                                                  VK_SHADER_STAGE_COMPUTE_BIT);
179         if (!shd)
180             return AVERROR(ENOMEM);
181
182         ff_vk_set_compute_shader_sizes(shd, CGROUPS);
183
184         RET(ff_vk_add_descriptor_set(vkctx, s->pl, shd,  desc_i, FF_ARRAY_ELEMS(desc_i), 0)); /* set 0 */
185         RET(ff_vk_add_descriptor_set(vkctx, s->pl, shd, &desc_b, 1, 0)); /* set 1 */
186
187         GLSLD(   scale_bilinear                                                  );
188
189         if (s->vkctx.output_format != s->vkctx.input_format) {
190             GLSLD(   rgb2yuv                                                     );
191         }
192
193         switch (s->vkctx.output_format) {
194         case AV_PIX_FMT_NV12:    GLSLD(write_nv12); break;
195         case AV_PIX_FMT_YUV420P: GLSLD( write_420); break;
196         case AV_PIX_FMT_YUV444P: GLSLD( write_444); break;
197         default: break;
198         }
199
200         GLSLC(0, void main()                                                     );
201         GLSLC(0, {                                                               );
202         GLSLC(1,     ivec2 size;                                                 );
203         GLSLC(1,     ivec2 pos = ivec2(gl_GlobalInvocationID.xy);                );
204         GLSLF(1,     vec2 in_d = vec2(%i, %i);             ,in->width, in->height);
205         GLSLF(1,     vec2 c_r = vec2(%i, %i) / in_d;              ,crop_w, crop_h);
206         GLSLF(1,     vec2 c_o = vec2(%i, %i) / in_d;               ,crop_x,crop_y);
207         GLSLC(0,                                                                 );
208
209         if (s->vkctx.output_format == s->vkctx.input_format) {
210             for (int i = 0; i < desc_i[1].elems; i++) {
211                 GLSLF(1,  size = imageSize(output_img[%i]);                    ,i);
212                 GLSLC(1,  if (IS_WITHIN(pos, size)) {                            );
213                 switch (s->scaler) {
214                 case F_NEAREST:
215                 case F_BILINEAR:
216                     GLSLF(2, vec4 res = scale_bilinear(%i, pos, c_r, c_o);     ,i);
217                     GLSLF(2, imageStore(output_img[%i], pos, res);             ,i);
218                     break;
219                 };
220                 GLSLC(1, }                                                       );
221             }
222         } else {
223             GLSLC(1, vec4 res = scale_bilinear(0, pos, c_r, c_o);                );
224             GLSLF(1, res = rgb2yuv(res, %i);    ,s->out_range == AVCOL_RANGE_JPEG);
225             switch (s->vkctx.output_format) {
226             case AV_PIX_FMT_NV12:    GLSLC(1, write_nv12(res, pos); ); break;
227             case AV_PIX_FMT_YUV420P: GLSLC(1,  write_420(res, pos); ); break;
228             case AV_PIX_FMT_YUV444P: GLSLC(1,  write_444(res, pos); ); break;
229             default: return AVERROR(EINVAL);
230             }
231         }
232
233         GLSLC(0, }                                                               );
234
235         RET(ff_vk_compile_shader(vkctx, shd, "main"));
236     }
237
238     RET(ff_vk_init_pipeline_layout(vkctx, s->pl));
239     RET(ff_vk_init_compute_pipeline(vkctx, s->pl));
240
241     if (s->vkctx.output_format != s->vkctx.input_format) {
242         const AVLumaCoefficients *lcoeffs;
243         double tmp_mat[3][3];
244
245         struct {
246             float yuv_matrix[4][4];
247         } *par;
248
249         lcoeffs = av_csp_luma_coeffs_from_avcsp(in->colorspace);
250         if (!lcoeffs) {
251             av_log(ctx, AV_LOG_ERROR, "Unsupported colorspace\n");
252             return AVERROR(EINVAL);
253         }
254
255         RET(ff_vk_create_buf(vkctx, &s->params_buf,
256                              sizeof(*par),
257                              VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
258                              VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT));
259
260         RET(ff_vk_map_buffers(vkctx, &s->params_buf, (uint8_t **)&par, 1, 0));
261
262         ff_fill_rgb2yuv_table(lcoeffs, tmp_mat);
263
264         memset(par, 0, sizeof(*par));
265
266         for (int y = 0; y < 3; y++)
267             for (int x = 0; x < 3; x++)
268                 par->yuv_matrix[x][y] = tmp_mat[x][y];
269
270         par->yuv_matrix[3][3] = 1.0;
271
272         RET(ff_vk_unmap_buffers(vkctx, &s->params_buf, 1, 1));
273
274         s->params_desc.buffer = s->params_buf.buf;
275         s->params_desc.range  = VK_WHOLE_SIZE;
276
277         ff_vk_update_descriptor_set(vkctx, s->pl, 1);
278     }
279
280     /* Execution context */
281     RET(ff_vk_create_exec_ctx(vkctx, &s->exec, &s->qf));
282
283     s->initialized = 1;
284
285     return 0;
286
287 fail:
288     return err;
289 }
290
291 static int process_frames(AVFilterContext *avctx, AVFrame *out_f, AVFrame *in_f)
292 {
293     int err = 0;
294     VkCommandBuffer cmd_buf;
295     ScaleVulkanContext *s = avctx->priv;
296     FFVulkanContext *vkctx = &s->vkctx;
297     FFVulkanFunctions *vk = &vkctx->vkfn;
298     AVVkFrame *in = (AVVkFrame *)in_f->data[0];
299     AVVkFrame *out = (AVVkFrame *)out_f->data[0];
300     VkImageMemoryBarrier barriers[AV_NUM_DATA_POINTERS*2];
301     int barrier_count = 0;
302     const int planes = av_pix_fmt_count_planes(s->vkctx.input_format);
303     const VkFormat *input_formats = av_vkfmt_from_pixfmt(s->vkctx.input_format);
304     const VkFormat *output_formats = av_vkfmt_from_pixfmt(s->vkctx.output_format);
305
306     /* Update descriptors and init the exec context */
307     ff_vk_start_exec_recording(vkctx, s->exec);
308     cmd_buf = ff_vk_get_exec_buf(s->exec);
309
310     for (int i = 0; i < planes; i++) {
311         RET(ff_vk_create_imageview(vkctx, s->exec,
312                                    &s->input_images[i].imageView, in->img[i],
313                                    input_formats[i],
314                                    ff_comp_identity_map));
315
316         RET(ff_vk_create_imageview(vkctx, s->exec,
317                                    &s->output_images[i].imageView, out->img[i],
318                                    output_formats[i],
319                                    ff_comp_identity_map));
320
321         s->input_images[i].imageLayout  = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
322         s->output_images[i].imageLayout = VK_IMAGE_LAYOUT_GENERAL;
323     }
324
325     ff_vk_update_descriptor_set(vkctx, s->pl, 0);
326
327     for (int i = 0; i < planes; i++) {
328         VkImageMemoryBarrier bar = {
329             .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
330             .srcAccessMask = 0,
331             .dstAccessMask = VK_ACCESS_SHADER_READ_BIT,
332             .oldLayout = in->layout[i],
333             .newLayout = s->input_images[i].imageLayout,
334             .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
335             .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
336             .image = in->img[i],
337             .subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
338             .subresourceRange.levelCount = 1,
339             .subresourceRange.layerCount = 1,
340         };
341
342         memcpy(&barriers[barrier_count++], &bar, sizeof(VkImageMemoryBarrier));
343
344         in->layout[i]  = bar.newLayout;
345         in->access[i]  = bar.dstAccessMask;
346     }
347
348     for (int i = 0; i < av_pix_fmt_count_planes(s->vkctx.output_format); i++) {
349         VkImageMemoryBarrier bar = {
350             .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
351             .srcAccessMask = 0,
352             .dstAccessMask = VK_ACCESS_SHADER_WRITE_BIT,
353             .oldLayout = out->layout[i],
354             .newLayout = s->output_images[i].imageLayout,
355             .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
356             .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
357             .image = out->img[i],
358             .subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
359             .subresourceRange.levelCount = 1,
360             .subresourceRange.layerCount = 1,
361         };
362
363         memcpy(&barriers[barrier_count++], &bar, sizeof(VkImageMemoryBarrier));
364
365         out->layout[i] = bar.newLayout;
366         out->access[i] = bar.dstAccessMask;
367     }
368
369     vk->CmdPipelineBarrier(cmd_buf, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
370                            VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0,
371                            0, NULL, 0, NULL, barrier_count, barriers);
372
373     ff_vk_bind_pipeline_exec(vkctx, s->exec, s->pl);
374
375     vk->CmdDispatch(cmd_buf,
376                     FFALIGN(vkctx->output_width,  CGROUPS[0])/CGROUPS[0],
377                     FFALIGN(vkctx->output_height, CGROUPS[1])/CGROUPS[1], 1);
378
379     ff_vk_add_exec_dep(vkctx, s->exec, in_f, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT);
380     ff_vk_add_exec_dep(vkctx, s->exec, out_f, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT);
381
382     err = ff_vk_submit_exec_queue(vkctx, s->exec);
383     if (err)
384         return err;
385
386     ff_vk_qf_rotate(&s->qf);
387
388     return err;
389
390 fail:
391     ff_vk_discard_exec_deps(s->exec);
392     return err;
393 }
394
395 static int scale_vulkan_filter_frame(AVFilterLink *link, AVFrame *in)
396 {
397     int err;
398     AVFilterContext *ctx = link->dst;
399     ScaleVulkanContext *s = ctx->priv;
400     AVFilterLink *outlink = ctx->outputs[0];
401
402     AVFrame *out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
403     if (!out) {
404         err = AVERROR(ENOMEM);
405         goto fail;
406     }
407
408     if (!s->initialized)
409         RET(init_filter(ctx, in));
410
411     RET(process_frames(ctx, out, in));
412
413     err = av_frame_copy_props(out, in);
414     if (err < 0)
415         goto fail;
416
417     if (s->out_range != AVCOL_RANGE_UNSPECIFIED)
418         out->color_range = s->out_range;
419     if (s->vkctx.output_format != s->vkctx.input_format)
420         out->chroma_location = AVCHROMA_LOC_TOPLEFT;
421
422     av_frame_free(&in);
423
424     return ff_filter_frame(outlink, out);
425
426 fail:
427     av_frame_free(&in);
428     av_frame_free(&out);
429     return err;
430 }
431
432 static int scale_vulkan_config_output(AVFilterLink *outlink)
433 {
434     int err;
435     AVFilterContext *avctx = outlink->src;
436     ScaleVulkanContext *s  = avctx->priv;
437     FFVulkanContext *vkctx = &s->vkctx;
438     AVFilterLink *inlink   = outlink->src->inputs[0];
439
440     err = ff_scale_eval_dimensions(s, s->w_expr, s->h_expr, inlink, outlink,
441                                    &vkctx->output_width,
442                                    &vkctx->output_height);
443     if (err < 0)
444         return err;
445
446     if (s->out_format_string) {
447         s->vkctx.output_format = av_get_pix_fmt(s->out_format_string);
448         if (s->vkctx.output_format == AV_PIX_FMT_NONE) {
449             av_log(avctx, AV_LOG_ERROR, "Invalid output format.\n");
450             return AVERROR(EINVAL);
451         }
452     } else {
453         s->vkctx.output_format = s->vkctx.input_format;
454     }
455
456     if (s->vkctx.output_format != s->vkctx.input_format) {
457         if (!ff_vk_mt_is_np_rgb(s->vkctx.input_format)) {
458             av_log(avctx, AV_LOG_ERROR, "Unsupported input format for conversion\n");
459             return AVERROR(EINVAL);
460         }
461         if (s->vkctx.output_format != AV_PIX_FMT_NV12 &&
462             s->vkctx.output_format != AV_PIX_FMT_YUV420P &&
463             s->vkctx.output_format != AV_PIX_FMT_YUV444P) {
464             av_log(avctx, AV_LOG_ERROR, "Unsupported output format\n");
465             return AVERROR(EINVAL);
466         }
467     } else if (s->out_range != AVCOL_RANGE_UNSPECIFIED) {
468         av_log(avctx, AV_LOG_ERROR, "Cannot change range without converting format\n");
469         return AVERROR(EINVAL);
470     }
471
472     return ff_vk_filter_config_output(outlink);
473 }
474
475 static void scale_vulkan_uninit(AVFilterContext *avctx)
476 {
477     ScaleVulkanContext *s = avctx->priv;
478
479     ff_vk_free_buf(&s->vkctx, &s->params_buf);
480     ff_vk_uninit(&s->vkctx);
481
482     s->initialized = 0;
483 }
484
485 #define OFFSET(x) offsetof(ScaleVulkanContext, x)
486 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
487 static const AVOption scale_vulkan_options[] = {
488     { "w", "Output video width",  OFFSET(w_expr), AV_OPT_TYPE_STRING, {.str = "iw"}, .flags = FLAGS },
489     { "h", "Output video height", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, .flags = FLAGS },
490     { "scaler", "Scaler function", OFFSET(scaler), AV_OPT_TYPE_INT, {.i64 = F_BILINEAR}, 0, F_NB, .flags = FLAGS, "scaler" },
491         { "bilinear", "Bilinear interpolation (fastest)", 0, AV_OPT_TYPE_CONST, {.i64 = F_BILINEAR}, 0, 0, .flags = FLAGS, "scaler" },
492         { "nearest", "Nearest (useful for pixel art)", 0, AV_OPT_TYPE_CONST, {.i64 = F_NEAREST}, 0, 0, .flags = FLAGS, "scaler" },
493     { "format", "Output video format (software format of hardware frames)", OFFSET(out_format_string), AV_OPT_TYPE_STRING, .flags = FLAGS },
494     { "out_range", "Output colour range (from 0 to 2) (default 0)", OFFSET(out_range), AV_OPT_TYPE_INT, {.i64 = AVCOL_RANGE_UNSPECIFIED}, AVCOL_RANGE_UNSPECIFIED, AVCOL_RANGE_JPEG, .flags = FLAGS, "range" },
495         { "full", "Full range", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_RANGE_JPEG }, 0, 0, FLAGS, "range" },
496         { "limited", "Limited range", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_RANGE_MPEG }, 0, 0, FLAGS, "range" },
497         { "jpeg", "Full range", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_RANGE_JPEG }, 0, 0, FLAGS, "range" },
498         { "mpeg", "Limited range", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_RANGE_MPEG }, 0, 0, FLAGS, "range" },
499         { "tv", "Limited range", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_RANGE_MPEG }, 0, 0, FLAGS, "range" },
500         { "pc", "Full range", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_RANGE_JPEG }, 0, 0, FLAGS, "range" },
501     { NULL },
502 };
503
504 AVFILTER_DEFINE_CLASS(scale_vulkan);
505
506 static const AVFilterPad scale_vulkan_inputs[] = {
507     {
508         .name         = "default",
509         .type         = AVMEDIA_TYPE_VIDEO,
510         .filter_frame = &scale_vulkan_filter_frame,
511         .config_props = &ff_vk_filter_config_input,
512     },
513 };
514
515 static const AVFilterPad scale_vulkan_outputs[] = {
516     {
517         .name = "default",
518         .type = AVMEDIA_TYPE_VIDEO,
519         .config_props = &scale_vulkan_config_output,
520     },
521 };
522
523 const AVFilter ff_vf_scale_vulkan = {
524     .name           = "scale_vulkan",
525     .description    = NULL_IF_CONFIG_SMALL("Scale Vulkan frames"),
526     .priv_size      = sizeof(ScaleVulkanContext),
527     .init           = &ff_vk_filter_init,
528     .uninit         = &scale_vulkan_uninit,
529     FILTER_INPUTS(scale_vulkan_inputs),
530     FILTER_OUTPUTS(scale_vulkan_outputs),
531     FILTER_SINGLE_PIXFMT(AV_PIX_FMT_VULKAN),
532     .priv_class     = &scale_vulkan_class,
533     .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
534 };