FFmpeg
vf_gblur_vulkan.c
Go to the documentation of this file.
1 /*
2  * copyright (c) 2021-2022 Wu Jianhua <jianhua.wu@intel.com>
3  * Copyright (c) Lynne
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include "libavutil/random_seed.h"
23 #include "libavutil/opt.h"
24 #include "vulkan_filter.h"
25 #include "vulkan_spirv.h"
26 #include "internal.h"
27 #include "video.h"
28 
29 #define CGS 32
30 #define GBLUR_MAX_KERNEL_SIZE 127
31 
32 typedef struct GBlurVulkanContext {
34 
38  VkSampler sampler;
45 
46  int size;
47  int sizeV;
48  int planes;
49  float sigma;
50  float sigmaV;
52 
53 static const char gblur_func[] = {
54  C(0, void gblur(const ivec2 pos, const int index) )
55  C(0, { )
56  C(1, vec4 sum = texture(input_images[index], pos) * kernel[0]; )
57  C(0, )
58  C(1, for(int i = 1; i < kernel.length(); i++) { )
59  C(2, sum += texture(input_images[index], pos + OFFSET) * kernel[i]; )
60  C(2, sum += texture(input_images[index], pos - OFFSET) * kernel[i]; )
61  C(1, } )
62  C(0, )
63  C(1, imageStore(output_images[index], pos, sum); )
64  C(0, } )
65 };
66 
67 static inline float gaussian(float sigma, float x)
68 {
69  return 1.0 / (sqrt(2.0 * M_PI) * sigma) *
70  exp(-(x * x) / (2.0 * sigma * sigma));
71 }
72 
73 static inline float gaussian_simpson_integration(float sigma, float a, float b)
74 {
75  return (b - a) * (1.0 / 6.0) * ((gaussian(sigma, a) +
76  4.0 * gaussian(sigma, (a + b) * 0.5) + gaussian(sigma, b)));
77 }
78 
79 static void init_gaussian_kernel(float *kernel, float sigma, float kernel_size)
80 {
81  int x;
82  float sum;
83 
84  sum = 0;
85  for (x = 0; x < kernel_size; x++) {
86  kernel[x] = gaussian_simpson_integration(sigma, x - 0.5f, x + 0.5f);
87  if (!x)
88  sum += kernel[x];
89  else
90  sum += kernel[x] * 2.0;
91  }
92  /* Normalized */
93  sum = 1.0 / sum;
94  for (x = 0; x < kernel_size; x++) {
95  kernel[x] *= sum;
96  }
97 }
98 
99 static inline void init_kernel_size(GBlurVulkanContext *s, int *out_size)
100 {
101  int size = *out_size;
102 
103  if (!(size & 1)) {
104  av_log(s, AV_LOG_WARNING, "The kernel size should be odd\n");
105  size++;
106  }
107 
108  *out_size = (size >> 1) + 1;
109 }
110 
112 {
113  if (s->sigmaV <= 0)
114  s->sigmaV = s->sigma;
115 
116  init_kernel_size(s, &s->size);
117 
118  if (s->sizeV <= 0)
119  s->sizeV = s->size;
120  else
121  init_kernel_size(s, &s->sizeV);
122 }
123 
125  FFVkSPIRVShader *shd, FFVkBuffer *params_buf,
126  int ksize, float sigma, FFVkSPIRVCompiler *spv)
127 {
128  int err = 0;
129  uint8_t *kernel_mapped;
130  uint8_t *spv_data;
131  size_t spv_len;
132  void *spv_opaque = NULL;
133 
134  const int planes = av_pix_fmt_count_planes(s->vkctx.output_format);
135 
136  FFVulkanDescriptorSetBinding buf_desc = {
137  .name = "data",
138  .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
139  .mem_quali = "readonly",
140  .mem_layout = "std430",
141  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
142  .buf_content = NULL,
143  };
144 
145  char *kernel_def = av_asprintf("float kernel[%i];", ksize);
146  if (!kernel_def)
147  return AVERROR(ENOMEM);
148 
149  buf_desc.buf_content = kernel_def;
150 
151  RET(ff_vk_pipeline_descriptor_set_add(&s->vkctx, pl, shd, &buf_desc, 1, 1, 0));
152 
153  GLSLD( gblur_func );
154  GLSLC(0, void main() );
155  GLSLC(0, { );
156  GLSLC(1, ivec2 size; );
157  GLSLC(1, const ivec2 pos = ivec2(gl_GlobalInvocationID.xy); );
158  for (int i = 0; i < planes; i++) {
159  GLSLC(0, );
160  GLSLF(1, size = imageSize(output_images[%i]); ,i);
161  GLSLC(1, if (!IS_WITHIN(pos, size)) );
162  GLSLC(2, return; );
163  if (s->planes & (1 << i)) {
164  GLSLF(1, gblur(pos, %i); ,i);
165  } else {
166  GLSLF(1, vec4 res = texture(input_images[%i], pos); ,i);
167  GLSLF(1, imageStore(output_images[%i], pos, res); ,i);
168  }
169  }
170  GLSLC(0, } );
171 
172  RET(spv->compile_shader(spv, s, shd, &spv_data, &spv_len, "main",
173  &spv_opaque));
174  RET(ff_vk_shader_create(&s->vkctx, shd, spv_data, spv_len, "main"));
175 
176  RET(ff_vk_init_compute_pipeline(&s->vkctx, pl, shd));
177  RET(ff_vk_exec_pipeline_register(&s->vkctx, &s->e, pl));
178 
179  RET(ff_vk_create_buf(&s->vkctx, params_buf, sizeof(float) * ksize, NULL, NULL,
180  VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT |
181  VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
182  VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT));
183  RET(ff_vk_map_buffer(&s->vkctx, params_buf, &kernel_mapped, 0));
184 
185  init_gaussian_kernel((float *)kernel_mapped, sigma, ksize);
186 
187  RET(ff_vk_unmap_buffer(&s->vkctx, params_buf, 1));
188 
189  RET(ff_vk_set_descriptor_buffer(&s->vkctx, pl, NULL, 1, 0, 0,
190  params_buf->address, params_buf->size,
191  VK_FORMAT_UNDEFINED));
192 
193 fail:
194  av_free(kernel_def);
195  if (spv_opaque)
196  spv->free_shader(spv, &spv_opaque);
197  return err;
198 }
199 
201 {
202  int err = 0;
203  GBlurVulkanContext *s = ctx->priv;
204  FFVulkanContext *vkctx = &s->vkctx;
205  const int planes = av_pix_fmt_count_planes(s->vkctx.output_format);
206 
207  FFVkSPIRVShader *shd;
208  FFVkSPIRVCompiler *spv;
210 
211  spv = ff_vk_spirv_init();
212  if (!spv) {
213  av_log(ctx, AV_LOG_ERROR, "Unable to initialize SPIR-V compiler!\n");
214  return AVERROR_EXTERNAL;
215  }
216 
217  ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT);
218  RET(ff_vk_exec_pool_init(vkctx, &s->qf, &s->e, s->qf.nb_queues*4, 0, 0, 0, NULL));
219  RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_LINEAR));
220  RET(ff_vk_shader_init(&s->pl_hor, &s->shd_hor, "gblur_hor_compute",
221  VK_SHADER_STAGE_COMPUTE_BIT, 0));
222  RET(ff_vk_shader_init(&s->pl_ver, &s->shd_ver, "gblur_ver_compute",
223  VK_SHADER_STAGE_COMPUTE_BIT, 0));
224 
226  {
227  .name = "input_images",
228  .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
229  .dimensions = 2,
230  .elems = planes,
231  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
232  .samplers = DUP_SAMPLER(s->sampler),
233  },
234  {
235  .name = "output_images",
236  .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
237  .mem_layout = ff_vk_shader_rep_fmt(s->vkctx.output_format),
238  .mem_quali = "writeonly",
239  .dimensions = 2,
240  .elems = planes,
241  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
242  },
243  };
244 
246 
247  {
248  shd = &s->shd_hor;
249  ff_vk_shader_set_compute_sizes(shd, 32, 1, 1);
250 
251  RET(ff_vk_pipeline_descriptor_set_add(vkctx, &s->pl_hor, shd, desc, 2, 0, 0));
252 
253  GLSLC(0, #define OFFSET (vec2(i, 0.0)));
254  RET(init_gblur_pipeline(s, &s->pl_hor, shd, &s->params_hor, s->size, s->sigma, spv));
255  }
256 
257  {
258  shd = &s->shd_ver;
259  ff_vk_shader_set_compute_sizes(shd, 1, 32, 1);
260 
261  RET(ff_vk_pipeline_descriptor_set_add(vkctx, &s->pl_ver, shd, desc, 2, 0, 0));
262 
263  GLSLC(0, #define OFFSET (vec2(0.0, i)));
264  RET(init_gblur_pipeline(s, &s->pl_ver, shd, &s->params_ver, s->sizeV, s->sigmaV, spv));
265  }
266 
267  s->initialized = 1;
268 
269 fail:
270  if (spv)
271  spv->uninit(&spv);
272 
273  return err;
274 }
275 
277 {
278  GBlurVulkanContext *s = avctx->priv;
279  FFVulkanContext *vkctx = &s->vkctx;
280  FFVulkanFunctions *vk = &vkctx->vkfn;
281 
282  ff_vk_exec_pool_free(vkctx, &s->e);
283  ff_vk_pipeline_free(vkctx, &s->pl_hor);
284  ff_vk_pipeline_free(vkctx, &s->pl_ver);
285  ff_vk_shader_free(vkctx, &s->shd_hor);
286  ff_vk_shader_free(vkctx, &s->shd_ver);
287  ff_vk_free_buf(vkctx, &s->params_hor);
288  ff_vk_free_buf(vkctx, &s->params_ver);
289 
290  if (s->sampler)
291  vk->DestroySampler(vkctx->hwctx->act_dev, s->sampler,
292  vkctx->hwctx->alloc);
293 
294  ff_vk_uninit(&s->vkctx);
295 
296  s->initialized = 0;
297 }
298 
300 {
301  int err;
302  AVFrame *tmp = NULL, *out = NULL;
303  AVFilterContext *ctx = link->dst;
304  GBlurVulkanContext *s = ctx->priv;
305  AVFilterLink *outlink = ctx->outputs[0];
306 
307  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
308  if (!out) {
309  err = AVERROR(ENOMEM);
310  goto fail;
311  }
312 
313  tmp = ff_get_video_buffer(outlink, outlink->w, outlink->h);
314  if (!tmp) {
315  err = AVERROR(ENOMEM);
316  goto fail;
317  }
318 
319  if (!s->initialized)
320  RET(init_filter(ctx, in));
321 
322  RET(ff_vk_filter_process_2pass(&s->vkctx, &s->e,
323  (FFVulkanPipeline *[2]){ &s->pl_hor, &s->pl_ver },
324  out, tmp, in, s->sampler, NULL, 0));
325 
326  err = av_frame_copy_props(out, in);
327  if (err < 0)
328  goto fail;
329 
330  av_frame_free(&in);
331  av_frame_free(&tmp);
332 
333  return ff_filter_frame(outlink, out);
334 
335 fail:
336  av_frame_free(&in);
337  av_frame_free(&tmp);
338  av_frame_free(&out);
339  return err;
340 }
341 
342 #define OFFSET(x) offsetof(GBlurVulkanContext, x)
343 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
344 static const AVOption gblur_vulkan_options[] = {
345  { "sigma", "Set sigma", OFFSET(sigma), AV_OPT_TYPE_FLOAT, { .dbl = 0.5 }, 0.01, 1024.0, FLAGS },
346  { "sigmaV", "Set vertical sigma", OFFSET(sigmaV), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, 0.0, 1024.0, FLAGS },
347  { "planes", "Set planes to filter", OFFSET(planes), AV_OPT_TYPE_INT, { .i64 = 0xF }, 0, 0xF, FLAGS },
348  { "size", "Set kernel size", OFFSET(size), AV_OPT_TYPE_INT, { .i64 = 19 }, 1, GBLUR_MAX_KERNEL_SIZE, FLAGS },
349  { "sizeV", "Set vertical kernel size", OFFSET(sizeV), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, GBLUR_MAX_KERNEL_SIZE, FLAGS },
350  { NULL },
351 };
352 
353 AVFILTER_DEFINE_CLASS(gblur_vulkan);
354 
356  {
357  .name = "default",
358  .type = AVMEDIA_TYPE_VIDEO,
359  .filter_frame = &gblur_vulkan_filter_frame,
360  .config_props = &ff_vk_filter_config_input,
361  }
362 };
363 
365  {
366  .name = "default",
367  .type = AVMEDIA_TYPE_VIDEO,
368  .config_props = &ff_vk_filter_config_output,
369  }
370 };
371 
373  .name = "gblur_vulkan",
374  .description = NULL_IF_CONFIG_SMALL("Gaussian Blur in Vulkan"),
375  .priv_size = sizeof(GBlurVulkanContext),
381  .priv_class = &gblur_vulkan_class,
382  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
383  .flags = AVFILTER_FLAG_HWDEVICE,
384 };
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:108
ff_vk_create_buf
int ff_vk_create_buf(FFVulkanContext *s, FFVkBuffer *buf, size_t size, void *pNext, void *alloc_pNext, VkBufferUsageFlags usage, VkMemoryPropertyFlagBits flags)
Definition: vulkan.c:848
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(gblur_vulkan)
GBlurVulkanContext::sigma
float sigma
Definition: vf_gblur_vulkan.c:49
ff_vk_pipeline_free
void ff_vk_pipeline_free(FFVulkanContext *s, FFVulkanPipeline *pl)
Definition: vulkan.c:1868
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
out
FILE * out
Definition: movenc.c:54
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:364
GBlurVulkanContext::pl_ver
FFVulkanPipeline pl_ver
Definition: vf_gblur_vulkan.c:42
gaussian_simpson_integration
static float gaussian_simpson_integration(float sigma, float a, float b)
Definition: vf_gblur_vulkan.c:73
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:978
FLAGS
#define FLAGS
Definition: vf_gblur_vulkan.c:343
OFFSET
#define OFFSET(x)
Definition: vf_gblur_vulkan.c:342
ff_vk_qf_init
int ff_vk_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf, VkQueueFlagBits dev_family)
Chooses a QF and loads it into a context.
Definition: vulkan.c:225
av_asprintf
char * av_asprintf(const char *fmt,...)
Definition: avstring.c:115
out_size
int out_size
Definition: movenc.c:55
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:100
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
GBlurVulkanContext::planes
int planes
Definition: vf_gblur_vulkan.c:48
ff_vk_filter_init
int ff_vk_filter_init(AVFilterContext *avctx)
General lavfi IO functions.
Definition: vulkan_filter.c:219
ff_vk_shader_create
int ff_vk_shader_create(FFVulkanContext *s, FFVkSPIRVShader *shd, uint8_t *spirv, size_t spirv_size, const char *entrypoint)
Definition: vulkan.c:1413
AVOption
AVOption.
Definition: opt.h:251
b
#define b
Definition: input.c:41
FFVkBuffer::address
VkDeviceAddress address
Definition: vulkan.h:101
GBlurVulkanContext::size
int size
Definition: vf_gblur_vulkan.c:46
ff_vk_uninit
void ff_vk_uninit(FFVulkanContext *s)
Frees main context.
Definition: vulkan.c:1897
FFVkSPIRVCompiler::uninit
void(* uninit)(struct FFVkSPIRVCompiler **ctx)
Definition: vulkan_spirv.h:33
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:170
ff_vk_pipeline_descriptor_set_add
int ff_vk_pipeline_descriptor_set_add(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkSPIRVShader *shd, FFVulkanDescriptorSetBinding *desc, int nb, int read_only, int print_to_shader_only)
Add descriptor to a pipeline.
Definition: vulkan.c:1463
ff_vk_shader_set_compute_sizes
void ff_vk_shader_set_compute_sizes(FFVkSPIRVShader *shd, int x, int y, int z)
Definition: vulkan.c:1371
FFVulkanDescriptorSetBinding::buf_content
const char * buf_content
Definition: vulkan.h:89
video.h
AV_PIX_FMT_VULKAN
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition: pixfmt.h:376
gblur_vulkan_inputs
static const AVFilterPad gblur_vulkan_inputs[]
Definition: vf_gblur_vulkan.c:355
init_gaussian_kernel
static void init_gaussian_kernel(float *kernel, float sigma, float kernel_size)
Definition: vf_gblur_vulkan.c:79
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3004
AVVulkanDeviceContext::alloc
const VkAllocationCallbacks * alloc
Custom memory allocator, else NULL.
Definition: hwcontext_vulkan.h:48
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:412
fail
#define fail()
Definition: checkasm.h:138
vulkan_filter.h
GBlurVulkanContext::e
FFVkExecPool e
Definition: vf_gblur_vulkan.c:36
GBlurVulkanContext::shd_ver
FFVkSPIRVShader shd_ver
Definition: vf_gblur_vulkan.c:43
gblur_vulkan_outputs
static const AVFilterPad gblur_vulkan_outputs[]
Definition: vf_gblur_vulkan.c:364
GBlurVulkanContext::qf
FFVkQueueFamilyCtx qf
Definition: vf_gblur_vulkan.c:37
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
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:47
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
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
av_cold
#define av_cold
Definition: attributes.h:90
s
#define s(width, name)
Definition: cbs_vp9.c:198
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts_bsf.c:365
ctx
AVFormatContext * ctx
Definition: movenc.c:48
gblur_vulkan_options
static const AVOption gblur_vulkan_options[]
Definition: vf_gblur_vulkan.c:344
ff_vk_unmap_buffer
static int ff_vk_unmap_buffer(FFVulkanContext *s, FFVkBuffer *buf, int flush)
Definition: vulkan.h:418
FFVkSPIRVCompiler::compile_shader
int(* compile_shader)(struct FFVkSPIRVCompiler *ctx, void *avctx, struct FFVkSPIRVShader *shd, uint8_t **data, size_t *size, const char *entrypoint, void **opaque)
Definition: vulkan_spirv.h:29
ff_vk_exec_pool_free
void ff_vk_exec_pool_free(FFVulkanContext *s, FFVkExecPool *pool)
Definition: vulkan.c:256
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:192
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
init_filter
static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
Definition: vf_gblur_vulkan.c:200
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:736
GLSLD
#define GLSLD(D)
Definition: vulkan.h:60
ff_vk_filter_config_output
int ff_vk_filter_config_output(AVFilterLink *outlink)
Definition: vulkan_filter.c:196
FFVkBuffer::size
size_t size
Definition: vulkan.h:100
ff_vk_init_compute_pipeline
int ff_vk_init_compute_pipeline(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkSPIRVShader *shd)
Definition: vulkan.c:1809
ff_vk_exec_pool_init
int ff_vk_exec_pool_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf, FFVkExecPool *pool, int nb_contexts, int nb_queries, VkQueryType query_type, int query_64bit, const void *query_create_pnext)
Allocates/frees an execution pool.
Definition: vulkan.c:296
GBlurVulkanContext::sampler
VkSampler sampler
Definition: vf_gblur_vulkan.c:38
FFVulkanContext
Definition: vulkan.h:229
GBLUR_MAX_KERNEL_SIZE
#define GBLUR_MAX_KERNEL_SIZE
Definition: vf_gblur_vulkan.c:30
exp
int8_t exp
Definition: eval.c:72
FFVulkanPipeline
Definition: vulkan.h:132
index
int index
Definition: gxfenc.c:89
ff_vk_shader_init
int ff_vk_shader_init(FFVulkanPipeline *pl, FFVkSPIRVShader *shd, const char *name, VkShaderStageFlags stage, uint32_t required_subgroup_size)
Shader management.
Definition: vulkan.c:1345
main
int main(int argc, char **argv)
Definition: avio_http_serve_files.c:99
f
f
Definition: af_crystalizer.c:121
FFVulkanDescriptorSetBinding
Definition: vulkan.h:84
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:106
AVFILTER_FLAG_HWDEVICE
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
Definition: avfilter.h:138
GBlurVulkanContext::initialized
int initialized
Definition: vf_gblur_vulkan.c:35
size
int size
Definition: twinvq_data.h:10344
FFVkQueueFamilyCtx
Definition: vulkan.h:111
GBlurVulkanContext::shd_hor
FFVkSPIRVShader shd_hor
Definition: vf_gblur_vulkan.c:40
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
GBlurVulkanContext
Definition: vf_gblur_vulkan.c:32
gblur_vulkan_uninit
static av_cold void gblur_vulkan_uninit(AVFilterContext *avctx)
Definition: vf_gblur_vulkan.c:276
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
FFVulkanDescriptorSetBinding::name
const char * name
Definition: vulkan.h:85
GBlurVulkanContext::params_ver
FFVkBuffer params_ver
Definition: vf_gblur_vulkan.c:44
M_PI
#define M_PI
Definition: mathematics.h:67
internal.h
FFVkSPIRVCompiler
Definition: vulkan_spirv.h:27
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:228
FILTER_SINGLE_PIXFMT
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition: internal.h:182
init_kernel_size
static void init_kernel_size(GBlurVulkanContext *s, int *out_size)
Definition: vf_gblur_vulkan.c:99
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
DUP_SAMPLER
#define DUP_SAMPLER(x)
Definition: vulkan.h:74
planes
static const struct @363 planes[]
ff_vk_shader_rep_fmt
const char * ff_vk_shader_rep_fmt(enum AVPixelFormat pixfmt)
Returns the format to use for images in shaders.
Definition: vulkan.c:1207
vulkan_spirv.h
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:53
GLSLF
#define GLSLF(N, S,...)
Definition: vulkan.h:55
ff_vk_free_buf
void ff_vk_free_buf(FFVulkanContext *s, FFVkBuffer *buf)
Definition: vulkan.c:1055
FFVkSPIRVCompiler::free_shader
void(* free_shader)(struct FFVkSPIRVCompiler *ctx, void **opaque)
Definition: vulkan_spirv.h:32
AVFilter
Filter definition.
Definition: avfilter.h:166
init_gaussian_params
static av_cold void init_gaussian_params(GBlurVulkanContext *s)
Definition: vf_gblur_vulkan.c:111
ff_vk_map_buffer
static int ff_vk_map_buffer(FFVulkanContext *s, FFVkBuffer *buf, uint8_t **mem, int invalidate)
Definition: vulkan.h:411
FFVulkanContext::vkfn
FFVulkanFunctions vkfn
Definition: vulkan.h:232
FFVkExecPool
Definition: vulkan.h:211
pos
unsigned int pos
Definition: spdifenc.c:413
gblur_vulkan_filter_frame
static int gblur_vulkan_filter_frame(AVFilterLink *link, AVFrame *in)
Definition: vf_gblur_vulkan.c:299
gblur_func
static const char gblur_func[]
Definition: vf_gblur_vulkan.c:53
random_seed.h
FFVkSPIRVShader
Definition: vulkan.h:76
ff_vf_gblur_vulkan
const AVFilter ff_vf_gblur_vulkan
Definition: vf_gblur_vulkan.c:372
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
GBlurVulkanContext::pl_hor
FFVulkanPipeline pl_hor
Definition: vf_gblur_vulkan.c:39
AVFilterContext
An instance of a filter.
Definition: avfilter.h:397
desc
const char * desc
Definition: libsvtav1.c:83
GLSLC
#define GLSLC(N, S)
Definition: vulkan.h:45
ff_vk_filter_config_input
int ff_vk_filter_config_input(AVFilterLink *inlink)
Definition: vulkan_filter.c:165
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
FFVulkanContext::hwctx
AVVulkanDeviceContext * hwctx
Definition: vulkan.h:254
ff_vk_set_descriptor_buffer
int ff_vk_set_descriptor_buffer(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkExecContext *e, int set, int bind, int offs, VkDeviceAddress addr, VkDeviceSize len, VkFormat fmt)
Definition: vulkan.c:1706
GBlurVulkanContext::sigmaV
float sigmaV
Definition: vf_gblur_vulkan.c:50
GBlurVulkanContext::params_hor
FFVkBuffer params_hor
Definition: vf_gblur_vulkan.c:41
AVVulkanDeviceContext::act_dev
VkDevice act_dev
Active device.
Definition: hwcontext_vulkan.h:70
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:193
ff_vk_init_sampler
int ff_vk_init_sampler(FFVulkanContext *s, VkSampler *sampler, int unnorm_coords, VkFilter filt)
Create a sampler.
Definition: vulkan.c:1163
init_gblur_pipeline
static int init_gblur_pipeline(GBlurVulkanContext *s, FFVulkanPipeline *pl, FFVkSPIRVShader *shd, FFVkBuffer *params_buf, int ksize, float sigma, FFVkSPIRVCompiler *spv)
Definition: vf_gblur_vulkan.c:124
FFVkBuffer
Definition: vulkan.h:96
ff_vk_exec_pipeline_register
int ff_vk_exec_pipeline_register(FFVulkanContext *s, FFVkExecPool *pool, FFVulkanPipeline *pl)
Register a pipeline with an exec pool.
Definition: vulkan.c:1577
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
uninit
static av_cold int uninit(AVCodecContext *avctx)
Definition: crystalhd.c:285
GBlurVulkanContext::sizeV
int sizeV
Definition: vf_gblur_vulkan.c:47
ff_vk_shader_free
void ff_vk_shader_free(FFVulkanContext *s, FFVkSPIRVShader *shd)
Definition: vulkan.c:1404
RET
#define RET(x)
Definition: vulkan.h:68
FFVulkanFunctions
Definition: vulkan_functions.h:226
GBlurVulkanContext::vkctx
FFVulkanContext vkctx
Definition: vf_gblur_vulkan.c:33
gaussian
static float gaussian(float sigma, float x)
Definition: vf_gblur_vulkan.c:67