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 "vulkan_filter.h"
24 #include "vulkan_spirv.h"
25 
26 #include "filters.h"
27 #include "framesync.h"
28 #include "video.h"
29 
30 typedef struct OverlayVulkanContext {
33 
39  VkSampler sampler;
40 
41  /* Push constants / options */
42  struct {
45  } opts;
46 
47  int overlay_x;
48  int overlay_y;
49  int overlay_w;
50  int overlay_h;
52 
53 static const char overlay_noalpha[] = {
54  C(0, void overlay_noalpha(int i, ivec2 pos) )
55  C(0, { )
56  C(1, if ((o_offset[i].x <= pos.x) && (o_offset[i].y <= pos.y) &&
57  (pos.x < (o_offset[i].x + o_size[i].x)) &&
58  (pos.y < (o_offset[i].y + o_size[i].y))) { )
59  C(2, vec4 res = texture(overlay_img[i], pos - o_offset[i]); )
60  C(2, imageStore(output_img[i], pos, res); )
61  C(1, } else { )
62  C(2, vec4 res = texture(main_img[i], pos); )
63  C(2, imageStore(output_img[i], pos, res); )
64  C(1, } )
65  C(0, } )
66 };
67 
68 static const char overlay_alpha[] = {
69  C(0, void overlay_alpha_opaque(int i, ivec2 pos) )
70  C(0, { )
71  C(1, vec4 res = texture(main_img[i], pos); )
72  C(1, if ((o_offset[i].x <= pos.x) && (o_offset[i].y <= pos.y) &&
73  (pos.x < (o_offset[i].x + o_size[i].x)) &&
74  (pos.y < (o_offset[i].y + o_size[i].y))) { )
75  C(2, vec4 ovr = texture(overlay_img[i], pos - o_offset[i]); )
76  C(2, res = ovr * ovr.a + res * (1.0f - ovr.a); )
77  C(2, res.a = 1.0f; )
78  C(2, imageStore(output_img[i], pos, res); )
79  C(1, } )
80  C(1, imageStore(output_img[i], pos, res); )
81  C(0, } )
82 };
83 
85 {
86  int err;
87  uint8_t *spv_data;
88  size_t spv_len;
89  void *spv_opaque = NULL;
90  OverlayVulkanContext *s = ctx->priv;
91  FFVulkanContext *vkctx = &s->vkctx;
92  const int planes = av_pix_fmt_count_planes(s->vkctx.output_format);
93  const int ialpha = av_pix_fmt_desc_get(s->vkctx.input_format)->flags & AV_PIX_FMT_FLAG_ALPHA;
94  const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(s->vkctx.output_format);
95  FFVkSPIRVShader *shd = &s->shd;
96  FFVkSPIRVCompiler *spv;
98 
99  spv = ff_vk_spirv_init();
100  if (!spv) {
101  av_log(ctx, AV_LOG_ERROR, "Unable to initialize SPIR-V compiler!\n");
102  return AVERROR_EXTERNAL;
103  }
104 
105  ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT);
106  RET(ff_vk_exec_pool_init(vkctx, &s->qf, &s->e, s->qf.nb_queues*4, 0, 0, 0, NULL));
107  RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_NEAREST));
108  RET(ff_vk_shader_init(&s->pl, &s->shd, "overlay_compute",
109  VK_SHADER_STAGE_COMPUTE_BIT, 0));
110 
111  ff_vk_shader_set_compute_sizes(&s->shd, 32, 32, 1);
112 
113  GLSLC(0, layout(push_constant, std430) uniform pushConstants { );
114  GLSLC(1, ivec2 o_offset[3]; );
115  GLSLC(1, ivec2 o_size[3]; );
116  GLSLC(0, }; );
117  GLSLC(0, );
118 
119  ff_vk_add_push_constant(&s->pl, 0, sizeof(s->opts),
120  VK_SHADER_STAGE_COMPUTE_BIT);
121 
123  {
124  .name = "main_img",
125  .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
126  .dimensions = 2,
127  .elems = planes,
128  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
129  .samplers = DUP_SAMPLER(s->sampler),
130  },
131  {
132  .name = "overlay_img",
133  .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
134  .dimensions = 2,
135  .elems = planes,
136  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
137  .samplers = DUP_SAMPLER(s->sampler),
138  },
139  {
140  .name = "output_img",
141  .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
142  .mem_layout = ff_vk_shader_rep_fmt(s->vkctx.output_format),
143  .mem_quali = "writeonly",
144  .dimensions = 2,
145  .elems = planes,
146  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
147  },
148  };
149 
150  RET(ff_vk_pipeline_descriptor_set_add(vkctx, &s->pl, shd, desc, 3, 0, 0));
151 
153  GLSLD( overlay_alpha );
154  GLSLC(0, void main() );
155  GLSLC(0, { );
156  GLSLC(1, ivec2 pos = ivec2(gl_GlobalInvocationID.xy); );
157  GLSLF(1, int planes = %i; ,planes);
158  GLSLC(1, for (int i = 0; i < planes; i++) { );
159  if (ialpha)
160  GLSLC(2, overlay_alpha_opaque(i, pos); );
161  else
162  GLSLC(2, overlay_noalpha(i, pos); );
163  GLSLC(1, } );
164  GLSLC(0, } );
165 
166  RET(spv->compile_shader(spv, ctx, shd, &spv_data, &spv_len, "main",
167  &spv_opaque));
168  RET(ff_vk_shader_create(vkctx, shd, spv_data, spv_len, "main"));
169 
170  RET(ff_vk_init_compute_pipeline(vkctx, &s->pl, shd));
171  RET(ff_vk_exec_pipeline_register(vkctx, &s->e, &s->pl));
172 
173  s->opts.o_offset[0] = s->overlay_x;
174  s->opts.o_offset[1] = s->overlay_y;
175  s->opts.o_offset[2] = s->opts.o_offset[0] >> pix_desc->log2_chroma_w;
176  s->opts.o_offset[3] = s->opts.o_offset[1] >> pix_desc->log2_chroma_h;
177  s->opts.o_offset[4] = s->opts.o_offset[0] >> pix_desc->log2_chroma_w;
178  s->opts.o_offset[5] = s->opts.o_offset[1] >> pix_desc->log2_chroma_h;
179 
180  s->opts.o_size[0] = s->overlay_w;
181  s->opts.o_size[1] = s->overlay_h;
182  s->opts.o_size[2] = s->opts.o_size[0] >> pix_desc->log2_chroma_w;
183  s->opts.o_size[3] = s->opts.o_size[1] >> pix_desc->log2_chroma_h;
184  s->opts.o_size[4] = s->opts.o_size[0] >> pix_desc->log2_chroma_w;
185  s->opts.o_size[5] = s->opts.o_size[1] >> pix_desc->log2_chroma_h;
186 
187  s->initialized = 1;
188 
189 fail:
190  if (spv_opaque)
191  spv->free_shader(spv, &spv_opaque);
192  if (spv)
193  spv->uninit(&spv);
194 
195  return err;
196 }
197 
199 {
200  int err;
201  AVFilterContext *ctx = fs->parent;
202  OverlayVulkanContext *s = ctx->priv;
203  AVFilterLink *outlink = ctx->outputs[0];
204  AVFrame *input_main, *input_overlay, *out;
205 
206  err = ff_framesync_get_frame(fs, 0, &input_main, 0);
207  if (err < 0)
208  goto fail;
209  err = ff_framesync_get_frame(fs, 1, &input_overlay, 0);
210  if (err < 0)
211  goto fail;
212 
213  if (!input_main || !input_overlay)
214  return 0;
215 
216  if (!s->initialized) {
217  AVHWFramesContext *main_fc = (AVHWFramesContext*)input_main->hw_frames_ctx->data;
218  AVHWFramesContext *overlay_fc = (AVHWFramesContext*)input_overlay->hw_frames_ctx->data;
219  if (main_fc->sw_format != overlay_fc->sw_format) {
220  av_log(ctx, AV_LOG_ERROR, "Mismatching sw formats!\n");
221  return AVERROR(EINVAL);
222  }
223 
224  s->overlay_w = input_overlay->width;
225  s->overlay_h = input_overlay->height;
226 
227  RET(init_filter(ctx));
228  }
229 
230  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
231  if (!out) {
232  err = AVERROR(ENOMEM);
233  goto fail;
234  }
235 
236  RET(ff_vk_filter_process_Nin(&s->vkctx, &s->e, &s->pl,
237  out, (AVFrame *[]){ input_main, input_overlay }, 2,
238  s->sampler, &s->opts, sizeof(s->opts)));
239 
240  err = av_frame_copy_props(out, input_main);
241  if (err < 0)
242  goto fail;
243 
244  return ff_filter_frame(outlink, out);
245 
246 fail:
247  av_frame_free(&out);
248  return err;
249 }
250 
252 {
253  int err;
254  AVFilterContext *avctx = outlink->src;
255  OverlayVulkanContext *s = avctx->priv;
256 
257  err = ff_vk_filter_config_output(outlink);
258  if (err < 0)
259  return err;
260 
261  err = ff_framesync_init_dualinput(&s->fs, avctx);
262  if (err < 0)
263  return err;
264 
265  return ff_framesync_configure(&s->fs);
266 }
267 
269 {
270  OverlayVulkanContext *s = avctx->priv;
271 
272  return ff_framesync_activate(&s->fs);
273 }
274 
276 {
277  OverlayVulkanContext *s = avctx->priv;
278 
279  s->fs.on_event = &overlay_vulkan_blend;
280 
281  return ff_vk_filter_init(avctx);
282 }
283 
285 {
286  OverlayVulkanContext *s = avctx->priv;
287  FFVulkanContext *vkctx = &s->vkctx;
288  FFVulkanFunctions *vk = &vkctx->vkfn;
289 
290  ff_vk_exec_pool_free(vkctx, &s->e);
291  ff_vk_pipeline_free(vkctx, &s->pl);
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 #define OFFSET(x) offsetof(OverlayVulkanContext, x)
305 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
307  { "x", "Set horizontal offset", OFFSET(overlay_x), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, .flags = FLAGS },
308  { "y", "Set vertical offset", OFFSET(overlay_y), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, .flags = FLAGS },
309  { NULL },
310 };
311 
312 AVFILTER_DEFINE_CLASS(overlay_vulkan);
313 
315  {
316  .name = "main",
317  .type = AVMEDIA_TYPE_VIDEO,
318  .config_props = &ff_vk_filter_config_input,
319  },
320  {
321  .name = "overlay",
322  .type = AVMEDIA_TYPE_VIDEO,
323  .config_props = &ff_vk_filter_config_input,
324  },
325 };
326 
328  {
329  .name = "default",
330  .type = AVMEDIA_TYPE_VIDEO,
331  .config_props = &overlay_vulkan_config_output,
332  },
333 };
334 
336  .name = "overlay_vulkan",
337  .description = NULL_IF_CONFIG_SMALL("Overlay a source on top of another"),
338  .priv_size = sizeof(OverlayVulkanContext),
345  .priv_class = &overlay_vulkan_class,
346  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
347  .flags = AVFILTER_FLAG_HWDEVICE,
348 };
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_vk_pipeline_free
void ff_vk_pipeline_free(FFVulkanContext *s, FFVulkanPipeline *pl)
Definition: vulkan.c:1810
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:302
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:1023
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2965
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:270
overlay_noalpha
static const char overlay_noalpha[]
Definition: vf_overlay_vulkan.c:53
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:228
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:160
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:374
AVFrame::width
int width
Definition: frame.h:446
ff_vk_filter_init
int ff_vk_filter_init(AVFilterContext *avctx)
General lavfi IO functions.
Definition: vulkan_filter.c:243
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:409
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:1379
AVOption
AVOption.
Definition: opt.h:429
overlay_vulkan_activate
static int overlay_vulkan_activate(AVFilterContext *avctx)
Definition: vf_overlay_vulkan.c:268
OverlayVulkanContext::opts
struct OverlayVulkanContext::@343 opts
overlay_vulkan_config_output
static int overlay_vulkan_config_output(AVFilterLink *outlink)
Definition: vf_overlay_vulkan.c:251
overlay_vulkan_outputs
static const AVFilterPad overlay_vulkan_outputs[]
Definition: vf_overlay_vulkan.c:327
ff_vk_uninit
void ff_vk_uninit(FFVulkanContext *s)
Frees main context.
Definition: vulkan.c:1839
FFVkSPIRVCompiler::uninit
void(* uninit)(struct FFVkSPIRVCompiler **ctx)
Definition: vulkan_spirv.h:33
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:205
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:1337
video.h
overlay_vulkan_blend
static int overlay_vulkan_blend(FFFrameSync *fs)
Definition: vf_overlay_vulkan.c:198
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:3005
AVVulkanDeviceContext::alloc
const VkAllocationCallbacks * alloc
Custom memory allocator, else NULL.
Definition: hwcontext_vulkan.h:63
ff_vk_add_push_constant
int ff_vk_add_push_constant(FFVulkanPipeline *pl, int offset, int size, VkShaderStageFlagBits stage)
Add/update push constants for execution.
Definition: vulkan.c:1106
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:472
fail
#define fail()
Definition: checkasm.h:188
vulkan_filter.h
OverlayVulkanContext::pl
FFVulkanPipeline pl
Definition: vf_overlay_vulkan.c:35
ff_vf_overlay_vulkan
const AVFilter ff_vf_overlay_vulkan
Definition: vf_overlay_vulkan.c:335
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
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
av_cold
#define av_cold
Definition: attributes.h:90
main
int main
Definition: dovi_rpuenc.c:37
OverlayVulkanContext::overlay_x
int overlay_x
Definition: vf_overlay_vulkan.c:47
s
#define s(width, name)
Definition: cbs_vp9.c:198
FLAGS
#define FLAGS
Definition: vf_overlay_vulkan.c:305
OverlayVulkanContext::o_offset
int32_t o_offset[2 *3]
Definition: vf_overlay_vulkan.c:43
filters.h
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:306
OFFSET
#define OFFSET(x)
Definition: vf_overlay_vulkan.c:304
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
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:238
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:84
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:711
GLSLD
#define GLSLD(D)
Definition: vulkan.h:59
fs
#define fs(width, name, subs,...)
Definition: cbs_vp9.c:200
overlay_vulkan_inputs
static const AVFilterPad overlay_vulkan_inputs[]
Definition: vf_overlay_vulkan.c:314
OverlayVulkanContext::overlay_w
int overlay_w
Definition: vf_overlay_vulkan.c:49
activate
filter_frame For filters that do not use the activate() callback
OverlayVulkanContext::e
FFVkExecPool e
Definition: vf_overlay_vulkan.c:36
ff_vk_filter_config_output
int ff_vk_filter_config_output(AVFilterLink *outlink)
Definition: vulkan_filter.c:219
ff_vk_init_compute_pipeline
int ff_vk_init_compute_pipeline(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkSPIRVShader *shd)
Definition: vulkan.c:1751
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:278
FFVulkanContext
Definition: vulkan.h:229
AVPixFmtDescriptor::flags
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
Definition: pixdesc.h:94
FFVulkanPipeline
Definition: vulkan.h:132
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_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:1311
overlay_vulkan_init
static av_cold int overlay_vulkan_init(AVFilterContext *avctx)
Definition: vf_overlay_vulkan.c:275
planes
static const struct @452 planes[]
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:366
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:94
ff_framesync_init_dualinput
int ff_framesync_init_dualinput(FFFrameSync *fs, AVFilterContext *parent)
Initialize a frame sync structure for dualinput.
Definition: framesync.c:373
AVFILTER_FLAG_HWDEVICE
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
Definition: avfilter.h:173
FFVkQueueFamilyCtx
Definition: vulkan.h:110
OverlayVulkanContext::sampler
VkSampler sampler
Definition: vf_overlay_vulkan.c:39
OverlayVulkanContext
Definition: vf_overlay_vulkan.c:30
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
FFVkSPIRVCompiler
Definition: vulkan_spirv.h:27
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:68
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:1171
vulkan_spirv.h
AVFilterPad::name
const char * name
Pad name.
Definition: filters.h:44
OverlayVulkanContext::vkctx
FFVulkanContext vkctx
Definition: vf_overlay_vulkan.c:31
GLSLF
#define GLSLF(N, S,...)
Definition: vulkan.h:54
OverlayVulkanContext::shd
FFVkSPIRVShader shd
Definition: vf_overlay_vulkan.c:38
FFVkSPIRVCompiler::free_shader
void(* free_shader)(struct FFVkSPIRVCompiler *ctx, void **opaque)
Definition: vulkan_spirv.h:32
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(overlay_vulkan)
AVFilter
Filter definition.
Definition: avfilter.h:201
AVHWFramesContext
This struct describes a set or pool of "hardware" frames (i.e.
Definition: hwcontext.h:115
ff_vk_pipeline_descriptor_set_add
int ff_vk_pipeline_descriptor_set_add(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkSPIRVShader *shd, FFVulkanDescriptorSetBinding *desc, int nb, int singular, int print_to_shader_only)
Add descriptor to a pipeline.
Definition: vulkan.c:1429
FFVulkanContext::vkfn
FFVulkanFunctions vkfn
Definition: vulkan.h:233
FFVkExecPool
Definition: vulkan.h:211
OverlayVulkanContext::o_size
int32_t o_size[2 *3]
Definition: vf_overlay_vulkan.c:44
pos
unsigned int pos
Definition: spdifenc.c:414
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:725
AVFrame::height
int height
Definition: frame.h:446
random_seed.h
framesync.h
FFVkSPIRVShader
Definition: vulkan.h:75
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:284
AVFilterContext
An instance of a filter.
Definition: avfilter.h:457
desc
const char * desc
Definition: libsvtav1.c:79
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:186
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
FFVulkanContext::hwctx
AVVulkanDeviceContext * hwctx
Definition: vulkan.h:257
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
ff_vk_init_sampler
int ff_vk_init_sampler(FFVulkanContext *s, VkSampler *sampler, int unnorm_coords, VkFilter filt)
Create a sampler.
Definition: vulkan.c:1126
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:1543
int32_t
int32_t
Definition: audioconvert.c:56
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
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:353
ff_vk_shader_free
void ff_vk_shader_free(FFVulkanContext *s, FFVkSPIRVShader *shd)
Definition: vulkan.c:1370
FILTER_SINGLE_PIXFMT
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition: filters.h:252
OverlayVulkanContext::initialized
int initialized
Definition: vf_overlay_vulkan.c:34
RET
#define RET(x)
Definition: vulkan.h:67
FFVulkanFunctions
Definition: vulkan_functions.h:249
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:48
OverlayVulkanContext::overlay_h
int overlay_h
Definition: vf_overlay_vulkan.c:50
OverlayVulkanContext::qf
FFVkQueueFamilyCtx qf
Definition: vf_overlay_vulkan.c:37