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/mem.h"
23 #include "libavutil/random_seed.h"
24 #include "libavutil/opt.h"
25 #include "vulkan_filter.h"
26 #include "vulkan_spirv.h"
27 #include "internal.h"
28 #include "video.h"
29 
30 #define CGS 32
31 #define GBLUR_MAX_KERNEL_SIZE 127
32 
33 typedef struct GBlurVulkanContext {
35 
39  VkSampler sampler;
46 
47  int size;
48  int sizeV;
49  int planes;
50  float sigma;
51  float sigmaV;
53 
54 static const char gblur_func[] = {
55  C(0, void gblur(const ivec2 pos, const int index) )
56  C(0, { )
57  C(1, vec4 sum = texture(input_images[index], pos) * kernel[0]; )
58  C(0, )
59  C(1, for(int i = 1; i < kernel.length(); i++) { )
60  C(2, sum += texture(input_images[index], pos + OFFSET) * kernel[i]; )
61  C(2, sum += texture(input_images[index], pos - OFFSET) * kernel[i]; )
62  C(1, } )
63  C(0, )
64  C(1, imageStore(output_images[index], pos, sum); )
65  C(0, } )
66 };
67 
68 static inline float gaussian(float sigma, float x)
69 {
70  return 1.0 / (sqrt(2.0 * M_PI) * sigma) *
71  exp(-(x * x) / (2.0 * sigma * sigma));
72 }
73 
74 static inline float gaussian_simpson_integration(float sigma, float a, float b)
75 {
76  return (b - a) * (1.0 / 6.0) * ((gaussian(sigma, a) +
77  4.0 * gaussian(sigma, (a + b) * 0.5) + gaussian(sigma, b)));
78 }
79 
80 static void init_gaussian_kernel(float *kernel, float sigma, float kernel_size)
81 {
82  int x;
83  float sum;
84 
85  sum = 0;
86  for (x = 0; x < kernel_size; x++) {
87  kernel[x] = gaussian_simpson_integration(sigma, x - 0.5f, x + 0.5f);
88  if (!x)
89  sum += kernel[x];
90  else
91  sum += kernel[x] * 2.0;
92  }
93  /* Normalized */
94  sum = 1.0 / sum;
95  for (x = 0; x < kernel_size; x++) {
96  kernel[x] *= sum;
97  }
98 }
99 
100 static inline void init_kernel_size(GBlurVulkanContext *s, int *out_size)
101 {
102  int size = *out_size;
103 
104  if (!(size & 1)) {
105  av_log(s, AV_LOG_WARNING, "The kernel size should be odd\n");
106  size++;
107  }
108 
109  *out_size = (size >> 1) + 1;
110 }
111 
113 {
114  if (s->sigmaV <= 0)
115  s->sigmaV = s->sigma;
116 
117  init_kernel_size(s, &s->size);
118 
119  if (s->sizeV <= 0)
120  s->sizeV = s->size;
121  else
122  init_kernel_size(s, &s->sizeV);
123 }
124 
126  FFVkSPIRVShader *shd, FFVkBuffer *params_buf,
127  int ksize, float sigma, FFVkSPIRVCompiler *spv)
128 {
129  int err = 0;
130  uint8_t *kernel_mapped;
131  uint8_t *spv_data;
132  size_t spv_len;
133  void *spv_opaque = NULL;
134 
135  const int planes = av_pix_fmt_count_planes(s->vkctx.output_format);
136 
137  FFVulkanDescriptorSetBinding buf_desc = {
138  .name = "data",
139  .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
140  .mem_quali = "readonly",
141  .mem_layout = "std430",
142  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
143  .buf_content = NULL,
144  };
145 
146  char *kernel_def = av_asprintf("float kernel[%i];", ksize);
147  if (!kernel_def)
148  return AVERROR(ENOMEM);
149 
150  buf_desc.buf_content = kernel_def;
151 
152  RET(ff_vk_pipeline_descriptor_set_add(&s->vkctx, pl, shd, &buf_desc, 1, 1, 0));
153 
154  GLSLD( gblur_func );
155  GLSLC(0, void main() );
156  GLSLC(0, { );
157  GLSLC(1, ivec2 size; );
158  GLSLC(1, const ivec2 pos = ivec2(gl_GlobalInvocationID.xy); );
159  for (int i = 0; i < planes; i++) {
160  GLSLC(0, );
161  GLSLF(1, size = imageSize(output_images[%i]); ,i);
162  GLSLC(1, if (!IS_WITHIN(pos, size)) );
163  GLSLC(2, return; );
164  if (s->planes & (1 << i)) {
165  GLSLF(1, gblur(pos, %i); ,i);
166  } else {
167  GLSLF(1, vec4 res = texture(input_images[%i], pos); ,i);
168  GLSLF(1, imageStore(output_images[%i], pos, res); ,i);
169  }
170  }
171  GLSLC(0, } );
172 
173  RET(spv->compile_shader(spv, s, shd, &spv_data, &spv_len, "main",
174  &spv_opaque));
175  RET(ff_vk_shader_create(&s->vkctx, shd, spv_data, spv_len, "main"));
176 
177  RET(ff_vk_init_compute_pipeline(&s->vkctx, pl, shd));
178  RET(ff_vk_exec_pipeline_register(&s->vkctx, &s->e, pl));
179 
180  RET(ff_vk_create_buf(&s->vkctx, params_buf, sizeof(float) * ksize, NULL, NULL,
181  VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT |
182  VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
183  VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT));
184  RET(ff_vk_map_buffer(&s->vkctx, params_buf, &kernel_mapped, 0));
185 
186  init_gaussian_kernel((float *)kernel_mapped, sigma, ksize);
187 
188  RET(ff_vk_unmap_buffer(&s->vkctx, params_buf, 1));
189 
190  RET(ff_vk_set_descriptor_buffer(&s->vkctx, pl, NULL, 1, 0, 0,
191  params_buf->address, params_buf->size,
192  VK_FORMAT_UNDEFINED));
193 
194 fail:
195  av_free(kernel_def);
196  if (spv_opaque)
197  spv->free_shader(spv, &spv_opaque);
198  return err;
199 }
200 
202 {
203  int err = 0;
204  GBlurVulkanContext *s = ctx->priv;
205  FFVulkanContext *vkctx = &s->vkctx;
206  const int planes = av_pix_fmt_count_planes(s->vkctx.output_format);
207 
208  FFVkSPIRVShader *shd;
209  FFVkSPIRVCompiler *spv;
211 
212  spv = ff_vk_spirv_init();
213  if (!spv) {
214  av_log(ctx, AV_LOG_ERROR, "Unable to initialize SPIR-V compiler!\n");
215  return AVERROR_EXTERNAL;
216  }
217 
218  ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT);
219  RET(ff_vk_exec_pool_init(vkctx, &s->qf, &s->e, s->qf.nb_queues*4, 0, 0, 0, NULL));
220  RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_LINEAR));
221  RET(ff_vk_shader_init(&s->pl_hor, &s->shd_hor, "gblur_hor_compute",
222  VK_SHADER_STAGE_COMPUTE_BIT, 0));
223  RET(ff_vk_shader_init(&s->pl_ver, &s->shd_ver, "gblur_ver_compute",
224  VK_SHADER_STAGE_COMPUTE_BIT, 0));
225 
227  {
228  .name = "input_images",
229  .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
230  .dimensions = 2,
231  .elems = planes,
232  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
233  .samplers = DUP_SAMPLER(s->sampler),
234  },
235  {
236  .name = "output_images",
237  .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
238  .mem_layout = ff_vk_shader_rep_fmt(s->vkctx.output_format),
239  .mem_quali = "writeonly",
240  .dimensions = 2,
241  .elems = planes,
242  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
243  },
244  };
245 
247 
248  {
249  shd = &s->shd_hor;
250  ff_vk_shader_set_compute_sizes(shd, 32, 1, 1);
251 
252  RET(ff_vk_pipeline_descriptor_set_add(vkctx, &s->pl_hor, shd, desc, 2, 0, 0));
253 
254  GLSLC(0, #define OFFSET (vec2(i, 0.0)));
255  RET(init_gblur_pipeline(s, &s->pl_hor, shd, &s->params_hor, s->size, s->sigma, spv));
256  }
257 
258  {
259  shd = &s->shd_ver;
260  ff_vk_shader_set_compute_sizes(shd, 1, 32, 1);
261 
262  RET(ff_vk_pipeline_descriptor_set_add(vkctx, &s->pl_ver, shd, desc, 2, 0, 0));
263 
264  GLSLC(0, #define OFFSET (vec2(0.0, i)));
265  RET(init_gblur_pipeline(s, &s->pl_ver, shd, &s->params_ver, s->sizeV, s->sigmaV, spv));
266  }
267 
268  s->initialized = 1;
269 
270 fail:
271  if (spv)
272  spv->uninit(&spv);
273 
274  return err;
275 }
276 
278 {
279  GBlurVulkanContext *s = avctx->priv;
280  FFVulkanContext *vkctx = &s->vkctx;
281  FFVulkanFunctions *vk = &vkctx->vkfn;
282 
283  ff_vk_exec_pool_free(vkctx, &s->e);
284  ff_vk_pipeline_free(vkctx, &s->pl_hor);
285  ff_vk_pipeline_free(vkctx, &s->pl_ver);
286  ff_vk_shader_free(vkctx, &s->shd_hor);
287  ff_vk_shader_free(vkctx, &s->shd_ver);
288  ff_vk_free_buf(vkctx, &s->params_hor);
289  ff_vk_free_buf(vkctx, &s->params_ver);
290 
291  if (s->sampler)
292  vk->DestroySampler(vkctx->hwctx->act_dev, s->sampler,
293  vkctx->hwctx->alloc);
294 
295  ff_vk_uninit(&s->vkctx);
296 
297  s->initialized = 0;
298 }
299 
301 {
302  int err;
303  AVFrame *tmp = NULL, *out = NULL;
304  AVFilterContext *ctx = link->dst;
305  GBlurVulkanContext *s = ctx->priv;
306  AVFilterLink *outlink = ctx->outputs[0];
307 
308  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
309  if (!out) {
310  err = AVERROR(ENOMEM);
311  goto fail;
312  }
313 
314  tmp = ff_get_video_buffer(outlink, outlink->w, outlink->h);
315  if (!tmp) {
316  err = AVERROR(ENOMEM);
317  goto fail;
318  }
319 
320  if (!s->initialized)
321  RET(init_filter(ctx, in));
322 
323  RET(ff_vk_filter_process_2pass(&s->vkctx, &s->e,
324  (FFVulkanPipeline *[2]){ &s->pl_hor, &s->pl_ver },
325  out, tmp, in, s->sampler, NULL, 0));
326 
327  err = av_frame_copy_props(out, in);
328  if (err < 0)
329  goto fail;
330 
331  av_frame_free(&in);
332  av_frame_free(&tmp);
333 
334  return ff_filter_frame(outlink, out);
335 
336 fail:
337  av_frame_free(&in);
338  av_frame_free(&tmp);
339  av_frame_free(&out);
340  return err;
341 }
342 
343 #define OFFSET(x) offsetof(GBlurVulkanContext, x)
344 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
345 static const AVOption gblur_vulkan_options[] = {
346  { "sigma", "Set sigma", OFFSET(sigma), AV_OPT_TYPE_FLOAT, { .dbl = 0.5 }, 0.01, 1024.0, FLAGS },
347  { "sigmaV", "Set vertical sigma", OFFSET(sigmaV), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, 0.0, 1024.0, FLAGS },
348  { "planes", "Set planes to filter", OFFSET(planes), AV_OPT_TYPE_INT, { .i64 = 0xF }, 0, 0xF, FLAGS },
349  { "size", "Set kernel size", OFFSET(size), AV_OPT_TYPE_INT, { .i64 = 19 }, 1, GBLUR_MAX_KERNEL_SIZE, FLAGS },
350  { "sizeV", "Set vertical kernel size", OFFSET(sizeV), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, GBLUR_MAX_KERNEL_SIZE, FLAGS },
351  { NULL },
352 };
353 
354 AVFILTER_DEFINE_CLASS(gblur_vulkan);
355 
357  {
358  .name = "default",
359  .type = AVMEDIA_TYPE_VIDEO,
360  .filter_frame = &gblur_vulkan_filter_frame,
361  .config_props = &ff_vk_filter_config_input,
362  }
363 };
364 
366  {
367  .name = "default",
368  .type = AVMEDIA_TYPE_VIDEO,
369  .config_props = &ff_vk_filter_config_output,
370  }
371 };
372 
374  .name = "gblur_vulkan",
375  .description = NULL_IF_CONFIG_SMALL("Gaussian Blur in Vulkan"),
376  .priv_size = sizeof(GBlurVulkanContext),
382  .priv_class = &gblur_vulkan_class,
383  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
384  .flags = AVFILTER_FLAG_HWDEVICE,
385 };
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:112
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:50
ff_vk_pipeline_free
void ff_vk_pipeline_free(FFVulkanContext *s, FFVulkanPipeline *pl)
Definition: vulkan.c:1844
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:55
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:351
GBlurVulkanContext::pl_ver
FFVulkanPipeline pl_ver
Definition: vf_gblur_vulkan.c:43
gaussian_simpson_integration
static float gaussian_simpson_integration(float sigma, float a, float b)
Definition: vf_gblur_vulkan.c:74
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1015
FLAGS
#define FLAGS
Definition: vf_gblur_vulkan.c:344
OFFSET
#define OFFSET(x)
Definition: vf_gblur_vulkan.c:343
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:56
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:160
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:374
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:28
GBlurVulkanContext::planes
int planes
Definition: vf_gblur_vulkan.c:49
ff_vk_filter_init
int ff_vk_filter_init(AVFilterContext *avctx)
General lavfi IO functions.
Definition: vulkan_filter.c:221
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:1415
AVOption
AVOption.
Definition: opt.h:346
b
#define b
Definition: input.c:41
FFVkBuffer::address
VkDeviceAddress address
Definition: vulkan.h:100
GBlurVulkanContext::size
int size
Definition: vf_gblur_vulkan.c:47
ff_vk_uninit
void ff_vk_uninit(FFVulkanContext *s)
Frees main context.
Definition: vulkan.c:1873
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:1465
ff_vk_shader_set_compute_sizes
void ff_vk_shader_set_compute_sizes(FFVkSPIRVShader *shd, int x, int y, int z)
Definition: vulkan.c:1373
FFVulkanDescriptorSetBinding::buf_content
const char * buf_content
Definition: vulkan.h:88
video.h
AV_PIX_FMT_VULKAN
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition: pixfmt.h:379
gblur_vulkan_inputs
static const AVFilterPad gblur_vulkan_inputs[]
Definition: vf_gblur_vulkan.c:356
init_gaussian_kernel
static void init_gaussian_kernel(float *kernel, float sigma, float kernel_size)
Definition: vf_gblur_vulkan.c:80
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3005
AVVulkanDeviceContext::alloc
const VkAllocationCallbacks * alloc
Custom memory allocator, else NULL.
Definition: hwcontext_vulkan.h:49
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:422
fail
#define fail()
Definition: checkasm.h:179
vulkan_filter.h
GBlurVulkanContext::e
FFVkExecPool e
Definition: vf_gblur_vulkan.c:37
GBlurVulkanContext::shd_ver
FFVkSPIRVShader shd_ver
Definition: vf_gblur_vulkan.c:44
gblur_vulkan_outputs
static const AVFilterPad gblur_vulkan_outputs[]
Definition: vf_gblur_vulkan.c:365
GBlurVulkanContext::qf
FFVkQueueFamilyCtx qf
Definition: vf_gblur_vulkan.c:38
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:298
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:33
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
ctx
AVFormatContext * ctx
Definition: movenc.c:49
gblur_vulkan_options
static const AVOption gblur_vulkan_options[]
Definition: vf_gblur_vulkan.c:345
ff_vk_unmap_buffer
static int ff_vk_unmap_buffer(FFVulkanContext *s, FFVkBuffer *buf, int flush)
Definition: vulkan.h:417
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:182
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:201
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:709
GLSLD
#define GLSLD(D)
Definition: vulkan.h:59
ff_vk_filter_config_output
int ff_vk_filter_config_output(AVFilterLink *outlink)
Definition: vulkan_filter.c:198
FFVkBuffer::size
size_t size
Definition: vulkan.h:99
ff_vk_init_compute_pipeline
int ff_vk_init_compute_pipeline(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkSPIRVShader *shd)
Definition: vulkan.c:1785
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:39
FFVulkanContext
Definition: vulkan.h:228
GBLUR_MAX_KERNEL_SIZE
#define GBLUR_MAX_KERNEL_SIZE
Definition: vf_gblur_vulkan.c:31
exp
int8_t exp
Definition: eval.c:73
FFVulkanPipeline
Definition: vulkan.h:131
index
int index
Definition: gxfenc.c:90
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:1347
main
int main(int argc, char **argv)
Definition: avio_http_serve_files.c:99
f
f
Definition: af_crystalizer.c:121
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:366
FFVulkanDescriptorSetBinding
Definition: vulkan.h:83
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:94
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:36
size
int size
Definition: twinvq_data.h:10344
FFVkQueueFamilyCtx
Definition: vulkan.h:110
GBlurVulkanContext::shd_hor
FFVkSPIRVShader shd_hor
Definition: vf_gblur_vulkan.c:41
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:33
gblur_vulkan_uninit
static av_cold void gblur_vulkan_uninit(AVFilterContext *avctx)
Definition: vf_gblur_vulkan.c:277
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
FFVulkanDescriptorSetBinding::name
const char * name
Definition: vulkan.h:84
GBlurVulkanContext::params_ver
FFVkBuffer params_ver
Definition: vf_gblur_vulkan.c:45
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:238
FILTER_SINGLE_PIXFMT
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition: internal.h:172
uninit
static void uninit(AVBSFContext *ctx)
Definition: pcm_rechunk.c:68
init_kernel_size
static void init_kernel_size(GBlurVulkanContext *s, int *out_size)
Definition: vf_gblur_vulkan.c:100
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
DUP_SAMPLER
#define DUP_SAMPLER(x)
Definition: vulkan.h:73
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:39
GLSLF
#define GLSLF(N, S,...)
Definition: vulkan.h:54
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:112
ff_vk_map_buffer
static int ff_vk_map_buffer(FFVulkanContext *s, FFVkBuffer *buf, uint8_t **mem, int invalidate)
Definition: vulkan.h:410
FFVulkanContext::vkfn
FFVulkanFunctions vkfn
Definition: vulkan.h:231
FFVkExecPool
Definition: vulkan.h:210
pos
unsigned int pos
Definition: spdifenc.c:414
gblur_vulkan_filter_frame
static int gblur_vulkan_filter_frame(AVFilterLink *link, AVFrame *in)
Definition: vf_gblur_vulkan.c:300
gblur_func
static const char gblur_func[]
Definition: vf_gblur_vulkan.c:54
random_seed.h
FFVkSPIRVShader
Definition: vulkan.h:75
ff_vf_gblur_vulkan
const AVFilter ff_vf_gblur_vulkan
Definition: vf_gblur_vulkan.c:373
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:235
GBlurVulkanContext::pl_hor
FFVulkanPipeline pl_hor
Definition: vf_gblur_vulkan.c:40
planes
static const struct @400 planes[]
AVFilterContext
An instance of a filter.
Definition: avfilter.h:407
desc
const char * desc
Definition: libsvtav1.c:75
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:166
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
FFVulkanContext::hwctx
AVVulkanDeviceContext * hwctx
Definition: vulkan.h:253
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:1682
mem.h
GBlurVulkanContext::sigmaV
float sigmaV
Definition: vf_gblur_vulkan.c:51
GBlurVulkanContext::params_hor
FFVkBuffer params_hor
Definition: vf_gblur_vulkan.c:42
AVVulkanDeviceContext::act_dev
VkDevice act_dev
Active device.
Definition: hwcontext_vulkan.h:71
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
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:125
FFVkBuffer
Definition: vulkan.h:95
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:1579
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
GBlurVulkanContext::sizeV
int sizeV
Definition: vf_gblur_vulkan.c:48
ff_vk_shader_free
void ff_vk_shader_free(FFVulkanContext *s, FFVkSPIRVShader *shd)
Definition: vulkan.c:1406
RET
#define RET(x)
Definition: vulkan.h:67
FFVulkanFunctions
Definition: vulkan_functions.h:226
GBlurVulkanContext::vkctx
FFVulkanContext vkctx
Definition: vf_gblur_vulkan.c:34
gaussian
static float gaussian(float sigma, float x)
Definition: vf_gblur_vulkan.c:68