FFmpeg
vulkan_filter.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) Lynne
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include "vulkan_filter.h"
22 
24  AVBufferRef *frames_ref,
25  int width, int height, enum AVPixelFormat sw_format)
26 {
27  int err;
28  AVHWFramesContext *frames_ctx;
29  AVHWDeviceContext *device_ctx;
30  AVVulkanFramesContext *vk_frames;
31  AVVulkanDeviceContext *vk_dev;
32  AVBufferRef *device_ref = avctx->hw_device_ctx;
33 
34  /* Check if context is reusable as-is */
35  if (frames_ref) {
36  int no_storage = 0;
38  const VkFormat *sub = av_vkfmt_from_pixfmt(sw_format);
39 
40  frames_ctx = (AVHWFramesContext *)frames_ref->data;
41  device_ctx = (AVHWDeviceContext *)frames_ctx->device_ref->data;
42  vk_frames = frames_ctx->hwctx;
43  vk_dev = device_ctx->hwctx;
44 
45  /* Width and height mismatch */
46  if (width != frames_ctx->width ||
47  height != frames_ctx->height)
48  goto skip;
49 
50  /* Format mismatch */
51  if (sw_format != frames_ctx->sw_format)
52  goto skip;
53 
54  /* Unusual tiling mismatch. Don't let linear through either. */
55  if (vk_frames->tiling != VK_IMAGE_TILING_OPTIMAL)
56  goto skip;
57 
58  /* Usage mismatch */
59  if ((vk_frames->usage & (VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT)) !=
60  (VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT))
61  goto skip;
62 
65  err = ff_vk_load_functions(device_ctx, &s->vkfn, s->extensions, 1, 1);
66  if (err < 0)
67  return err;
68  vk = &s->vkfn;
69 
70  /* Check if the subformats can do storage */
71  for (int i = 0; sub[i] != VK_FORMAT_UNDEFINED; i++) {
72  VkFormatProperties2 prop = {
73  .sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2,
74  };
75  vk->GetPhysicalDeviceFormatProperties2(vk_dev->phys_dev, sub[i],
76  &prop);
77 
78  if (vk_frames->tiling == VK_IMAGE_TILING_LINEAR) {
79  no_storage |= !(prop.formatProperties.linearTilingFeatures &
80  VK_FORMAT_FEATURE_2_STORAGE_IMAGE_BIT);
81  } else {
82  no_storage |= !(prop.formatProperties.optimalTilingFeatures &
83  VK_FORMAT_FEATURE_2_STORAGE_IMAGE_BIT);
84  }
85  }
86 
87  /* Check if it's usable */
88  if (no_storage) {
89 skip:
90  device_ref = frames_ctx->device_ref;
91  frames_ref = NULL;
92  } else {
93  frames_ref = av_buffer_ref(frames_ref);
94  if (!frames_ref)
95  return AVERROR(ENOMEM);
96  }
97  }
98 
99  if (!frames_ref) {
100  if (!device_ref) {
101  av_log(avctx, AV_LOG_ERROR,
102  "Vulkan filtering requires a device context!\n");
103  return AVERROR(EINVAL);
104  }
105 
106  frames_ref = av_hwframe_ctx_alloc(device_ref);
107 
108  frames_ctx = (AVHWFramesContext *)frames_ref->data;
109  frames_ctx->format = AV_PIX_FMT_VULKAN;
110  frames_ctx->sw_format = sw_format;
111  frames_ctx->width = width;
112  frames_ctx->height = height;
113 
114  vk_frames = frames_ctx->hwctx;
115  vk_frames->tiling = VK_IMAGE_TILING_OPTIMAL;
116  vk_frames->usage = VK_IMAGE_USAGE_SAMPLED_BIT |
117  VK_IMAGE_USAGE_STORAGE_BIT |
118  VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
119  VK_IMAGE_USAGE_TRANSFER_DST_BIT;
120 
121  err = av_hwframe_ctx_init(frames_ref);
122  if (err < 0) {
123  av_buffer_unref(&frames_ref);
124  return err;
125  }
126 
127  device_ctx = (AVHWDeviceContext *)frames_ctx->device_ref->data;
128  vk_dev = device_ctx->hwctx;
129  }
130 
131  s->extensions = ff_vk_extensions_to_mask(vk_dev->enabled_dev_extensions,
132  vk_dev->nb_enabled_dev_extensions);
133 
134  /**
135  * libplacebo does not use descriptor buffers.
136  */
137  if (!(s->extensions & FF_VK_EXT_DESCRIPTOR_BUFFER) &&
138  strcmp(avctx->filter->name, "libplacebo")) {
139  av_log(avctx, AV_LOG_ERROR, "Vulkan filtering requires that "
140  "the %s extension is supported!\n",
141  VK_EXT_DESCRIPTOR_BUFFER_EXTENSION_NAME);
142  av_buffer_unref(&frames_ref);
143  return AVERROR(EINVAL);
144  }
145 
146  err = ff_vk_load_functions(device_ctx, &s->vkfn, s->extensions, 1, 1);
147  if (err < 0) {
148  av_buffer_unref(&frames_ref);
149  return err;
150  }
151 
152  s->frames_ref = frames_ref;
153  s->frames = frames_ctx;
154  s->hwfc = vk_frames;
155  s->device = device_ctx;
156  s->hwctx = device_ctx->hwctx;
157 
158  err = ff_vk_load_props(s);
159  if (err < 0)
160  av_buffer_unref(&s->frames_ref);
161 
162  return err;
163 }
164 
166 {
167  AVHWFramesContext *input_frames;
168  AVFilterContext *avctx = inlink->dst;
169  FFVulkanContext *s = inlink->dst->priv;
170 
171  if (!inlink->hw_frames_ctx) {
172  av_log(inlink->dst, AV_LOG_ERROR, "Vulkan filtering requires a "
173  "hardware frames context on the input.\n");
174  return AVERROR(EINVAL);
175  }
176 
177  input_frames = (AVHWFramesContext *)inlink->hw_frames_ctx->data;
178  if (input_frames->format != AV_PIX_FMT_VULKAN)
179  return AVERROR(EINVAL);
180 
181  /* Extract the device and default output format from the first input. */
182  if (avctx->inputs[0] != inlink)
183  return 0;
184 
185  /* Save the ref, without reffing it */
186  s->input_frames_ref = inlink->hw_frames_ctx;
187 
188  /* Defaults */
189  s->output_format = input_frames->sw_format;
190  s->output_width = inlink->w;
191  s->output_height = inlink->h;
192 
193  return 0;
194 }
195 
197 {
198  int err;
199  FFVulkanContext *s = outlink->src->priv;
200 
201  av_buffer_unref(&outlink->hw_frames_ctx);
202 
203  err = ff_vk_filter_init_context(outlink->src, s, s->input_frames_ref,
204  s->output_width, s->output_height,
205  s->output_format);
206  if (err < 0)
207  return err;
208 
209  outlink->hw_frames_ctx = av_buffer_ref(s->frames_ref);
210  if (!outlink->hw_frames_ctx)
211  return AVERROR(ENOMEM);
212 
213  outlink->w = s->output_width;
214  outlink->h = s->output_height;
215 
216  return err;
217 }
218 
220 {
221  FFVulkanContext *s = avctx->priv;
222 
223  s->output_format = AV_PIX_FMT_NONE;
224 
225  return 0;
226 }
227 
229  FFVulkanPipeline *pl, AVFrame *out_f, AVFrame *in_f,
230  VkSampler sampler, void *push_src, size_t push_size)
231 {
232  int err = 0;
233  FFVulkanFunctions *vk = &vkctx->vkfn;
234  VkImageView in_views[AV_NUM_DATA_POINTERS];
235  VkImageView out_views[AV_NUM_DATA_POINTERS];
236  VkImageMemoryBarrier2 img_bar[37];
237  int nb_img_bar = 0;
238 
239  /* Update descriptors and init the exec context */
240  FFVkExecContext *exec = ff_vk_exec_get(e);
241  ff_vk_exec_start(vkctx, exec);
242 
243  ff_vk_exec_bind_pipeline(vkctx, exec, pl);
244 
245  if (push_src)
246  ff_vk_update_push_exec(vkctx, exec, pl, VK_SHADER_STAGE_COMPUTE_BIT,
247  0, push_size, push_src);
248 
249  if (in_f) {
250  RET(ff_vk_exec_add_dep_frame(vkctx, exec, in_f,
251  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
252  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
253  RET(ff_vk_create_imageviews(vkctx, exec, in_views, in_f));
254  ff_vk_update_descriptor_img_array(vkctx, pl, exec, in_f, in_views, 0, 0,
255  VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
256  sampler);
257  ff_vk_frame_barrier(vkctx, exec, in_f, img_bar, &nb_img_bar,
258  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
259  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
260  VK_ACCESS_SHADER_READ_BIT,
261  VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
262  VK_QUEUE_FAMILY_IGNORED);
263  }
264 
265  RET(ff_vk_exec_add_dep_frame(vkctx, exec, out_f,
266  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
267  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
268  RET(ff_vk_create_imageviews(vkctx, exec, out_views, out_f));
269  ff_vk_update_descriptor_img_array(vkctx, pl, exec, out_f, out_views, 0, !!in_f,
270  VK_IMAGE_LAYOUT_GENERAL,
271  VK_NULL_HANDLE);
272  ff_vk_frame_barrier(vkctx, exec, out_f, img_bar, &nb_img_bar,
273  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
274  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
275  VK_ACCESS_SHADER_WRITE_BIT,
276  VK_IMAGE_LAYOUT_GENERAL,
277  VK_QUEUE_FAMILY_IGNORED);
278 
279  vk->CmdPipelineBarrier2(exec->buf, &(VkDependencyInfo) {
280  .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
281  .pImageMemoryBarriers = img_bar,
282  .imageMemoryBarrierCount = nb_img_bar,
283  });
284 
285  vk->CmdDispatch(exec->buf,
286  FFALIGN(vkctx->output_width, pl->wg_size[0])/pl->wg_size[0],
287  FFALIGN(vkctx->output_height, pl->wg_size[1])/pl->wg_size[1],
288  pl->wg_size[2]);
289 
290  return ff_vk_exec_submit(vkctx, exec);
291 fail:
292  ff_vk_exec_discard_deps(vkctx, exec);
293  return err;
294 }
295 
297  FFVulkanPipeline *pls[2],
298  AVFrame *out, AVFrame *tmp, AVFrame *in,
299  VkSampler sampler, void *push_src, size_t push_size)
300 {
301  int err = 0;
302  FFVulkanFunctions *vk = &vkctx->vkfn;
303  VkImageView in_views[AV_NUM_DATA_POINTERS];
304  VkImageView tmp_views[AV_NUM_DATA_POINTERS];
305  VkImageView out_views[AV_NUM_DATA_POINTERS];
306  VkImageMemoryBarrier2 img_bar[37];
307  int nb_img_bar = 0;
308 
309  /* Update descriptors and init the exec context */
310  FFVkExecContext *exec = ff_vk_exec_get(e);
311  ff_vk_exec_start(vkctx, exec);
312 
313  RET(ff_vk_exec_add_dep_frame(vkctx, exec, in,
314  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
315  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
316  RET(ff_vk_exec_add_dep_frame(vkctx, exec, tmp,
317  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
318  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
319  RET(ff_vk_exec_add_dep_frame(vkctx, exec, out,
320  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
321  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
322 
323  RET(ff_vk_create_imageviews(vkctx, exec, in_views, in));
324  RET(ff_vk_create_imageviews(vkctx, exec, tmp_views, tmp));
325  RET(ff_vk_create_imageviews(vkctx, exec, out_views, out));
326 
327  ff_vk_frame_barrier(vkctx, exec, in, img_bar, &nb_img_bar,
328  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
329  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
330  VK_ACCESS_SHADER_READ_BIT,
331  VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
332  VK_QUEUE_FAMILY_IGNORED);
333  ff_vk_frame_barrier(vkctx, exec, tmp, img_bar, &nb_img_bar,
334  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
335  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
336  VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT,
337  VK_IMAGE_LAYOUT_GENERAL,
338  VK_QUEUE_FAMILY_IGNORED);
339  ff_vk_frame_barrier(vkctx, exec, out, img_bar, &nb_img_bar,
340  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
341  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
342  VK_ACCESS_SHADER_WRITE_BIT,
343  VK_IMAGE_LAYOUT_GENERAL,
344  VK_QUEUE_FAMILY_IGNORED);
345 
346  vk->CmdPipelineBarrier2(exec->buf, &(VkDependencyInfo) {
347  .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
348  .pImageMemoryBarriers = img_bar,
349  .imageMemoryBarrierCount = nb_img_bar,
350  });
351 
352  for (int i = 0; i < 2; i++) {
353  FFVulkanPipeline *pl = pls[i];
354  AVFrame *src_f = !i ? in : tmp;
355  AVFrame *dst_f = !i ? tmp : out;
356  VkImageView *src_views = !i ? in_views : tmp_views;
357  VkImageView *dst_views = !i ? tmp_views : out_views;
358 
359  ff_vk_exec_bind_pipeline(vkctx, exec, pl);
360 
361  if (push_src)
362  ff_vk_update_push_exec(vkctx, exec, pl, VK_SHADER_STAGE_COMPUTE_BIT,
363  0, push_size, push_src);
364 
365  ff_vk_update_descriptor_img_array(vkctx, pl, exec, src_f, src_views, 0, 0,
366  !i ? VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL :
367  VK_IMAGE_LAYOUT_GENERAL,
368  sampler);
369  ff_vk_update_descriptor_img_array(vkctx, pl, exec, dst_f, dst_views, 0, 1,
370  VK_IMAGE_LAYOUT_GENERAL,
371  VK_NULL_HANDLE);
372 
373  vk->CmdDispatch(exec->buf,
374  FFALIGN(vkctx->output_width, pl->wg_size[0])/pl->wg_size[0],
375  FFALIGN(vkctx->output_height, pl->wg_size[1])/pl->wg_size[1],
376  pl->wg_size[2]);
377  }
378 
379  return ff_vk_exec_submit(vkctx, exec);
380 fail:
381  ff_vk_exec_discard_deps(vkctx, exec);
382  return err;
383 }
384 
386  FFVulkanPipeline *pl,
387  AVFrame *out, AVFrame *in[], int nb_in,
388  VkSampler sampler, void *push_src, size_t push_size)
389 {
390  int err = 0;
391  FFVulkanFunctions *vk = &vkctx->vkfn;
392  VkImageView in_views[16][AV_NUM_DATA_POINTERS];
393  VkImageView out_views[AV_NUM_DATA_POINTERS];
394  VkImageMemoryBarrier2 img_bar[128];
395  int nb_img_bar = 0;
396 
397  /* Update descriptors and init the exec context */
398  FFVkExecContext *exec = ff_vk_exec_get(e);
399  ff_vk_exec_start(vkctx, exec);
400 
401  /* Inputs */
402  for (int i = 0; i < nb_in; i++) {
403  RET(ff_vk_exec_add_dep_frame(vkctx, exec, in[i],
404  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
405  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
406  RET(ff_vk_create_imageviews(vkctx, exec, in_views[i], in[i]));
407 
408  ff_vk_frame_barrier(vkctx, exec, in[i], img_bar, &nb_img_bar,
409  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
410  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
411  VK_ACCESS_SHADER_READ_BIT,
412  VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
413  VK_QUEUE_FAMILY_IGNORED);
414  }
415 
416  /* Output */
417  RET(ff_vk_exec_add_dep_frame(vkctx, exec, out,
418  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
419  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
420  RET(ff_vk_create_imageviews(vkctx, exec, out_views, out));
421  ff_vk_frame_barrier(vkctx, exec, out, img_bar, &nb_img_bar,
422  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
423  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
424  VK_ACCESS_SHADER_WRITE_BIT,
425  VK_IMAGE_LAYOUT_GENERAL,
426  VK_QUEUE_FAMILY_IGNORED);
427 
428  vk->CmdPipelineBarrier2(exec->buf, &(VkDependencyInfo) {
429  .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
430  .pImageMemoryBarriers = img_bar,
431  .imageMemoryBarrierCount = nb_img_bar,
432  });
433 
434  ff_vk_exec_bind_pipeline(vkctx, exec, pl);
435 
436  if (push_src)
437  ff_vk_update_push_exec(vkctx, exec, pl, VK_SHADER_STAGE_COMPUTE_BIT,
438  0, push_size, push_src);
439 
440  for (int i = 0; i < nb_in; i++)
441  ff_vk_update_descriptor_img_array(vkctx, pl, exec, in[i], in_views[i], 0, i,
442  VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
443  sampler);
444 
445  ff_vk_update_descriptor_img_array(vkctx, pl, exec, out, out_views, 0, nb_in,
446  VK_IMAGE_LAYOUT_GENERAL,
447  VK_NULL_HANDLE);
448 
449  vk->CmdDispatch(exec->buf,
450  FFALIGN(vkctx->output_width, pl->wg_size[0])/pl->wg_size[0],
451  FFALIGN(vkctx->output_height, pl->wg_size[1])/pl->wg_size[1],
452  pl->wg_size[2]);
453 
454  return ff_vk_exec_submit(vkctx, exec);
455 fail:
456  ff_vk_exec_discard_deps(vkctx, exec);
457  return err;
458 }
AVHWDeviceContext::hwctx
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
Definition: hwcontext.h:92
ff_vk_load_props
int ff_vk_load_props(FFVulkanContext *s)
Loads props/mprops/driver_props.
Definition: vulkan.c:86
AVVulkanDeviceContext::phys_dev
VkPhysicalDevice phys_dev
Physical device.
Definition: hwcontext_vulkan.h:65
ff_vk_exec_get
FFVkExecContext * ff_vk_exec_get(FFVkExecPool *pool)
Retrieve an execution pool.
Definition: vulkan.c:497
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
ff_vk_update_descriptor_img_array
void ff_vk_update_descriptor_img_array(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkExecContext *e, AVFrame *f, VkImageView *views, int set, int binding, VkImageLayout layout, VkSampler sampler)
Definition: vulkan.c:1751
FFVulkanContext::output_height
int output_height
Definition: vulkan.h:266
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
out
FILE * out
Definition: movenc.c:54
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
AVHWFramesContext::format
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
Definition: hwcontext.h:209
inlink
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
Definition: filter_design.txt:212
av_hwframe_ctx_init
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
Definition: hwcontext.c:334
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:340
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:28
ff_vk_filter_init
int ff_vk_filter_init(AVFilterContext *avctx)
General lavfi IO functions.
Definition: vulkan_filter.c:219
av_hwframe_ctx_alloc
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
Allocate an AVHWFramesContext tied to a given device context.
Definition: hwcontext.c:248
ff_vk_filter_process_Nin
int ff_vk_filter_process_Nin(FFVulkanContext *vkctx, FFVkExecPool *e, FFVulkanPipeline *pl, AVFrame *out, AVFrame *in[], int nb_in, VkSampler sampler, void *push_src, size_t push_size)
Up to 16 inputs, one output.
Definition: vulkan_filter.c:385
FF_VK_EXT_DESCRIPTOR_BUFFER
@ FF_VK_EXT_DESCRIPTOR_BUFFER
Definition: vulkan_functions.h:40
AVFilterContext::hw_device_ctx
AVBufferRef * hw_device_ctx
For filters which will create hardware frames, sets the device the filter should create them in.
Definition: avfilter.h:457
av_buffer_ref
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition: buffer.c:103
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:170
AVHWFramesContext::width
int width
The allocated dimensions of the frames in this pool.
Definition: hwcontext.h:229
AV_PIX_FMT_VULKAN
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition: pixfmt.h:376
ff_vk_exec_add_dep_frame
int ff_vk_exec_add_dep_frame(FFVulkanContext *s, FFVkExecContext *e, AVFrame *f, VkPipelineStageFlagBits2 wait_stage, VkPipelineStageFlagBits2 signal_stage)
Definition: vulkan.c:599
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:412
fail
#define fail()
Definition: checkasm.h:138
FFVulkanPipeline::wg_size
int wg_size[3]
Definition: vulkan.h:144
vulkan_filter.h
ff_vk_filter_init_context
int ff_vk_filter_init_context(AVFilterContext *avctx, FFVulkanContext *s, AVBufferRef *frames_ref, int width, int height, enum AVPixelFormat sw_format)
Can be called manually, if not using ff_vk_filter_config_output.
Definition: vulkan_filter.c:23
AVVulkanFramesContext
Allocated as AVHWFramesContext.hwctx, used to set pool-specific options.
Definition: hwcontext_vulkan.h:176
ff_vk_filter_process_2pass
int ff_vk_filter_process_2pass(FFVulkanContext *vkctx, FFVkExecPool *e, FFVulkanPipeline *pls[2], AVFrame *out, AVFrame *tmp, AVFrame *in, VkSampler sampler, void *push_src, size_t push_size)
Submit a compute shader with a single in and single out with 2 stages.
Definition: vulkan_filter.c:296
AVHWDeviceContext
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
Definition: hwcontext.h:61
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
AVHWFramesContext::height
int height
Definition: hwcontext.h:229
FFVulkanContext::output_width
int output_width
Definition: vulkan.h:265
width
#define width
s
#define s(width, name)
Definition: cbs_vp9.c:198
ff_vk_load_functions
static int ff_vk_load_functions(AVHWDeviceContext *ctx, FFVulkanFunctions *vk, uint64_t extensions_mask, int has_inst, int has_dev)
Function loader.
Definition: vulkan_loader.h:89
ff_vk_exec_bind_pipeline
void ff_vk_exec_bind_pipeline(FFVulkanContext *s, FFVkExecContext *e, FFVulkanPipeline *pl)
Definition: vulkan.c:1846
if
if(ret)
Definition: filter_design.txt:179
AVVulkanDeviceContext
Main Vulkan context, allocated as AVHWDeviceContext.hwctx.
Definition: hwcontext_vulkan.h:44
NULL
#define NULL
Definition: coverity.c:32
AVHWFramesContext::sw_format
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
Definition: hwcontext.h:222
av_buffer_unref
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
Definition: buffer.c:139
AVVulkanDeviceContext::nb_enabled_dev_extensions
int nb_enabled_dev_extensions
Definition: hwcontext_vulkan.h:99
AVHWFramesContext::device_ref
AVBufferRef * device_ref
A reference to the parent AVHWDeviceContext.
Definition: hwcontext.h:141
AVFilterContext::inputs
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:405
ff_vk_filter_config_output
int ff_vk_filter_config_output(AVFilterLink *outlink)
Definition: vulkan_filter.c:196
AVVulkanFramesContext::usage
VkImageUsageFlagBits usage
Defines extra usage of output frames.
Definition: hwcontext_vulkan.h:195
FFVulkanContext
Definition: vulkan.h:229
FFVulkanPipeline
Definition: vulkan.h:132
AV_NUM_DATA_POINTERS
#define AV_NUM_DATA_POINTERS
Definition: frame.h:341
height
#define height
FFVkExecContext
Definition: vulkan.h:153
ff_vk_update_push_exec
void ff_vk_update_push_exec(FFVulkanContext *s, FFVkExecContext *e, FFVulkanPipeline *pl, VkShaderStageFlagBits stage, int offset, size_t size, void *src)
Definition: vulkan.c:1764
ff_vk_filter_process_simple
int ff_vk_filter_process_simple(FFVulkanContext *vkctx, FFVkExecPool *e, FFVulkanPipeline *pl, AVFrame *out_f, AVFrame *in_f, VkSampler sampler, void *push_src, size_t push_size)
Submit a compute shader with a zero/one input and single out for execution.
Definition: vulkan_filter.c:228
av_vkfmt_from_pixfmt
const VkFormat * av_vkfmt_from_pixfmt(enum AVPixelFormat p)
Returns the optimal per-plane Vulkan format for a given sw_format, one for each plane.
Definition: hwcontext_stub.c:30
ff_vk_exec_start
int ff_vk_exec_start(FFVulkanContext *s, FFVkExecContext *e)
Start/submit/wait an execution.
Definition: vulkan.c:513
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
VkFormat
enum VkFormat VkFormat
Definition: hwcontext_stub.c:25
ff_vk_frame_barrier
void ff_vk_frame_barrier(FFVulkanContext *s, FFVkExecContext *e, AVFrame *pic, VkImageMemoryBarrier2 *bar, int *nb_bar, VkPipelineStageFlags src_stage, VkPipelineStageFlags dst_stage, VkAccessFlagBits new_access, VkImageLayout new_layout, uint32_t new_qf)
Definition: vulkan.c:1304
AVHWFramesContext
This struct describes a set or pool of "hardware" frames (i.e.
Definition: hwcontext.h:124
FFVulkanContext::vkfn
FFVulkanFunctions vkfn
Definition: vulkan.h:232
AVHWFramesContext::hwctx
void * hwctx
The format-specific data, allocated and freed automatically along with this context.
Definition: hwcontext.h:162
FFVkExecPool
Definition: vulkan.h:211
FFVkExecContext::buf
VkCommandBuffer buf
Definition: vulkan.h:165
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AVVulkanFramesContext::tiling
VkImageTiling tiling
Controls the tiling of allocated frames.
Definition: hwcontext_vulkan.h:185
AVFilterContext
An instance of a filter.
Definition: avfilter.h:397
AVVulkanDeviceContext::enabled_dev_extensions
const char *const * enabled_dev_extensions
Enabled device extensions.
Definition: hwcontext_vulkan.h:98
ff_vk_filter_config_input
int ff_vk_filter_config_input(AVFilterLink *inlink)
Definition: vulkan_filter.c:165
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
ff_vk_exec_discard_deps
void ff_vk_exec_discard_deps(FFVulkanContext *s, FFVkExecContext *e)
Definition: vulkan.c:549
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
ff_vk_exec_submit
int ff_vk_exec_submit(FFVulkanContext *s, FFVkExecContext *e)
Definition: vulkan.c:724
ff_vk_extensions_to_mask
static uint64_t ff_vk_extensions_to_mask(const char *const *extensions, int nb_extensions)
Definition: vulkan_loader.h:34
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
ff_vk_create_imageviews
int ff_vk_create_imageviews(FFVulkanContext *s, FFVkExecContext *e, VkImageView views[AV_NUM_DATA_POINTERS], AVFrame *f)
Create an imageview and add it as a dependency to an execution.
Definition: vulkan.c:1231
AVFilterContext::filter
const AVFilter * filter
the AVFilter of which this is an instance
Definition: avfilter.h:400
RET
#define RET(x)
Definition: vulkan.h:68
FFVulkanFunctions
Definition: vulkan_functions.h:226
skip
static void BS_FUNC() skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
Definition: bitstream_template.h:375