FFmpeg
vulkan_prores_raw.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2025 Lynne <dev@lynne.ee>
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 "vulkan_decode.h"
22 #include "hwaccel_internal.h"
23 
24 #include "prores_raw.h"
25 #include "libavutil/vulkan_spirv.h"
26 #include "libavutil/mem.h"
27 
28 extern const char *ff_source_common_comp;
29 extern const char *ff_source_prores_raw_comp;
30 
33  .decode_extension = FF_VK_EXT_PUSH_DESCRIPTOR,
34  .queue_flags = VK_QUEUE_COMPUTE_BIT,
35 };
36 
39 
41  uint32_t nb_tiles;
43 
46 
48 
51 
52 typedef struct DecodePushData {
53  VkDeviceAddress tile_data;
54  VkDeviceAddress pkt_data;
55  uint32_t frame_size[2];
56  uint32_t tile_size[2];
57  uint8_t qmat[64];
59 
60 typedef struct TileData {
62  uint32_t offset;
63  uint32_t size;
64 } TileData;
65 
67  const AVBufferRef *buffer_ref,
68  av_unused const uint8_t *buffer,
69  av_unused uint32_t size)
70 {
71  int err;
74  ProResRAWVulkanDecodeContext *prv = ctx->sd_ctx;
75  ProResRAWContext *prr = avctx->priv_data;
76 
78  FFVulkanDecodePicture *vp = &pp->vp;
79 
80  /* Host map the input tile data if supported */
81  if (ctx->s.extensions & FF_VK_EXT_EXTERNAL_HOST_MEMORY)
82  ff_vk_host_map_buffer(&ctx->s, &vp->slices_buf, buffer_ref->data,
83  buffer_ref,
84  VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
85  VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT);
86 
87  /* Allocate tile data */
89  &pp->tile_data,
90  VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
91  VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT,
92  NULL, prr->nb_tiles*sizeof(TileData),
93  VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
94  VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT);
95  if (err < 0)
96  return err;
97 
98  /* Prepare frame to be used */
99  err = ff_vk_decode_prepare_frame_sdr(dec, prr->frame, vp, 1,
100  FF_VK_REP_FLOAT, 0);
101  if (err < 0)
102  return err;
103 
104  return 0;
105 }
106 
108  const uint8_t *data,
109  uint32_t size)
110 {
111  ProResRAWContext *prr = avctx->priv_data;
112 
114  FFVulkanDecodePicture *vp = &pp->vp;
115 
116  FFVkBuffer *tile_data_buf = (FFVkBuffer *)pp->tile_data->data;
117  TileData *td = (TileData *)tile_data_buf->mapped_mem;
118  FFVkBuffer *slices_buf = vp->slices_buf ? (FFVkBuffer *)vp->slices_buf->data : NULL;
119 
120  td[pp->nb_tiles].pos[0] = prr->tiles[pp->nb_tiles].x;
121  td[pp->nb_tiles].pos[1] = prr->tiles[pp->nb_tiles].y;
122  td[pp->nb_tiles].size = size;
123 
124  if (vp->slices_buf && slices_buf->host_ref) {
125  td[pp->nb_tiles].offset = data - slices_buf->mapped_mem;
126  pp->nb_tiles++;
127  } else {
128  int err;
129  td[pp->nb_tiles].offset = vp->slices_size;
130  err = ff_vk_decode_add_slice(avctx, vp, data, size, 0,
131  &pp->nb_tiles, NULL);
132  if (err < 0)
133  return err;
134  }
135 
136  return 0;
137 }
138 
140 {
141  int err;
144  FFVulkanFunctions *vk = &ctx->s.vkfn;
145 
146  ProResRAWContext *prr = avctx->priv_data;
147  ProResRAWVulkanDecodeContext *prv = ctx->sd_ctx;
148 
150  FFVulkanDecodePicture *vp = &pp->vp;
151 
152  FFVkBuffer *slices_buf = (FFVkBuffer *)vp->slices_buf->data;
153  FFVkBuffer *tile_data = (FFVkBuffer *)pp->tile_data->data;
154 
155  VkImageMemoryBarrier2 img_bar[8];
156  int nb_img_bar = 0;
157 
158  FFVkExecContext *exec = ff_vk_exec_get(&ctx->s, &ctx->exec_pool);
159  ff_vk_exec_start(&ctx->s, exec);
160 
161  /* Prepare deps */
162  RET(ff_vk_exec_add_dep_frame(&ctx->s, exec, prr->frame,
163  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
164  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
165 
166  err = ff_vk_exec_mirror_sem_value(&ctx->s, exec, &vp->sem, &vp->sem_value,
167  prr->frame);
168  if (err < 0)
169  return err;
170 
171  RET(ff_vk_exec_add_dep_buf(&ctx->s, exec, &pp->tile_data, 1, 0));
172  pp->tile_data = NULL;
173  RET(ff_vk_exec_add_dep_buf(&ctx->s, exec, &vp->slices_buf, 1, 0));
174  vp->slices_buf = NULL;
175 
176  ff_vk_frame_barrier(&ctx->s, exec, prr->frame, img_bar, &nb_img_bar,
177  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
178  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
179  VK_ACCESS_2_TRANSFER_WRITE_BIT,
180  VK_IMAGE_LAYOUT_GENERAL,
181  VK_QUEUE_FAMILY_IGNORED);
182 
183  vk->CmdPipelineBarrier2(exec->buf, &(VkDependencyInfo) {
184  .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
185  .pImageMemoryBarriers = img_bar,
186  .imageMemoryBarrierCount = nb_img_bar,
187  });
188  nb_img_bar = 0;
189 
190  FFVulkanShader *decode_shader = &prv->decode[prr->version];
191  ff_vk_shader_update_img_array(&ctx->s, exec, decode_shader,
192  prr->frame, vp->view.out,
193  0, 0,
194  VK_IMAGE_LAYOUT_GENERAL,
195  VK_NULL_HANDLE);
196 
197  ff_vk_exec_bind_shader(&ctx->s, exec, decode_shader);
198 
199  /* Update push data */
200  DecodePushData pd_decode = (DecodePushData) {
201  .tile_data = tile_data->address,
202  .pkt_data = slices_buf->address,
203  .frame_size[0] = avctx->width,
204  .frame_size[1] = avctx->height,
205  .tile_size[0] = prr->tw,
206  .tile_size[1] = prr->th,
207  };
208  memcpy(pd_decode.qmat, prr->qmat, 64);
209  ff_vk_shader_update_push_const(&ctx->s, exec, decode_shader,
210  VK_SHADER_STAGE_COMPUTE_BIT,
211  0, sizeof(pd_decode), &pd_decode);
212 
213  vk->CmdDispatch(exec->buf, prr->nb_tw, prr->nb_th, 1);
214 
215  err = ff_vk_exec_submit(&ctx->s, exec);
216  if (err < 0)
217  return err;
218 
219 fail:
220  return 0;
221 }
222 
224  FFVkExecPool *pool, FFVkSPIRVCompiler *spv,
225  FFVulkanShader *shd, int version)
226 {
227  int err;
229  int parallel_rows = 1;
230 
231  uint8_t *spv_data;
232  size_t spv_len;
233  void *spv_opaque = NULL;
234 
235  if (s->props.properties.limits.maxComputeWorkGroupInvocations < 512 ||
236  s->props.properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU)
237  parallel_rows = 0;
238 
239  RET(ff_vk_shader_init(s, shd, "prores_raw",
240  VK_SHADER_STAGE_COMPUTE_BIT,
241  (const char *[]) { "GL_EXT_buffer_reference",
242  "GL_EXT_buffer_reference2",
243  "GL_EXT_null_initializer" }, 3,
244  parallel_rows ? 8 : 1 /* 8x8 transforms, 8-point width */,
245  version == 0 ? 8 : 16 /* Horizontal blocks */,
246  4 /* Components */,
247  0));
248 
249  if (parallel_rows)
250  GLSLC(0, #define PARALLEL_ROWS );
251 
252  /* Common codec header */
254 
255  GLSLC(0, layout(buffer_reference, buffer_reference_align = 16) buffer TileData { );
256  GLSLC(1, ivec2 pos; );
257  GLSLC(1, uint offset; );
258  GLSLC(1, uint size; );
259  GLSLC(0, }; );
260  GLSLC(0, );
261  GLSLC(0, layout(push_constant, scalar) uniform pushConstants { );
262  GLSLC(1, TileData tile_data; );
263  GLSLC(1, u8buf pkt_data; );
264  GLSLC(1, uvec2 frame_size; );
265  GLSLC(1, uvec2 tile_size; );
266  GLSLC(1, uint8_t qmat[64]; );
267  GLSLC(0, }; );
268  GLSLC(0, );
270  VK_SHADER_STAGE_COMPUTE_BIT);
271 
272  desc_set = (FFVulkanDescriptorSetBinding []) {
273  {
274  .name = "dst",
275  .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
276  .mem_layout = "r16",
277  .mem_quali = "writeonly",
278  .dimensions = 2,
279  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
280  },
281  };
282  RET(ff_vk_shader_add_descriptor_set(s, shd, desc_set, 1, 0, 0));
283 
284  desc_set = (FFVulkanDescriptorSetBinding []) {
285  {
286  .name = "dct_scale_buf",
287  .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
288  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
289  .mem_layout = "scalar",
290  .buf_content = "float idct_8x8_scales[64];",
291  },
292  {
293  .name = "scan_buf",
294  .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
295  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
296  .mem_layout = "scalar",
297  .buf_content = "uint8_t scan[64];",
298  },
299  {
300  .name = "dc_cb_buf",
301  .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
302  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
303  .mem_layout = "scalar",
304  .buf_content = "uint8_t dc_cb[13];",
305  },
306  {
307  .name = "ac_cb_buf",
308  .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
309  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
310  .mem_layout = "scalar",
311  .buf_content = "int16_t ac_cb[95];",
312  },
313  {
314  .name = "rn_cb_buf",
315  .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
316  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
317  .mem_layout = "scalar",
318  .buf_content = "int16_t rn_cb[28];",
319  },
320  {
321  .name = "ln_cb_buf",
322  .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
323  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
324  .mem_layout = "scalar",
325  .buf_content = "int16_t ln_cb[15];",
326  },
327  };
328  RET(ff_vk_shader_add_descriptor_set(s, shd, desc_set, 6, 1, 0));
329 
331 
332  RET(spv->compile_shader(s, spv, shd, &spv_data, &spv_len, "main",
333  &spv_opaque));
334  RET(ff_vk_shader_link(s, shd, spv_data, spv_len, "main"));
335 
336  RET(ff_vk_shader_register_exec(s, pool, shd));
337 
338 fail:
339  if (spv_opaque)
340  spv->free_shader(spv, &spv_opaque);
341 
342  return err;
343 }
344 
346 {
347  ProResRAWVulkanDecodeContext *fv = ctx->sd_ctx;
348 
349  ff_vk_shader_free(&ctx->s, &fv->decode[0]);
350  ff_vk_shader_free(&ctx->s, &fv->decode[1]);
351 
352  ff_vk_free_buf(&ctx->s, &fv->uniform_buf);
353 
355 
356  av_freep(&fv);
357 }
358 
360 {
361  int err;
362  ProResRAWContext *prr = avctx->priv_data;
364 
365  FFVkSPIRVCompiler *spv = ff_vk_spirv_init();
366  if (!spv) {
367  av_log(avctx, AV_LOG_ERROR, "Unable to initialize SPIR-V compiler!\n");
368  return AVERROR_EXTERNAL;
369  }
370 
371  err = ff_vk_decode_init(avctx);
372  if (err < 0)
373  return err;
374 
376  ProResRAWVulkanDecodeContext *prv = ctx->sd_ctx = av_mallocz(sizeof(*prv));
377  if (!prv) {
378  err = AVERROR(ENOMEM);
379  goto fail;
380  }
381 
382  ctx->sd_ctx_free = &vk_decode_prores_raw_uninit;
383 
384  /* Setup decode shader */
385  RET(init_decode_shader(prr, &ctx->s, &ctx->exec_pool, spv, &prv->decode[0], 0));
386  RET(init_decode_shader(prr, &ctx->s, &ctx->exec_pool, spv, &prv->decode[1], 1));
387 
388  /* Size in bytes of each codebook table */
389  size_t cb_size[5] = {
390  13*sizeof(uint8_t),
391  95*sizeof(int16_t),
392  28*sizeof(int16_t),
393  15*sizeof(int16_t),
394  };
395 
396  /* Offset of each codebook table */
397  size_t cb_offset[5];
398  size_t ua = ctx->s.props.properties.limits.minUniformBufferOffsetAlignment;
399  cb_offset[0] = 64*sizeof(float) + 64*sizeof(uint8_t);
400  cb_offset[1] = cb_offset[0] + FFALIGN(cb_size[0], ua);
401  cb_offset[2] = cb_offset[1] + FFALIGN(cb_size[1], ua);
402  cb_offset[3] = cb_offset[2] + FFALIGN(cb_size[2], ua);
403  cb_offset[4] = cb_offset[3] + FFALIGN(cb_size[3], ua);
404 
405  RET(ff_vk_create_buf(&ctx->s, &prv->uniform_buf,
406  64*sizeof(float) + 64*sizeof(uint8_t) + cb_offset[4] + 256,
407  NULL, NULL,
408  VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT |
409  VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
410  VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
411  VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT));
412 
413  uint8_t *uniform_buf;
414  RET(ff_vk_map_buffer(&ctx->s, &prv->uniform_buf, &uniform_buf, 0));
415 
416  /* DCT scales */
417  float *dct_scale_buf = (float *)uniform_buf;
418  double idct_8_scales[8] = {
419  cos(4.0*M_PI/16.0) / 2.0,
420  cos(1.0*M_PI/16.0) / 2.0,
421  cos(2.0*M_PI/16.0) / 2.0,
422  cos(3.0*M_PI/16.0) / 2.0,
423  cos(4.0*M_PI/16.0) / 2.0,
424  cos(5.0*M_PI/16.0) / 2.0,
425  cos(6.0*M_PI/16.0) / 2.0,
426  cos(7.0*M_PI/16.0) / 2.0,
427  };
428  for (int i = 0; i < 64; i++)
429  dct_scale_buf[i] = (float)(idct_8_scales[i >> 3] *
430  idct_8_scales[i & 7]);
431 
432  /* Scan table */
433  uint8_t *scan_buf = uniform_buf + 64*sizeof(float);
434  for (int i = 0; i < 64; i++)
435  scan_buf[prr->scan[i]] = i;
436 
437  /* Codebooks */
438  memcpy(uniform_buf + cb_offset[0], ff_prores_raw_dc_cb,
439  sizeof(ff_prores_raw_dc_cb));
440  memcpy(uniform_buf + cb_offset[1], ff_prores_raw_ac_cb,
441  sizeof(ff_prores_raw_ac_cb));
442  memcpy(uniform_buf + cb_offset[2], ff_prores_raw_rn_cb,
443  sizeof(ff_prores_raw_rn_cb));
444  memcpy(uniform_buf + cb_offset[3], ff_prores_raw_ln_cb,
445  sizeof(ff_prores_raw_ln_cb));
446 
447  RET(ff_vk_unmap_buffer(&ctx->s, &prv->uniform_buf, 1));
448 
449  /* Done; update descriptors */
450  for (int i = 0; i < 2; i++) {
451  RET(ff_vk_shader_update_desc_buffer(&ctx->s, &ctx->exec_pool.contexts[0],
452  &prv->decode[i], 1, 0, 0,
453  &prv->uniform_buf,
454  0, 64*sizeof(float),
455  VK_FORMAT_UNDEFINED));
456  RET(ff_vk_shader_update_desc_buffer(&ctx->s, &ctx->exec_pool.contexts[0],
457  &prv->decode[i], 1, 1, 0,
458  &prv->uniform_buf,
459  64*sizeof(float), 64*sizeof(uint8_t),
460  VK_FORMAT_UNDEFINED));
461  for (int j = 0; j < 4; j++)
462  RET(ff_vk_shader_update_desc_buffer(&ctx->s, &ctx->exec_pool.contexts[0],
463  &prv->decode[i], 1, 2 + j, 0,
464  &prv->uniform_buf,
465  cb_offset[j], cb_size[j],
466  VK_FORMAT_UNDEFINED));
467  }
468 
469 fail:
470  spv->uninit(&spv);
471 
472  return err;
473 }
474 
476 {
477  AVHWDeviceContext *dev_ctx = _hwctx.nc;
478 
480  FFVulkanDecodePicture *vp = &pp->vp;
481 
482  ff_vk_decode_free_frame(dev_ctx, vp);
483 }
484 
486  .p.name = "prores_raw_vulkan",
487  .p.type = AVMEDIA_TYPE_VIDEO,
488  .p.id = AV_CODEC_ID_PRORES_RAW,
489  .p.pix_fmt = AV_PIX_FMT_VULKAN,
490  .start_frame = &vk_prores_raw_start_frame,
491  .decode_slice = &vk_prores_raw_decode_slice,
492  .end_frame = &vk_prores_raw_end_frame,
493  .free_frame_priv = &vk_prores_raw_free_frame_priv,
494  .frame_priv_data_size = sizeof(ProResRAWVulkanDecodePicture),
497  .decode_params = &ff_vk_params_invalidate,
500  .frame_params = &ff_vk_frame_params,
501  .priv_data_size = sizeof(FFVulkanDecodeContext),
503 };
ff_vk_create_buf
int ff_vk_create_buf(FFVulkanContext *s, FFVkBuffer *buf, size_t size, void *pNext, void *alloc_pNext, VkBufferUsageFlags usage, VkMemoryPropertyFlagBits flags)
Definition: vulkan.c:1021
FFVulkanDecodePicture::slices_size
size_t slices_size
Definition: vulkan_decode.h:102
DecodePushData::pkt_data
VkDeviceAddress pkt_data
Definition: vulkan_prores_raw.c:54
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
vk_decode_prores_raw_uninit
static void vk_decode_prores_raw_uninit(FFVulkanDecodeShared *ctx)
Definition: vulkan_prores_raw.c:345
DecodePushData::frame_size
uint32_t frame_size[2]
Definition: vulkan_prores_raw.c:55
ff_vk_shader_free
void ff_vk_shader_free(FFVulkanContext *s, FFVulkanShader *shd)
Free a shader.
Definition: vulkan.c:2923
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:2056
AVBufferPool
The buffer pool.
Definition: buffer_internal.h:88
ff_vk_decode_prepare_frame_sdr
int ff_vk_decode_prepare_frame_sdr(FFVulkanDecodeContext *dec, AVFrame *pic, FFVulkanDecodePicture *vkpic, int is_current, enum FFVkShaderRepFormat rep_fmt, int alloc_dpb)
Software-defined decoder version of ff_vk_decode_prepare_frame.
Definition: vulkan_decode.c:233
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
FFVulkanDecodeContext::shared_ctx
FFVulkanDecodeShared * shared_ctx
Definition: vulkan_decode.h:57
RET
#define RET(x)
Definition: vulkan.h:66
AVRefStructOpaque
RefStruct is an API for creating reference-counted objects with minimal overhead.
Definition: refstruct.h:58
AVRefStructOpaque::nc
void * nc
Definition: refstruct.h:59
av_unused
#define av_unused
Definition: attributes.h:131
FFHWAccel::p
AVHWAccel p
The public AVHWAccel.
Definition: hwaccel_internal.h:38
FFVkBuffer::host_ref
AVBufferRef * host_ref
Definition: vulkan.h:108
vk_prores_raw_free_frame_priv
static void vk_prores_raw_free_frame_priv(AVRefStructOpaque _hwctx, void *data)
Definition: vulkan_prores_raw.c:475
ff_vk_map_buffer
static int ff_vk_map_buffer(FFVulkanContext *s, FFVkBuffer *buf, uint8_t **mem, int invalidate)
Definition: vulkan.h:534
data
const char data[16]
Definition: mxf.c:149
FFVulkanDecodeDescriptor::codec_id
enum AVCodecID codec_id
Definition: vulkan_decode.h:30
TileContext::y
unsigned y
Definition: prores_raw.h:33
ProResRAWContext::tw
int tw
Definition: prores_raw.h:43
FFVulkanDecodePicture::view
struct FFVulkanDecodePicture::@319 view
ProResRAWContext::version
int version
Definition: prores_raw.h:50
FFVkBuffer::address
VkDeviceAddress address
Definition: vulkan.h:92
ff_vk_exec_get
FFVkExecContext * ff_vk_exec_get(FFVulkanContext *s, FFVkExecPool *pool)
Retrieve an execution pool.
Definition: vulkan.c:547
FFVkSPIRVCompiler::uninit
void(* uninit)(struct FFVkSPIRVCompiler **ctx)
Definition: vulkan_spirv.h:32
ff_prores_raw_ln_cb
const int16_t ff_prores_raw_ln_cb[LN_CB_MAX+1]
Definition: prores_raw.c:126
FFVulkanDecodeContext
Definition: vulkan_decode.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:779
ProResRAWVulkanDecodePicture::nb_tiles
uint32_t nb_tiles
Definition: vulkan_prores_raw.c:41
FFHWAccel
Definition: hwaccel_internal.h:34
fail
#define fail()
Definition: checkasm.h:199
FFVulkanDecodePicture::sem_value
uint64_t sem_value
Definition: vulkan_decode.h:87
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:2800
HWACCEL_CAP_THREAD_SAFE
#define HWACCEL_CAP_THREAD_SAFE
Definition: hwaccel_internal.h:32
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:2563
ff_vk_host_map_buffer
int ff_vk_host_map_buffer(FFVulkanContext *s, AVBufferRef **dst, uint8_t *src_data, const AVBufferRef *src_buf, VkBufferUsageFlags usage)
Maps a system RAM buffer into a Vulkan buffer.
Definition: vulkan.c:1361
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:2428
FFVulkanDecodeShared
Definition: vulkan_decode.h:38
AV_CODEC_ID_PRORES_RAW
@ AV_CODEC_ID_PRORES_RAW
Definition: codec_id.h:333
AVHWDeviceContext
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
Definition: hwcontext.h:63
ProResRAWContext::nb_tiles
int nb_tiles
Definition: prores_raw.h:42
GLSLC
#define GLSLC(N, S)
Definition: vulkan.h:43
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:210
ProResRAWContext::tiles
TileContext * tiles
Definition: prores_raw.h:40
float
float
Definition: af_crystalizer.c:122
s
#define s(width, name)
Definition: cbs_vp9.c:198
FFVulkanDecodePicture
Definition: vulkan_decode.h:75
ff_vk_exec_mirror_sem_value
int ff_vk_exec_mirror_sem_value(FFVulkanContext *s, FFVkExecContext *e, VkSemaphore *dst, uint64_t *dst_val, AVFrame *f)
Definition: vulkan.c:878
ProResRAWVulkanDecodePicture
Definition: vulkan_prores_raw.c:37
frame_size
int frame_size
Definition: mxfenc.c:2474
ff_prores_raw_rn_cb
const int16_t ff_prores_raw_rn_cb[RN_CB_MAX+1]
Definition: prores_raw.c:120
prores_raw.h
vk_prores_raw_end_frame
static int vk_prores_raw_end_frame(AVCodecContext *avctx)
Definition: vulkan_prores_raw.c:139
FF_VK_REP_FLOAT
@ FF_VK_REP_FLOAT
Definition: vulkan.h:408
ctx
AVFormatContext * ctx
Definition: movenc.c:49
ProResRAWVulkanDecodeContext::decode
FFVulkanShader decode[2]
Definition: vulkan_prores_raw.c:45
DecodePushData
Definition: vulkan_prores_raw.c:52
ff_vk_exec_add_dep_buf
int ff_vk_exec_add_dep_buf(FFVulkanContext *s, FFVkExecContext *e, AVBufferRef **deps, int nb_deps, int ref)
Execution dependency management.
Definition: vulkan.c:619
GLSLD
#define GLSLD(D)
Definition: vulkan.h:58
init_decode_shader
static int init_decode_shader(ProResRAWContext *prr, FFVulkanContext *s, FFVkExecPool *pool, FFVkSPIRVCompiler *spv, FFVulkanShader *shd, int version)
Definition: vulkan_prores_raw.c:223
vk_prores_raw_decode_slice
static int vk_prores_raw_decode_slice(AVCodecContext *avctx, const uint8_t *data, uint32_t size)
Definition: vulkan_prores_raw.c:107
if
if(ret)
Definition: filter_design.txt:179
vk_prores_raw_start_frame
static int vk_prores_raw_start_frame(AVCodecContext *avctx, const AVBufferRef *buffer_ref, av_unused const uint8_t *buffer, av_unused uint32_t size)
Definition: vulkan_prores_raw.c:66
HWACCEL_CAP_ASYNC_SAFE
#define HWACCEL_CAP_ASYNC_SAFE
Header providing the internals of AVHWAccel.
Definition: hwaccel_internal.h:31
ff_prores_raw_dc_cb
const uint8_t ff_prores_raw_dc_cb[DC_CB_MAX+1]
Definition: prores_raw.c:103
NULL
#define NULL
Definition: coverity.c:32
ProResRAWVulkanDecodePicture::tile_data
AVBufferRef * tile_data
Definition: vulkan_prores_raw.c:40
hwaccel_internal.h
ff_vk_decode_free_frame
void ff_vk_decode_free_frame(AVHWDeviceContext *dev_ctx, FFVulkanDecodePicture *vp)
Free a frame and its state.
Definition: vulkan_decode.c:603
AVCodecContext::internal
struct AVCodecInternal * internal
Private context used for internal data.
Definition: avcodec.h:466
av_buffer_pool_uninit
void av_buffer_pool_uninit(AVBufferPool **ppool)
Mark the pool as being available for freeing.
Definition: buffer.c:328
ff_vk_decode_uninit
int ff_vk_decode_uninit(AVCodecContext *avctx)
Free decoder.
Definition: vulkan_decode.c:1191
flush
void(* flush)(AVBSFContext *ctx)
Definition: dts2pts.c:370
ProResRAWContext
Definition: prores_raw.h:36
TileData::size
uint32_t size
Definition: vulkan_prores_raw.c:63
FFVkBuffer::mapped_mem
uint8_t * mapped_mem
Definition: vulkan.h:100
FFVulkanContext
Definition: vulkan.h:274
ff_vk_frame_params
int ff_vk_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx)
Initialize hw_frames_ctx with the parameters needed to decode the stream using the parameters from av...
Definition: vulkan_decode.c:1075
ProResRAWContext::th
int th
Definition: prores_raw.h:43
DecodePushData::tile_size
uint32_t tile_size[2]
Definition: vulkan_prores_raw.c:56
ProResRAWContext::scan
uint8_t scan[64]
Definition: prores_raw.h:52
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
ff_vk_shader_update_push_const
void ff_vk_shader_update_push_const(FFVulkanContext *s, FFVkExecContext *e, FFVulkanShader *shd, VkShaderStageFlagBits stage, int offset, size_t size, void *src)
Update push constant in a shader.
Definition: vulkan.c:2879
ff_source_prores_raw_comp
const char * ff_source_prores_raw_comp
FFVulkanDescriptorSetBinding
Definition: vulkan.h:74
ProResRAWContext::nb_tw
int nb_tw
Definition: prores_raw.h:44
AVCodecInternal::hwaccel_priv_data
void * hwaccel_priv_data
hwaccel-specific private data
Definition: internal.h:130
size
int size
Definition: twinvq_data.h:10344
FF_VK_EXT_PUSH_DESCRIPTOR
#define FF_VK_EXT_PUSH_DESCRIPTOR
Definition: vulkan_functions.h:48
FFVulkanShader
Definition: vulkan.h:190
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
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
FFVkExecContext
Definition: vulkan.h:111
ProResRAWVulkanDecodeContext
Definition: vulkan_prores_raw.c:44
ff_vk_shader_update_desc_buffer
int ff_vk_shader_update_desc_buffer(FFVulkanContext *s, FFVkExecContext *e, FFVulkanShader *shd, int set, int bind, int elem, FFVkBuffer *buf, VkDeviceSize offset, VkDeviceSize len, VkFormat fmt)
Update a descriptor in a buffer with a buffer.
Definition: vulkan.c:2813
FFVulkanDescriptorSetBinding::name
const char * name
Definition: vulkan.h:75
version
version
Definition: libkvazaar.c:315
M_PI
#define M_PI
Definition: mathematics.h:67
FFVkSPIRVCompiler
Definition: vulkan_spirv.h:26
AVHWAccel::name
const char * name
Name of the hardware accelerated codec.
Definition: avcodec.h:1942
DecodePushData::tile_data
VkDeviceAddress tile_data
Definition: vulkan_prores_raw.c:53
DecodePushData::qmat
uint8_t qmat[64]
Definition: vulkan_prores_raw.c:57
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
FF_VK_EXT_EXTERNAL_HOST_MEMORY
#define FF_VK_EXT_EXTERNAL_HOST_MEMORY
Definition: vulkan_functions.h:36
TileData::offset
uint32_t offset
Definition: vulkan_prores_raw.c:62
uninit
static void uninit(AVBSFContext *ctx)
Definition: pcm_rechunk.c:68
FFVulkanDecodePicture::out
VkImageView out[AV_NUM_DATA_POINTERS]
Definition: vulkan_decode.h:80
ff_vk_exec_start
int ff_vk_exec_start(FFVulkanContext *s, FFVkExecContext *e)
Start/submit/wait an execution.
Definition: vulkan.c:559
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
ProResRAWVulkanDecodeContext::uniform_buf
FFVkBuffer uniform_buf
Definition: vulkan_prores_raw.c:49
ProResRAWVulkanDecodePicture::vp
FFVulkanDecodePicture vp
Definition: vulkan_prores_raw.c:38
ff_vk_frame_barrier
void ff_vk_frame_barrier(FFVulkanContext *s, FFVkExecContext *e, AVFrame *pic, VkImageMemoryBarrier2 *bar, int *nb_bar, VkPipelineStageFlags src_stage, VkPipelineStageFlags dst_stage, VkAccessFlagBits new_access, VkImageLayout new_layout, uint32_t new_qf)
Definition: vulkan.c:2013
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:2353
ff_vk_unmap_buffer
static int ff_vk_unmap_buffer(FFVulkanContext *s, FFVkBuffer *buf, int flush)
Definition: vulkan.h:541
FFVulkanDecodePicture::sem
VkSemaphore sem
Definition: vulkan_decode.h:86
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:256
vulkan_spirv.h
ff_source_common_comp
const char * ff_source_common_comp
ff_vk_free_buf
void ff_vk_free_buf(FFVulkanContext *s, FFVkBuffer *buf)
Definition: vulkan.c:1212
AVCodecContext::height
int height
Definition: avcodec.h:592
ProResRAWContext::frame
AVFrame * frame
Definition: prores_raw.h:47
FFVkSPIRVCompiler::free_shader
void(* free_shader)(struct FFVkSPIRVCompiler *ctx, void **opaque)
Definition: vulkan_spirv.h:31
ff_vk_exec_bind_shader
void ff_vk_exec_bind_shader(FFVulkanContext *s, FFVkExecContext *e, FFVulkanShader *shd)
Bind a shader.
Definition: vulkan.c:2889
ff_vk_decode_flush
void ff_vk_decode_flush(AVCodecContext *avctx)
Flush decoder.
Definition: vulkan_decode.c:361
FFVkExecPool
Definition: vulkan.h:252
ff_vk_decode_add_slice
int ff_vk_decode_add_slice(AVCodecContext *avctx, FFVulkanDecodePicture *vp, const uint8_t *data, size_t size, int add_startcode, uint32_t *nb_slices, const uint32_t **offsets)
Add slice data to frame.
Definition: vulkan_decode.c:280
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:1459
FFVkExecContext::buf
VkCommandBuffer buf
Definition: vulkan.h:122
ff_vk_dec_prores_raw_desc
const FFVulkanDecodeDescriptor ff_vk_dec_prores_raw_desc
Definition: vulkan_prores_raw.c:31
AVCodecContext
main external API structure.
Definition: avcodec.h:431
buffer
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
Definition: filter_design.txt:49
update_thread_context
the pkt_dts and pkt_pts fields in AVFrame will work as usual Restrictions on codec whose streams don t reset across will not work because their bitstreams cannot be decoded in parallel *The contents of buffers must not be read before as well as code calling up to before the decode process starts Call have update_thread_context() run it in the next thread. Add AV_CODEC_CAP_FRAME_THREADS to the codec capabilities. There will be very little speed gain at this point but it should work. Use ff_thread_get_buffer()(or ff_progress_frame_get_buffer() in case you have inter-frame dependencies and use the ProgressFrame API) to allocate frame buffers. Call ff_progress_frame_report() after some part of the current picture has decoded. A good place to put this is where draw_horiz_band() is called - add this if it isn 't called anywhere
FFVulkanDecodeDescriptor
Definition: vulkan_decode.h:29
TileData::pos
int32_t pos[2]
Definition: vulkan_prores_raw.c:61
ff_vk_params_invalidate
int ff_vk_params_invalidate(AVCodecContext *avctx, int t, const uint8_t *b, uint32_t s)
Removes current session parameters to recreate them.
Definition: vulkan_decode.c:138
ff_vk_update_thread_context
int ff_vk_update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
Synchronize the contexts between 2 threads.
Definition: vulkan_decode.c:120
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:200
FFVulkanDecodePicture::slices_buf
AVBufferRef * slices_buf
Definition: vulkan_decode.h:101
mem.h
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
vk_decode_prores_raw_init
static int vk_decode_prores_raw_init(AVCodecContext *avctx)
Definition: vulkan_prores_raw.c:359
vulkan_decode.h
ProResRAWContext::nb_th
int nb_th
Definition: prores_raw.h:44
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:458
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
ff_prores_raw_ac_cb
const int16_t ff_prores_raw_ac_cb[AC_CB_MAX+1]
Definition: prores_raw.c:108
ProResRAWVulkanDecodeContext::tile_data_pool
AVBufferPool * tile_data_pool
Definition: vulkan_prores_raw.c:47
FFVkBuffer
Definition: vulkan.h:87
TileContext::x
unsigned x
Definition: prores_raw.h:33
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:592
int32_t
int32_t
Definition: audioconvert.c:56
ff_vk_exec_submit
int ff_vk_exec_submit(FFVulkanContext *s, FFVkExecContext *e)
Definition: vulkan.c:904
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
ff_vk_decode_init
int ff_vk_decode_init(AVCodecContext *avctx)
Initialize decoder.
Definition: vulkan_decode.c:1243
ff_prores_raw_vulkan_hwaccel
const FFHWAccel ff_prores_raw_vulkan_hwaccel
Definition: vulkan_prores_raw.c:485
ProResRAWContext::hwaccel_picture_private
void * hwaccel_picture_private
Definition: prores_raw.h:48
FFVulkanFunctions
Definition: vulkan_functions.h:276
TileData
Definition: vulkan_prores_raw.c:60
ff_vk_get_pooled_buffer
int ff_vk_get_pooled_buffer(FFVulkanContext *ctx, AVBufferPool **buf_pool, AVBufferRef **buf, VkBufferUsageFlags usage, void *create_pNext, size_t size, VkMemoryPropertyFlagBits mem_props)
Initialize a pool and create AVBufferRefs containing FFVkBuffer.
Definition: vulkan.c:1254
ProResRAWContext::qmat
uint8_t qmat[64]
Definition: prores_raw.h:53