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 "libavutil/vulkan_spirv.h"
26 #include "vulkan_filter.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;
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  FFVulkanShader *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_shader_add_descriptor_set(&s->vkctx, 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(&s->vkctx, spv, shd, &spv_data, &spv_len, "main",
173  &spv_opaque));
174  RET(ff_vk_shader_link(&s->vkctx, shd, spv_data, spv_len, "main"));
175 
176  RET(ff_vk_shader_register_exec(&s->vkctx, &s->e, shd));
177 
178  RET(ff_vk_create_buf(&s->vkctx, params_buf, sizeof(float) * ksize, NULL, NULL,
179  VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT |
180  VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
181  VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT));
182  RET(ff_vk_map_buffer(&s->vkctx, params_buf, &kernel_mapped, 0));
183 
184  init_gaussian_kernel((float *)kernel_mapped, sigma, ksize);
185 
186  RET(ff_vk_unmap_buffer(&s->vkctx, params_buf, 1));
187  RET(ff_vk_shader_update_desc_buffer(&s->vkctx, &s->e.contexts[0], shd, 1, 0, 0,
188  params_buf, 0, params_buf->size,
189  VK_FORMAT_UNDEFINED));
190 
191 fail:
192  av_free(kernel_def);
193  if (spv_opaque)
194  spv->free_shader(spv, &spv_opaque);
195  return err;
196 }
197 
199 {
200  int err = 0;
201  GBlurVulkanContext *s = ctx->priv;
202  FFVulkanContext *vkctx = &s->vkctx;
203  const int planes = av_pix_fmt_count_planes(s->vkctx.output_format);
204 
205  FFVulkanShader *shd;
206  FFVkSPIRVCompiler *spv;
208 
209  spv = ff_vk_spirv_init();
210  if (!spv) {
211  av_log(ctx, AV_LOG_ERROR, "Unable to initialize SPIR-V compiler!\n");
212  return AVERROR_EXTERNAL;
213  }
214 
215  s->qf = ff_vk_qf_find(vkctx, VK_QUEUE_COMPUTE_BIT, 0);
216  if (!s->qf) {
217  av_log(ctx, AV_LOG_ERROR, "Device has no compute queues\n");
218  err = AVERROR(ENOTSUP);
219  goto fail;
220  }
221 
222  RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL));
223  RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_LINEAR));
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, FF_VK_REP_FLOAT),
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  RET(ff_vk_shader_init(vkctx, shd, "gblur_hor",
250  VK_SHADER_STAGE_COMPUTE_BIT,
251  NULL, 0,
252  32, 1, 1,
253  0));
254 
255  RET(ff_vk_shader_add_descriptor_set(vkctx, shd, desc, 2, 0, 0));
256 
257  GLSLC(0, #define OFFSET (vec2(i, 0.0)));
258  RET(init_gblur_pipeline(s, shd, &s->params_hor, s->size, s->sigma, spv));
259  }
260 
261  {
262  shd = &s->shd_ver;
263  RET(ff_vk_shader_init(vkctx, shd, "gblur_hor",
264  VK_SHADER_STAGE_COMPUTE_BIT,
265  NULL, 0,
266  1, 32, 1,
267  0));
268 
269  RET(ff_vk_shader_add_descriptor_set(vkctx, shd, desc, 2, 0, 0));
270 
271  GLSLC(0, #define OFFSET (vec2(0.0, i)));
272  RET(init_gblur_pipeline(s, shd, &s->params_ver, s->sizeV, s->sigmaV, spv));
273  }
274 
275  s->initialized = 1;
276 
277 fail:
278  if (spv)
279  spv->uninit(&spv);
280 
281  return err;
282 }
283 
285 {
286  GBlurVulkanContext *s = avctx->priv;
287  FFVulkanContext *vkctx = &s->vkctx;
288  FFVulkanFunctions *vk = &vkctx->vkfn;
289 
290  ff_vk_exec_pool_free(vkctx, &s->e);
291  ff_vk_shader_free(vkctx, &s->shd_hor);
292  ff_vk_shader_free(vkctx, &s->shd_ver);
293  ff_vk_free_buf(vkctx, &s->params_hor);
294  ff_vk_free_buf(vkctx, &s->params_ver);
295 
296  if (s->sampler)
297  vk->DestroySampler(vkctx->hwctx->act_dev, s->sampler,
298  vkctx->hwctx->alloc);
299 
300  ff_vk_uninit(&s->vkctx);
301 
302  s->initialized = 0;
303 }
304 
306 {
307  int err;
308  AVFrame *tmp = NULL, *out = NULL;
309  AVFilterContext *ctx = link->dst;
310  GBlurVulkanContext *s = ctx->priv;
311  AVFilterLink *outlink = ctx->outputs[0];
312 
313  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
314  if (!out) {
315  err = AVERROR(ENOMEM);
316  goto fail;
317  }
318 
319  tmp = ff_get_video_buffer(outlink, outlink->w, outlink->h);
320  if (!tmp) {
321  err = AVERROR(ENOMEM);
322  goto fail;
323  }
324 
325  if (!s->initialized)
326  RET(init_filter(ctx, in));
327 
328  RET(ff_vk_filter_process_2pass(&s->vkctx, &s->e,
329  (FFVulkanShader *[2]){ &s->shd_hor, &s->shd_ver },
330  out, tmp, in, s->sampler, NULL, 0));
331 
332  err = av_frame_copy_props(out, in);
333  if (err < 0)
334  goto fail;
335 
336  av_frame_free(&in);
337  av_frame_free(&tmp);
338 
339  return ff_filter_frame(outlink, out);
340 
341 fail:
342  av_frame_free(&in);
343  av_frame_free(&tmp);
344  av_frame_free(&out);
345  return err;
346 }
347 
348 #define OFFSET(x) offsetof(GBlurVulkanContext, x)
349 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
350 static const AVOption gblur_vulkan_options[] = {
351  { "sigma", "Set sigma", OFFSET(sigma), AV_OPT_TYPE_FLOAT, { .dbl = 0.5 }, 0.01, 1024.0, FLAGS },
352  { "sigmaV", "Set vertical sigma", OFFSET(sigmaV), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, 0.0, 1024.0, FLAGS },
353  { "planes", "Set planes to filter", OFFSET(planes), AV_OPT_TYPE_INT, { .i64 = 0xF }, 0, 0xF, FLAGS },
354  { "size", "Set kernel size", OFFSET(size), AV_OPT_TYPE_INT, { .i64 = 19 }, 1, GBLUR_MAX_KERNEL_SIZE, FLAGS },
355  { "sizeV", "Set vertical kernel size", OFFSET(sizeV), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, GBLUR_MAX_KERNEL_SIZE, FLAGS },
356  { NULL },
357 };
358 
359 AVFILTER_DEFINE_CLASS(gblur_vulkan);
360 
362  {
363  .name = "default",
364  .type = AVMEDIA_TYPE_VIDEO,
365  .filter_frame = &gblur_vulkan_filter_frame,
366  .config_props = &ff_vk_filter_config_input,
367  }
368 };
369 
371  {
372  .name = "default",
373  .type = AVMEDIA_TYPE_VIDEO,
374  .config_props = &ff_vk_filter_config_output,
375  }
376 };
377 
379  .name = "gblur_vulkan",
380  .description = NULL_IF_CONFIG_SMALL("Gaussian Blur in Vulkan"),
381  .priv_size = sizeof(GBlurVulkanContext),
387  .priv_class = &gblur_vulkan_class,
388  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
389  .flags = AVFILTER_FLAG_HWDEVICE,
390 };
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:928
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:215
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(gblur_vulkan)
GBlurVulkanContext::sigma
float sigma
Definition: vf_gblur_vulkan.c:49
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
ff_vk_shader_free
void ff_vk_shader_free(FFVulkanContext *s, FFVulkanShader *shd)
Free a shader.
Definition: vulkan.c:2564
ff_vk_shader_init
int ff_vk_shader_init(FFVulkanContext *s, FFVulkanShader *shd, const char *name, VkPipelineStageFlags stage, const char *extensions[], int nb_extensions, int lg_x, int lg_y, int lg_z, uint32_t required_subgroup_size)
Initialize a shader object, with a specific set of extensions, type+bind, local group size,...
Definition: vulkan.c:1715
out
FILE * out
Definition: movenc.c:55
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:1061
RET
#define RET(x)
Definition: vulkan.h:67
ff_vk_exec_pool_init
int ff_vk_exec_pool_init(FFVulkanContext *s, AVVulkanDeviceQueueFamily *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
FLAGS
#define FLAGS
Definition: vf_gblur_vulkan.c:349
OFFSET
#define OFFSET(x)
Definition: vf_gblur_vulkan.c:348
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:163
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:403
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:233
ff_vk_map_buffer
static int ff_vk_map_buffer(FFVulkanContext *s, FFVkBuffer *buf, uint8_t **mem, int invalidate)
Definition: vulkan.h:495
AVOption
AVOption.
Definition: opt.h:429
b
#define b
Definition: input.c:41
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:2603
FFVkSPIRVCompiler::uninit
void(* uninit)(struct FFVkSPIRVCompiler **ctx)
Definition: vulkan_spirv.h:32
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:205
FFVulkanDescriptorSetBinding::buf_content
const char * buf_content
Definition: vulkan.h:80
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:361
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:3210
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:472
fail
#define fail()
Definition: checkasm.h:193
vulkan_filter.h
GBlurVulkanContext::e
FFVkExecPool e
Definition: vf_gblur_vulkan.c:38
planes
static const struct @469 planes[]
ff_vk_shader_register_exec
int ff_vk_shader_register_exec(FFVulkanContext *s, FFVkExecPool *pool, FFVulkanShader *shd)
Register a shader with an exec pool.
Definition: vulkan.c:2204
ff_vk_shader_add_descriptor_set
int ff_vk_shader_add_descriptor_set(FFVulkanContext *s, FFVulkanShader *shd, FFVulkanDescriptorSetBinding *desc, int nb, int singular, int print_to_shader_only)
Add descriptor to a shader.
Definition: vulkan.c:2079
gblur_vulkan_outputs
static const AVFilterPad gblur_vulkan_outputs[]
Definition: vf_gblur_vulkan.c:370
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
GLSLC
#define GLSLC(N, S)
Definition: vulkan.h:44
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:209
av_cold
#define av_cold
Definition: attributes.h:90
main
int main
Definition: dovi_rpuenc.c:37
GBlurVulkanContext::shd_ver
FFVulkanShader shd_ver
Definition: vf_gblur_vulkan.c:43
s
#define s(width, name)
Definition: cbs_vp9.c:198
filters.h
FF_VK_REP_FLOAT
@ FF_VK_REP_FLOAT
Definition: vulkan.h:376
ctx
AVFormatContext * ctx
Definition: movenc.c:49
gblur_vulkan_options
static const AVOption gblur_vulkan_options[]
Definition: vf_gblur_vulkan.c:350
GLSLD
#define GLSLD(D)
Definition: vulkan.h:59
ff_vk_exec_pool_free
void ff_vk_exec_pool_free(FFVulkanContext *s, FFVkExecPool *pool)
Definition: vulkan.c:233
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
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:198
ff_vk_shader_rep_fmt
const char * ff_vk_shader_rep_fmt(enum AVPixelFormat pix_fmt, enum FFVkShaderRepFormat rep_fmt)
Definition: vulkan.c:1322
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:726
DUP_SAMPLER
#define DUP_SAMPLER(x)
Definition: vulkan.h:73
init_gblur_pipeline
static int init_gblur_pipeline(GBlurVulkanContext *s, FFVulkanShader *shd, FFVkBuffer *params_buf, int ksize, float sigma, FFVkSPIRVCompiler *spv)
Definition: vf_gblur_vulkan.c:124
ff_vk_filter_config_output
int ff_vk_filter_config_output(AVFilterLink *outlink)
Definition: vulkan_filter.c:209
FFVkBuffer::size
size_t size
Definition: vulkan.h:91
GBlurVulkanContext::sampler
VkSampler sampler
Definition: vf_gblur_vulkan.c:40
FFVulkanContext
Definition: vulkan.h:266
GBLUR_MAX_KERNEL_SIZE
#define GBLUR_MAX_KERNEL_SIZE
Definition: vf_gblur_vulkan.c:32
exp
int8_t exp
Definition: eval.c:73
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
f
f
Definition: af_crystalizer.c:122
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
FFVulkanDescriptorSetBinding
Definition: vulkan.h:75
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:173
GBlurVulkanContext::initialized
int initialized
Definition: vf_gblur_vulkan.c:37
size
int size
Definition: twinvq_data.h:10344
FFVulkanShader
Definition: vulkan.h:182
FFVkSPIRVCompiler::compile_shader
int(* compile_shader)(FFVulkanContext *s, struct FFVkSPIRVCompiler *ctx, FFVulkanShader *shd, uint8_t **data, size_t *size, const char *entrypoint, void **opaque)
Definition: vulkan_spirv.h:28
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:284
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
ff_vk_shader_update_desc_buffer
int ff_vk_shader_update_desc_buffer(FFVulkanContext *s, FFVkExecContext *e, FFVulkanShader *shd, int set, int bind, int elem, FFVkBuffer *buf, VkDeviceSize offset, VkDeviceSize len, VkFormat fmt)
Update a descriptor in a buffer with a buffer.
Definition: vulkan.c:2441
FFVulkanDescriptorSetBinding::name
const char * name
Definition: vulkan.h:76
GBlurVulkanContext::params_ver
FFVkBuffer params_ver
Definition: vf_gblur_vulkan.c:44
M_PI
#define M_PI
Definition: mathematics.h:67
FFVkSPIRVCompiler
Definition: vulkan_spirv.h:26
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:99
ff_vk_filter_process_2pass
int ff_vk_filter_process_2pass(FFVulkanContext *vkctx, FFVkExecPool *e, FFVulkanShader *shd_list[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:312
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
ff_vk_shader_link
int ff_vk_shader_link(FFVulkanContext *s, FFVulkanShader *shd, uint8_t *spirv, size_t spirv_len, const char *entrypoint)
Link a shader into an executable.
Definition: vulkan.c:2004
ff_vk_unmap_buffer
static int ff_vk_unmap_buffer(FFVulkanContext *s, FFVkBuffer *buf, int flush)
Definition: vulkan.h:502
vulkan_spirv.h
AVFilterPad::name
const char * name
Pad name.
Definition: filters.h:44
ff_vk_free_buf
void ff_vk_free_buf(FFVulkanContext *s, FFVkBuffer *buf)
Definition: vulkan.c:1142
FFVkSPIRVCompiler::free_shader
void(* free_shader)(struct FFVkSPIRVCompiler *ctx, void **opaque)
Definition: vulkan_spirv.h:31
AVFilter
Filter definition.
Definition: avfilter.h:201
init_gaussian_params
static av_cold void init_gaussian_params(GBlurVulkanContext *s)
Definition: vf_gblur_vulkan.c:111
GBlurVulkanContext::qf
AVVulkanDeviceQueueFamily * qf
Definition: vf_gblur_vulkan.c:39
FFVulkanContext::vkfn
FFVulkanFunctions vkfn
Definition: vulkan.h:270
FFVkExecPool
Definition: vulkan.h:244
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:305
ff_vk_qf_find
AVVulkanDeviceQueueFamily * ff_vk_qf_find(FFVulkanContext *s, VkQueueFlagBits dev_family, VkVideoCodecOperationFlagBitsKHR vid_ops)
Chooses an appropriate QF.
Definition: vulkan.c:220
gblur_func
static const char gblur_func[]
Definition: vf_gblur_vulkan.c:53
random_seed.h
GBlurVulkanContext::shd_hor
FFVulkanShader shd_hor
Definition: vf_gblur_vulkan.c:41
ff_vf_gblur_vulkan
const AVFilter ff_vf_gblur_vulkan
Definition: vf_gblur_vulkan.c:378
GLSLF
#define GLSLF(N, S,...)
Definition: vulkan.h:54
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
AVFilterContext
An instance of a filter.
Definition: avfilter.h:457
desc
const char * desc
Definition: libsvtav1.c:79
ff_vk_filter_config_input
int ff_vk_filter_config_input(AVFilterLink *inlink)
Definition: vulkan_filter.c:176
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
FFVulkanContext::hwctx
AVVulkanDeviceContext * hwctx
Definition: vulkan.h:295
mem.h
GBlurVulkanContext::sigmaV
float sigmaV
Definition: vf_gblur_vulkan.c:50
GBlurVulkanContext::params_hor
FFVkBuffer params_hor
Definition: vf_gblur_vulkan.c:42
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:1252
FFVkBuffer
Definition: vulkan.h:87
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVVulkanDeviceQueueFamily
Definition: hwcontext_vulkan.h:33
GBlurVulkanContext::sizeV
int sizeV
Definition: vf_gblur_vulkan.c:47
FILTER_SINGLE_PIXFMT
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition: filters.h:252
FFVulkanFunctions
Definition: vulkan_functions.h:264
GBlurVulkanContext::vkctx
FFVulkanContext vkctx
Definition: vf_gblur_vulkan.c:35
gaussian
static float gaussian(float sigma, float x)
Definition: vf_gblur_vulkan.c:67