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/opt.h"
25 #include "vulkan_filter.h"
26 
27 #include "filters.h"
28 #include "framesync.h"
29 #include "blend.h"
30 #include "video.h"
31 
32 extern const unsigned char ff_blend_comp_spv_data[];
33 extern const unsigned int ff_blend_comp_spv_len;
34 
35 #define IN_TOP 0
36 #define IN_BOTTOM 1
37 
38 typedef struct FilterParamsVulkan {
39  float opacity[4];
40  int mode[4];
42 
43 typedef struct BlendVulkanContext {
46 
51 
53  float all_opacity;
54  /* enum BlendMode */
55  int all_mode;
57 
58 static int config_params(AVFilterContext *avctx)
59 {
60  BlendVulkanContext *s = avctx->priv;
61 
62  if (s->all_opacity < 1.0) {
63  s->params.opacity[0] = s->all_opacity;
64  s->params.opacity[1] = s->all_opacity;
65  s->params.opacity[2] = s->all_opacity;
66  s->params.opacity[3] = s->all_opacity;
67  }
68 
69  if (s->all_mode >= 0) {
70  s->params.mode[0] = s->all_mode;
71  s->params.mode[1] = s->all_mode;
72  s->params.mode[2] = s->all_mode;
73  s->params.mode[3] = s->all_mode;
74  }
75 
76  return 0;
77 }
78 
79 static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
80  char *res, int res_len, int flags)
81 {
82  int ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
83  if (ret < 0)
84  return ret;
85 
86  return config_params(ctx);
87 }
88 
90 {
91  int err = 0;
92  BlendVulkanContext *s = avctx->priv;
93  FFVulkanContext *vkctx = &s->vkctx;
94  const int planes = av_pix_fmt_count_planes(s->vkctx.output_format);
96 
97  config_params(avctx);
98 
99  s->qf = ff_vk_qf_find(vkctx, VK_QUEUE_COMPUTE_BIT, 0);
100  if (!s->qf) {
101  av_log(avctx, AV_LOG_ERROR, "Device has no compute queues\n");
102  err = AVERROR(ENOTSUP);
103  goto fail;
104  }
105 
106  RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL));
107 
108  SPEC_LIST_CREATE(sl, 1, 1*sizeof(uint32_t))
109  SPEC_LIST_ADD(sl, 0, 32, planes);
110 
111  ff_vk_shader_load(&s->shd, VK_SHADER_STAGE_COMPUTE_BIT, sl,
112  (int []) { 32, 32, 1 }, 0);
113 
114  ff_vk_shader_add_push_const(&s->shd, 0, sizeof(s->params),
115  VK_SHADER_STAGE_COMPUTE_BIT);
116 
118  { /* top_images */
119  .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
120  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
121  .elems = planes,
122  },
123  { /* bottom_images */
124  .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
125  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
126  .elems = planes,
127  },
128  { /* output_images */
129  .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
130  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
131  .elems = planes,
132  },
133  };
134  ff_vk_shader_add_descriptor_set(vkctx, &s->shd, desc, 3, 0, 0);
135 
136  RET(ff_vk_shader_link(vkctx, &s->shd,
138  ff_blend_comp_spv_len, "main"));
139 
140  RET(ff_vk_shader_register_exec(vkctx, &s->e, &s->shd));
141 
142  s->initialized = 1;
143 
144 fail:
145  return err;
146 }
147 
149 {
150  int err;
151  AVFilterContext *avctx = fs->parent;
152  BlendVulkanContext *s = avctx->priv;
153  AVFilterLink *outlink = avctx->outputs[0];
154  AVFrame *top, *bottom, *out;
155 
156  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
157  if (!out) {
158  err = AVERROR(ENOMEM);
159  goto fail;
160  }
161 
162  RET(ff_framesync_get_frame(fs, IN_TOP, &top, 0));
163  RET(ff_framesync_get_frame(fs, IN_BOTTOM, &bottom, 0));
164 
165  RET(av_frame_copy_props(out, top));
166 
167  if (!s->initialized) {
169  AVHWFramesContext *bottom_fc = (AVHWFramesContext*)bottom->hw_frames_ctx->data;
170  if (top_fc->sw_format != bottom_fc->sw_format) {
171  av_log(avctx, AV_LOG_ERROR,
172  "Currently the sw format of the bottom video need to match the top!\n");
173  err = AVERROR(EINVAL);
174  goto fail;
175  }
176  RET(init_filter(avctx));
177  }
178 
179  RET(ff_vk_filter_process_Nin(&s->vkctx, &s->e, &s->shd,
180  out, (AVFrame *[]){ top, bottom }, 2,
181  VK_NULL_HANDLE, 1, &s->params, sizeof(s->params)));
182 
183  return ff_filter_frame(outlink, out);
184 
185 fail:
186  av_frame_free(&out);
187  return err;
188 }
189 
190 static av_cold int init(AVFilterContext *avctx)
191 {
192  BlendVulkanContext *s = avctx->priv;
193 
194  s->fs.on_event = blend_frame;
195 
196  return ff_vk_filter_init(avctx);
197 }
198 
199 static av_cold void uninit(AVFilterContext *avctx)
200 {
201  BlendVulkanContext *s = avctx->priv;
202  FFVulkanContext *vkctx = &s->vkctx;
203 
204  ff_vk_exec_pool_free(vkctx, &s->e);
205  ff_vk_shader_free(vkctx, &s->shd);
206 
207  ff_vk_uninit(&s->vkctx);
208  ff_framesync_uninit(&s->fs);
209 
210  s->initialized = 0;
211 }
212 
213 static int config_props_output(AVFilterLink *outlink)
214 {
215  int err;
216  FilterLink *outl = ff_filter_link(outlink);
217  AVFilterContext *avctx = outlink->src;
218  BlendVulkanContext *s = avctx->priv;
219  AVFilterLink *toplink = avctx->inputs[IN_TOP];
220  FilterLink *tl = ff_filter_link(toplink);
221  AVFilterLink *bottomlink = avctx->inputs[IN_BOTTOM];
222 
223  if (toplink->w != bottomlink->w || toplink->h != bottomlink->h) {
224  av_log(avctx, AV_LOG_ERROR, "First input link %s parameters "
225  "(size %dx%d) do not match the corresponding "
226  "second input link %s parameters (size %dx%d)\n",
227  avctx->input_pads[IN_TOP].name, toplink->w, toplink->h,
228  avctx->input_pads[IN_BOTTOM].name, bottomlink->w, bottomlink->h);
229  return AVERROR(EINVAL);
230  }
231 
232  outlink->sample_aspect_ratio = toplink->sample_aspect_ratio;
233  outl->frame_rate = tl->frame_rate;
234 
236 
237  RET(ff_framesync_init_dualinput(&s->fs, avctx));
238 
240  outlink->time_base = s->fs.time_base;
241 
242  RET(config_params(avctx));
243 
244 fail:
245  return err;
246 }
247 
248 static int activate(AVFilterContext *avctx)
249 {
250  BlendVulkanContext *s = avctx->priv;
251  return ff_framesync_activate(&s->fs);
252 }
253 
254 #define OFFSET(x) offsetof(BlendVulkanContext, x)
255 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
256 
257 static const AVOption blend_vulkan_options[] = {
258  { "c0_mode", "set component #0 blend mode", OFFSET(params.mode[0]), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, BLEND_NB - 1, FLAGS, .unit = "mode" },
259  { "c1_mode", "set component #1 blend mode", OFFSET(params.mode[1]), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, BLEND_NB - 1, FLAGS, .unit = "mode" },
260  { "c2_mode", "set component #2 blend mode", OFFSET(params.mode[2]), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, BLEND_NB - 1, FLAGS, .unit = "mode" },
261  { "c3_mode", "set component #3 blend mode", OFFSET(params.mode[3]), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, BLEND_NB - 1, FLAGS, .unit = "mode" },
262  { "all_mode", "set blend mode for all components", OFFSET(all_mode), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, BLEND_NB - 1, FLAGS, .unit = "mode" },
263  { "addition", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_ADDITION}, 0, 0, FLAGS, .unit = "mode" },
264  { "addition128","", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_GRAINMERGE}, 0, 0, FLAGS, .unit = "mode" },
265  { "grainmerge", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_GRAINMERGE}, 0, 0, FLAGS, .unit = "mode" },
266  { "and", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_AND}, 0, 0, FLAGS, .unit = "mode" },
267  { "average", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_AVERAGE}, 0, 0, FLAGS, .unit = "mode" },
268  { "burn", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_BURN}, 0, 0, FLAGS, .unit = "mode" },
269  { "darken", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_DARKEN}, 0, 0, FLAGS, .unit = "mode" },
270  { "difference", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_DIFFERENCE}, 0, 0, FLAGS, .unit = "mode" },
271  { "difference128", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_GRAINEXTRACT}, 0, 0, FLAGS, .unit = "mode" },
272  { "grainextract", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_GRAINEXTRACT}, 0, 0, FLAGS, .unit = "mode" },
273  { "divide", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_DIVIDE}, 0, 0, FLAGS, .unit = "mode" },
274  { "dodge", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_DODGE}, 0, 0, FLAGS, .unit = "mode" },
275  { "exclusion", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_EXCLUSION}, 0, 0, FLAGS, .unit = "mode" },
276  { "extremity", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_EXTREMITY}, 0, 0, FLAGS, .unit = "mode" },
277  { "freeze", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_FREEZE}, 0, 0, FLAGS, .unit = "mode" },
278  { "glow", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_GLOW}, 0, 0, FLAGS, .unit = "mode" },
279  { "hardlight", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_HARDLIGHT}, 0, 0, FLAGS, .unit = "mode" },
280  { "hardmix", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_HARDMIX}, 0, 0, FLAGS, .unit = "mode" },
281  { "heat", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_HEAT}, 0, 0, FLAGS, .unit = "mode" },
282  { "lighten", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_LIGHTEN}, 0, 0, FLAGS, .unit = "mode" },
283  { "linearlight","", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_LINEARLIGHT},0, 0, FLAGS, .unit = "mode" },
284  { "multiply", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_MULTIPLY}, 0, 0, FLAGS, .unit = "mode" },
285  { "multiply128","", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_MULTIPLY128},0, 0, FLAGS, .unit = "mode" },
286  { "negation", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_NEGATION}, 0, 0, FLAGS, .unit = "mode" },
287  { "normal", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_NORMAL}, 0, 0, FLAGS, .unit = "mode" },
288  { "or", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_OR}, 0, 0, FLAGS, .unit = "mode" },
289  { "overlay", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_OVERLAY}, 0, 0, FLAGS, .unit = "mode" },
290  { "phoenix", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_PHOENIX}, 0, 0, FLAGS, .unit = "mode" },
291  { "pinlight", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_PINLIGHT}, 0, 0, FLAGS, .unit = "mode" },
292  { "reflect", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_REFLECT}, 0, 0, FLAGS, .unit = "mode" },
293  { "screen", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_SCREEN}, 0, 0, FLAGS, .unit = "mode" },
294  { "softlight", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_SOFTLIGHT}, 0, 0, FLAGS, .unit = "mode" },
295  { "subtract", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_SUBTRACT}, 0, 0, FLAGS, .unit = "mode" },
296  { "vividlight", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_VIVIDLIGHT}, 0, 0, FLAGS, .unit = "mode" },
297  { "xor", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_XOR}, 0, 0, FLAGS, .unit = "mode" },
298  { "softdifference","", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_SOFTDIFFERENCE}, 0, 0, FLAGS, .unit = "mode" },
299  { "geometric", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_GEOMETRIC}, 0, 0, FLAGS, .unit = "mode" },
300  { "harmonic", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_HARMONIC}, 0, 0, FLAGS, .unit = "mode" },
301  { "bleach", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_BLEACH}, 0, 0, FLAGS, .unit = "mode" },
302  { "stain", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_STAIN}, 0, 0, FLAGS, .unit = "mode" },
303  { "interpolate","", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_INTERPOLATE},0, 0, FLAGS, .unit = "mode" },
304  { "hardoverlay","", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_HARDOVERLAY},0, 0, FLAGS, .unit = "mode" },
305 
306  { "c0_opacity", "set color component #0 opacity", OFFSET(params.opacity[0]), AV_OPT_TYPE_FLOAT, { .dbl = 1.0 }, 0, 1, FLAGS },
307  { "c1_opacity", "set color component #1 opacity", OFFSET(params.opacity[1]), AV_OPT_TYPE_FLOAT, { .dbl = 1.0 }, 0, 1, FLAGS },
308  { "c2_opacity", "set color component #2 opacity", OFFSET(params.opacity[2]), AV_OPT_TYPE_FLOAT, { .dbl = 1.0 }, 0, 1, FLAGS },
309  { "c3_opacity", "set color component #3 opacity", OFFSET(params.opacity[3]), AV_OPT_TYPE_FLOAT, { .dbl = 1.0 }, 0, 1, FLAGS },
310  { "all_opacity", "set opacity for all color components", OFFSET(all_opacity), AV_OPT_TYPE_FLOAT, { .dbl = 1.0 }, 0, 1, FLAGS },
311 
312  { NULL }
313 };
314 
315 AVFILTER_DEFINE_CLASS(blend_vulkan);
316 
318  {
319  .name = "top",
320  .type = AVMEDIA_TYPE_VIDEO,
321  .config_props = &ff_vk_filter_config_input,
322  },
323  {
324  .name = "bottom",
325  .type = AVMEDIA_TYPE_VIDEO,
326  .config_props = &ff_vk_filter_config_input,
327  },
328 };
329 
330 
332  {
333  .name = "default",
334  .type = AVMEDIA_TYPE_VIDEO,
335  .config_props = &config_props_output,
336  }
337 };
338 
340  .p.name = "blend_vulkan",
341  .p.description = NULL_IF_CONFIG_SMALL("Blend two video frames in Vulkan"),
342  .p.priv_class = &blend_vulkan_class,
343  .p.flags = AVFILTER_FLAG_HWDEVICE,
344  .priv_size = sizeof(BlendVulkanContext),
345  .init = &init,
346  .uninit = &uninit,
347  .activate = &activate,
351  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
352  .process_command = &process_command,
353 };
BLEND_GLOW
@ BLEND_GLOW
Definition: blend.h:56
flags
const SwsFlags flags[]
Definition: swscale.c:72
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:89
ff_framesync_configure
int ff_framesync_configure(FFFrameSync *fs)
Configure a frame sync structure.
Definition: framesync.c:137
BlendVulkanContext::all_mode
int all_mode
Definition: vf_blend_vulkan.c:55
BLEND_EXCLUSION
@ BLEND_EXCLUSION
Definition: blend.h:39
BlendVulkanContext::all_opacity
float all_opacity
Definition: vf_blend_vulkan.c:53
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:2820
ff_framesync_uninit
void ff_framesync_uninit(FFFrameSync *fs)
Free all memory currently allocated.
Definition: framesync.c:301
out
static 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:1067
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
RET
#define RET(x)
Definition: vulkan.h:68
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:357
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:213
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:208
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:64
mode
Definition: swscale.c:60
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:434
ff_vk_filter_init
int ff_vk_filter_init(AVFilterContext *avctx)
General lavfi IO functions.
Definition: vulkan_filter.c:233
AVOption
AVOption.
Definition: opt.h:429
FILTER_SINGLE_PIXFMT
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition: filters.h:254
filters.h
BLEND_NEGATION
@ BLEND_NEGATION
Definition: blend.h:43
ff_vk_uninit
void ff_vk_uninit(FFVulkanContext *s)
Frees main context.
Definition: vulkan.c:2846
SPEC_LIST_ADD
#define SPEC_LIST_ADD(name, idx, val_bits, val)
Definition: vulkan.h:86
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:220
BlendVulkanContext::e
FFVkExecPool e
Definition: vf_blend_vulkan.c:48
FFFrameSync
Frame sync structure.
Definition: framesync.h:168
BLEND_HARMONIC
@ BLEND_HARMONIC
Definition: blend.h:64
video.h
BLEND_ADDITION
@ BLEND_ADDITION
Definition: blend.h:30
BLEND_MULTIPLY128
@ BLEND_MULTIPLY128
Definition: blend.h:58
AV_PIX_FMT_VULKAN
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition: pixfmt.h:379
BLEND_GEOMETRIC
@ BLEND_GEOMETRIC
Definition: blend.h:63
BLEND_BLEACH
@ BLEND_BLEACH
Definition: blend.h:65
BLEND_NB
@ BLEND_NB
Definition: blend.h:69
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, uint32_t wgc_z, void *push_src, size_t push_size)
Up to 16 inputs, one output.
Definition: vulkan_filter.c:409
FilterParamsVulkan::opacity
float opacity[4]
Definition: vf_blend_vulkan.c:39
BLEND_DIVIDE
@ BLEND_DIVIDE
Definition: blend.h:37
BLEND_PHOENIX
@ BLEND_PHOENIX
Definition: blend.h:46
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3496
BlendVulkanContext::fs
FFFrameSync fs
Definition: vf_blend_vulkan.c:45
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:289
fail
#define fail()
Definition: checkasm.h:224
init
static av_cold int init(AVFilterContext *avctx)
Definition: vf_blend_vulkan.c:190
vulkan_filter.h
blend_vulkan_outputs
static const AVFilterPad blend_vulkan_outputs[]
Definition: vf_blend_vulkan.c:331
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:2613
BLEND_AND
@ BLEND_AND
Definition: blend.h:31
BlendVulkanContext::shd
FFVulkanShader shd
Definition: vf_blend_vulkan.c:50
AVFilterPad
A filter pad used for either input or output.
Definition: filters.h:40
BLEND_SOFTLIGHT
@ BLEND_SOFTLIGHT
Definition: blend.h:50
OFFSET
#define OFFSET(x)
Definition: vf_blend_vulkan.c:254
AVFilterContext::input_pads
AVFilterPad * input_pads
array of input pads
Definition: avfilter.h:281
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:210
av_cold
#define av_cold
Definition: attributes.h:111
FFFilter
Definition: filters.h:267
blend_vulkan_inputs
static const AVFilterPad blend_vulkan_inputs[]
Definition: vf_blend_vulkan.c:317
s
#define s(width, name)
Definition: cbs_vp9.c:198
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:265
BLEND_OR
@ BLEND_OR
Definition: blend.h:44
BLEND_SCREEN
@ BLEND_SCREEN
Definition: blend.h:49
ff_filter_link
static FilterLink * ff_filter_link(AVFilterLink *link)
Definition: filters.h:199
FilterParamsVulkan
Definition: vf_blend_vulkan.c:38
ctx
static AVFormatContext * ctx
Definition: movenc.c:49
activate
static int activate(AVFilterContext *avctx)
Definition: vf_blend_vulkan.c:248
init_filter
static av_cold int init_filter(AVFilterContext *avctx)
Definition: vf_blend_vulkan.c:89
BlendVulkanContext::initialized
int initialized
Definition: vf_blend_vulkan.c:47
ff_vk_exec_pool_free
void ff_vk_exec_pool_free(FFVulkanContext *s, FFVkExecPool *pool)
Definition: vulkan.c:299
BLEND_EXTREMITY
@ BLEND_EXTREMITY
Definition: blend.h:61
BLEND_PINLIGHT
@ BLEND_PINLIGHT
Definition: blend.h:47
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:213
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:599
BLEND_MULTIPLY
@ BLEND_MULTIPLY
Definition: blend.h:42
fs
#define fs(width, name, subs,...)
Definition: cbs_vp9.c:200
AVFilterContext::inputs
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:282
ff_vk_filter_config_output
int ff_vk_filter_config_output(AVFilterLink *outlink)
Definition: vulkan_filter.c:209
ff_vk_shader_link
int ff_vk_shader_link(FFVulkanContext *s, FFVulkanShader *shd, const char *spirv, size_t spirv_len, const char *entrypoint)
Link a shader into an executable.
Definition: vulkan.c:2386
config_params
static int config_params(AVFilterContext *avctx)
Definition: vf_blend_vulkan.c:58
SPEC_LIST_CREATE
#define SPEC_LIST_CREATE(name, max_length, max_size)
Definition: vulkan.h:76
blend_vulkan_options
static const AVOption blend_vulkan_options[]
Definition: vf_blend_vulkan.c:257
BlendVulkanContext::qf
AVVulkanDeviceQueueFamily * qf
Definition: vf_blend_vulkan.c:49
FFVulkanContext
Definition: vulkan.h:312
BLEND_SUBTRACT
@ BLEND_SUBTRACT
Definition: blend.h:51
BlendVulkanContext
Definition: vf_blend_vulkan.c:43
BLEND_FREEZE
@ BLEND_FREEZE
Definition: blend.h:60
ff_blend_comp_spv_len
const unsigned int ff_blend_comp_spv_len
BLEND_LIGHTEN
@ BLEND_LIGHTEN
Definition: blend.h:41
BLEND_HEAT
@ BLEND_HEAT
Definition: blend.h:59
FLAGS
#define FLAGS
Definition: vf_blend_vulkan.c:255
BlendVulkanContext::params
FilterParamsVulkan params
Definition: vf_blend_vulkan.c:52
FFVulkanDescriptorSetBinding
Definition: vulkan.h:112
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:148
IN_TOP
#define IN_TOP
Definition: vf_blend_vulkan.c:35
AVFILTER_FLAG_HWDEVICE
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
Definition: avfilter.h:188
BLEND_DODGE
@ BLEND_DODGE
Definition: blend.h:38
FFVulkanShader
Definition: vulkan.h:225
IN_BOTTOM
#define IN_BOTTOM
Definition: vf_blend_vulkan.c:36
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:905
planes
static const struct @585 planes[]
BLEND_INTERPOLATE
@ BLEND_INTERPOLATE
Definition: blend.h:67
BLEND_HARDLIGHT
@ BLEND_HARDLIGHT
Definition: blend.h:40
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
Definition: opt.h:271
BlendVulkanContext::vkctx
FFVulkanContext vkctx
Definition: vf_blend_vulkan.c:44
blend.h
BLEND_STAIN
@ BLEND_STAIN
Definition: blend.h:66
BLEND_SOFTDIFFERENCE
@ BLEND_SOFTDIFFERENCE
Definition: blend.h:62
ff_blend_comp_spv_data
const unsigned char ff_blend_comp_spv_data[]
AVFilterPad::name
const char * name
Pad name.
Definition: filters.h:46
BLEND_VIVIDLIGHT
@ BLEND_VIVIDLIGHT
Definition: blend.h:52
BLEND_DIFFERENCE
@ BLEND_DIFFERENCE
Definition: blend.h:35
AVHWFramesContext
This struct describes a set or pool of "hardware" frames (i.e.
Definition: hwcontext.h:118
BLEND_HARDMIX
@ BLEND_HARDMIX
Definition: blend.h:54
ret
ret
Definition: filter_design.txt:187
BLEND_GRAINMERGE
@ BLEND_GRAINMERGE
Definition: blend.h:57
FFVkExecPool
Definition: vulkan.h:290
ff_vk_shader_add_push_const
int ff_vk_shader_add_push_const(FFVulkanShader *shd, int offset, int size, VkShaderStageFlagBits stage)
Add/update push constants for execution.
Definition: vulkan.c:1499
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:264
ff_vk_qf_find
AVVulkanDeviceQueueFamily * ff_vk_qf_find(FFVulkanContext *s, VkQueueFlagBits dev_family, VkVideoCodecOperationFlagBitsKHR vid_ops)
Chooses an appropriate QF.
Definition: vulkan.c:286
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:731
ff_vk_shader_add_descriptor_set
int ff_vk_shader_add_descriptor_set(FFVulkanContext *s, FFVulkanShader *shd, const FFVulkanDescriptorSetBinding *desc, int nb, int singular, int print_to_shader_only)
Add descriptor to a shader.
Definition: vulkan.c:2513
BLEND_HARDOVERLAY
@ BLEND_HARDOVERLAY
Definition: blend.h:68
framesync.h
uninit
static av_cold void uninit(AVFilterContext *avctx)
Definition: vf_blend_vulkan.c:199
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:79
BLEND_XOR
@ BLEND_XOR
Definition: blend.h:53
AVFilterContext
An instance of a filter.
Definition: avfilter.h:274
desc
const char * desc
Definition: libsvtav1.c:82
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:200
FFFilter::p
AVFilter p
The public AVFilter.
Definition: filters.h:271
BLEND_DARKEN
@ BLEND_DARKEN
Definition: blend.h:34
ff_vf_blend_vulkan
const FFFilter ff_vf_blend_vulkan
Definition: vf_blend_vulkan.c:339
BLEND_AVERAGE
@ BLEND_AVERAGE
Definition: blend.h:32
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVVulkanDeviceQueueFamily
Definition: hwcontext_vulkan.h:33
BLEND_BURN
@ BLEND_BURN
Definition: blend.h:33
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
BLEND_REFLECT
@ BLEND_REFLECT
Definition: blend.h:48
BLEND_GRAINEXTRACT
@ BLEND_GRAINEXTRACT
Definition: blend.h:36
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
ff_vk_shader_load
int ff_vk_shader_load(FFVulkanShader *shd, VkPipelineStageFlags stage, VkSpecializationInfo *spec, uint32_t wg_size[3], uint32_t required_subgroup_size)
Initialize a shader object.
Definition: vulkan.c:2103
BLEND_LINEARLIGHT
@ BLEND_LINEARLIGHT
Definition: blend.h:55
BLEND_NORMAL
@ BLEND_NORMAL
Definition: blend.h:29
BLEND_OVERLAY
@ BLEND_OVERLAY
Definition: blend.h:45
AVFilterContext::outputs
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:286