FFmpeg
vf_xfade_vulkan.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #include "libavutil/avassert.h"
20 #include "libavutil/opt.h"
21 
22 #include "vulkan_filter.h"
23 #include "filters.h"
24 #include "video.h"
25 
26 #define IN_A 0
27 #define IN_B 1
28 #define IN_NB 2
29 
30 extern const unsigned char ff_xfade_comp_spv_data[];
31 extern const unsigned int ff_xfade_comp_spv_len;
32 
33 typedef struct XFadeParameters {
34  float progress;
36 
37 typedef struct XFadeVulkanContext {
39 
43 
48  VkSampler sampler;
49 
50  // PTS when the fade should start (in IN_A timebase)
52 
53  // PTS offset between IN_A and IN_B
55 
56  // Duration of the transition
58 
59  // Current PTS of the first input (IN_A)
61 
62  // If frames are currently just passed through
63  // unmodified, like before and after the actual
64  // transition.
66 
67  int status[IN_NB];
69 
89 };
90 
92 {
93  int err = 0;
94  XFadeVulkanContext *s = avctx->priv;
95  FFVulkanContext *vkctx = &s->vkctx;
96  const int planes = av_pix_fmt_count_planes(s->vkctx.output_format);
97 
98  s->qf = ff_vk_qf_find(vkctx, VK_QUEUE_COMPUTE_BIT, 0);
99  if (!s->qf) {
100  av_log(avctx, AV_LOG_ERROR, "Device has no compute queues\n");
101  err = AVERROR(ENOTSUP);
102  goto fail;
103  }
104 
105  RET(ff_vk_exec_pool_init(vkctx, s->qf, &s->e, s->qf->num*4, 0, 0, 0, NULL));
106  RET(ff_vk_init_sampler(vkctx, &s->sampler, 1, VK_FILTER_NEAREST));
107 
108  SPEC_LIST_CREATE(sl, 2, 2*sizeof(int))
109  SPEC_LIST_ADD(sl, 0, 32, s->transition);
110  SPEC_LIST_ADD(sl, 1, 32, planes);
111 
112  ff_vk_shader_load(&s->shd, VK_SHADER_STAGE_COMPUTE_BIT,
113  NULL, (int []) { 32, 32, 1 }, 0);
114 
116  { /* a_images */
117  .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
118  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
119  .samplers = DUP_SAMPLER(s->sampler),
120  },
121  { /* b_images */
122  .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
123  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
124  .samplers = DUP_SAMPLER(s->sampler),
125  },
126  { /* output_images */
127  .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
128  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
129  },
130  };
131  ff_vk_shader_add_descriptor_set(vkctx, &s->shd, desc, 3, 0, 0);
132 
134  VK_SHADER_STAGE_COMPUTE_BIT);
135 
136  RET(ff_vk_shader_link(vkctx, &s->shd,
138  ff_xfade_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 
148 static int xfade_frame(AVFilterContext *avctx, AVFrame *frame_a, AVFrame *frame_b)
149 {
150  int err;
151  AVFilterLink *outlink = avctx->outputs[0];
152  XFadeVulkanContext *s = avctx->priv;
153  float progress;
154 
155  AVFrame *output = ff_get_video_buffer(outlink, outlink->w, outlink->h);
156  if (!output) {
157  err = AVERROR(ENOMEM);
158  goto fail;
159  }
160 
161  if (!s->initialized) {
164  if (a_fc->sw_format != b_fc->sw_format) {
165  av_log(avctx, AV_LOG_ERROR,
166  "Currently the sw format of the first input needs to match the second!\n");
167  return AVERROR(EINVAL);
168  }
169  RET(init_vulkan(avctx));
170  }
171 
172  RET(av_frame_copy_props(output, frame_a));
173  output->pts = s->pts;
174 
175  progress = av_clipf((float)(s->pts - s->start_pts) / s->duration_pts,
176  0.f, 1.f);
177 
178  RET(ff_vk_filter_process_Nin(&s->vkctx, &s->e, &s->shd, output,
179  (AVFrame *[]){ frame_a, frame_b }, 2, s->sampler, 1,
180  &(XFadeParameters){ progress }, sizeof(XFadeParameters)));
181 
182  return ff_filter_frame(outlink, output);
183 
184 fail:
186  return err;
187 }
188 
189 static int config_props_output(AVFilterLink *outlink)
190 {
191  int err;
192  AVFilterContext *avctx = outlink->src;
193  XFadeVulkanContext *s = avctx->priv;
194  AVFilterLink *inlink_a = avctx->inputs[IN_A];
195  AVFilterLink *inlink_b = avctx->inputs[IN_B];
196  FilterLink *il = ff_filter_link(inlink_a);
197  FilterLink *ol = ff_filter_link(outlink);
198 
199  if (inlink_a->w != inlink_b->w || inlink_a->h != inlink_b->h) {
200  av_log(avctx, AV_LOG_ERROR, "First input link %s parameters "
201  "(size %dx%d) do not match the corresponding "
202  "second input link %s parameters (size %dx%d)\n",
203  avctx->input_pads[IN_A].name, inlink_a->w, inlink_a->h,
204  avctx->input_pads[IN_B].name, inlink_b->w, inlink_b->h);
205  return AVERROR(EINVAL);
206  }
207 
208  if (inlink_a->time_base.num != inlink_b->time_base.num ||
209  inlink_a->time_base.den != inlink_b->time_base.den) {
210  av_log(avctx, AV_LOG_ERROR, "First input link %s timebase "
211  "(%d/%d) does not match the corresponding "
212  "second input link %s timebase (%d/%d)\n",
213  avctx->input_pads[IN_A].name, inlink_a->time_base.num, inlink_a->time_base.den,
214  avctx->input_pads[IN_B].name, inlink_b->time_base.num, inlink_b->time_base.den);
215  return AVERROR(EINVAL);
216  }
217 
218  s->start_pts = s->inputs_offset_pts = AV_NOPTS_VALUE;
219 
220  outlink->time_base = inlink_a->time_base;
221  ol->frame_rate = il->frame_rate;
222  outlink->sample_aspect_ratio = inlink_a->sample_aspect_ratio;
223 
224  if (s->duration)
225  s->duration_pts = av_rescale_q(s->duration, AV_TIME_BASE_Q, inlink_a->time_base);
227 
228 fail:
229  return err;
230 }
231 
233  AVFilterLink *inlink, AVFilterLink *outlink)
234 {
235  int64_t status_pts;
236  int ret = 0, status;
237  AVFrame *frame = NULL;
238 
240  if (ret < 0)
241  return ret;
242 
243  if (ret > 0) {
244  // If we do not have an offset yet, it's because we
245  // never got a first input. Just offset to 0
246  if (s->inputs_offset_pts == AV_NOPTS_VALUE)
247  s->inputs_offset_pts = -frame->pts;
248 
249  // We got a frame, nothing to do other than adjusting the timestamp
250  frame->pts += s->inputs_offset_pts;
251  return ff_filter_frame(outlink, frame);
252  }
253 
254  // Forward status with our timestamp
255  if (ff_inlink_acknowledge_status(inlink, &status, &status_pts)) {
256  if (s->inputs_offset_pts == AV_NOPTS_VALUE)
257  s->inputs_offset_pts = -status_pts;
258 
259  ff_outlink_set_status(outlink, status, status_pts + s->inputs_offset_pts);
260  return 0;
261  }
262 
263  // No frame available, request one if needed
264  if (ff_outlink_frame_wanted(outlink))
266 
267  return 0;
268 }
269 
270 static int activate(AVFilterContext *avctx)
271 {
272  XFadeVulkanContext *s = avctx->priv;
273  AVFilterLink *in_a = avctx->inputs[IN_A];
274  AVFilterLink *in_b = avctx->inputs[IN_B];
275  AVFilterLink *outlink = avctx->outputs[0];
276  int64_t status_pts;
277 
278  FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, avctx);
279 
280  // Check if we already transitioned or IN_A ended prematurely,
281  // in which case just forward the frames from IN_B with adjusted
282  // timestamps until EOF.
283  if (s->status[IN_A] && !s->status[IN_B])
284  return forward_frame(s, in_b, outlink);
285 
286  // We did not finish transitioning yet and the first stream
287  // did not end either, so check if there are more frames to consume.
289  AVFrame *peeked_frame = ff_inlink_peek_frame(in_a, 0);
290  s->pts = peeked_frame->pts;
291 
292  if (s->start_pts == AV_NOPTS_VALUE)
293  s->start_pts =
294  s->pts + av_rescale_q(s->offset, AV_TIME_BASE_Q, in_a->time_base);
295 
296  // Check if we are not yet transitioning, in which case
297  // just request and forward the input frame.
298  if (s->start_pts > s->pts) {
299  AVFrame *frame_a = NULL;
300  s->passthrough = 1;
301  ff_inlink_consume_frame(in_a, &frame_a);
302  return ff_filter_frame(outlink, frame_a);
303  }
304  s->passthrough = 0;
305 
306  // We are transitioning, so we need a frame from IN_B
308  int ret;
309  AVFrame *frame_a = NULL, *frame_b = NULL;
310  ff_inlink_consume_frame(avctx->inputs[IN_A], &frame_a);
311  ff_inlink_consume_frame(avctx->inputs[IN_B], &frame_b);
312 
313  // Calculate PTS offset to first input
314  if (s->inputs_offset_pts == AV_NOPTS_VALUE)
315  s->inputs_offset_pts = s->pts - frame_b->pts;
316 
317  // Check if we finished transitioning, in which case we
318  // report back EOF to IN_A as it is no longer needed.
319  if (s->pts - s->start_pts > s->duration_pts) {
320  s->status[IN_A] = AVERROR_EOF;
322  s->passthrough = 1;
323  }
324  ret = xfade_frame(avctx, frame_a, frame_b);
325  av_frame_free(&frame_a);
326  av_frame_free(&frame_b);
327  return ret;
328  }
329 
330  // We did not get a frame from IN_B, check its status.
331  if (ff_inlink_acknowledge_status(in_b, &s->status[IN_B], &status_pts)) {
332  // We should transition, but IN_B is EOF so just report EOF output now.
333  ff_outlink_set_status(outlink, s->status[IN_B], s->pts);
334  return 0;
335  }
336 
337  // We did not get a frame for IN_B but no EOF either, so just request more.
338  if (ff_outlink_frame_wanted(outlink)) {
340  return 0;
341  }
342  }
343 
344  // We did not get a frame from IN_A, check its status.
345  if (ff_inlink_acknowledge_status(in_a, &s->status[IN_A], &status_pts)) {
346  // No more frames from IN_A, do not report EOF though, we will just
347  // forward the IN_B frames in the next activate calls.
348  s->passthrough = 1;
349  ff_filter_set_ready(avctx, 100);
350  return 0;
351  }
352 
353  // We have no frames yet from IN_A and no EOF, so request some.
354  if (ff_outlink_frame_wanted(outlink)) {
356  return 0;
357  }
358 
359  return FFERROR_NOT_READY;
360 }
361 
362 static av_cold void uninit(AVFilterContext *avctx)
363 {
364  XFadeVulkanContext *s = avctx->priv;
365  FFVulkanContext *vkctx = &s->vkctx;
366  FFVulkanFunctions *vk = &vkctx->vkfn;
367 
368  ff_vk_exec_pool_free(vkctx, &s->e);
369  ff_vk_shader_free(vkctx, &s->shd);
370 
371  if (s->sampler)
372  vk->DestroySampler(vkctx->hwctx->act_dev, s->sampler,
373  vkctx->hwctx->alloc);
374 
375  ff_vk_uninit(&s->vkctx);
376 
377  s->initialized = 0;
378 }
379 
381 {
382  XFadeVulkanContext *s = inlink->dst->priv;
383 
384  return s->passthrough ?
387 }
388 
389 #define OFFSET(x) offsetof(XFadeVulkanContext, x)
390 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
391 
392 static const AVOption xfade_vulkan_options[] = {
393  { "transition", "set cross fade transition", OFFSET(transition), AV_OPT_TYPE_INT, {.i64=FADE}, 0, NB_TRANSITIONS-1, FLAGS, .unit = "transition" },
394  { "fade", "fade transition", 0, AV_OPT_TYPE_CONST, {.i64=FADE}, 0, 0, FLAGS, .unit = "transition" },
395  { "wipeleft", "wipe left transition", 0, AV_OPT_TYPE_CONST, {.i64=WIPELEFT}, 0, 0, FLAGS, .unit = "transition" },
396  { "wiperight", "wipe right transition", 0, AV_OPT_TYPE_CONST, {.i64=WIPERIGHT}, 0, 0, FLAGS, .unit = "transition" },
397  { "wipeup", "wipe up transition", 0, AV_OPT_TYPE_CONST, {.i64=WIPEUP}, 0, 0, FLAGS, .unit = "transition" },
398  { "wipedown", "wipe down transition", 0, AV_OPT_TYPE_CONST, {.i64=WIPEDOWN}, 0, 0, FLAGS, .unit = "transition" },
399  { "slidedown", "slide down transition", 0, AV_OPT_TYPE_CONST, {.i64=SLIDEDOWN}, 0, 0, FLAGS, .unit = "transition" },
400  { "slideup", "slide up transition", 0, AV_OPT_TYPE_CONST, {.i64=SLIDEUP}, 0, 0, FLAGS, .unit = "transition" },
401  { "slideleft", "slide left transition", 0, AV_OPT_TYPE_CONST, {.i64=SLIDELEFT}, 0, 0, FLAGS, .unit = "transition" },
402  { "slideright", "slide right transition", 0, AV_OPT_TYPE_CONST, {.i64=SLIDERIGHT}, 0, 0, FLAGS, .unit = "transition" },
403  { "circleopen", "circleopen transition", 0, AV_OPT_TYPE_CONST, {.i64=CIRCLEOPEN}, 0, 0, FLAGS, .unit = "transition" },
404  { "circleclose", "circleclose transition", 0, AV_OPT_TYPE_CONST, {.i64=CIRCLECLOSE}, 0, 0, FLAGS, .unit = "transition" },
405  { "dissolve", "dissolve transition", 0, AV_OPT_TYPE_CONST, {.i64=DISSOLVE}, 0, 0, FLAGS, .unit = "transition" },
406  { "pixelize", "pixelize transition", 0, AV_OPT_TYPE_CONST, {.i64=PIXELIZE}, 0, 0, FLAGS, .unit = "transition" },
407  { "wipetl", "wipe top left transition", 0, AV_OPT_TYPE_CONST, {.i64=WIPETL}, 0, 0, FLAGS, .unit = "transition" },
408  { "wipetr", "wipe top right transition", 0, AV_OPT_TYPE_CONST, {.i64=WIPETR}, 0, 0, FLAGS, .unit = "transition" },
409  { "wipebl", "wipe bottom left transition", 0, AV_OPT_TYPE_CONST, {.i64=WIPEBL}, 0, 0, FLAGS, .unit = "transition" },
410  { "wipebr", "wipe bottom right transition", 0, AV_OPT_TYPE_CONST, {.i64=WIPEBR}, 0, 0, FLAGS, .unit = "transition" },
411  { "duration", "set cross fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=1000000}, 0, 60000000, FLAGS },
412  { "offset", "set cross fade start relative to first input stream", OFFSET(offset), AV_OPT_TYPE_DURATION, {.i64=0}, INT64_MIN, INT64_MAX, FLAGS },
413  { NULL }
414 };
415 
416 AVFILTER_DEFINE_CLASS(xfade_vulkan);
417 
419  {
420  .name = "main",
421  .type = AVMEDIA_TYPE_VIDEO,
422  .get_buffer.video = &get_video_buffer,
423  .config_props = &ff_vk_filter_config_input,
424  },
425  {
426  .name = "xfade",
427  .type = AVMEDIA_TYPE_VIDEO,
428  .get_buffer.video = &get_video_buffer,
429  .config_props = &ff_vk_filter_config_input,
430  },
431 };
432 
434  {
435  .name = "default",
436  .type = AVMEDIA_TYPE_VIDEO,
437  .config_props = &config_props_output,
438  },
439 };
440 
442  .p.name = "xfade_vulkan",
443  .p.description = NULL_IF_CONFIG_SMALL("Cross fade one video with another video."),
444  .p.priv_class = &xfade_vulkan_class,
445  .p.flags = AVFILTER_FLAG_HWDEVICE,
446  .priv_size = sizeof(XFadeVulkanContext),
448  .uninit = &uninit,
449  .activate = &activate,
453  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
454 };
IN_A
#define IN_A
Definition: vf_xfade_vulkan.c:26
WIPETR
@ WIPETR
Definition: vf_xfade_vulkan.c:85
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
IN_B
#define IN_B
Definition: vf_xfade_vulkan.c:27
WIPELEFT
@ WIPELEFT
Definition: vf_xfade_vulkan.c:72
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:2810
xfade_frame
static int xfade_frame(AVFilterContext *avctx, AVFrame *frame_a, AVFrame *frame_b)
Definition: vf_xfade_vulkan.c:148
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1067
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
RET
#define RET(x)
Definition: vulkan.h:68
FFERROR_NOT_READY
return FFERROR_NOT_READY
Definition: filter_design.txt:204
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
AV_TIME_BASE_Q
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
Definition: avutil.h:263
int64_t
long long int64_t
Definition: coverity.c:34
output
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce output
Definition: filter_design.txt:226
inlink
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
Definition: filter_design.txt:212
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
XFadeVulkanContext::start_pts
int64_t start_pts
Definition: vf_xfade_vulkan.c:51
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:434
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:536
ff_vk_filter_init
int ff_vk_filter_init(AVFilterContext *avctx)
General lavfi IO functions.
Definition: vulkan_filter.c:233
XFadeVulkanContext::status
int status[IN_NB]
Definition: vf_xfade_vulkan.c:67
XFadeVulkanContext::transition
int transition
Definition: vf_xfade_vulkan.c:40
AVOption
AVOption.
Definition: opt.h:429
FILTER_SINGLE_PIXFMT
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition: filters.h:254
get_video_buffer
static AVFrame * get_video_buffer(AVFilterLink *inlink, int w, int h)
Definition: vf_xfade_vulkan.c:380
CIRCLEOPEN
@ CIRCLEOPEN
Definition: vf_xfade_vulkan.c:80
filters.h
AV_OPT_TYPE_DURATION
@ AV_OPT_TYPE_DURATION
Underlying C type is int64_t.
Definition: opt.h:319
forward_frame
static int forward_frame(XFadeVulkanContext *s, AVFilterLink *inlink, AVFilterLink *outlink)
Definition: vf_xfade_vulkan.c:232
XFadeVulkanContext::e
FFVkExecPool e
Definition: vf_xfade_vulkan.c:45
XFadeVulkanContext::initialized
int initialized
Definition: vf_xfade_vulkan.c:44
ff_vk_uninit
void ff_vk_uninit(FFVulkanContext *s)
Frees main context.
Definition: vulkan.c:2836
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
video.h
AV_PIX_FMT_VULKAN
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition: pixfmt.h:379
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
ff_inlink_consume_frame
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
Definition: avfilter.c:1515
ff_default_get_video_buffer
AVFrame * ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
Definition: video.c:84
WIPEBL
@ WIPEBL
Definition: vf_xfade_vulkan.c:86
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3496
SLIDELEFT
@ SLIDELEFT
Definition: vf_xfade_vulkan.c:78
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:289
fail
#define fail()
Definition: checkasm.h:224
SLIDEDOWN
@ SLIDEDOWN
Definition: vf_xfade_vulkan.c:76
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:2603
SLIDEUP
@ SLIDEUP
Definition: vf_xfade_vulkan.c:77
XFadeVulkanContext::pts
int64_t pts
Definition: vf_xfade_vulkan.c:60
AVRational::num
int num
Numerator.
Definition: rational.h:59
XFadeVulkanContext::passthrough
int passthrough
Definition: vf_xfade_vulkan.c:65
AVFilterPad
A filter pad used for either input or output.
Definition: filters.h:40
AVFilterContext::input_pads
AVFilterPad * input_pads
array of input pads
Definition: avfilter.h:281
avassert.h
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
ff_inlink_request_frame
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
Definition: avfilter.c:1618
s
#define s(width, name)
Definition: cbs_vp9.c:198
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:265
ff_filter_link
static FilterLink * ff_filter_link(AVFilterLink *link)
Definition: filters.h:199
ff_outlink_set_status
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
Definition: filters.h:629
av_rescale_q
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
ff_vk_exec_pool_free
void ff_vk_exec_pool_free(FFVulkanContext *s, FFVkExecPool *pool)
Definition: vulkan.c:299
XFadeVulkanContext::qf
AVVulkanDeviceQueueFamily * qf
Definition: vf_xfade_vulkan.c:46
ff_inlink_peek_frame
AVFrame * ff_inlink_peek_frame(AVFilterLink *link, size_t idx)
Access a frame in the link fifo without consuming it.
Definition: avfilter.c:1556
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
DUP_SAMPLER
#define DUP_SAMPLER(x)
Definition: vulkan.h:104
AVFilterContext::inputs
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:282
activate
static int activate(AVFilterContext *avctx)
Definition: vf_xfade_vulkan.c:270
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:2376
SPEC_LIST_CREATE
#define SPEC_LIST_CREATE(name, max_length, max_size)
Definition: vulkan.h:76
xfade_vulkan_outputs
static const AVFilterPad xfade_vulkan_outputs[]
Definition: vf_xfade_vulkan.c:433
xfade_vulkan_options
static const AVOption xfade_vulkan_options[]
Definition: vf_xfade_vulkan.c:392
av_clipf
av_clipf
Definition: af_crystalizer.c:122
FFVulkanContext
Definition: vulkan.h:312
ff_inlink_acknowledge_status
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
Definition: avfilter.c:1462
XFadeVulkanContext::shd
FFVulkanShader shd
Definition: vf_xfade_vulkan.c:47
PIXELIZE
@ PIXELIZE
Definition: vf_xfade_vulkan.c:83
DISSOLVE
@ DISSOLVE
Definition: vf_xfade_vulkan.c:82
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:550
FLAGS
#define FLAGS
Definition: vf_xfade_vulkan.c:390
ff_inlink_set_status
void ff_inlink_set_status(AVFilterLink *link, int status)
Set the status on an input link.
Definition: avfilter.c:1627
ff_inlink_check_available_frame
int ff_inlink_check_available_frame(AVFilterLink *link)
Test if a frame is available on the link.
Definition: avfilter.c:1484
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
AVFILTER_FLAG_HWDEVICE
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
Definition: avfilter.h:188
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:247
FFVulkanShader
Definition: vulkan.h:225
XFadeVulkanContext::sampler
VkSampler sampler
Definition: vf_xfade_vulkan.c:48
ff_xfade_comp_spv_data
const unsigned char ff_xfade_comp_spv_data[]
XFadeVulkanContext::duration
int64_t duration
Definition: vf_xfade_vulkan.c:41
XFadeVulkanContext::offset
int64_t offset
Definition: vf_xfade_vulkan.c:42
planes
static const struct @585 planes[]
offset
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
Definition: writing_filters.txt:86
XFadeVulkanContext::inputs_offset_pts
int64_t inputs_offset_pts
Definition: vf_xfade_vulkan.c:54
ff_null_get_video_buffer
AVFrame * ff_null_get_video_buffer(AVFilterLink *link, int w, int h)
Definition: video.c:44
xfade_vulkan_inputs
static const AVFilterPad xfade_vulkan_inputs[]
Definition: vf_xfade_vulkan.c:418
NB_TRANSITIONS
@ NB_TRANSITIONS
Definition: vf_xfade_vulkan.c:88
AVFilterPad::name
const char * name
Pad name.
Definition: filters.h:46
CIRCLECLOSE
@ CIRCLECLOSE
Definition: vf_xfade_vulkan.c:81
XFadeParameters
Definition: vf_xfade_vulkan.c:33
AVHWFramesContext
This struct describes a set or pool of "hardware" frames (i.e.
Definition: hwcontext.h:118
ret
ret
Definition: filter_design.txt:187
ff_vf_xfade_vulkan
const FFFilter ff_vf_xfade_vulkan
Definition: vf_xfade_vulkan.c:441
WIPERIGHT
@ WIPERIGHT
Definition: vf_xfade_vulkan.c:73
FADE
@ FADE
Definition: vf_xfade_vulkan.c:71
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:265
FFVulkanContext::vkfn
FFVulkanFunctions vkfn
Definition: vulkan.h:316
FFVkExecPool
Definition: vulkan.h:290
XFadeVulkanContext::duration_pts
int64_t duration_pts
Definition: vf_xfade_vulkan.c:57
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:1489
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
XFadeVulkanContext::vkctx
FFVulkanContext vkctx
Definition: vf_xfade_vulkan.c:38
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:2503
status
ov_status_e status
Definition: dnn_backend_openvino.c:100
AVRational::den
int den
Denominator.
Definition: rational.h:60
WIPEBR
@ WIPEBR
Definition: vf_xfade_vulkan.c:87
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
config_props_output
static int config_props_output(AVFilterLink *outlink)
Definition: vf_xfade_vulkan.c:189
init_vulkan
static av_cold int init_vulkan(AVFilterContext *avctx)
Definition: vf_xfade_vulkan.c:91
ff_xfade_comp_spv_len
const unsigned int ff_xfade_comp_spv_len
XFadeVulkanContext
Definition: vf_xfade_vulkan.c:37
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
FFVulkanContext::hwctx
AVVulkanDeviceContext * hwctx
Definition: vulkan.h:349
WIPEDOWN
@ WIPEDOWN
Definition: vf_xfade_vulkan.c:75
AVVulkanDeviceContext::act_dev
VkDevice act_dev
Active device.
Definition: hwcontext_vulkan.h:84
w
uint8_t w
Definition: llvidencdsp.c:39
XFadeTransitions
XFadeTransitions
Definition: vf_xfade.c:29
WIPETL
@ WIPETL
Definition: vf_xfade_vulkan.c:84
FF_FILTER_FORWARD_STATUS_BACK_ALL
#define FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, filter)
Forward the status on an output link to all input links.
Definition: filters.h:652
ff_vk_init_sampler
int ff_vk_init_sampler(FFVulkanContext *s, VkSampler *sampler, int unnorm_coords, VkFilter filt)
Create a sampler.
Definition: vulkan.c:1500
SLIDERIGHT
@ SLIDERIGHT
Definition: vf_xfade_vulkan.c:79
XFadeParameters::progress
float progress
Definition: vf_xfade_vulkan.c:34
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVVulkanDeviceQueueFamily
Definition: hwcontext_vulkan.h:33
IN_NB
#define IN_NB
Definition: vf_xfade_vulkan.c:28
h
h
Definition: vp9dsp_template.c:2070
ff_outlink_frame_wanted
the definition of that something depends on the semantic of the filter The callback must examine the status of the filter s links and proceed accordingly The status of output links is stored in the status_in and status_out fields and tested by the ff_outlink_frame_wanted() function. If this function returns true
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(xfade_vulkan)
WIPEUP
@ WIPEUP
Definition: vf_xfade_vulkan.c:74
uninit
static av_cold void uninit(AVFilterContext *avctx)
Definition: vf_xfade_vulkan.c:362
OFFSET
#define OFFSET(x)
Definition: vf_xfade_vulkan.c:389
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
FFVulkanFunctions
Definition: vulkan_functions.h:275
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:2093
duration
static int64_t duration
Definition: ffplay.c:329
ff_filter_set_ready
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.
Definition: avfilter.c:229
AVFilterContext::outputs
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:286