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  ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT);
216  RET(ff_vk_exec_pool_init(vkctx, &s->qf, &s->e, s->qf.nb_queues*4, 0, 0, 0, NULL));
217  RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_LINEAR));
218 
220  {
221  .name = "input_images",
222  .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
223  .dimensions = 2,
224  .elems = planes,
225  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
226  .samplers = DUP_SAMPLER(s->sampler),
227  },
228  {
229  .name = "output_images",
230  .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
231  .mem_layout = ff_vk_shader_rep_fmt(s->vkctx.output_format, FF_VK_REP_FLOAT),
232  .mem_quali = "writeonly",
233  .dimensions = 2,
234  .elems = planes,
235  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
236  },
237  };
238 
240 
241  {
242  shd = &s->shd_hor;
243  RET(ff_vk_shader_init(vkctx, shd, "gblur_hor",
244  VK_SHADER_STAGE_COMPUTE_BIT,
245  NULL, 0,
246  32, 1, 1,
247  0));
248 
249  RET(ff_vk_shader_add_descriptor_set(vkctx, shd, desc, 2, 0, 0));
250 
251  GLSLC(0, #define OFFSET (vec2(i, 0.0)));
252  RET(init_gblur_pipeline(s, shd, &s->params_hor, s->size, s->sigma, spv));
253  }
254 
255  {
256  shd = &s->shd_ver;
257  RET(ff_vk_shader_init(vkctx, shd, "gblur_hor",
258  VK_SHADER_STAGE_COMPUTE_BIT,
259  NULL, 0,
260  1, 32, 1,
261  0));
262 
263  RET(ff_vk_shader_add_descriptor_set(vkctx, shd, desc, 2, 0, 0));
264 
265  GLSLC(0, #define OFFSET (vec2(0.0, i)));
266  RET(init_gblur_pipeline(s, 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_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  (FFVulkanShader *[2]){ &s->shd_hor, &s->shd_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: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:950
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:2586
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:1737
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
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:232
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:162
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:389
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:497
AVOption
AVOption.
Definition: opt.h:429
b
#define b
Definition: input.c:41
planes
static const struct @467 planes[]
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:2625
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: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: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
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:2226
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:2101
gblur_vulkan_outputs
static const AVFilterPad gblur_vulkan_outputs[]
Definition: vf_gblur_vulkan.c:364
GBlurVulkanContext::qf
FFVkQueueFamilyCtx qf
Definition: vf_gblur_vulkan.c:39
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:381
ctx
AVFormatContext * ctx
Definition: movenc.c:49
gblur_vulkan_options
static const AVOption gblur_vulkan_options[]
Definition: vf_gblur_vulkan.c:344
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:242
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:1344
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:725
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
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:306
GBlurVulkanContext::sampler
VkSampler sampler
Definition: vf_gblur_vulkan.c:40
FFVulkanContext
Definition: vulkan.h:271
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
FFVkQueueFamilyCtx
Definition: vulkan.h:102
FFVulkanShader
Definition: vulkan.h:187
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:278
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:2463
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:2026
ff_vk_unmap_buffer
static int ff_vk_unmap_buffer(FFVulkanContext *s, FFVkBuffer *buf, int flush)
Definition: vulkan.h:504
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:1164
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
FFVulkanContext::vkfn
FFVulkanFunctions vkfn
Definition: vulkan.h:275
FFVkExecPool
Definition: vulkan.h:249
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:299
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:372
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:300
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:1274
FFVkBuffer
Definition: vulkan.h:87
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
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