FFmpeg
vf_overlay_vulkan.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) Lynne
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include "libavutil/random_seed.h"
22 #include "libavutil/opt.h"
23 #include "libavutil/vulkan_spirv.h"
24 #include "vulkan_filter.h"
25 
26 #include "filters.h"
27 #include "framesync.h"
28 #include "video.h"
29 
30 typedef struct OverlayVulkanContext {
33 
38  VkSampler sampler;
39 
40  /* Push constants / options */
41  struct {
44  } opts;
45 
46  int overlay_x;
47  int overlay_y;
48  int overlay_w;
49  int overlay_h;
51 
52 static const char overlay_noalpha[] = {
53  C(0, void overlay_noalpha(int i, ivec2 pos) )
54  C(0, { )
55  C(1, if ((o_offset[i].x <= pos.x) && (o_offset[i].y <= pos.y) &&
56  (pos.x < (o_offset[i].x + o_size[i].x)) &&
57  (pos.y < (o_offset[i].y + o_size[i].y))) { )
58  C(2, vec4 res = texture(overlay_img[i], pos - o_offset[i]); )
59  C(2, imageStore(output_img[i], pos, res); )
60  C(1, } else { )
61  C(2, vec4 res = texture(main_img[i], pos); )
62  C(2, imageStore(output_img[i], pos, res); )
63  C(1, } )
64  C(0, } )
65 };
66 
67 static const char overlay_alpha[] = {
68  C(0, void overlay_alpha_opaque(int i, ivec2 pos) )
69  C(0, { )
70  C(1, vec4 res = texture(main_img[i], pos); )
71  C(1, if ((o_offset[i].x <= pos.x) && (o_offset[i].y <= pos.y) &&
72  (pos.x < (o_offset[i].x + o_size[i].x)) &&
73  (pos.y < (o_offset[i].y + o_size[i].y))) { )
74  C(2, vec4 ovr = texture(overlay_img[i], pos - o_offset[i]); )
75  C(2, res = ovr * ovr.a + res * (1.0f - ovr.a); )
76  C(2, res.a = 1.0f; )
77  C(2, imageStore(output_img[i], pos, res); )
78  C(1, } )
79  C(1, imageStore(output_img[i], pos, res); )
80  C(0, } )
81 };
82 
84 {
85  int err;
86  uint8_t *spv_data;
87  size_t spv_len;
88  void *spv_opaque = NULL;
89  OverlayVulkanContext *s = ctx->priv;
90  FFVulkanContext *vkctx = &s->vkctx;
91  const int planes = av_pix_fmt_count_planes(s->vkctx.output_format);
92  const int ialpha = av_pix_fmt_desc_get(s->vkctx.input_format)->flags & AV_PIX_FMT_FLAG_ALPHA;
93  const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(s->vkctx.output_format);
94  FFVulkanShader *shd = &s->shd;
95  FFVkSPIRVCompiler *spv;
97 
98  spv = ff_vk_spirv_init();
99  if (!spv) {
100  av_log(ctx, AV_LOG_ERROR, "Unable to initialize SPIR-V compiler!\n");
101  return AVERROR_EXTERNAL;
102  }
103 
104  s->qf = ff_vk_qf_find(vkctx, VK_QUEUE_COMPUTE_BIT, 0);
105  if (!s->qf) {
106  av_log(ctx, AV_LOG_ERROR, "Device has no compute queues\n");
107  err = AVERROR(ENOTSUP);
108  goto fail;
109  }
110 
111  RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL));
112  RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_NEAREST));
113  RET(ff_vk_shader_init(vkctx, &s->shd, "overlay",
114  VK_SHADER_STAGE_COMPUTE_BIT,
115  NULL, 0,
116  32, 32, 1,
117  0));
118 
119  GLSLC(0, layout(push_constant, std430) uniform pushConstants { );
120  GLSLC(1, ivec2 o_offset[3]; );
121  GLSLC(1, ivec2 o_size[3]; );
122  GLSLC(0, }; );
123  GLSLC(0, );
124 
125  ff_vk_shader_add_push_const(&s->shd, 0, sizeof(s->opts),
126  VK_SHADER_STAGE_COMPUTE_BIT);
127 
129  {
130  .name = "main_img",
131  .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
132  .dimensions = 2,
133  .elems = planes,
134  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
135  .samplers = DUP_SAMPLER(s->sampler),
136  },
137  {
138  .name = "overlay_img",
139  .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
140  .dimensions = 2,
141  .elems = planes,
142  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
143  .samplers = DUP_SAMPLER(s->sampler),
144  },
145  {
146  .name = "output_img",
147  .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
148  .mem_layout = ff_vk_shader_rep_fmt(s->vkctx.output_format, FF_VK_REP_FLOAT),
149  .mem_quali = "writeonly",
150  .dimensions = 2,
151  .elems = planes,
152  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
153  },
154  };
155 
156  RET(ff_vk_shader_add_descriptor_set(vkctx, &s->shd, desc, 3, 0, 0));
157 
159  GLSLD( overlay_alpha );
160  GLSLC(0, void main() );
161  GLSLC(0, { );
162  GLSLC(1, ivec2 pos = ivec2(gl_GlobalInvocationID.xy); );
163  GLSLF(1, int planes = %i; ,planes);
164  GLSLC(1, for (int i = 0; i < planes; i++) { );
165  if (ialpha)
166  GLSLC(2, overlay_alpha_opaque(i, pos); );
167  else
168  GLSLC(2, overlay_noalpha(i, pos); );
169  GLSLC(1, } );
170  GLSLC(0, } );
171 
172  RET(spv->compile_shader(vkctx, spv, shd, &spv_data, &spv_len, "main",
173  &spv_opaque));
174  RET(ff_vk_shader_link(vkctx, shd, spv_data, spv_len, "main"));
175 
176  RET(ff_vk_shader_register_exec(vkctx, &s->e, &s->shd));
177 
178  s->opts.o_offset[0] = s->overlay_x;
179  s->opts.o_offset[1] = s->overlay_y;
180  s->opts.o_offset[2] = s->opts.o_offset[0] >> pix_desc->log2_chroma_w;
181  s->opts.o_offset[3] = s->opts.o_offset[1] >> pix_desc->log2_chroma_h;
182  s->opts.o_offset[4] = s->opts.o_offset[0] >> pix_desc->log2_chroma_w;
183  s->opts.o_offset[5] = s->opts.o_offset[1] >> pix_desc->log2_chroma_h;
184 
185  s->opts.o_size[0] = s->overlay_w;
186  s->opts.o_size[1] = s->overlay_h;
187  s->opts.o_size[2] = s->opts.o_size[0] >> pix_desc->log2_chroma_w;
188  s->opts.o_size[3] = s->opts.o_size[1] >> pix_desc->log2_chroma_h;
189  s->opts.o_size[4] = s->opts.o_size[0] >> pix_desc->log2_chroma_w;
190  s->opts.o_size[5] = s->opts.o_size[1] >> pix_desc->log2_chroma_h;
191 
192  s->initialized = 1;
193 
194 fail:
195  if (spv_opaque)
196  spv->free_shader(spv, &spv_opaque);
197  if (spv)
198  spv->uninit(&spv);
199 
200  return err;
201 }
202 
204 {
205  int err;
206  AVFilterContext *ctx = fs->parent;
207  OverlayVulkanContext *s = ctx->priv;
208  AVFilterLink *outlink = ctx->outputs[0];
209  AVFrame *input_main, *input_overlay, *out;
210 
211  err = ff_framesync_get_frame(fs, 0, &input_main, 0);
212  if (err < 0)
213  goto fail;
214  err = ff_framesync_get_frame(fs, 1, &input_overlay, 0);
215  if (err < 0)
216  goto fail;
217 
218  if (!input_main || !input_overlay)
219  return 0;
220 
221  if (!s->initialized) {
222  AVHWFramesContext *main_fc = (AVHWFramesContext*)input_main->hw_frames_ctx->data;
223  AVHWFramesContext *overlay_fc = (AVHWFramesContext*)input_overlay->hw_frames_ctx->data;
224  if (main_fc->sw_format != overlay_fc->sw_format) {
225  av_log(ctx, AV_LOG_ERROR, "Mismatching sw formats!\n");
226  return AVERROR(EINVAL);
227  }
228 
229  s->overlay_w = input_overlay->width;
230  s->overlay_h = input_overlay->height;
231 
232  RET(init_filter(ctx));
233  }
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_vk_filter_process_Nin(&s->vkctx, &s->e, &s->shd,
242  out, (AVFrame *[]){ input_main, input_overlay }, 2,
243  s->sampler, &s->opts, sizeof(s->opts)));
244 
245  err = av_frame_copy_props(out, input_main);
246  if (err < 0)
247  goto fail;
248 
249  return ff_filter_frame(outlink, out);
250 
251 fail:
252  av_frame_free(&out);
253  return err;
254 }
255 
257 {
258  int err;
259  AVFilterContext *avctx = outlink->src;
260  OverlayVulkanContext *s = avctx->priv;
261 
262  err = ff_vk_filter_config_output(outlink);
263  if (err < 0)
264  return err;
265 
266  err = ff_framesync_init_dualinput(&s->fs, avctx);
267  if (err < 0)
268  return err;
269 
270  return ff_framesync_configure(&s->fs);
271 }
272 
274 {
275  OverlayVulkanContext *s = avctx->priv;
276 
277  return ff_framesync_activate(&s->fs);
278 }
279 
281 {
282  OverlayVulkanContext *s = avctx->priv;
283 
284  s->fs.on_event = &overlay_vulkan_blend;
285 
286  return ff_vk_filter_init(avctx);
287 }
288 
290 {
291  OverlayVulkanContext *s = avctx->priv;
292  FFVulkanContext *vkctx = &s->vkctx;
293  FFVulkanFunctions *vk = &vkctx->vkfn;
294 
295  ff_vk_exec_pool_free(vkctx, &s->e);
296  ff_vk_shader_free(vkctx, &s->shd);
297 
298  if (s->sampler)
299  vk->DestroySampler(vkctx->hwctx->act_dev, s->sampler,
300  vkctx->hwctx->alloc);
301 
302  ff_vk_uninit(&s->vkctx);
303  ff_framesync_uninit(&s->fs);
304 
305  s->initialized = 0;
306 }
307 
308 #define OFFSET(x) offsetof(OverlayVulkanContext, x)
309 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
311  { "x", "Set horizontal offset", OFFSET(overlay_x), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, .flags = FLAGS },
312  { "y", "Set vertical offset", OFFSET(overlay_y), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, .flags = FLAGS },
313  { NULL },
314 };
315 
316 AVFILTER_DEFINE_CLASS(overlay_vulkan);
317 
319  {
320  .name = "main",
321  .type = AVMEDIA_TYPE_VIDEO,
322  .config_props = &ff_vk_filter_config_input,
323  },
324  {
325  .name = "overlay",
326  .type = AVMEDIA_TYPE_VIDEO,
327  .config_props = &ff_vk_filter_config_input,
328  },
329 };
330 
332  {
333  .name = "default",
334  .type = AVMEDIA_TYPE_VIDEO,
335  .config_props = &overlay_vulkan_config_output,
336  },
337 };
338 
340  .p.name = "overlay_vulkan",
341  .p.description = NULL_IF_CONFIG_SMALL("Overlay a source on top of another"),
342  .p.priv_class = &overlay_vulkan_class,
343  .p.flags = AVFILTER_FLAG_HWDEVICE,
344  .priv_size = sizeof(OverlayVulkanContext),
351  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
352 };
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
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:1062
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3170
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
overlay_noalpha
static const char overlay_noalpha[]
Definition: vf_overlay_vulkan.c:52
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:163
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:403
AVFrame::width
int width
Definition: frame.h:475
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
overlay_vulkan_activate
static int overlay_vulkan_activate(AVFilterContext *avctx)
Definition: vf_overlay_vulkan.c:273
overlay_vulkan_config_output
static int overlay_vulkan_config_output(AVFilterLink *outlink)
Definition: vf_overlay_vulkan.c:256
overlay_vulkan_outputs
static const AVFilterPad overlay_vulkan_outputs[]
Definition: vf_overlay_vulkan.c:331
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:203
FFFrameSync
Frame sync structure.
Definition: framesync.h:168
video.h
overlay_vulkan_blend
static int overlay_vulkan_blend(FFFrameSync *fs)
Definition: vf_overlay_vulkan.c:203
AV_PIX_FMT_VULKAN
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition: pixfmt.h:379
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:272
fail
#define fail()
Definition: checkasm.h:193
vulkan_filter.h
ff_vk_shader_register_exec
int ff_vk_shader_register_exec(FFVulkanContext *s, FFVkExecPool *pool, FFVulkanShader *shd)
Register a shader with an exec pool.
Definition: vulkan.c:2204
ff_vk_shader_add_descriptor_set
int ff_vk_shader_add_descriptor_set(FFVulkanContext *s, FFVulkanShader *shd, FFVulkanDescriptorSetBinding *desc, int nb, int singular, int print_to_shader_only)
Add descriptor to a shader.
Definition: vulkan.c:2079
OverlayVulkanContext::opts
struct OverlayVulkanContext::@349 opts
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
FFFilter
Definition: filters.h:265
OverlayVulkanContext::overlay_x
int overlay_x
Definition: vf_overlay_vulkan.c:46
s
#define s(width, name)
Definition: cbs_vp9.c:198
FLAGS
#define FLAGS
Definition: vf_overlay_vulkan.c:309
OverlayVulkanContext::o_offset
int32_t o_offset[2 *3]
Definition: vf_overlay_vulkan.c:42
filters.h
FF_VK_REP_FLOAT
@ FF_VK_REP_FLOAT
Definition: vulkan.h:376
AV_PIX_FMT_FLAG_ALPHA
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
Definition: pixdesc.h:147
ctx
AVFormatContext * ctx
Definition: movenc.c:49
overlay_vulkan_options
static const AVOption overlay_vulkan_options[]
Definition: vf_overlay_vulkan.c:310
OFFSET
#define OFFSET(x)
Definition: vf_overlay_vulkan.c:308
AVPixFmtDescriptor::log2_chroma_w
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:80
GLSLD
#define GLSLD(D)
Definition: vulkan.h:59
ff_vk_exec_pool_free
void ff_vk_exec_pool_free(FFVulkanContext *s, FFVkExecPool *pool)
Definition: vulkan.c:233
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
init_filter
static av_cold int init_filter(AVFilterContext *ctx)
Definition: vf_overlay_vulkan.c:83
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
fs
#define fs(width, name, subs,...)
Definition: cbs_vp9.c:200
DUP_SAMPLER
#define DUP_SAMPLER(x)
Definition: vulkan.h:73
overlay_vulkan_inputs
static const AVFilterPad overlay_vulkan_inputs[]
Definition: vf_overlay_vulkan.c:318
OverlayVulkanContext::overlay_w
int overlay_w
Definition: vf_overlay_vulkan.c:48
activate
filter_frame For filters that do not use the activate() callback
OverlayVulkanContext::e
FFVkExecPool e
Definition: vf_overlay_vulkan.c:35
ff_vk_filter_config_output
int ff_vk_filter_config_output(AVFilterLink *outlink)
Definition: vulkan_filter.c:209
FFVulkanContext
Definition: vulkan.h:266
AVPixFmtDescriptor::flags
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
Definition: pixdesc.h:94
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
overlay_vulkan_init
static av_cold int overlay_vulkan_init(AVFilterContext *avctx)
Definition: vf_overlay_vulkan.c:280
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
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
ff_framesync_init_dualinput
int ff_framesync_init_dualinput(FFFrameSync *fs, AVFilterContext *parent)
Initialize a frame sync structure for dualinput.
Definition: framesync.c:372
planes
static const struct @472 planes[]
AVFILTER_FLAG_HWDEVICE
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
Definition: avfilter.h:171
FFVulkanShader
Definition: vulkan.h:182
OverlayVulkanContext::sampler
VkSampler sampler
Definition: vf_overlay_vulkan.c:38
OverlayVulkanContext
Definition: vf_overlay_vulkan.c:30
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
layout
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 layout
Definition: filter_design.txt:18
uninit
static void uninit(AVBSFContext *ctx)
Definition: pcm_rechunk.c:68
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
overlay_alpha
static const char overlay_alpha[]
Definition: vf_overlay_vulkan.c:67
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
OverlayVulkanContext::shd
FFVulkanShader shd
Definition: vf_overlay_vulkan.c:37
vulkan_spirv.h
AVFilterPad::name
const char * name
Pad name.
Definition: filters.h:44
OverlayVulkanContext::vkctx
FFVulkanContext vkctx
Definition: vf_overlay_vulkan.c:31
FFVkSPIRVCompiler::free_shader
void(* free_shader)(struct FFVkSPIRVCompiler *ctx, void **opaque)
Definition: vulkan_spirv.h:31
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(overlay_vulkan)
AVHWFramesContext
This struct describes a set or pool of "hardware" frames (i.e.
Definition: hwcontext.h:115
FFVulkanContext::vkfn
FFVulkanFunctions vkfn
Definition: vulkan.h:270
FFVkExecPool
Definition: vulkan.h:244
OverlayVulkanContext::o_size
int32_t o_size[2 *3]
Definition: vf_overlay_vulkan.c:43
pos
unsigned int pos
Definition: spdifenc.c:414
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:1231
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:762
AVFrame::height
int height
Definition: frame.h:475
ff_vf_overlay_vulkan
const FFFilter ff_vf_overlay_vulkan
Definition: vf_overlay_vulkan.c:339
random_seed.h
framesync.h
GLSLF
#define GLSLF(N, S,...)
Definition: vulkan.h:54
OverlayVulkanContext::fs
FFFrameSync fs
Definition: vf_overlay_vulkan.c:32
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
overlay_vulkan_uninit
static void overlay_vulkan_uninit(AVFilterContext *avctx)
Definition: vf_overlay_vulkan.c:289
AVFilterContext
An instance of a filter.
Definition: avfilter.h:257
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
FFFilter::p
AVFilter p
The public AVFilter.
Definition: filters.h:269
FFVulkanContext::hwctx
AVVulkanDeviceContext * hwctx
Definition: vulkan.h:295
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
AVVulkanDeviceContext::act_dev
VkDevice act_dev
Active device.
Definition: hwcontext_vulkan.h:84
OverlayVulkanContext::qf
AVVulkanDeviceQueueFamily * qf
Definition: vf_overlay_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:1252
int32_t
int32_t
Definition: audioconvert.c:56
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVVulkanDeviceQueueFamily
Definition: hwcontext_vulkan.h:33
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
FILTER_SINGLE_PIXFMT
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition: filters.h:252
OverlayVulkanContext::initialized
int initialized
Definition: vf_overlay_vulkan.c:34
FFVulkanFunctions
Definition: vulkan_functions.h:263
AVPixFmtDescriptor::log2_chroma_h
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:89
OverlayVulkanContext::overlay_y
int overlay_y
Definition: vf_overlay_vulkan.c:47
OverlayVulkanContext::overlay_h
int overlay_h
Definition: vf_overlay_vulkan.c:49