FFmpeg
vf_avgblur_vulkan.c
Go to the documentation of this file.
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 "internal.h"
23 
24 #define CGS 32
25 
26 typedef struct AvgBlurVulkanContext {
28 
34 
35  /* Shader updators, must be in the main filter struct */
36  VkDescriptorImageInfo input_images[3];
37  VkDescriptorImageInfo tmp_images[3];
38  VkDescriptorImageInfo output_images[3];
39 
40  int size_x;
41  int size_y;
42  int planes;
44 
45 static const char blur_kernel[] = {
46  C(0, shared vec4 cache[DIR(gl_WorkGroupSize) + FILTER_RADIUS*2 + 1]; )
47  C(0, )
48  C(0, void distort(const ivec2 pos, const int idx) )
49  C(0, { )
50  C(1, const uint cp = DIR(gl_LocalInvocationID) + FILTER_RADIUS; )
51  C(0, )
52  C(1, cache[cp] = texture(input_img[idx], pos); )
53  C(0, )
54  C(1, const ivec2 loc_l = pos - INC(FILTER_RADIUS); )
55  C(1, cache[cp - FILTER_RADIUS] = texture(input_img[idx], loc_l); )
56  C(0, )
57  C(1, const ivec2 loc_h = pos + INC(DIR(gl_WorkGroupSize)); )
58  C(1, cache[cp + DIR(gl_WorkGroupSize)] = texture(input_img[idx], loc_h); )
59  C(0, )
60  C(1, barrier(); )
61  C(0, )
62  C(1, vec4 sum = vec4(0); )
63  C(1, for (int p = -FILTER_RADIUS; p <= FILTER_RADIUS; p++) )
64  C(2, sum += cache[cp + p]; )
65  C(0, )
66  C(1, sum /= vec4(FILTER_RADIUS*2 + 1); )
67  C(1, imageStore(output_img[idx], pos, sum); )
68  C(0, } )
69 };
70 
72 {
73  int err;
74  FFVkSPIRVShader *shd;
75  AvgBlurVulkanContext *s = ctx->priv;
76  FFVulkanContext *vkctx = &s->vkctx;
77  const int planes = av_pix_fmt_count_planes(s->vkctx.output_format);
78 
79  FFVulkanDescriptorSetBinding desc_i[2] = {
80  {
81  .name = "input_img",
82  .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
83  .dimensions = 2,
84  .elems = planes,
85  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
86  },
87  {
88  .name = "output_img",
89  .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
90  .mem_layout = ff_vk_shader_rep_fmt(s->vkctx.output_format),
91  .mem_quali = "writeonly",
92  .dimensions = 2,
93  .elems = planes,
94  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
95  },
96  };
97 
98  ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT, 0);
99 
100  desc_i[0].sampler = ff_vk_init_sampler(vkctx, 1, VK_FILTER_LINEAR);
101  if (!desc_i[0].sampler)
102  return AVERROR_EXTERNAL;
103 
104  { /* Create shader for the horizontal pass */
105  desc_i[0].updater = s->input_images;
106  desc_i[1].updater = s->tmp_images;
107 
108  s->pl_hor = ff_vk_create_pipeline(vkctx, &s->qf);
109  if (!s->pl_hor)
110  return AVERROR(ENOMEM);
111 
112  shd = ff_vk_init_shader(s->pl_hor, "avgblur_compute_hor",
113  VK_SHADER_STAGE_COMPUTE_BIT);
114  if (!shd)
115  return AVERROR(ENOMEM);
116 
117  ff_vk_set_compute_shader_sizes(shd, (int [3]){ CGS, 1, 1 });
118 
119  RET(ff_vk_add_descriptor_set(vkctx, s->pl_hor, shd, desc_i, FF_ARRAY_ELEMS(desc_i), 0));
120 
121  GLSLF(0, #define FILTER_RADIUS (%i) ,s->size_x - 1);
122  GLSLC(0, #define INC(x) (ivec2(x, 0)) );
123  GLSLC(0, #define DIR(var) (var.x) );
124  GLSLD( blur_kernel );
125  GLSLC(0, void main() );
126  GLSLC(0, { );
127  GLSLC(1, ivec2 size; );
128  GLSLC(1, const ivec2 pos = ivec2(gl_GlobalInvocationID.xy); );
129  for (int i = 0; i < planes; i++) {
130  GLSLC(0, );
131  GLSLF(1, size = imageSize(output_img[%i]); ,i);
132  GLSLC(1, if (IS_WITHIN(pos, size)) { );
133  if (s->planes & (1 << i)) {
134  GLSLF(2, distort(pos, %i); ,i);
135  } else {
136  GLSLF(2, vec4 res = texture(input_img[%i], pos); ,i);
137  GLSLF(2, imageStore(output_img[%i], pos, res); ,i);
138  }
139  GLSLC(1, } );
140  }
141  GLSLC(0, } );
142 
143  RET(ff_vk_compile_shader(vkctx, shd, "main"));
144 
145  RET(ff_vk_init_pipeline_layout(vkctx, s->pl_hor));
146  RET(ff_vk_init_compute_pipeline(vkctx, s->pl_hor));
147  }
148 
149  { /* Create shader for the vertical pass */
150  desc_i[0].updater = s->tmp_images;
151  desc_i[1].updater = s->output_images;
152 
153  s->pl_ver = ff_vk_create_pipeline(vkctx, &s->qf);
154  if (!s->pl_ver)
155  return AVERROR(ENOMEM);
156 
157  shd = ff_vk_init_shader(s->pl_ver, "avgblur_compute_ver",
158  VK_SHADER_STAGE_COMPUTE_BIT);
159  if (!shd)
160  return AVERROR(ENOMEM);
161 
162  ff_vk_set_compute_shader_sizes(shd, (int [3]){ 1, CGS, 1 });
163 
164  RET(ff_vk_add_descriptor_set(vkctx, s->pl_ver, shd, desc_i, FF_ARRAY_ELEMS(desc_i), 0));
165 
166  GLSLF(0, #define FILTER_RADIUS (%i) ,s->size_y - 1);
167  GLSLC(0, #define INC(x) (ivec2(0, x)) );
168  GLSLC(0, #define DIR(var) (var.y) );
169  GLSLD( blur_kernel );
170  GLSLC(0, void main() );
171  GLSLC(0, { );
172  GLSLC(1, ivec2 size; );
173  GLSLC(1, const ivec2 pos = ivec2(gl_GlobalInvocationID.xy); );
174  for (int i = 0; i < planes; i++) {
175  GLSLC(0, );
176  GLSLF(1, size = imageSize(output_img[%i]); ,i);
177  GLSLC(1, if (IS_WITHIN(pos, size)) { );
178  if (s->planes & (1 << i)) {
179  GLSLF(2, distort(pos, %i); ,i);
180  } else {
181  GLSLF(2, vec4 res = texture(input_img[%i], pos); ,i);
182  GLSLF(2, imageStore(output_img[%i], pos, res); ,i);
183  }
184  GLSLC(1, } );
185  }
186  GLSLC(0, } );
187 
188  RET(ff_vk_compile_shader(vkctx, shd, "main"));
189 
190  RET(ff_vk_init_pipeline_layout(vkctx, s->pl_ver));
191  RET(ff_vk_init_compute_pipeline(vkctx, s->pl_ver));
192  }
193 
194  /* Execution context */
195  RET(ff_vk_create_exec_ctx(vkctx, &s->exec, &s->qf));
196 
197  s->initialized = 1;
198 
199  return 0;
200 
201 fail:
202  return err;
203 }
204 
205 static int process_frames(AVFilterContext *avctx, AVFrame *out_f, AVFrame *tmp_f, AVFrame *in_f)
206 {
207  int err;
208  VkCommandBuffer cmd_buf;
209  AvgBlurVulkanContext *s = avctx->priv;
210  FFVulkanContext *vkctx = &s->vkctx;
211  FFVulkanFunctions *vk = &vkctx->vkfn;
212  AVVkFrame *in = (AVVkFrame *)in_f->data[0];
213  AVVkFrame *tmp = (AVVkFrame *)tmp_f->data[0];
214  AVVkFrame *out = (AVVkFrame *)out_f->data[0];
215 
216  const VkFormat *input_formats = av_vkfmt_from_pixfmt(s->vkctx.input_format);
217  const VkFormat *output_formats = av_vkfmt_from_pixfmt(s->vkctx.output_format);
218 
219  int planes = av_pix_fmt_count_planes(s->vkctx.output_format);
220 
221  /* Update descriptors and init the exec context */
222  ff_vk_start_exec_recording(vkctx, s->exec);
223  cmd_buf = ff_vk_get_exec_buf(s->exec);
224 
225  for (int i = 0; i < planes; i++) {
226  RET(ff_vk_create_imageview(vkctx, s->exec,
227  &s->input_images[i].imageView, in->img[i],
228  input_formats[i],
230 
231  RET(ff_vk_create_imageview(vkctx, s->exec,
232  &s->tmp_images[i].imageView, tmp->img[i],
233  output_formats[i],
235 
236  RET(ff_vk_create_imageview(vkctx, s->exec,
237  &s->output_images[i].imageView, out->img[i],
238  output_formats[i],
240 
241  s->input_images[i].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
242  s->tmp_images[i].imageLayout = VK_IMAGE_LAYOUT_GENERAL;
243  s->output_images[i].imageLayout = VK_IMAGE_LAYOUT_GENERAL;
244  }
245 
246  ff_vk_update_descriptor_set(vkctx, s->pl_hor, 0);
247  ff_vk_update_descriptor_set(vkctx, s->pl_ver, 0);
248 
249  for (int i = 0; i < planes; i++) {
250  VkImageMemoryBarrier bar[] = {
251  {
252  .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
253  .srcAccessMask = 0,
254  .dstAccessMask = VK_ACCESS_SHADER_READ_BIT,
255  .oldLayout = in->layout[i],
256  .newLayout = s->input_images[i].imageLayout,
257  .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
258  .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
259  .image = in->img[i],
260  .subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
261  .subresourceRange.levelCount = 1,
262  .subresourceRange.layerCount = 1,
263  },
264  {
265  .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
266  .srcAccessMask = 0,
267  .dstAccessMask = VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_SHADER_READ_BIT,
268  .oldLayout = tmp->layout[i],
269  .newLayout = s->tmp_images[i].imageLayout,
270  .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
271  .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
272  .image = tmp->img[i],
273  .subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
274  .subresourceRange.levelCount = 1,
275  .subresourceRange.layerCount = 1,
276  },
277  {
278  .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
279  .srcAccessMask = 0,
280  .dstAccessMask = VK_ACCESS_SHADER_WRITE_BIT,
281  .oldLayout = out->layout[i],
282  .newLayout = s->output_images[i].imageLayout,
283  .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
284  .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
285  .image = out->img[i],
286  .subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
287  .subresourceRange.levelCount = 1,
288  .subresourceRange.layerCount = 1,
289  },
290  };
291 
292  vk->CmdPipelineBarrier(cmd_buf, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
293  VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0,
294  0, NULL, 0, NULL, FF_ARRAY_ELEMS(bar), bar);
295 
296  in->layout[i] = bar[0].newLayout;
297  in->access[i] = bar[0].dstAccessMask;
298 
299  tmp->layout[i] = bar[1].newLayout;
300  tmp->access[i] = bar[1].dstAccessMask;
301 
302  out->layout[i] = bar[2].newLayout;
303  out->access[i] = bar[2].dstAccessMask;
304  }
305 
306  ff_vk_bind_pipeline_exec(vkctx, s->exec, s->pl_hor);
307 
308  vk->CmdDispatch(cmd_buf, FFALIGN(s->vkctx.output_width, CGS)/CGS,
309  s->vkctx.output_height, 1);
310 
311  ff_vk_bind_pipeline_exec(vkctx, s->exec, s->pl_ver);
312 
313  vk->CmdDispatch(cmd_buf, s->vkctx.output_width,
314  FFALIGN(s->vkctx.output_height, CGS)/CGS, 1);
315 
316  ff_vk_add_exec_dep(vkctx, s->exec, in_f, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT);
317  ff_vk_add_exec_dep(vkctx, s->exec, out_f, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT);
318 
319  err = ff_vk_submit_exec_queue(vkctx,s->exec);
320  if (err)
321  return err;
322 
323  ff_vk_qf_rotate(&s->qf);
324 
325  return err;
326 
327 fail:
328  ff_vk_discard_exec_deps(s->exec);
329  return err;
330 }
331 
333 {
334  int err;
335  AVFrame *tmp = NULL, *out = NULL;
336  AVFilterContext *ctx = link->dst;
337  AvgBlurVulkanContext *s = ctx->priv;
338  AVFilterLink *outlink = ctx->outputs[0];
339 
340  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
341  if (!out) {
342  err = AVERROR(ENOMEM);
343  goto fail;
344  }
345 
346  tmp = ff_get_video_buffer(outlink, outlink->w, outlink->h);
347  if (!tmp) {
348  err = AVERROR(ENOMEM);
349  goto fail;
350  }
351 
352  if (!s->initialized)
353  RET(init_filter(ctx, in));
354 
355  RET(process_frames(ctx, out, tmp, in));
356 
357  err = av_frame_copy_props(out, in);
358  if (err < 0)
359  goto fail;
360 
361  av_frame_free(&in);
362  av_frame_free(&tmp);
363 
364  return ff_filter_frame(outlink, out);
365 
366 fail:
367  av_frame_free(&in);
368  av_frame_free(&tmp);
369  av_frame_free(&out);
370  return err;
371 }
372 
374 {
375  AvgBlurVulkanContext *s = avctx->priv;
376 
377  ff_vk_uninit(&s->vkctx);
378 
379  s->initialized = 0;
380 }
381 
382 #define OFFSET(x) offsetof(AvgBlurVulkanContext, x)
383 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
385  { "sizeX", "Set horizontal radius", OFFSET(size_x), AV_OPT_TYPE_INT, {.i64 = 3}, 1, 32, .flags = FLAGS },
386  { "planes", "Set planes to filter (bitmask)", OFFSET(planes), AV_OPT_TYPE_INT, {.i64 = 0xF}, 0, 0xF, .flags = FLAGS },
387  { "sizeY", "Set vertical radius", OFFSET(size_y), AV_OPT_TYPE_INT, {.i64 = 3}, 1, 32, .flags = FLAGS },
388  { NULL },
389 };
390 
391 AVFILTER_DEFINE_CLASS(avgblur_vulkan);
392 
394  {
395  .name = "default",
396  .type = AVMEDIA_TYPE_VIDEO,
397  .filter_frame = &avgblur_vulkan_filter_frame,
398  .config_props = &ff_vk_filter_config_input,
399  },
400 };
401 
403  {
404  .name = "default",
405  .type = AVMEDIA_TYPE_VIDEO,
406  .config_props = &ff_vk_filter_config_output,
407  },
408 };
409 
411  .name = "avgblur_vulkan",
412  .description = NULL_IF_CONFIG_SMALL("Apply avgblur mask to input video"),
413  .priv_size = sizeof(AvgBlurVulkanContext),
419  .priv_class = &avgblur_vulkan_class,
420  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
421 };
ff_get_video_buffer
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:98
AvgBlurVulkanContext
Definition: vf_avgblur_vulkan.c:26
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
FLAGS
#define FLAGS
Definition: vf_avgblur_vulkan.c:383
ff_comp_identity_map
const VkComponentMapping ff_comp_identity_map
Definition: vulkan.c:51
avgblur_vulkan_outputs
static const AVFilterPad avgblur_vulkan_outputs[]
Definition: vf_avgblur_vulkan.c:402
out
FILE * out
Definition: movenc.c:54
AvgBlurVulkanContext::pl_ver
FFVulkanPipeline * pl_ver
Definition: vf_avgblur_vulkan.c:33
FF_FILTER_FLAG_HWFRAME_AWARE
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
Definition: internal.h:371
avgblur_vulkan_inputs
static const AVFilterPad avgblur_vulkan_inputs[]
Definition: vf_avgblur_vulkan.c:393
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1018
ff_vk_bind_pipeline_exec
void ff_vk_bind_pipeline_exec(FFVulkanContext *s, FFVkExecContext *e, FFVulkanPipeline *pl)
Add a command to bind the completed pipeline and its descriptor sets.
Definition: vulkan.c:1263
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:109
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:317
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:26
ff_vk_filter_init
int ff_vk_filter_init(AVFilterContext *avctx)
General lavfi IO functions.
Definition: vulkan_filter.c:184
AVOption
AVOption.
Definition: opt.h:247
ff_vk_compile_shader
int ff_vk_compile_shader(FFVulkanContext *s, FFVkSPIRVShader *shd, const char *entrypoint)
Compiles the shader, entrypoint must be set to "main".
Definition: vulkan.c:848
ff_vf_avgblur_vulkan
const AVFilter ff_vf_avgblur_vulkan
Definition: vf_avgblur_vulkan.c:410
ff_vk_uninit
void ff_vk_uninit(FFVulkanContext *s)
Frees the main Vulkan context.
Definition: vulkan.c:1378
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:169
avgblur_vulkan_uninit
static void avgblur_vulkan_uninit(AVFilterContext *avctx)
Definition: vf_avgblur_vulkan.c:373
AvgBlurVulkanContext::initialized
int initialized
Definition: vf_avgblur_vulkan.c:29
blur_kernel
static const char blur_kernel[]
Definition: vf_avgblur_vulkan.c:45
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(avgblur_vulkan)
AV_PIX_FMT_VULKAN
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition: pixfmt.h:346
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:338
ff_vk_add_exec_dep
int ff_vk_add_exec_dep(FFVulkanContext *s, FFVkExecContext *e, AVFrame *frame, VkPipelineStageFlagBits in_wait_dst_flag)
Adds a frame as a queue dependency.
Definition: vulkan.c:509
init
static int init
Definition: av_tx.c:47
ff_vk_get_exec_buf
VkCommandBuffer ff_vk_get_exec_buf(FFVkExecContext *e)
Gets the command buffer to use for this submission from the exe context.
Definition: vulkan.c:504
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2700
AVVkFrame::img
VkImage img[AV_NUM_DATA_POINTERS]
Vulkan images to which the memory is bound to.
Definition: hwcontext_vulkan.h:217
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:417
fail
#define fail()
Definition: checkasm.h:127
vulkan_filter.h
avgblur_vulkan_options
static const AVOption avgblur_vulkan_options[]
Definition: vf_avgblur_vulkan.c:384
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:50
C
s EdgeDetect Foobar g libavfilter vf_edgedetect c libavfilter vf_foobar c edit libavfilter and add an entry for foobar following the pattern of the other filters edit libavfilter allfilters and add an entry for foobar following the pattern of the other filters configure make j< whatever > ffmpeg ffmpeg i you should get a foobar png with Lena edge detected That s your new playground is ready Some little details about what s going which in turn will define variables for the build system and the C
Definition: writing_filters.txt:58
ff_vk_qf_init
void ff_vk_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf, VkQueueFlagBits dev_family, int nb_queues)
Initialize a queue family with a specific number of queues.
Definition: vulkan.c:96
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
av_cold
#define av_cold
Definition: attributes.h:90
ff_vk_create_imageview
int ff_vk_create_imageview(FFVulkanContext *s, FFVkExecContext *e, VkImageView *v, VkImage img, VkFormat fmt, const VkComponentMapping map)
Create an imageview.
Definition: vulkan.c:742
s
#define s(width, name)
Definition: cbs_vp9.c:257
AvgBlurVulkanContext::input_images
VkDescriptorImageInfo input_images[3]
Definition: vf_avgblur_vulkan.c:36
ff_vk_init_shader
FFVkSPIRVShader * ff_vk_init_shader(FFVulkanPipeline *pl, const char *name, VkShaderStageFlags stage)
Inits a shader for a specific pipeline.
Definition: vulkan.c:795
ctx
AVFormatContext * ctx
Definition: movenc.c:48
process_frames
static int process_frames(AVFilterContext *avctx, AVFrame *out_f, AVFrame *tmp_f, AVFrame *in_f)
Definition: vf_avgblur_vulkan.c:205
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:191
link
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a link
Definition: filter_design.txt:23
ff_vk_update_descriptor_set
void ff_vk_update_descriptor_set(FFVulkanContext *s, FFVulkanPipeline *pl, int set_id)
Updates a descriptor set via the updaters defined.
Definition: vulkan.c:1079
planes
static const struct @321 planes[]
ff_vk_start_exec_recording
int ff_vk_start_exec_recording(FFVulkanContext *s, FFVkExecContext *e)
Begin recording to the command buffer.
Definition: vulkan.c:463
av_vkfmt_from_pixfmt
const VkFormat * av_vkfmt_from_pixfmt(enum AVPixelFormat p)
Returns the format of each image up to the number of planes for a given sw_format.
Definition: hwcontext_vulkan.c:238
main
int main(int argc, char *argv[])
Definition: avio_list_dir.c:112
NULL
#define NULL
Definition: coverity.c:32
av_frame_copy_props
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:537
GLSLD
#define GLSLD(D)
Definition: vulkan.h:47
AvgBlurVulkanContext::output_images
VkDescriptorImageInfo output_images[3]
Definition: vf_avgblur_vulkan.c:38
AvgBlurVulkanContext::qf
FFVkQueueFamilyCtx qf
Definition: vf_avgblur_vulkan.c:30
ff_vk_create_exec_ctx
int ff_vk_create_exec_ctx(FFVulkanContext *s, FFVkExecContext **ctx, FFVkQueueFamilyCtx *qf)
Init an execution context for command recording and queue submission.
Definition: vulkan.c:385
OFFSET
#define OFFSET(x)
Definition: vf_avgblur_vulkan.c:382
ff_vk_filter_config_output
int ff_vk_filter_config_output(AVFilterLink *outlink)
Definition: vulkan_filter.c:133
ff_vk_qf_rotate
void ff_vk_qf_rotate(FFVkQueueFamilyCtx *qf)
Rotate through the queues in a queue family.
Definition: vulkan.c:132
FFVulkanDescriptorSetBinding::updater
void * updater
Definition: vulkan.h:88
AvgBlurVulkanContext::size_y
int size_y
Definition: vf_avgblur_vulkan.c:41
FFVulkanContext
Definition: vulkan.h:188
FFVulkanPipeline
Definition: vulkan.h:104
ff_vk_discard_exec_deps
void ff_vk_discard_exec_deps(FFVkExecContext *e)
Discards all queue dependencies.
Definition: vulkan.c:447
AvgBlurVulkanContext::planes
int planes
Definition: vf_avgblur_vulkan.c:42
AVVkFrame::access
VkAccessFlagBits access[AV_NUM_DATA_POINTERS]
Updated after every barrier.
Definition: hwcontext_vulkan.h:240
FFVulkanDescriptorSetBinding
Definition: vulkan.h:78
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
AVVkFrame
Definition: hwcontext_vulkan.h:213
ff_vk_init_pipeline_layout
int ff_vk_init_pipeline_layout(FFVulkanContext *s, FFVulkanPipeline *pl)
Initializes the pipeline layout after all shaders and descriptor sets have been finished.
Definition: vulkan.c:1115
size
int size
Definition: twinvq_data.h:10344
AvgBlurVulkanContext::tmp_images
VkDescriptorImageInfo tmp_images[3]
Definition: vf_avgblur_vulkan.c:37
FFVkQueueFamilyCtx
Definition: vulkan.h:97
AvgBlurVulkanContext::vkctx
FFVulkanContext vkctx
Definition: vf_avgblur_vulkan.c:27
init_filter
static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
Definition: vf_avgblur_vulkan.c:71
ff_vk_submit_exec_queue
int ff_vk_submit_exec_queue(FFVulkanContext *s, FFVkExecContext *e)
Submits a command buffer to the queue for execution.
Definition: vulkan.c:590
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
FFVkExecContext
Definition: vulkan.h:154
FFVulkanDescriptorSetBinding::name
const char * name
Definition: vulkan.h:79
internal.h
FILTER_SINGLE_PIXFMT
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition: internal.h:181
ff_vk_init_compute_pipeline
int ff_vk_init_compute_pipeline(FFVulkanContext *s, FFVulkanPipeline *pl)
Initializes a compute pipeline.
Definition: vulkan.c:1228
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
ff_vk_shader_rep_fmt
const char * ff_vk_shader_rep_fmt(enum AVPixelFormat pixfmt)
Gets the glsl format string for a pixel format.
Definition: vulkan.c:721
AvgBlurVulkanContext::size_x
int size_x
Definition: vf_avgblur_vulkan.c:40
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:56
GLSLF
#define GLSLF(N, S,...)
Definition: vulkan.h:46
ff_vk_create_pipeline
FFVulkanPipeline * ff_vk_create_pipeline(FFVulkanContext *s, FFVkQueueFamilyCtx *qf)
Inits a pipeline.
Definition: vulkan.c:1219
AVFilter
Filter definition.
Definition: avfilter.h:165
FFVulkanContext::vkfn
FFVulkanFunctions vkfn
Definition: vulkan.h:191
pos
unsigned int pos
Definition: spdifenc.c:412
AvgBlurVulkanContext::exec
FFVkExecContext * exec
Definition: vf_avgblur_vulkan.c:31
ff_vk_add_descriptor_set
int ff_vk_add_descriptor_set(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkSPIRVShader *shd, FFVulkanDescriptorSetBinding *desc, int num, int only_print_to_shader)
Adds a descriptor set to the shader and registers them in the pipeline.
Definition: vulkan.c:922
random_seed.h
FFVkSPIRVShader
Definition: vulkan.h:58
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
CGS
#define CGS
Definition: vf_avgblur_vulkan.c:24
FFVulkanDescriptorSetBinding::sampler
FFVkSampler * sampler
Definition: vulkan.h:87
ff_vk_init_sampler
FFVkSampler * ff_vk_init_sampler(FFVulkanContext *s, int unnorm_coords, VkFilter filt)
Create a Vulkan sampler, will be auto-freed in ff_vk_filter_uninit()
Definition: vulkan.c:670
AVFilterContext
An instance of a filter.
Definition: avfilter.h:402
avgblur_vulkan_filter_frame
static int avgblur_vulkan_filter_frame(AVFilterLink *link, AVFrame *in)
Definition: vf_avgblur_vulkan.c:332
GLSLC
#define GLSLC(N, S)
Definition: vulkan.h:44
ff_vk_filter_config_input
int ff_vk_filter_config_input(AVFilterLink *inlink)
Definition: vulkan_filter.c:52
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AVVkFrame::layout
VkImageLayout layout[AV_NUM_DATA_POINTERS]
Definition: hwcontext_vulkan.h:241
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:192
ff_vk_set_compute_shader_sizes
void ff_vk_set_compute_shader_sizes(FFVkSPIRVShader *shd, int local_size[3])
Writes the workgroup size for a shader.
Definition: vulkan.c:816
uninit
static av_cold int uninit(AVCodecContext *avctx)
Definition: crystalhd.c:282
AvgBlurVulkanContext::pl_hor
FFVulkanPipeline * pl_hor
Definition: vf_avgblur_vulkan.c:32
RET
#define RET(x)
Definition: vulkan.h:52
FFVulkanFunctions
Definition: vulkan_functions.h:175