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