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/vulkan_spirv.h"
26 #include "libavutil/opt.h"
27 #include "vulkan_filter.h"
28 
29 #include "filters.h"
30 #include "framesync.h"
31 #include "blend.h"
32 #include "video.h"
33 
34 #define IN_TOP 0
35 #define IN_BOTTOM 1
36 
37 typedef struct FilterParamsVulkan {
38  const char *blend;
39  const char *blend_func;
40  double opacity;
43 
44 typedef struct BlendVulkanContext {
47 
52  VkSampler sampler;
53 
55  double all_opacity;
58 
59 #define DEFINE_BLEND_MODE(MODE, EXPR) \
60 static const char blend_##MODE[] = "blend_"#MODE; \
61 static const char blend_##MODE##_func[] = { \
62  C(0, vec4 blend_##MODE(vec4 top, vec4 bottom, float opacity) { ) \
63  C(1, vec4 dst = EXPR; ) \
64  C(1, return dst; ) \
65  C(0, } ) \
66 };
67 
68 #define A top
69 #define B bottom
70 
71 #define FN(EXPR) A + ((EXPR) - A) * opacity
72 
73 DEFINE_BLEND_MODE(NORMAL, A * opacity + B * (1.0f - opacity))
74 DEFINE_BLEND_MODE(MULTIPLY, FN(1.0f * A * B / 1.0f))
75 
76 static inline void init_blend_func(FilterParamsVulkan *param)
77 {
78 #define CASE(MODE) case BLEND_##MODE: \
79  param->blend = blend_##MODE;\
80  param->blend_func = blend_##MODE##_func; \
81  break;
82 
83  switch (param->mode) {
84  CASE(NORMAL)
85  CASE(MULTIPLY)
86  default: param->blend = NULL; break;
87  }
88 
89 #undef CASE
90 }
91 
92 static int config_params(AVFilterContext *avctx)
93 {
94  BlendVulkanContext *s = avctx->priv;
95 
96  for (int plane = 0; plane < FF_ARRAY_ELEMS(s->params); plane++) {
97  FilterParamsVulkan *param = &s->params[plane];
98 
99  if (s->all_mode >= 0)
100  param->mode = s->all_mode;
101  if (s->all_opacity < 1)
102  param->opacity = s->all_opacity;
103 
104  init_blend_func(param);
105  if (!param->blend) {
106  av_log(avctx, AV_LOG_ERROR,
107  "Currently the blend mode specified is not supported yet.\n");
108  return AVERROR(EINVAL);
109  }
110  }
111 
112  return 0;
113 }
114 
115 static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
116  char *res, int res_len, int flags)
117 {
118  int ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
119  if (ret < 0)
120  return ret;
121 
122  return config_params(ctx);
123 }
124 
126 {
127  int err = 0;
128  uint8_t *spv_data;
129  size_t spv_len;
130  void *spv_opaque = NULL;
131  BlendVulkanContext *s = avctx->priv;
132  FFVulkanContext *vkctx = &s->vkctx;
133  const int planes = av_pix_fmt_count_planes(s->vkctx.output_format);
134  FFVulkanShader *shd = &s->shd;
135  FFVkSPIRVCompiler *spv;
137 
138  spv = ff_vk_spirv_init();
139  if (!spv) {
140  av_log(avctx, AV_LOG_ERROR, "Unable to initialize SPIR-V compiler!\n");
141  return AVERROR_EXTERNAL;
142  }
143 
144  s->qf = ff_vk_qf_find(vkctx, VK_QUEUE_COMPUTE_BIT, 0);
145  if (!s->qf) {
146  av_log(avctx, AV_LOG_ERROR, "Device has no compute queues\n");
147  err = AVERROR(ENOTSUP);
148  goto fail;
149  }
150 
151  RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL));
152  RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_NEAREST));
153  RET(ff_vk_shader_init(vkctx, &s->shd, "blend",
154  VK_SHADER_STAGE_COMPUTE_BIT,
155  NULL, 0,
156  32, 32, 1,
157  0));
158 
160  {
161  .name = "top_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 = "bottom_images",
170  .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
171  .dimensions = 2,
172  .elems = planes,
173  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
174  .samplers = DUP_SAMPLER(s->sampler),
175  },
176  {
177  .name = "output_images",
178  .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
179  .mem_layout = ff_vk_shader_rep_fmt(s->vkctx.output_format, FF_VK_REP_FLOAT),
180  .mem_quali = "writeonly",
181  .dimensions = 2,
182  .elems = planes,
183  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
184  },
185  };
186 
187  RET(ff_vk_shader_add_descriptor_set(vkctx, &s->shd, desc, 3, 0, 0));
188 
189  for (int i = 0, j = 0; i < planes; i++) {
190  for (j = 0; j < i; j++)
191  if (s->params[i].blend_func == s->params[j].blend_func)
192  break;
193  /* note: the bracket is needed, for GLSLD is a macro with multiple statements. */
194  if (j == i) {
195  GLSLD(s->params[i].blend_func);
196  }
197  }
198 
199  GLSLC(0, void main() );
200  GLSLC(0, { );
201  GLSLC(1, ivec2 size; );
202  GLSLC(1, const ivec2 pos = ivec2(gl_GlobalInvocationID.xy); );
203  for (int i = 0; i < planes; i++) {
204  GLSLC(0, );
205  GLSLF(1, size = imageSize(output_images[%i]); ,i);
206  GLSLC(1, if (IS_WITHIN(pos, size)) { );
207  GLSLF(2, const vec4 top = texture(top_images[%i], pos); ,i);
208  GLSLF(2, const vec4 bottom = texture(bottom_images[%i], pos); ,i);
209  GLSLF(2, const float opacity = %f; ,s->params[i].opacity);
210  GLSLF(2, vec4 dst = %s(top, bottom, opacity); ,s->params[i].blend);
211  GLSLC(0, );
212  GLSLF(2, imageStore(output_images[%i], pos, dst); ,i);
213  GLSLC(1, } );
214  }
215  GLSLC(0, } );
216 
217  RET(spv->compile_shader(vkctx, spv, shd, &spv_data, &spv_len, "main",
218  &spv_opaque));
219  RET(ff_vk_shader_link(vkctx, shd, spv_data, spv_len, "main"));
220 
221  RET(ff_vk_shader_register_exec(vkctx, &s->e, &s->shd));
222 
223  s->initialized = 1;
224 
225 fail:
226  if (spv_opaque)
227  spv->free_shader(spv, &spv_opaque);
228  if (spv)
229  spv->uninit(&spv);
230 
231  return err;
232 }
233 
235 {
236  int err;
237  AVFilterContext *avctx = fs->parent;
238  BlendVulkanContext *s = avctx->priv;
239  AVFilterLink *outlink = avctx->outputs[0];
240  AVFrame *top, *bottom, *out;
241 
242  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
243  if (!out) {
244  err = AVERROR(ENOMEM);
245  goto fail;
246  }
247 
248  RET(ff_framesync_get_frame(fs, IN_TOP, &top, 0));
249  RET(ff_framesync_get_frame(fs, IN_BOTTOM, &bottom, 0));
250 
251  RET(av_frame_copy_props(out, top));
252 
253  if (!s->initialized) {
255  AVHWFramesContext *bottom_fc = (AVHWFramesContext*)bottom->hw_frames_ctx->data;
256  if (top_fc->sw_format != bottom_fc->sw_format) {
257  av_log(avctx, AV_LOG_ERROR,
258  "Currently the sw format of the bottom video need to match the top!\n");
259  err = AVERROR(EINVAL);
260  goto fail;
261  }
262  RET(init_filter(avctx));
263  }
264 
265  RET(ff_vk_filter_process_Nin(&s->vkctx, &s->e, &s->shd,
266  out, (AVFrame *[]){ top, bottom }, 2,
267  s->sampler, NULL, 0));
268 
269  return ff_filter_frame(outlink, out);
270 
271 fail:
272  av_frame_free(&out);
273  return err;
274 }
275 
276 static av_cold int init(AVFilterContext *avctx)
277 {
278  BlendVulkanContext *s = avctx->priv;
279 
280  s->fs.on_event = blend_frame;
281 
282  return ff_vk_filter_init(avctx);
283 }
284 
285 static av_cold void uninit(AVFilterContext *avctx)
286 {
287  BlendVulkanContext *s = avctx->priv;
288  FFVulkanContext *vkctx = &s->vkctx;
289  FFVulkanFunctions *vk = &vkctx->vkfn;
290 
291  ff_vk_exec_pool_free(vkctx, &s->e);
292  ff_vk_shader_free(vkctx, &s->shd);
293 
294  if (s->sampler)
295  vk->DestroySampler(vkctx->hwctx->act_dev, s->sampler,
296  vkctx->hwctx->alloc);
297 
298  ff_vk_uninit(&s->vkctx);
299  ff_framesync_uninit(&s->fs);
300 
301  s->initialized = 0;
302 }
303 
304 static int config_props_output(AVFilterLink *outlink)
305 {
306  int err;
307  FilterLink *outl = ff_filter_link(outlink);
308  AVFilterContext *avctx = outlink->src;
309  BlendVulkanContext *s = avctx->priv;
310  AVFilterLink *toplink = avctx->inputs[IN_TOP];
311  FilterLink *tl = ff_filter_link(toplink);
312  AVFilterLink *bottomlink = avctx->inputs[IN_BOTTOM];
313 
314  if (toplink->w != bottomlink->w || toplink->h != bottomlink->h) {
315  av_log(avctx, AV_LOG_ERROR, "First input link %s parameters "
316  "(size %dx%d) do not match the corresponding "
317  "second input link %s parameters (size %dx%d)\n",
318  avctx->input_pads[IN_TOP].name, toplink->w, toplink->h,
319  avctx->input_pads[IN_BOTTOM].name, bottomlink->w, bottomlink->h);
320  return AVERROR(EINVAL);
321  }
322 
323  outlink->sample_aspect_ratio = toplink->sample_aspect_ratio;
324  outl->frame_rate = tl->frame_rate;
325 
327 
328  RET(ff_framesync_init_dualinput(&s->fs, avctx));
329 
331  outlink->time_base = s->fs.time_base;
332 
333  RET(config_params(avctx));
334 
335 fail:
336  return err;
337 }
338 
339 static int activate(AVFilterContext *avctx)
340 {
341  BlendVulkanContext *s = avctx->priv;
342  return ff_framesync_activate(&s->fs);
343 }
344 
345 #define OFFSET(x) offsetof(BlendVulkanContext, x)
346 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
347 
348 static const AVOption blend_vulkan_options[] = {
349  { "c0_mode", "set component #0 blend mode", OFFSET(params[0].mode), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, BLEND_NB - 1, FLAGS, .unit = "mode" },
350  { "c1_mode", "set component #1 blend mode", OFFSET(params[1].mode), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, BLEND_NB - 1, FLAGS, .unit = "mode" },
351  { "c2_mode", "set component #2 blend mode", OFFSET(params[2].mode), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, BLEND_NB - 1, FLAGS, .unit = "mode" },
352  { "c3_mode", "set component #3 blend mode", OFFSET(params[3].mode), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, BLEND_NB - 1, FLAGS, .unit = "mode" },
353  { "all_mode", "set blend mode for all components", OFFSET(all_mode), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, BLEND_NB - 1, FLAGS, .unit = "mode" },
354  { "normal", "", 0, AV_OPT_TYPE_CONST, { .i64 = BLEND_NORMAL }, 0, 0, FLAGS, .unit = "mode" },
355  { "multiply", "", 0, AV_OPT_TYPE_CONST, { .i64 = BLEND_MULTIPLY }, 0, 0, FLAGS, .unit = "mode" },
356 
357  { "c0_opacity", "set color component #0 opacity", OFFSET(params[0].opacity), AV_OPT_TYPE_DOUBLE, { .dbl = 1 }, 0, 1, FLAGS },
358  { "c1_opacity", "set color component #1 opacity", OFFSET(params[1].opacity), AV_OPT_TYPE_DOUBLE, { .dbl = 1 }, 0, 1, FLAGS },
359  { "c2_opacity", "set color component #2 opacity", OFFSET(params[2].opacity), AV_OPT_TYPE_DOUBLE, { .dbl = 1 }, 0, 1, FLAGS },
360  { "c3_opacity", "set color component #3 opacity", OFFSET(params[3].opacity), AV_OPT_TYPE_DOUBLE, { .dbl = 1 }, 0, 1, FLAGS },
361  { "all_opacity", "set opacity for all color components", OFFSET(all_opacity), AV_OPT_TYPE_DOUBLE, { .dbl = 1 }, 0, 1, FLAGS },
362 
363  { NULL }
364 };
365 
366 AVFILTER_DEFINE_CLASS(blend_vulkan);
367 
369  {
370  .name = "top",
371  .type = AVMEDIA_TYPE_VIDEO,
372  .config_props = &ff_vk_filter_config_input,
373  },
374  {
375  .name = "bottom",
376  .type = AVMEDIA_TYPE_VIDEO,
377  .config_props = &ff_vk_filter_config_input,
378  },
379 };
380 
381 
383  {
384  .name = "default",
385  .type = AVMEDIA_TYPE_VIDEO,
386  .config_props = &config_props_output,
387  }
388 };
389 
391  .name = "blend_vulkan",
392  .description = NULL_IF_CONFIG_SMALL("Blend two video frames in Vulkan"),
393  .priv_size = sizeof(BlendVulkanContext),
394  .init = &init,
395  .uninit = &uninit,
396  .activate = &activate,
400  .priv_class = &blend_vulkan_class,
401  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
402  .flags = AVFILTER_FLAG_HWDEVICE,
403  .process_command = &process_command,
404 };
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_framesync_configure
int ff_framesync_configure(FFFrameSync *fs)
Configure a frame sync structure.
Definition: framesync.c:137
ff_vf_blend_vulkan
const AVFilter ff_vf_blend_vulkan
Definition: vf_blend_vulkan.c:390
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
ff_framesync_uninit
void ff_framesync_uninit(FFFrameSync *fs)
Free all memory currently allocated.
Definition: framesync.c:301
out
FILE * out
Definition: movenc.c:55
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1061
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
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
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:269
config_props_output
static int config_props_output(AVFilterLink *outlink)
Definition: vf_blend_vulkan.c:304
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
mode
Definition: swscale.c:52
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:403
init_blend_func
static void init_blend_func(FilterParamsVulkan *param)
Definition: vf_blend_vulkan.c:76
ff_vk_filter_init
int ff_vk_filter_init(AVFilterContext *avctx)
General lavfi IO functions.
Definition: vulkan_filter.c:233
B
#define B
Definition: vf_blend_vulkan.c:69
AVOption
AVOption.
Definition: opt.h:429
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
BlendVulkanContext::e
FFVkExecPool e
Definition: vf_blend_vulkan.c:49
FFFrameSync
Frame sync structure.
Definition: framesync.h:168
video.h
MULTIPLY
#define MULTIPLY(var, const)
Definition: 4xm.c:165
AV_PIX_FMT_VULKAN
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition: pixfmt.h:379
BLEND_NB
@ BLEND_NB
Definition: blend.h:69
BlendVulkanContext::all_opacity
double all_opacity
Definition: vf_blend_vulkan.c:55
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3210
BlendVulkanContext::fs
FFFrameSync fs
Definition: vf_blend_vulkan.c:46
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
init
static av_cold int init(AVFilterContext *avctx)
Definition: vf_blend_vulkan.c:276
BlendVulkanContext::params
FilterParamsVulkan params[4]
Definition: vf_blend_vulkan.c:54
vulkan_filter.h
blend_vulkan_outputs
static const AVFilterPad blend_vulkan_outputs[]
Definition: vf_blend_vulkan.c:382
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
BlendVulkanContext::sampler
VkSampler sampler
Definition: vf_blend_vulkan.c:52
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
BlendVulkanContext::shd
FFVulkanShader shd
Definition: vf_blend_vulkan.c:51
AVFilterPad
A filter pad used for either input or output.
Definition: filters.h:38
OFFSET
#define OFFSET(x)
Definition: vf_blend_vulkan.c:345
AVFilterContext::input_pads
AVFilterPad * input_pads
array of input pads
Definition: avfilter.h:464
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
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
av_cold
#define av_cold
Definition: attributes.h:90
main
int main
Definition: dovi_rpuenc.c:37
blend_vulkan_inputs
static const AVFilterPad blend_vulkan_inputs[]
Definition: vf_blend_vulkan.c:368
s
#define s(width, name)
Definition: cbs_vp9.c:198
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
Definition: opt.h:267
FilterParamsVulkan
Definition: vf_blend_vulkan.c:37
filters.h
FF_VK_REP_FLOAT
@ FF_VK_REP_FLOAT
Definition: vulkan.h:376
ctx
AVFormatContext * ctx
Definition: movenc.c:49
activate
static int activate(AVFilterContext *avctx)
Definition: vf_blend_vulkan.c:339
GLSLD
#define GLSLD(D)
Definition: vulkan.h:59
init_filter
static av_cold int init_filter(AVFilterContext *avctx)
Definition: vf_blend_vulkan.c:125
BlendVulkanContext::initialized
int initialized
Definition: vf_blend_vulkan.c:48
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
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
AVHWFramesContext::sw_format
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
Definition: hwcontext.h:210
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
BLEND_MULTIPLY
@ BLEND_MULTIPLY
Definition: blend.h:42
fs
#define fs(width, name, subs,...)
Definition: cbs_vp9.c:200
DUP_SAMPLER
#define DUP_SAMPLER(x)
Definition: vulkan.h:73
BlendMode
BlendMode
Definition: blend.h:27
AVFilterContext::inputs
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:465
ff_vk_filter_config_output
int ff_vk_filter_config_output(AVFilterLink *outlink)
Definition: vulkan_filter.c:209
config_params
static int config_params(AVFilterContext *avctx)
Definition: vf_blend_vulkan.c:92
blend_vulkan_options
static const AVOption blend_vulkan_options[]
Definition: vf_blend_vulkan.c:348
BlendVulkanContext::qf
AVVulkanDeviceQueueFamily * qf
Definition: vf_blend_vulkan.c:50
FFVulkanContext
Definition: vulkan.h:266
BlendVulkanContext
Definition: vf_blend_vulkan.c:44
A
#define A
Definition: vf_blend_vulkan.c:68
ff_filter_link
static FilterLink * ff_filter_link(AVFilterLink *link)
Definition: filters.h:197
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_filter_process_Nin
int ff_vk_filter_process_Nin(FFVulkanContext *vkctx, FFVkExecPool *e, FFVulkanShader *shd, 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:401
FLAGS
#define FLAGS
Definition: vf_blend_vulkan.c:346
f
f
Definition: af_crystalizer.c:122
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
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:234
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
IN_TOP
#define IN_TOP
Definition: vf_blend_vulkan.c:34
AVFILTER_FLAG_HWDEVICE
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
Definition: avfilter.h:173
size
int size
Definition: twinvq_data.h:10344
FFVulkanShader
Definition: vulkan.h:182
FilterParamsVulkan::opacity
double opacity
Definition: vf_blend_vulkan.c:40
IN_BOTTOM
#define IN_BOTTOM
Definition: vf_blend_vulkan.c:35
FilterParamsVulkan::blend_func
const char * blend_func
Definition: vf_blend_vulkan.c:39
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:900
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
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
FFVkSPIRVCompiler
Definition: vulkan_spirv.h:26
CASE
#define CASE(MODE)
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
BlendVulkanContext::vkctx
FFVulkanContext vkctx
Definition: vf_blend_vulkan.c:45
blend.h
BlendVulkanContext::all_mode
enum BlendMode all_mode
Definition: vf_blend_vulkan.c:56
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
vulkan_spirv.h
AVFilterPad::name
const char * name
Pad name.
Definition: filters.h:44
FFVkSPIRVCompiler::free_shader
void(* free_shader)(struct FFVkSPIRVCompiler *ctx, void **opaque)
Definition: vulkan_spirv.h:31
AVFilter
Filter definition.
Definition: avfilter.h:201
AVHWFramesContext
This struct describes a set or pool of "hardware" frames (i.e.
Definition: hwcontext.h:115
ret
ret
Definition: filter_design.txt:187
FFVulkanContext::vkfn
FFVulkanFunctions vkfn
Definition: vulkan.h:270
FFVkExecPool
Definition: vulkan.h:244
pos
unsigned int pos
Definition: spdifenc.c:414
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
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:754
random_seed.h
framesync.h
uninit
static av_cold void uninit(AVFilterContext *avctx)
Definition: vf_blend_vulkan.c:285
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
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:115
DEFINE_BLEND_MODE
#define DEFINE_BLEND_MODE(MODE, EXPR)
Definition: vf_blend_vulkan.c:59
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
FilterParamsVulkan::mode
enum BlendMode mode
Definition: vf_blend_vulkan.c:41
AVVulkanDeviceContext::act_dev
VkDevice act_dev
Active device.
Definition: hwcontext_vulkan.h:84
FilterParamsVulkan::blend
const char * blend
Definition: vf_blend_vulkan.c:38
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
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:482
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVVulkanDeviceQueueFamily
Definition: hwcontext_vulkan.h:33
FN
#define FN(EXPR)
Definition: vf_blend_vulkan.c:71
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:352
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
FILTER_SINGLE_PIXFMT
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition: filters.h:252
FFVulkanFunctions
Definition: vulkan_functions.h:264
BLEND_NORMAL
@ BLEND_NORMAL
Definition: blend.h:29
AVFilterContext::outputs
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:469