FFmpeg
vf_blend_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  * The blend modes are based on the blend.c.
6  *
7  * This file is part of FFmpeg.
8  *
9  * FFmpeg is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * FFmpeg is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with FFmpeg; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  */
23 
24 #include "libavutil/random_seed.h"
25 #include "libavutil/opt.h"
26 #include "vulkan_filter.h"
27 #include "vulkan_spirv.h"
28 #include "internal.h"
29 #include "framesync.h"
30 #include "blend.h"
31 
32 #define IN_TOP 0
33 #define IN_BOTTOM 1
34 
35 typedef struct FilterParamsVulkan {
36  const char *blend;
37  const char *blend_func;
38  double opacity;
41 
42 typedef struct BlendVulkanContext {
45 
51  VkSampler sampler;
52 
54  double all_opacity;
57 
58 #define DEFINE_BLEND_MODE(MODE, EXPR) \
59 static const char blend_##MODE[] = "blend_"#MODE; \
60 static const char blend_##MODE##_func[] = { \
61  C(0, vec4 blend_##MODE(vec4 top, vec4 bottom, float opacity) { ) \
62  C(1, vec4 dst = EXPR; ) \
63  C(1, return dst; ) \
64  C(0, } ) \
65 };
66 
67 #define A top
68 #define B bottom
69 
70 #define FN(EXPR) A + ((EXPR) - A) * opacity
71 
72 DEFINE_BLEND_MODE(NORMAL, A * opacity + B * (1.0f - opacity))
73 DEFINE_BLEND_MODE(MULTIPLY, FN(1.0f * A * B / 1.0f))
74 
75 static inline void init_blend_func(FilterParamsVulkan *param)
76 {
77 #define CASE(MODE) case BLEND_##MODE: \
78  param->blend = blend_##MODE;\
79  param->blend_func = blend_##MODE##_func; \
80  break;
81 
82  switch (param->mode) {
83  CASE(NORMAL)
84  CASE(MULTIPLY)
85  default: param->blend = NULL; break;
86  }
87 
88 #undef CASE
89 }
90 
91 static int config_params(AVFilterContext *avctx)
92 {
93  BlendVulkanContext *s = avctx->priv;
94 
95  for (int plane = 0; plane < FF_ARRAY_ELEMS(s->params); plane++) {
96  FilterParamsVulkan *param = &s->params[plane];
97 
98  if (s->all_mode >= 0)
99  param->mode = s->all_mode;
100  if (s->all_opacity < 1)
101  param->opacity = s->all_opacity;
102 
103  init_blend_func(param);
104  if (!param->blend) {
105  av_log(avctx, AV_LOG_ERROR,
106  "Currently the blend mode specified is not supported yet.\n");
107  return AVERROR(EINVAL);
108  }
109  }
110 
111  return 0;
112 }
113 
114 static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
115  char *res, int res_len, int flags)
116 {
117  int ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
118  if (ret < 0)
119  return ret;
120 
121  return config_params(ctx);
122 }
123 
125 {
126  int err = 0;
127  uint8_t *spv_data;
128  size_t spv_len;
129  void *spv_opaque = NULL;
130  BlendVulkanContext *s = avctx->priv;
131  FFVulkanContext *vkctx = &s->vkctx;
132  const int planes = av_pix_fmt_count_planes(s->vkctx.output_format);
133  FFVkSPIRVShader *shd = &s->shd;
134  FFVkSPIRVCompiler *spv;
136 
137  spv = ff_vk_spirv_init();
138  if (!spv) {
139  av_log(avctx, AV_LOG_ERROR, "Unable to initialize SPIR-V compiler!\n");
140  return AVERROR_EXTERNAL;
141  }
142 
143  ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT);
144  RET(ff_vk_exec_pool_init(vkctx, &s->qf, &s->e, s->qf.nb_queues*4, 0, 0, 0, NULL));
145  RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_NEAREST));
146  RET(ff_vk_shader_init(&s->pl, &s->shd, "blend_compute",
147  VK_SHADER_STAGE_COMPUTE_BIT, 0));
148 
149  ff_vk_shader_set_compute_sizes(&s->shd, 32, 32, 1);
150 
152  {
153  .name = "top_images",
154  .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
155  .dimensions = 2,
156  .elems = planes,
157  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
158  .samplers = DUP_SAMPLER(s->sampler),
159  },
160  {
161  .name = "bottom_images",
162  .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
163  .dimensions = 2,
164  .elems = planes,
165  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
166  .samplers = DUP_SAMPLER(s->sampler),
167  },
168  {
169  .name = "output_images",
170  .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
171  .mem_layout = ff_vk_shader_rep_fmt(s->vkctx.output_format),
172  .mem_quali = "writeonly",
173  .dimensions = 2,
174  .elems = planes,
175  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
176  },
177  };
178 
179  RET(ff_vk_pipeline_descriptor_set_add(vkctx, &s->pl, shd, desc, 3, 0, 0));
180 
181  for (int i = 0, j = 0; i < planes; i++) {
182  for (j = 0; j < i; j++)
183  if (s->params[i].blend_func == s->params[j].blend_func)
184  break;
185  /* note: the bracket is needed, for GLSLD is a macro with multiple statements. */
186  if (j == i) {
187  GLSLD(s->params[i].blend_func);
188  }
189  }
190 
191  GLSLC(0, void main() );
192  GLSLC(0, { );
193  GLSLC(1, ivec2 size; );
194  GLSLC(1, const ivec2 pos = ivec2(gl_GlobalInvocationID.xy); );
195  for (int i = 0; i < planes; i++) {
196  GLSLC(0, );
197  GLSLF(1, size = imageSize(output_images[%i]); ,i);
198  GLSLC(1, if (IS_WITHIN(pos, size)) { );
199  GLSLF(2, const vec4 top = texture(top_images[%i], pos); ,i);
200  GLSLF(2, const vec4 bottom = texture(bottom_images[%i], pos); ,i);
201  GLSLF(2, const float opacity = %f; ,s->params[i].opacity);
202  GLSLF(2, vec4 dst = %s(top, bottom, opacity); ,s->params[i].blend);
203  GLSLC(0, );
204  GLSLF(2, imageStore(output_images[%i], pos, dst); ,i);
205  GLSLC(1, } );
206  }
207  GLSLC(0, } );
208 
209  RET(spv->compile_shader(spv, avctx, shd, &spv_data, &spv_len, "main",
210  &spv_opaque));
211  RET(ff_vk_shader_create(vkctx, shd, spv_data, spv_len, "main"));
212 
213  RET(ff_vk_init_compute_pipeline(vkctx, &s->pl, shd));
214  RET(ff_vk_exec_pipeline_register(vkctx, &s->e, &s->pl));
215 
216  s->initialized = 1;
217 
218 fail:
219  if (spv_opaque)
220  spv->free_shader(spv, &spv_opaque);
221  if (spv)
222  spv->uninit(&spv);
223 
224  return err;
225 }
226 
228 {
229  int err;
230  AVFilterContext *avctx = fs->parent;
231  BlendVulkanContext *s = avctx->priv;
232  AVFilterLink *outlink = avctx->outputs[0];
233  AVFrame *top, *bottom, *out;
234 
235  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
236  if (!out) {
237  err = AVERROR(ENOMEM);
238  goto fail;
239  }
240 
241  RET(ff_framesync_get_frame(fs, IN_TOP, &top, 0));
242  RET(ff_framesync_get_frame(fs, IN_BOTTOM, &bottom, 0));
243 
244  RET(av_frame_copy_props(out, top));
245 
246  if (!s->initialized) {
248  AVHWFramesContext *bottom_fc = (AVHWFramesContext*)bottom->hw_frames_ctx->data;
249  if (top_fc->sw_format != bottom_fc->sw_format) {
250  av_log(avctx, AV_LOG_ERROR,
251  "Currently the sw format of the bottom video need to match the top!\n");
252  return AVERROR(EINVAL);
253  }
254  RET(init_filter(avctx));
255  }
256 
257  RET(ff_vk_filter_process_Nin(&s->vkctx, &s->e, &s->pl,
258  out, (AVFrame *[]){ top, bottom }, 2,
259  s->sampler, NULL, 0));
260 
261  return ff_filter_frame(outlink, out);
262 
263 fail:
264  av_frame_free(&out);
265  return err;
266 }
267 
268 static av_cold int init(AVFilterContext *avctx)
269 {
270  BlendVulkanContext *s = avctx->priv;
271 
272  s->fs.on_event = blend_frame;
273 
274  return ff_vk_filter_init(avctx);
275 }
276 
277 static av_cold void uninit(AVFilterContext *avctx)
278 {
279  BlendVulkanContext *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);
285  ff_vk_shader_free(vkctx, &s->shd);
286 
287  if (s->sampler)
288  vk->DestroySampler(vkctx->hwctx->act_dev, s->sampler,
289  vkctx->hwctx->alloc);
290 
291  ff_vk_uninit(&s->vkctx);
292  ff_framesync_uninit(&s->fs);
293 
294  s->initialized = 0;
295 }
296 
297 static int config_props_output(AVFilterLink *outlink)
298 {
299  int err;
300  AVFilterContext *avctx = outlink->src;
301  BlendVulkanContext *s = avctx->priv;
302  AVFilterLink *toplink = avctx->inputs[IN_TOP];
303  AVFilterLink *bottomlink = avctx->inputs[IN_BOTTOM];
304 
305  if (toplink->w != bottomlink->w || toplink->h != bottomlink->h) {
306  av_log(avctx, AV_LOG_ERROR, "First input link %s parameters "
307  "(size %dx%d) do not match the corresponding "
308  "second input link %s parameters (size %dx%d)\n",
309  avctx->input_pads[IN_TOP].name, toplink->w, toplink->h,
310  avctx->input_pads[IN_BOTTOM].name, bottomlink->w, bottomlink->h);
311  return AVERROR(EINVAL);
312  }
313 
314  outlink->sample_aspect_ratio = toplink->sample_aspect_ratio;
315  outlink->frame_rate = toplink->frame_rate;
316 
318 
319  RET(ff_framesync_init_dualinput(&s->fs, avctx));
320 
322  outlink->time_base = s->fs.time_base;
323 
324  RET(config_params(avctx));
325 
326 fail:
327  return err;
328 }
329 
330 static int activate(AVFilterContext *avctx)
331 {
332  BlendVulkanContext *s = avctx->priv;
333  return ff_framesync_activate(&s->fs);
334 }
335 
336 #define OFFSET(x) offsetof(BlendVulkanContext, x)
337 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
338 
339 static const AVOption blend_vulkan_options[] = {
340  { "c0_mode", "set component #0 blend mode", OFFSET(params[0].mode), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, BLEND_NB - 1, FLAGS, "mode" },
341  { "c1_mode", "set component #1 blend mode", OFFSET(params[1].mode), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, BLEND_NB - 1, FLAGS, "mode" },
342  { "c2_mode", "set component #2 blend mode", OFFSET(params[2].mode), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, BLEND_NB - 1, FLAGS, "mode" },
343  { "c3_mode", "set component #3 blend mode", OFFSET(params[3].mode), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, BLEND_NB - 1, FLAGS, "mode" },
344  { "all_mode", "set blend mode for all components", OFFSET(all_mode), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, BLEND_NB - 1, FLAGS, "mode" },
345  { "normal", "", 0, AV_OPT_TYPE_CONST, { .i64 = BLEND_NORMAL }, 0, 0, FLAGS, "mode" },
346  { "multiply", "", 0, AV_OPT_TYPE_CONST, { .i64 = BLEND_MULTIPLY }, 0, 0, FLAGS, "mode" },
347 
348  { "c0_opacity", "set color component #0 opacity", OFFSET(params[0].opacity), AV_OPT_TYPE_DOUBLE, { .dbl = 1 }, 0, 1, FLAGS },
349  { "c1_opacity", "set color component #1 opacity", OFFSET(params[1].opacity), AV_OPT_TYPE_DOUBLE, { .dbl = 1 }, 0, 1, FLAGS },
350  { "c2_opacity", "set color component #2 opacity", OFFSET(params[2].opacity), AV_OPT_TYPE_DOUBLE, { .dbl = 1 }, 0, 1, FLAGS },
351  { "c3_opacity", "set color component #3 opacity", OFFSET(params[3].opacity), AV_OPT_TYPE_DOUBLE, { .dbl = 1 }, 0, 1, FLAGS },
352  { "all_opacity", "set opacity for all color components", OFFSET(all_opacity), AV_OPT_TYPE_DOUBLE, { .dbl = 1 }, 0, 1, FLAGS },
353 
354  { NULL }
355 };
356 
357 AVFILTER_DEFINE_CLASS(blend_vulkan);
358 
360  {
361  .name = "top",
362  .type = AVMEDIA_TYPE_VIDEO,
363  .config_props = &ff_vk_filter_config_input,
364  },
365  {
366  .name = "bottom",
367  .type = AVMEDIA_TYPE_VIDEO,
368  .config_props = &ff_vk_filter_config_input,
369  },
370 };
371 
372 
374  {
375  .name = "default",
376  .type = AVMEDIA_TYPE_VIDEO,
377  .config_props = &config_props_output,
378  }
379 };
380 
382  .name = "blend_vulkan",
383  .description = NULL_IF_CONFIG_SMALL("Blend two video frames in Vulkan"),
384  .priv_size = sizeof(BlendVulkanContext),
385  .init = &init,
386  .uninit = &uninit,
387  .activate = &activate,
391  .priv_class = &blend_vulkan_class,
392  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
393  .flags = AVFILTER_FLAG_HWDEVICE,
394  .process_command = &process_command,
395 };
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:101
ff_framesync_configure
int ff_framesync_configure(FFFrameSync *fs)
Configure a frame sync structure.
Definition: framesync.c:134
ff_vf_blend_vulkan
const AVFilter ff_vf_blend_vulkan
Definition: vf_blend_vulkan.c:381
ff_vk_pipeline_free
void ff_vk_pipeline_free(FFVulkanContext *s, FFVulkanPipeline *pl)
Definition: vulkan.c:1829
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_framesync_uninit
void ff_framesync_uninit(FFFrameSync *fs)
Free all memory currently allocated.
Definition: framesync.c:304
out
FILE * out
Definition: movenc.c:54
FF_FILTER_FLAG_HWFRAME_AWARE
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
Definition: internal.h:374
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:971
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
ff_framesync_get_frame
int ff_framesync_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe, unsigned get)
Get the current frame in an input.
Definition: framesync.c:267
config_props_output
static int config_props_output(AVFilterLink *outlink)
Definition: vf_blend_vulkan.c:297
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:202
BlendVulkanContext::shd
FFVkSPIRVShader shd
Definition: vf_blend_vulkan.c:50
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:100
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:330
init_blend_func
static void init_blend_func(FilterParamsVulkan *param)
Definition: vf_blend_vulkan.c:75
ff_vk_filter_init
int ff_vk_filter_init(AVFilterContext *avctx)
General lavfi IO functions.
Definition: vulkan_filter.c:214
ff_vk_filter_process_Nin
int ff_vk_filter_process_Nin(FFVulkanContext *vkctx, FFVkExecPool *e, FFVulkanPipeline *pl, AVFrame *out, AVFrame *in[], int nb_in, VkSampler sampler, void *push_src, size_t push_size)
Up to 16 inputs, one output.
Definition: vulkan_filter.c:380
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:1374
B
#define B
Definition: vf_blend_vulkan.c:68
AVOption
AVOption.
Definition: opt.h:251
ff_vk_uninit
void ff_vk_uninit(FFVulkanContext *s)
Frees main context.
Definition: vulkan.c:1857
FFVkSPIRVCompiler::uninit
void(* uninit)(struct FFVkSPIRVCompiler **ctx)
Definition: vulkan_spirv.h:33
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:170
BlendVulkanContext::e
FFVkExecPool e
Definition: vf_blend_vulkan.c:48
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:1424
FFFrameSync
Frame sync structure.
Definition: framesync.h:168
ff_vk_shader_set_compute_sizes
void ff_vk_shader_set_compute_sizes(FFVkSPIRVShader *shd, int x, int y, int z)
Definition: vulkan.c:1332
MULTIPLY
#define MULTIPLY(var, const)
Definition: 4xm.c:164
AV_PIX_FMT_VULKAN
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition: pixfmt.h:376
BLEND_NB
@ BLEND_NB
Definition: blend.h:69
BlendVulkanContext::all_opacity
double all_opacity
Definition: vf_blend_vulkan.c:54
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2976
BlendVulkanContext::fs
FFFrameSync fs
Definition: vf_blend_vulkan.c:44
AVVulkanDeviceContext::alloc
const VkAllocationCallbacks * alloc
Custom memory allocator, else NULL.
Definition: hwcontext_vulkan.h:48
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:412
fail
#define fail()
Definition: checkasm.h:137
init
static av_cold int init(AVFilterContext *avctx)
Definition: vf_blend_vulkan.c:268
BlendVulkanContext::params
FilterParamsVulkan params[4]
Definition: vf_blend_vulkan.c:53
vulkan_filter.h
blend_vulkan_outputs
static const AVFilterPad blend_vulkan_outputs[]
Definition: vf_blend_vulkan.c:373
BlendVulkanContext::sampler
VkSampler sampler
Definition: vf_blend_vulkan.c:51
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:49
OFFSET
#define OFFSET(x)
Definition: vf_blend_vulkan.c:336
AVFilterContext::input_pads
AVFilterPad * input_pads
array of input pads
Definition: avfilter.h:404
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
av_cold
#define av_cold
Definition: attributes.h:90
blend_vulkan_inputs
static const AVFilterPad blend_vulkan_inputs[]
Definition: vf_blend_vulkan.c:359
s
#define s(width, name)
Definition: cbs_vp9.c:256
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Definition: opt.h:227
FilterParamsVulkan
Definition: vf_blend_vulkan.c:35
ctx
AVFormatContext * ctx
Definition: movenc.c:48
activate
static int activate(AVFilterContext *avctx)
Definition: vf_blend_vulkan.c:330
init_filter
static av_cold int init_filter(AVFilterContext *avctx)
Definition: vf_blend_vulkan.c:124
BlendVulkanContext::initialized
int initialized
Definition: vf_blend_vulkan.c:46
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:233
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:194
BlendVulkanContext::qf
FFVkQueueFamilyCtx qf
Definition: vf_blend_vulkan.c:49
NULL
#define NULL
Definition: coverity.c:32
AVHWFramesContext::sw_format
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
Definition: hwcontext.h:222
av_frame_copy_props
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:736
BLEND_MULTIPLY
@ BLEND_MULTIPLY
Definition: blend.h:42
GLSLD
#define GLSLD(D)
Definition: vulkan.h:59
fs
#define fs(width, name, subs,...)
Definition: cbs_vp9.c:258
BlendMode
BlendMode
Definition: blend.h:27
AVFilterContext::inputs
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:405
ff_vk_filter_config_output
int ff_vk_filter_config_output(AVFilterLink *outlink)
Definition: vulkan_filter.c:191
config_params
static int config_params(AVFilterContext *avctx)
Definition: vf_blend_vulkan.c:91
blend_vulkan_options
static const AVOption blend_vulkan_options[]
Definition: vf_blend_vulkan.c:339
ff_vk_init_compute_pipeline
int ff_vk_init_compute_pipeline(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkSPIRVShader *shd)
Definition: vulkan.c:1770
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:272
FFVulkanContext
Definition: vulkan.h:227
BlendVulkanContext
Definition: vf_blend_vulkan.c:42
A
#define A
Definition: vf_blend_vulkan.c:67
FFVulkanPipeline
Definition: vulkan.h:131
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:1306
main
int main(int argc, char **argv)
Definition: avio_http_serve_files.c:99
FLAGS
#define FLAGS
Definition: vf_blend_vulkan.c:337
f
f
Definition: af_crystalizer.c:122
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:114
ff_framesync_init_dualinput
int ff_framesync_init_dualinput(FFFrameSync *fs, AVFilterContext *parent)
Initialize a frame sync structure for dualinput.
Definition: framesync.c:372
blend_frame
static int blend_frame(FFFrameSync *fs)
Definition: vf_blend_vulkan.c:227
IN_TOP
#define IN_TOP
Definition: vf_blend_vulkan.c:32
AVFILTER_FLAG_HWDEVICE
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
Definition: avfilter.h:138
size
int size
Definition: twinvq_data.h:10344
FFVkQueueFamilyCtx
Definition: vulkan.h:110
FilterParamsVulkan::opacity
double opacity
Definition: vf_blend_vulkan.c:38
BlendVulkanContext::pl
FFVulkanPipeline pl
Definition: vf_blend_vulkan.c:47
IN_BOTTOM
#define IN_BOTTOM
Definition: vf_blend_vulkan.c:33
FilterParamsVulkan::blend_func
const char * blend_func
Definition: vf_blend_vulkan.c:37
ff_filter_process_command
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
Definition: avfilter.c:844
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
internal.h
FFVkSPIRVCompiler
Definition: vulkan_spirv.h:27
planes
static const struct @352 planes[]
FILTER_SINGLE_PIXFMT
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition: internal.h:184
CASE
#define CASE(MODE)
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
BlendVulkanContext::vkctx
FFVulkanContext vkctx
Definition: vf_blend_vulkan.c:43
blend.h
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:1168
BlendVulkanContext::all_mode
enum BlendMode all_mode
Definition: vf_blend_vulkan.c:55
vulkan_spirv.h
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:55
GLSLF
#define GLSLF(N, S,...)
Definition: vulkan.h:54
FFVkSPIRVCompiler::free_shader
void(* free_shader)(struct FFVkSPIRVCompiler *ctx, void **opaque)
Definition: vulkan_spirv.h:32
AVFilter
Filter definition.
Definition: avfilter.h:166
AVHWFramesContext
This struct describes a set or pool of "hardware" frames (i.e.
Definition: hwcontext.h:124
ret
ret
Definition: filter_design.txt:187
FFVulkanContext::vkfn
FFVulkanFunctions vkfn
Definition: vulkan.h:230
FFVkExecPool
Definition: vulkan.h:208
pos
unsigned int pos
Definition: spdifenc.c:413
AVFrame::hw_frames_ctx
AVBufferRef * hw_frames_ctx
For hwaccel-format frames, this should be a reference to the AVHWFramesContext describing the frame.
Definition: frame.h:742
random_seed.h
framesync.h
uninit
static av_cold void uninit(AVFilterContext *avctx)
Definition: vf_blend_vulkan.c:277
FFVkSPIRVShader
Definition: vulkan.h:75
mode
mode
Definition: ebur128.h:83
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
process_command
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: vf_blend_vulkan.c:114
DEFINE_BLEND_MODE
#define DEFINE_BLEND_MODE(MODE, EXPR)
Definition: vf_blend_vulkan.c:58
AVFilterContext
An instance of a filter.
Definition: avfilter.h:397
desc
const char * desc
Definition: libsvtav1.c:83
GLSLC
#define GLSLC(N, S)
Definition: vulkan.h:44
ff_vk_filter_config_input
int ff_vk_filter_config_input(AVFilterLink *inlink)
Definition: vulkan_filter.c:160
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
FFVulkanContext::hwctx
AVVulkanDeviceContext * hwctx
Definition: vulkan.h:248
FilterParamsVulkan::mode
enum BlendMode mode
Definition: vf_blend_vulkan.c:39
AVVulkanDeviceContext::act_dev
VkDevice act_dev
Active device.
Definition: hwcontext_vulkan.h:70
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:195
FilterParamsVulkan::blend
const char * blend
Definition: vf_blend_vulkan.c:36
ff_vk_init_sampler
int ff_vk_init_sampler(FFVulkanContext *s, VkSampler *sampler, int unnorm_coords, VkFilter filt)
Create a sampler.
Definition: vulkan.c:1124
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:1538
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
FN
#define FN(EXPR)
Definition: vf_blend_vulkan.c:70
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(blend_vulkan)
ff_framesync_activate
int ff_framesync_activate(FFFrameSync *fs)
Examine the frames in the filter's input and try to produce output.
Definition: framesync.c:355
ff_vk_shader_free
void ff_vk_shader_free(FFVulkanContext *s, FFVkSPIRVShader *shd)
Definition: vulkan.c:1365
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234
RET
#define RET(x)
Definition: vulkan.h:67
FFVulkanFunctions
Definition: vulkan_functions.h:224
BLEND_NORMAL
@ BLEND_NORMAL
Definition: blend.h:29
AVFilterContext::outputs
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:409