FFmpeg
ops.c
Go to the documentation of this file.
1 /**
2  * Copyright (C) 2026 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/mem.h"
22 #include "libavutil/refstruct.h"
23 
24 #include "../ops_internal.h"
25 #include "../swscale_internal.h"
26 
27 #include "ops.h"
28 
29 static void ff_sws_vk_uninit(AVRefStructOpaque opaque, void *obj)
30 {
31  FFVulkanOpsCtx *s = obj;
32 
33 #if CONFIG_LIBSHADERC || CONFIG_LIBGLSLANG
34  if (s->spvc)
35  s->spvc->uninit(&s->spvc);
36 #endif
37  ff_vk_exec_pool_free(&s->vkctx, &s->e);
38  ff_vk_uninit(&s->vkctx);
39 }
40 
42 {
43  int err;
44  SwsInternal *c = sws_internal(sws);
45 
46  if (!c->hw_priv) {
47  c->hw_priv = av_refstruct_alloc_ext(sizeof(FFVulkanOpsCtx), 0, NULL,
49  if (!c->hw_priv)
50  return AVERROR(ENOMEM);
51  }
52 
53  FFVulkanOpsCtx *s = c->hw_priv;
54  if (s->vkctx.device_ref && s->vkctx.device_ref->data != dev_ref->data) {
55  /* Reinitialize with new context */
56  ff_vk_exec_pool_free(&s->vkctx, &s->e);
57  ff_vk_uninit(&s->vkctx);
58  } else if (s->vkctx.device_ref && s->vkctx.device_ref->data == dev_ref->data) {
59  return 0;
60  }
61 
62  err = ff_vk_init(&s->vkctx, sws, dev_ref, NULL);
63  if (err < 0)
64  return err;
65 
66  s->qf = ff_vk_qf_find(&s->vkctx, VK_QUEUE_COMPUTE_BIT, 0);
67  if (!s->qf) {
68  av_log(sws, AV_LOG_ERROR, "Device has no compute queues\n");
69  return AVERROR(ENOTSUP);
70  }
71 
72  err = ff_vk_exec_pool_init(&s->vkctx, s->qf, &s->e, 1,
73  0, 0, 0, NULL);
74  if (err < 0)
75  return err;
76 
77 #if CONFIG_LIBSHADERC || CONFIG_LIBGLSLANG
78  if (!s->spvc) {
79  s->spvc = ff_vk_spirv_init();
80  if (!s->spvc)
81  return AVERROR(ENOMEM);
82  }
83 #endif
84 
85  return 0;
86 }
87 
88 typedef struct VulkanPriv {
93 } VulkanPriv;
94 
95 static void process(const SwsFrame *dst, const SwsFrame *src, int y, int h,
96  const SwsPass *pass)
97 {
98  VulkanPriv *p = (VulkanPriv *) pass->priv;
99  FFVkExecContext *ec = ff_vk_exec_get(&p->s->vkctx, &p->s->e);
100  FFVulkanFunctions *vk = &p->s->vkctx.vkfn;
101  ff_vk_exec_start(&p->s->vkctx, ec);
102 
103  AVFrame *src_f = (AVFrame *) src->avframe;
104  AVFrame *dst_f = (AVFrame *) dst->avframe;
105  ff_vk_exec_add_dep_frame(&p->s->vkctx, ec, src_f,
106  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
107  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT);
108  ff_vk_exec_add_dep_frame(&p->s->vkctx, ec, dst_f,
109  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
110  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT);
111 
112  VkImageView src_views[AV_NUM_DATA_POINTERS];
113  VkImageView dst_views[AV_NUM_DATA_POINTERS];
114  ff_vk_create_imageviews(&p->s->vkctx, ec, src_views, src_f, p->src_rep);
115  ff_vk_create_imageviews(&p->s->vkctx, ec, dst_views, dst_f, p->dst_rep);
116 
117  ff_vk_shader_update_img_array(&p->s->vkctx, ec, &p->shd, src_f, src_views,
118  0, 0, VK_IMAGE_LAYOUT_GENERAL, VK_NULL_HANDLE);
119  ff_vk_shader_update_img_array(&p->s->vkctx, ec, &p->shd, dst_f, dst_views,
120  0, 1, VK_IMAGE_LAYOUT_GENERAL, VK_NULL_HANDLE);
121 
122  int nb_img_bar = 0;
123  VkImageMemoryBarrier2 img_bar[8];
124  ff_vk_frame_barrier(&p->s->vkctx, ec, src_f, img_bar, &nb_img_bar,
125  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
126  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
127  VK_ACCESS_SHADER_READ_BIT,
128  VK_IMAGE_LAYOUT_GENERAL,
129  VK_QUEUE_FAMILY_IGNORED);
130  ff_vk_frame_barrier(&p->s->vkctx, ec, dst_f, img_bar, &nb_img_bar,
131  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
132  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
133  VK_ACCESS_SHADER_WRITE_BIT,
134  VK_IMAGE_LAYOUT_GENERAL,
135  VK_QUEUE_FAMILY_IGNORED);
136  vk->CmdPipelineBarrier2(ec->buf, &(VkDependencyInfo) {
137  .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
138  .pImageMemoryBarriers = img_bar,
139  .imageMemoryBarrierCount = nb_img_bar,
140  });
141 
142  ff_vk_exec_bind_shader(&p->s->vkctx, ec, &p->shd);
143 
144  vk->CmdDispatch(ec->buf,
145  FFALIGN(src_f->width, p->shd.lg_size[0])/p->shd.lg_size[0],
146  FFALIGN(src_f->height, p->shd.lg_size[1])/p->shd.lg_size[1],
147  1);
148 
149  ff_vk_exec_submit(&p->s->vkctx, ec);
150  ff_vk_exec_wait(&p->s->vkctx, ec);
151 }
152 
153 static void free_fn(void *priv)
154 {
155  VulkanPriv *p = priv;
156  ff_vk_shader_free(&p->s->vkctx, &p->shd);
157  av_free(priv);
158 }
159 
160 #if CONFIG_LIBSHADERC || CONFIG_LIBGLSLANG
161 static void add_desc_read_write(FFVulkanDescriptorSetBinding *out_desc,
162  enum FFVkShaderRepFormat *out_rep,
163  const SwsOp *op)
164 {
165  const char *img_type = op->type == SWS_PIXEL_F32 ? "rgba32f" :
166  op->type == SWS_PIXEL_U32 ? "rgba32ui" :
167  op->type == SWS_PIXEL_U16 ? "rgba16ui" :
168  "rgba8ui";
169 
170  *out_desc = (FFVulkanDescriptorSetBinding) {
171  .name = op->op == SWS_OP_WRITE ? "dst_img" : "src_img",
172  .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
173  .mem_layout = img_type,
174  .mem_quali = op->op == SWS_OP_WRITE ? "writeonly" : "readonly",
175  .dimensions = 2,
176  .elems = op->rw.packed ? 1 : op->rw.elems,
177  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
178  };
179 
180  *out_rep = op->type == SWS_PIXEL_F32 ? FF_VK_REP_FLOAT : FF_VK_REP_UINT;
181 }
182 
183 #define QSTR "(%i/%i%s)"
184 #define QTYPE(i) op->c.q4[i].num, op->c.q4[i].den, \
185  cur_type == SWS_PIXEL_F32 ? ".0f" : ""
186 
187 static int add_ops_glsl(VulkanPriv *p, FFVulkanOpsCtx *s,
188  SwsOpList *ops, FFVulkanShader *shd)
189 {
190  int err;
191  uint8_t *spv_data;
192  size_t spv_len;
193  void *spv_opaque = NULL;
194 
195  /* Interlaced formats are not currently supported */
196  if (ops->src.interlaced || ops->dst.interlaced)
197  return AVERROR(ENOTSUP);
198 
199  err = ff_vk_shader_init(&s->vkctx, shd, "sws_pass",
200  VK_SHADER_STAGE_COMPUTE_BIT,
201  NULL, 0, 32, 32, 1, 0);
202  if (err < 0)
203  return err;
204 
205  int nb_desc = 0;
206  FFVulkanDescriptorSetBinding buf_desc[8];
207 
208  const SwsOp *read = ff_sws_op_list_input(ops);
209  const SwsOp *write = ff_sws_op_list_output(ops);
210  if (read)
211  add_desc_read_write(&buf_desc[nb_desc++], &p->src_rep, read);
212  add_desc_read_write(&buf_desc[nb_desc++], &p->dst_rep, write);
213  ff_vk_shader_add_descriptor_set(&s->vkctx, shd, buf_desc, nb_desc, 0, 0);
214 
215  GLSLC(0, void main() );
216  GLSLC(0, { );
217  GLSLC(1, ivec2 pos = ivec2(gl_GlobalInvocationID.xy); );
218  GLSLC(1, ivec2 size = imageSize(src_img[0]); );
219  GLSLC(1, if (any(greaterThanEqual(pos, size))) );
220  GLSLC(2, return; );
221  GLSLC(0, );
222  GLSLC(1, u8vec4 u8; );
223  GLSLC(1, u16vec4 u16; );
224  GLSLC(1, u32vec4 u32; );
225  GLSLC(1, precise f32vec4 f32; );
226  GLSLC(1, precise f32vec4 tmp; );
227  GLSLC(0, );
228 
229  for (int n = 0; n < ops->num_ops; n++) {
230  const SwsOp *op = &ops->ops[n];
231  SwsPixelType cur_type = op->op == SWS_OP_CONVERT ? op->convert.to :
232  op->type;
233  const char *type_name = ff_sws_pixel_type_name(cur_type);
234  const char *type_v = cur_type == SWS_PIXEL_F32 ? "f32vec4" :
235  cur_type == SWS_PIXEL_U32 ? "u32vec4" :
236  cur_type == SWS_PIXEL_U16 ? "u16vec4" : "u8vec4";
237  const char *type_s = cur_type == SWS_PIXEL_F32 ? "float" :
238  cur_type == SWS_PIXEL_U32 ? "uint32_t" :
239  cur_type == SWS_PIXEL_U16 ? "uint16_t" : "uint8_t";
240  av_bprintf(&shd->src, " // %s\n", ff_sws_op_type_name(op->op));
241 
242  switch (op->op) {
243  case SWS_OP_READ: {
244  if (op->rw.frac || op->rw.filter) {
245  return AVERROR(ENOTSUP);
246  } else if (op->rw.packed) {
247  GLSLF(1, %s = %s(imageLoad(src_img[%i], pos)); ,
248  type_name, type_v, ops->plane_src[0]);
249  } else {
250  for (int i = 0; i < op->rw.elems; i++)
251  GLSLF(1, %s.%c = %s(imageLoad(src_img[%i], pos)[0]); ,
252  type_name, "xyzw"[i], type_s, ops->plane_src[i]);
253  }
254  break;
255  }
256  case SWS_OP_WRITE: {
257  if (op->rw.frac || op->rw.filter) {
258  return AVERROR(ENOTSUP);
259  } else if (op->rw.packed) {
260  GLSLF(1, imageStore(dst_img[%i], pos, %s(%s)); ,
261  ops->plane_dst[0], type_v, type_name);
262  } else {
263  for (int i = 0; i < op->rw.elems; i++)
264  GLSLF(1, imageStore(dst_img[%i], pos, %s(%s[%i])); ,
265  ops->plane_dst[i], type_v, type_name, i);
266  }
267  break;
268  }
269  case SWS_OP_SWIZZLE: {
270  av_bprintf(&shd->src, " %s = %s.", type_name, type_name);
271  for (int i = 0; i < 4; i++)
272  av_bprintf(&shd->src, "%c", "xyzw"[op->swizzle.in[i]]);
273  av_bprintf(&shd->src, ";\n");
274  break;
275  }
276  case SWS_OP_CLEAR: {
277  for (int i = 0; i < 4; i++) {
278  if (!op->c.q4[i].den)
279  continue;
280  av_bprintf(&shd->src, " %s.%c = %s"QSTR";\n", type_name,
281  "xyzw"[i], type_s, QTYPE(i));
282  }
283  break;
284  }
285  case SWS_OP_SCALE:
286  av_bprintf(&shd->src, " %s = %s*%i/%i;\n",
287  type_name, type_name, op->c.q.num, op->c.q.den);
288  break;
289  case SWS_OP_MIN:
290  case SWS_OP_MAX:
291  for (int i = 0; i < 4; i++) {
292  if (!op->c.q4[i].den)
293  continue;
294  av_bprintf(&shd->src, " %s.%c = %s(%s.%c, "QSTR");\n",
295  type_name, "xyzw"[i],
296  op->op == SWS_OP_MIN ? "min" : "max",
297  type_name, "xyzw"[i],
298  op->c.q4[i].num, op->c.q4[i].den,
299  cur_type == SWS_PIXEL_F32 ? ".0f" : "");
300  }
301  break;
302  case SWS_OP_LSHIFT:
303  case SWS_OP_RSHIFT:
304  av_bprintf(&shd->src, " %s %s= %i;\n", type_name,
305  op->op == SWS_OP_LSHIFT ? "<<" : ">>", op->c.u);
306  break;
307  case SWS_OP_CONVERT:
308  if (ff_sws_pixel_type_is_int(cur_type) && op->convert.expand) {
309  const AVRational sc = ff_sws_pixel_expand(op->type, op->convert.to);
310  av_bprintf(&shd->src, " %s = %s((%s*%i)/%i);\n",
311  type_name, type_v, ff_sws_pixel_type_name(op->type),
312  sc.num, sc.den);
313  } else {
314  av_bprintf(&shd->src, " %s = %s(%s);\n",
315  type_name, type_v, ff_sws_pixel_type_name(op->type));
316  }
317  break;
318  case SWS_OP_DITHER:
319  av_bprintf(&shd->src, " precise const float dm%i[%i][%i] = {\n",
320  n, 1 << op->dither.size_log2, 1 << op->dither.size_log2);
321  int size = (1 << op->dither.size_log2);
322  for (int i = 0; i < size; i++) {
323  av_bprintf(&shd->src, " { ");
324  for (int j = 0; j < size; j++)
325  av_bprintf(&shd->src, "%i/%i.0, ",
326  op->dither.matrix[i*size + j].num,
327  op->dither.matrix[i*size + j].den);
328  av_bprintf(&shd->src, "}, %s\n", i == (size - 1) ? "\n };" : "");
329  }
330  for (int i = 0; i < 4; i++) {
331  if (op->dither.y_offset[i] < 0)
332  continue;
333  av_bprintf(&shd->src, " %s.%c += dm%i[(pos.y + %i) & %i]"
334  "[pos.x & %i];\n",
335  type_name, "xyzw"[i], n,
336  op->dither.y_offset[i], size - 1,
337  size - 1);
338  }
339  break;
340  case SWS_OP_LINEAR:
341  for (int i = 0; i < 4; i++) {
342  if (op->lin.m[i][4].num)
343  av_bprintf(&shd->src, " tmp.%c = (%i/%i.0);\n", "xyzw"[i],
344  op->lin.m[i][4].num, op->lin.m[i][4].den);
345  else
346  av_bprintf(&shd->src, " tmp.%c = 0;\n", "xyzw"[i]);
347  for (int j = 0; j < 4; j++) {
348  if (!op->lin.m[i][j].num)
349  continue;
350  av_bprintf(&shd->src, " tmp.%c += f32.%c*(%i/%i.0);\n",
351  "xyzw"[i], "xyzw"[j],
352  op->lin.m[i][j].num, op->lin.m[i][j].den);
353  }
354  }
355  av_bprintf(&shd->src, " f32 = tmp;\n");
356  break;
357  default:
358  return AVERROR(ENOTSUP);
359  }
360  }
361 
362  GLSLC(0, } );
363 
364  err = s->spvc->compile_shader(&s->vkctx, s->spvc, shd,
365  &spv_data, &spv_len, "main",
366  &spv_opaque);
367  if (err < 0)
368  return err;
369 
370  err = ff_vk_shader_link(&s->vkctx, shd, spv_data, spv_len, "main");
371 
372  if (spv_opaque)
373  s->spvc->free_shader(s->spvc, &spv_opaque);
374 
375  if (err < 0)
376  return err;
377 
378  return 0;
379 }
380 #endif
381 
382 static int compile(SwsContext *sws, SwsOpList *ops, SwsCompiledOp *out)
383 {
384  int err;
385  SwsInternal *c = sws_internal(sws);
386  FFVulkanOpsCtx *s = c->hw_priv;
387  if (!s)
388  return AVERROR(ENOTSUP);
389 
390  VulkanPriv p = {
391  .s = s,
392  };
393 
394 #if CONFIG_LIBSHADERC || CONFIG_LIBGLSLANG
395  {
396  err = add_ops_glsl(&p, s, ops, &p.shd);
397  if (err < 0)
398  return err;
399  }
400 #else
401  return AVERROR(ENOTSUP);
402 #endif
403 
404  err = ff_vk_shader_register_exec(&s->vkctx, &s->e, &p.shd);
405  if (err < 0)
406  return err;
407 
408  *out = (SwsCompiledOp) {
409  .opaque = true,
410  .func_opaque = process,
411  .priv = av_memdup(&p, sizeof(p)),
412  .free = free_fn,
413  };
414  return 0;
415 }
416 
418  .name = "vulkan",
419  .compile = compile,
420  .hw_format = AV_PIX_FMT_VULKAN,
421 };
SWS_OP_READ
@ SWS_OP_READ
Definition: ops.h:50
SWS_PIXEL_U16
@ SWS_PIXEL_U16
Definition: ops.h:36
FFVulkanOpsCtx
Copyright (C) 2026 Lynne.
Definition: ops.h:31
SWS_OP_SWIZZLE
@ SWS_OP_SWIZZLE
Definition: ops.h:53
SwsPass
Represents a single filter pass in the scaling graph.
Definition: graph.h:71
VulkanPriv::src_rep
enum FFVkShaderRepFormat src_rep
Definition: ops.c:91
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
SWS_OP_LSHIFT
@ SWS_OP_LSHIFT
Definition: ops.h:58
ff_vk_shader_free
void ff_vk_shader_free(FFVulkanContext *s, FFVulkanShader *shd)
Free a shader.
Definition: vulkan.c:2799
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:2111
out
static FILE * out
Definition: movenc.c:55
SwsFormat::interlaced
int interlaced
Definition: format.h:79
ff_sws_op_list_input
const SwsOp * ff_sws_op_list_input(const SwsOpList *ops)
Returns the input operation for a given op list, or NULL if there is none (e.g.
Definition: ops.c:631
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
SWS_OP_CLEAR
@ SWS_OP_CLEAR
Definition: ops.h:62
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
AVRefStructOpaque
RefStruct is an API for creating reference-counted objects with minimal overhead.
Definition: refstruct.h:58
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:427
backend_vulkan
const SwsOpBackend backend_vulkan
Definition: ops.c:417
AVFrame::width
int width
Definition: frame.h:499
SWS_OP_DITHER
@ SWS_OP_DITHER
Definition: ops.h:70
FFVulkanShader::src
AVBPrint src
Definition: vulkan.h:234
VulkanPriv::s
FFVulkanOpsCtx * s
Definition: ops.c:89
ff_vk_init
int ff_vk_init(FFVulkanContext *s, void *log_parent, AVBufferRef *device_ref, AVBufferRef *frames_ref)
Initializes the AVClass, in case this context is not used as the main user's context.
Definition: vulkan.c:2837
ff_vk_exec_get
FFVkExecContext * ff_vk_exec_get(FFVulkanContext *s, FFVkExecPool *pool)
Retrieve an execution pool.
Definition: vulkan.c:548
SWS_PIXEL_U32
@ SWS_PIXEL_U32
Definition: ops.h:37
ff_vk_uninit
void ff_vk_uninit(FFVulkanContext *s)
Frees main context.
Definition: vulkan.c:2825
ff_vk_exec_bind_shader
void ff_vk_exec_bind_shader(FFVulkanContext *s, FFVkExecContext *e, const FFVulkanShader *shd)
Bind a shader.
Definition: vulkan.c:2776
SwsOpBackend::name
const char * name
Definition: ops_internal.h:56
AV_PIX_FMT_VULKAN
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition: pixfmt.h:379
ff_vk_exec_add_dep_frame
int ff_vk_exec_add_dep_frame(FFVulkanContext *s, FFVkExecContext *e, AVFrame *f, VkPipelineStageFlagBits2 wait_stage, VkPipelineStageFlagBits2 signal_stage)
Definition: vulkan.c:780
FFVkShaderRepFormat
FFVkShaderRepFormat
Returns the format to use for images in shaders.
Definition: vulkan.h:447
av_memdup
void * av_memdup(const void *p, size_t size)
Duplicate a buffer with av_malloc().
Definition: mem.c:304
SwsPixelType
SwsPixelType
Copyright (C) 2025 Niklas Haas.
Definition: ops.h:33
SwsOpList::plane_dst
uint8_t plane_dst[4]
Definition: ops.h:262
compile
static int compile(SwsContext *sws, SwsOpList *ops, SwsCompiledOp *out)
Definition: ops.c:382
SWS_PIXEL_F32
@ SWS_PIXEL_F32
Definition: ops.h:38
SwsOpList::num_ops
int num_ops
Definition: ops.h:256
ff_vk_shader_update_img_array
void ff_vk_shader_update_img_array(FFVulkanContext *s, FFVkExecContext *e, FFVulkanShader *shd, AVFrame *f, VkImageView *views, int set, int binding, VkImageLayout layout, VkSampler sampler)
Update a descriptor in a buffer with an image array.
Definition: vulkan.c:2727
ff_vk_frame_barrier
void ff_vk_frame_barrier(FFVulkanContext *s, FFVkExecContext *e, AVFrame *pic, VkImageMemoryBarrier2 *bar, int *nb_bar, VkPipelineStageFlags2 src_stage, VkPipelineStageFlags2 dst_stage, VkAccessFlagBits2 new_access, VkImageLayout new_layout, uint32_t new_qf)
Definition: vulkan.c:2039
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:2592
ff_sws_pixel_type_is_int
bool ff_sws_pixel_type_is_int(SwsPixelType type)
Definition: ops.c:83
AVRational::num
int num
Numerator.
Definition: rational.h:59
refstruct.h
SwsFrame
Represents a view into a single field of frame data.
Definition: format.h:193
SWS_OP_SCALE
@ SWS_OP_SCALE
Definition: ops.h:66
GLSLC
#define GLSLC(N, S)
Definition: vulkan.h:45
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:210
main
int main
Definition: dovi_rpuenc.c:38
SwsPass::priv
void * priv
Definition: graph.h:106
ff_sws_vk_init
int ff_sws_vk_init(SwsContext *sws, AVBufferRef *dev_ref)
Definition: ops.c:41
s
#define s(width, name)
Definition: cbs_vp9.c:198
op
static int op(uint8_t **dst, const uint8_t *dst_end, GetByteContext *gb, int pixel, int count, int *x, int width, int linesize)
Perform decode operation.
Definition: anm.c:76
ops.h
ff_vk_exec_wait
void ff_vk_exec_wait(FFVulkanContext *s, FFVkExecContext *e)
Definition: vulkan.c:553
FF_VK_REP_FLOAT
@ FF_VK_REP_FLOAT
Definition: vulkan.h:451
av_refstruct_alloc_ext
static void * av_refstruct_alloc_ext(size_t size, unsigned flags, void *opaque, void(*free_cb)(AVRefStructOpaque opaque, void *obj))
A wrapper around av_refstruct_alloc_ext_c() for the common case of a non-const qualified opaque.
Definition: refstruct.h:94
SWS_OP_MIN
@ SWS_OP_MIN
Definition: ops.h:64
ff_sws_pixel_expand
static AVRational ff_sws_pixel_expand(SwsPixelType from, SwsPixelType to)
Definition: ops_internal.h:31
SWS_OP_LINEAR
@ SWS_OP_LINEAR
Definition: ops.h:69
ff_sws_op_list_output
const SwsOp * ff_sws_op_list_output(const SwsOpList *ops)
Returns the output operation for a given op list, or NULL if there is none.
Definition: ops.c:640
ff_vk_exec_pool_free
void ff_vk_exec_pool_free(FFVulkanContext *s, FFVkExecPool *pool)
Definition: vulkan.c:299
SwsOpBackend
Definition: ops_internal.h:55
tmp
static uint8_t tmp[40]
Definition: aes_ctr.c:52
NULL
#define NULL
Definition: coverity.c:32
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
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:2365
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
FFVulkanDescriptorSetBinding
Definition: vulkan.h:112
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:87
i
#define i(width, name, range_min, range_max)
Definition: cbs_h264.c:63
size
int size
Definition: twinvq_data.h:10344
AV_NUM_DATA_POINTERS
#define AV_NUM_DATA_POINTERS
Definition: frame.h:428
SWS_OP_RSHIFT
@ SWS_OP_RSHIFT
Definition: ops.h:59
VulkanPriv::dst_rep
enum FFVkShaderRepFormat dst_rep
Definition: ops.c:92
SwsOpList::src
SwsFormat src
Definition: ops.h:259
FFVulkanShader
Definition: vulkan.h:225
SWS_OP_WRITE
@ SWS_OP_WRITE
Definition: ops.h:51
FFVkExecContext
Definition: vulkan.h:145
FFVulkanDescriptorSetBinding::name
const char * name
Definition: vulkan.h:113
EnumOpaque::opaque
void * opaque
Definition: ops.c:1042
ff_vk_exec_start
int ff_vk_exec_start(FFVulkanContext *s, FFVkExecContext *e)
Start/submit/wait an execution.
Definition: vulkan.c:560
FF_VK_REP_UINT
@ FF_VK_REP_UINT
Definition: vulkan.h:455
process
static void process(const SwsFrame *dst, const SwsFrame *src, int y, int h, const SwsPass *pass)
Definition: ops.c:95
SwsOpList::ops
SwsOp * ops
Definition: ops.h:255
VulkanPriv
Definition: ops.c:88
SwsOp
Definition: ops.h:212
SwsInternal
Definition: swscale_internal.h:334
ff_vk_create_imageviews
int ff_vk_create_imageviews(FFVulkanContext *s, FFVkExecContext *e, VkImageView views[AV_NUM_DATA_POINTERS], AVFrame *f, enum FFVkShaderRepFormat rep_fmt)
Create an imageview and add it as a dependency to an execution.
Definition: vulkan.c:1956
SwsOpList::dst
SwsFormat dst
Definition: ops.h:259
SWS_OP_MAX
@ SWS_OP_MAX
Definition: ops.h:65
SwsCompiledOp
Definition: ops_dispatch.h:100
pos
unsigned int pos
Definition: spdifenc.c:414
av_bprintf
void av_bprintf(AVBPrint *buf, const char *fmt,...)
Definition: bprint.c:122
ff_vk_qf_find
AVVulkanDeviceQueueFamily * ff_vk_qf_find(FFVulkanContext *s, VkQueueFlagBits dev_family, VkVideoCodecOperationFlagBitsKHR vid_ops)
Chooses an appropriate QF.
Definition: vulkan.c:286
AVFrame::height
int height
Definition: frame.h:499
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:2492
GLSLF
#define GLSLF(N, S,...)
Definition: vulkan.h:55
AVRational::den
int den
Denominator.
Definition: rational.h:60
ff_sws_pixel_type_name
const char * ff_sws_pixel_type_name(SwsPixelType type)
Definition: ops.c:53
VulkanPriv::shd
FFVulkanShader shd
Definition: ops.c:90
Windows::Graphics::DirectX::Direct3D11::p
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
Definition: vsrc_gfxcapture_winrt.hpp:53
free_fn
static void free_fn(void *priv)
Definition: ops.c:153
mem.h
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
av_free
#define av_free(p)
Definition: tableprint_vlc.h:34
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
SWS_OP_CONVERT
@ SWS_OP_CONVERT
Definition: ops.h:63
ff_sws_vk_uninit
static void ff_sws_vk_uninit(AVRefStructOpaque opaque, void *obj)
Copyright (C) 2026 Lynne.
Definition: ops.c:29
ff_vk_exec_submit
int ff_vk_exec_submit(FFVulkanContext *s, FFVkExecContext *e)
Definition: vulkan.c:905
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
sws_internal
static SwsInternal * sws_internal(const SwsContext *sws)
Definition: swscale_internal.h:78
h
h
Definition: vp9dsp_template.c:2070
SwsOpList::plane_src
uint8_t plane_src[4]
Definition: ops.h:262
SwsOpList
Helper struct for representing a list of operations.
Definition: ops.h:254
ff_sws_op_type_name
const char * ff_sws_op_type_name(SwsOpType op)
Definition: ops.c:100
SwsContext
Main external API structure.
Definition: swscale.h:206
FFVulkanFunctions
Definition: vulkan_functions.h:274
src
#define src
Definition: vp8dsp.c:248
read
static uint32_t BS_FUNC() read(BSCTX *bc, unsigned int n)
Return n bits from the buffer, n has to be in the 0-32 range.
Definition: bitstream_template.h:239