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  ff_vk_qf_init(vkctx, &s->qf, VK_QUEUE_COMPUTE_BIT);
105  RET(ff_vk_exec_pool_init(vkctx, &s->qf, &s->e, s->qf.nb_queues*4, 0, 0, 0, NULL));
106  RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_NEAREST));
107  RET(ff_vk_shader_init(vkctx, &s->shd, "overlay",
108  VK_SHADER_STAGE_COMPUTE_BIT,
109  NULL, 0,
110  32, 32, 1,
111  0));
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_shader_add_push_const(&s->shd, 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, FF_VK_REP_FLOAT),
143  .mem_quali = "writeonly",
144  .dimensions = 2,
145  .elems = planes,
146  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
147  },
148  };
149 
150  RET(ff_vk_shader_add_descriptor_set(vkctx, &s->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(vkctx, spv, shd, &spv_data, &spv_len, "main",
167  &spv_opaque));
168  RET(ff_vk_shader_link(vkctx, shd, spv_data, spv_len, "main"));
169 
170  RET(ff_vk_shader_register_exec(vkctx, &s->e, &s->shd));
171 
172  s->opts.o_offset[0] = s->overlay_x;
173  s->opts.o_offset[1] = s->overlay_y;
174  s->opts.o_offset[2] = s->opts.o_offset[0] >> pix_desc->log2_chroma_w;
175  s->opts.o_offset[3] = s->opts.o_offset[1] >> pix_desc->log2_chroma_h;
176  s->opts.o_offset[4] = s->opts.o_offset[0] >> pix_desc->log2_chroma_w;
177  s->opts.o_offset[5] = s->opts.o_offset[1] >> pix_desc->log2_chroma_h;
178 
179  s->opts.o_size[0] = s->overlay_w;
180  s->opts.o_size[1] = s->overlay_h;
181  s->opts.o_size[2] = s->opts.o_size[0] >> pix_desc->log2_chroma_w;
182  s->opts.o_size[3] = s->opts.o_size[1] >> pix_desc->log2_chroma_h;
183  s->opts.o_size[4] = s->opts.o_size[0] >> pix_desc->log2_chroma_w;
184  s->opts.o_size[5] = s->opts.o_size[1] >> pix_desc->log2_chroma_h;
185 
186  s->initialized = 1;
187 
188 fail:
189  if (spv_opaque)
190  spv->free_shader(spv, &spv_opaque);
191  if (spv)
192  spv->uninit(&spv);
193 
194  return err;
195 }
196 
198 {
199  int err;
200  AVFilterContext *ctx = fs->parent;
201  OverlayVulkanContext *s = ctx->priv;
202  AVFilterLink *outlink = ctx->outputs[0];
203  AVFrame *input_main, *input_overlay, *out;
204 
205  err = ff_framesync_get_frame(fs, 0, &input_main, 0);
206  if (err < 0)
207  goto fail;
208  err = ff_framesync_get_frame(fs, 1, &input_overlay, 0);
209  if (err < 0)
210  goto fail;
211 
212  if (!input_main || !input_overlay)
213  return 0;
214 
215  if (!s->initialized) {
216  AVHWFramesContext *main_fc = (AVHWFramesContext*)input_main->hw_frames_ctx->data;
217  AVHWFramesContext *overlay_fc = (AVHWFramesContext*)input_overlay->hw_frames_ctx->data;
218  if (main_fc->sw_format != overlay_fc->sw_format) {
219  av_log(ctx, AV_LOG_ERROR, "Mismatching sw formats!\n");
220  return AVERROR(EINVAL);
221  }
222 
223  s->overlay_w = input_overlay->width;
224  s->overlay_h = input_overlay->height;
225 
226  RET(init_filter(ctx));
227  }
228 
229  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
230  if (!out) {
231  err = AVERROR(ENOMEM);
232  goto fail;
233  }
234 
235  RET(ff_vk_filter_process_Nin(&s->vkctx, &s->e, &s->shd,
236  out, (AVFrame *[]){ input_main, input_overlay }, 2,
237  s->sampler, &s->opts, sizeof(s->opts)));
238 
239  err = av_frame_copy_props(out, input_main);
240  if (err < 0)
241  goto fail;
242 
243  return ff_filter_frame(outlink, out);
244 
245 fail:
246  av_frame_free(&out);
247  return err;
248 }
249 
251 {
252  int err;
253  AVFilterContext *avctx = outlink->src;
254  OverlayVulkanContext *s = avctx->priv;
255 
256  err = ff_vk_filter_config_output(outlink);
257  if (err < 0)
258  return err;
259 
260  err = ff_framesync_init_dualinput(&s->fs, avctx);
261  if (err < 0)
262  return err;
263 
264  return ff_framesync_configure(&s->fs);
265 }
266 
268 {
269  OverlayVulkanContext *s = avctx->priv;
270 
271  return ff_framesync_activate(&s->fs);
272 }
273 
275 {
276  OverlayVulkanContext *s = avctx->priv;
277 
278  s->fs.on_event = &overlay_vulkan_blend;
279 
280  return ff_vk_filter_init(avctx);
281 }
282 
284 {
285  OverlayVulkanContext *s = avctx->priv;
286  FFVulkanContext *vkctx = &s->vkctx;
287  FFVulkanFunctions *vk = &vkctx->vkfn;
288 
289  ff_vk_exec_pool_free(vkctx, &s->e);
290  ff_vk_shader_free(vkctx, &s->shd);
291 
292  if (s->sampler)
293  vk->DestroySampler(vkctx->hwctx->act_dev, s->sampler,
294  vkctx->hwctx->alloc);
295 
296  ff_vk_uninit(&s->vkctx);
297  ff_framesync_uninit(&s->fs);
298 
299  s->initialized = 0;
300 }
301 
302 #define OFFSET(x) offsetof(OverlayVulkanContext, x)
303 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
305  { "x", "Set horizontal offset", OFFSET(overlay_x), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, .flags = FLAGS },
306  { "y", "Set vertical offset", OFFSET(overlay_y), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, .flags = FLAGS },
307  { NULL },
308 };
309 
310 AVFILTER_DEFINE_CLASS(overlay_vulkan);
311 
313  {
314  .name = "main",
315  .type = AVMEDIA_TYPE_VIDEO,
316  .config_props = &ff_vk_filter_config_input,
317  },
318  {
319  .name = "overlay",
320  .type = AVMEDIA_TYPE_VIDEO,
321  .config_props = &ff_vk_filter_config_input,
322  },
323 };
324 
326  {
327  .name = "default",
328  .type = AVMEDIA_TYPE_VIDEO,
329  .config_props = &overlay_vulkan_config_output,
330  },
331 };
332 
334  .name = "overlay_vulkan",
335  .description = NULL_IF_CONFIG_SMALL("Overlay a source on top of another"),
336  .priv_size = sizeof(OverlayVulkanContext),
343  .priv_class = &overlay_vulkan_class,
344  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
345  .flags = AVFILTER_FLAG_HWDEVICE,
346 };
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:2529
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:1680
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_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
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:162
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:389
AVFrame::width
int width
Definition: frame.h:461
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:267
overlay_vulkan_config_output
static int overlay_vulkan_config_output(AVFilterLink *outlink)
Definition: vf_overlay_vulkan.c:250
overlay_vulkan_outputs
static const AVFilterPad overlay_vulkan_outputs[]
Definition: vf_overlay_vulkan.c:325
ff_vk_uninit
void ff_vk_uninit(FFVulkanContext *s)
Frees main context.
Definition: vulkan.c:2568
FFVkSPIRVCompiler::uninit
void(* uninit)(struct FFVkSPIRVCompiler **ctx)
Definition: vulkan_spirv.h:32
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:205
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:197
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:472
fail
#define fail()
Definition: checkasm.h:188
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:2169
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:2044
ff_vf_overlay_vulkan
const AVFilter ff_vf_overlay_vulkan
Definition: vf_overlay_vulkan.c:333
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
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:303
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:367
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:304
OFFSET
#define OFFSET(x)
Definition: vf_overlay_vulkan.c:302
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:238
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
planes
static const struct @465 planes[]
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:1291
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:713
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:312
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
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:300
FFVulkanContext
Definition: vulkan.h:263
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
OverlayVulkanContext::opts
struct OverlayVulkanContext::@348 opts
overlay_vulkan_init
static av_cold int overlay_vulkan_init(AVFilterContext *avctx)
Definition: vf_overlay_vulkan.c:274
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
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:102
FFVulkanShader
Definition: vulkan.h:179
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:1969
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)
AVFilter
Filter definition.
Definition: avfilter.h:201
AVHWFramesContext
This struct describes a set or pool of "hardware" frames (i.e.
Definition: hwcontext.h:115
FFVulkanContext::vkfn
FFVulkanFunctions vkfn
Definition: vulkan.h:267
FFVkExecPool
Definition: vulkan.h:241
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:1223
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:740
AVFrame::height
int height
Definition: frame.h:461
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:283
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:291
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:1244
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: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
OverlayVulkanContext::qf
FFVkQueueFamilyCtx qf
Definition: vf_overlay_vulkan.c:36