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/mem.h"
26 
27 extern const unsigned char ff_prores_raw_decode_comp_spv_data[];
28 extern const unsigned int ff_prores_raw_decode_comp_spv_len;
29 
30 extern const unsigned char ff_prores_raw_idct_comp_spv_data[];
31 extern const unsigned int ff_prores_raw_idct_comp_spv_len;
32 
35  .queue_flags = VK_QUEUE_COMPUTE_BIT,
36 };
37 
40 
42  uint32_t nb_tiles;
44 
48 
51 
52 typedef struct DecodePushData {
53  VkDeviceAddress pkt_data;
54  uint8_t qmat[64];
55  uint16_t lin_curve[8];
57 
58 typedef struct TileData {
60  uint32_t offset;
61  uint32_t size;
62  uint32_t log2_nb_blocks;
63 } TileData;
64 
66  const AVBufferRef *buffer_ref,
67  av_unused const uint8_t *buffer,
68  av_unused uint32_t size)
69 {
70  int err;
73  ProResRAWVulkanDecodeContext *prv = ctx->sd_ctx;
74  ProResRAWContext *prr = avctx->priv_data;
75 
77  FFVulkanDecodePicture *vp = &pp->vp;
78 
79  /* Host map the input tile data if supported */
80  if (ctx->s.extensions & FF_VK_EXT_EXTERNAL_HOST_MEMORY)
81  ff_vk_host_map_buffer(&ctx->s, &vp->slices_buf, buffer_ref->data,
82  buffer_ref,
83  VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
84  VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT);
85 
86  /* Allocate tile data */
88  &pp->frame_data_buf,
89  VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
90  NULL, prr->nb_tiles*sizeof(TileData),
91  VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
92  VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT);
93  if (err < 0)
94  return err;
95 
96  return 0;
97 }
98 
100  const uint8_t *data,
101  uint32_t size)
102 {
103  ProResRAWContext *prr = avctx->priv_data;
104 
106  FFVulkanDecodePicture *vp = &pp->vp;
107 
108  FFVkBuffer *frame_data_buf = (FFVkBuffer *)pp->frame_data_buf->data;
109  TileData *td = (TileData *)frame_data_buf->mapped_mem;
110  FFVkBuffer *slices_buf = vp->slices_buf ?
111  (FFVkBuffer *)vp->slices_buf->data : NULL;
112 
113  td[pp->nb_tiles].pos[0] = prr->tiles[pp->nb_tiles].x;
114  td[pp->nb_tiles].pos[1] = prr->tiles[pp->nb_tiles].y;
115  td[pp->nb_tiles].size = size;
116  td[pp->nb_tiles].log2_nb_blocks = prr->tiles[pp->nb_tiles].log2_nb_blocks;
117 
118  if (vp->slices_buf && slices_buf->host_ref) {
119  td[pp->nb_tiles].offset = data - slices_buf->mapped_mem;
120  pp->nb_tiles++;
121  } else {
122  int err;
123  td[pp->nb_tiles].offset = vp->slices_size;
124  err = ff_vk_decode_add_slice(avctx, vp, data, size, 0,
125  &pp->nb_tiles, NULL);
126  if (err < 0)
127  return err;
128  }
129 
130  return 0;
131 }
132 
134 {
135  int err;
138  FFVulkanFunctions *vk = &ctx->s.vkfn;
139 
140  ProResRAWContext *prr = avctx->priv_data;
141  ProResRAWVulkanDecodeContext *prv = ctx->sd_ctx;
142 
144  FFVulkanDecodePicture *vp = &pp->vp;
145 
146  FFVkBuffer *slices_buf = (FFVkBuffer *)vp->slices_buf->data;
147  FFVkBuffer *frame_data_buf = (FFVkBuffer *)pp->frame_data_buf->data;
148 
149  VkImageMemoryBarrier2 img_bar[8];
150  int nb_img_bar = 0;
151 
152  FFVkExecContext *exec = ff_vk_exec_get(&ctx->s, &ctx->exec_pool);
153  ff_vk_exec_start(&ctx->s, exec);
154 
155  /* Prepare deps */
156  RET(ff_vk_exec_add_dep_frame(&ctx->s, exec, prr->frame,
157  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
158  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
159 
160  /* Exec-owned output views: freed on exec recycle, so releasing a picture
161  * needs no blocking wait. No mirror_sem: nothing consumes vp->sem here. */
162  VkImageView views[AV_NUM_DATA_POINTERS];
163  RET(ff_vk_create_imageviews(&ctx->s, exec, views, prr->frame,
165 
166  RET(ff_vk_exec_add_dep_buf(&ctx->s, exec, &pp->frame_data_buf, 1, 0));
167  pp->frame_data_buf = NULL;
168  RET(ff_vk_exec_add_dep_buf(&ctx->s, exec, &vp->slices_buf, 1, 0));
169  vp->slices_buf = NULL;
170 
171  AVVkFrame *vkf = (AVVkFrame *)prr->frame->data[0];
172  vkf->layout[0] = VK_IMAGE_LAYOUT_UNDEFINED;
173  vkf->access[0] = VK_ACCESS_2_NONE;
174 
175  ff_vk_frame_barrier(&ctx->s, exec, prr->frame, img_bar, &nb_img_bar,
176  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
177  VK_PIPELINE_STAGE_2_CLEAR_BIT,
178  VK_ACCESS_2_TRANSFER_WRITE_BIT,
179  VK_IMAGE_LAYOUT_GENERAL,
180  VK_QUEUE_FAMILY_IGNORED);
181 
182  vk->CmdPipelineBarrier2(exec->buf, &(VkDependencyInfo) {
183  .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
184  .pImageMemoryBarriers = img_bar,
185  .imageMemoryBarrierCount = nb_img_bar,
186  });
187  nb_img_bar = 0;
188 
189  vk->CmdClearColorImage(exec->buf, vkf->img[0],
190  VK_IMAGE_LAYOUT_GENERAL,
191  &((VkClearColorValue) { 0 }),
192  1, &((VkImageSubresourceRange) {
193  .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
194  .levelCount = 1,
195  .layerCount = 1,
196  }));
197 
198  ff_vk_frame_barrier(&ctx->s, exec, prr->frame, img_bar, &nb_img_bar,
199  VK_PIPELINE_STAGE_2_CLEAR_BIT,
200  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
201  VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT,
202  VK_IMAGE_LAYOUT_GENERAL,
203  VK_QUEUE_FAMILY_IGNORED);
204 
205  vk->CmdPipelineBarrier2(exec->buf, &(VkDependencyInfo) {
206  .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
207  .pImageMemoryBarriers = img_bar,
208  .imageMemoryBarrierCount = nb_img_bar,
209  });
210  nb_img_bar = 0;
211 
212  FFVulkanShader *decode_shader = &prv->decode;
213  ff_vk_shader_update_img_array(&ctx->s, exec, decode_shader,
214  prr->frame, views,
215  0, 0,
216  VK_IMAGE_LAYOUT_GENERAL,
217  VK_NULL_HANDLE);
218  ff_vk_shader_update_desc_buffer(&ctx->s, exec, decode_shader,
219  0, 1, 0,
220  frame_data_buf,
221  0, prr->nb_tiles*sizeof(TileData),
222  VK_FORMAT_UNDEFINED);
223 
224  ff_vk_exec_bind_shader(&ctx->s, exec, decode_shader);
225 
226  /* Update push data */
227  DecodePushData pd_decode = (DecodePushData) {
228  .pkt_data = slices_buf->address,
229  };
230  memcpy(pd_decode.qmat, prr->qmat, 64);
231  memcpy(pd_decode.lin_curve, prr->lin_curve, sizeof(pd_decode.lin_curve));
232  ff_vk_shader_update_push_const(&ctx->s, exec, decode_shader,
233  VK_SHADER_STAGE_COMPUTE_BIT,
234  0, offsetof(DecodePushData, qmat), &pd_decode);
235 
236  vk->CmdDispatch(exec->buf, prr->nb_tw, prr->nb_th, 1);
237 
238  ff_vk_frame_barrier(&ctx->s, exec, prr->frame, img_bar, &nb_img_bar,
239  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
240  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
241  VK_ACCESS_2_SHADER_STORAGE_READ_BIT |
242  VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT,
243  VK_IMAGE_LAYOUT_GENERAL,
244  VK_QUEUE_FAMILY_IGNORED);
245 
246  FFVulkanShader *idct_shader = &prv->idct;
247  ff_vk_shader_update_img_array(&ctx->s, exec, idct_shader,
248  prr->frame, views,
249  0, 0,
250  VK_IMAGE_LAYOUT_GENERAL,
251  VK_NULL_HANDLE);
252  ff_vk_shader_update_desc_buffer(&ctx->s, exec, idct_shader,
253  0, 1, 0,
254  frame_data_buf,
255  0, prr->nb_tiles*sizeof(TileData),
256  VK_FORMAT_UNDEFINED);
257  ff_vk_exec_bind_shader(&ctx->s, exec, idct_shader);
258  ff_vk_shader_update_push_const(&ctx->s, exec, idct_shader,
259  VK_SHADER_STAGE_COMPUTE_BIT,
260  0, sizeof(pd_decode), &pd_decode);
261 
262  vk->CmdPipelineBarrier2(exec->buf, &(VkDependencyInfo) {
263  .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
264  .pImageMemoryBarriers = img_bar,
265  .imageMemoryBarrierCount = nb_img_bar,
266  });
267  nb_img_bar = 0;
268 
269  vk->CmdDispatch(exec->buf, prr->nb_tw, prr->nb_th, 1);
270 
271  err = ff_vk_exec_submit(&ctx->s, exec);
272  if (err < 0)
273  return err;
274 
275 fail:
276  return 0;
277 }
278 
280  FFVulkanShader *shd)
281 {
282  const FFVulkanDescriptorSetBinding desc_set[] = {
283  { /* dst */
284  .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
285  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
286  },
287  { /* frame_data_buf */
288  .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
289  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
290  },
291  };
292 
293  ff_vk_shader_add_descriptor_set(s, shd, desc_set, 2, 0);
294 
295  return 0;
296 }
297 
299  FFVkExecPool *pool, FFVulkanShader *shd,
300  int version)
301 {
302  int err;
303 
304  ff_vk_shader_add_push_const(shd, 0, offsetof(DecodePushData, qmat),
305  VK_SHADER_STAGE_COMPUTE_BIT);
306  ff_vk_shader_load(shd, VK_SHADER_STAGE_COMPUTE_BIT, NULL,
307  (uint32_t []) { 1, 4, 1 }, 0);
308 
309  add_desc(avctx, s, shd);
310 
311  RET(ff_vk_shader_link(s, shd,
314 
315  RET(ff_vk_shader_register_exec(s, pool, shd));
316 
317 fail:
318  return err;
319 }
320 
322  FFVkExecPool *pool, FFVulkanShader *shd,
323  int version)
324 {
325  int err;
326  SPEC_LIST_CREATE(sl, 2 + 64, (2 + 64)*sizeof(uint32_t))
327 
328  int nb_blocks = version == 0 ? 8 : 16;
329  SPEC_LIST_ADD(sl, 16, 32, nb_blocks);
330  SPEC_LIST_ADD(sl, 17, 32, 4); /* nb_components */
331 
332  const double idct_8_scales[8] = {
333  cos(4.0*M_PI/16.0) / 2.0, cos(1.0*M_PI/16.0) / 2.0,
334  cos(2.0*M_PI/16.0) / 2.0, cos(3.0*M_PI/16.0) / 2.0,
335  cos(4.0*M_PI/16.0) / 2.0, cos(5.0*M_PI/16.0) / 2.0,
336  cos(6.0*M_PI/16.0) / 2.0, cos(7.0*M_PI/16.0) / 2.0,
337  };
338  for (int i = 0; i < 64; i++)
339  SPEC_LIST_ADD(sl, 18 + i, 32,
340  av_float2int(8*idct_8_scales[i >> 3]*idct_8_scales[i & 7]));
341 
342  ff_vk_shader_load(shd, VK_SHADER_STAGE_COMPUTE_BIT, sl,
343  (uint32_t []) { 8, nb_blocks, 4 }, 0);
344 
346  VK_SHADER_STAGE_COMPUTE_BIT);
347  add_desc(avctx, s, shd);
348 
349  RET(ff_vk_shader_link(s, shd,
352 
353  RET(ff_vk_shader_register_exec(s, pool, shd));
354 
355 fail:
356  return err;
357 }
358 
360 {
361  ProResRAWVulkanDecodeContext *fv = ctx->sd_ctx;
362 
363  ff_vk_shader_free(&ctx->s, &fv->decode);
364  ff_vk_shader_free(&ctx->s, &fv->idct);
365 
367 
368  av_freep(&fv);
369 }
370 
372 {
373  int err;
375  ProResRAWContext *prr = avctx->priv_data;
376 
377  err = ff_vk_decode_init(avctx);
378  if (err < 0)
379  return err;
380 
382  ProResRAWVulkanDecodeContext *prv = ctx->sd_ctx = av_mallocz(sizeof(*prv));
383  if (!prv) {
384  err = AVERROR(ENOMEM);
385  goto fail;
386  }
387 
388  ctx->sd_ctx_free = &vk_decode_prores_raw_uninit;
389 
390  /* Setup decode shader */
391  RET(init_decode_shader(avctx, &ctx->s, &ctx->exec_pool, &prv->decode,
392  prr->version));
393  RET(init_idct_shader(avctx, &ctx->s, &ctx->exec_pool, &prv->idct,
394  prr->version));
395 
396 fail:
397  return err;
398 }
399 
401 {
402  AVHWDeviceContext *dev_ctx = _hwctx.nc;
403 
405  FFVulkanDecodePicture *vp = &pp->vp;
406 
407  ff_vk_decode_free_frame(dev_ctx, vp);
408 
410 }
411 
413  .p.name = "prores_raw_vulkan",
414  .p.type = AVMEDIA_TYPE_VIDEO,
415  .p.id = AV_CODEC_ID_PRORES_RAW,
416  .p.pix_fmt = AV_PIX_FMT_VULKAN,
417  .start_frame = &vk_prores_raw_start_frame,
418  .decode_slice = &vk_prores_raw_decode_slice,
419  .end_frame = &vk_prores_raw_end_frame,
420  .free_frame_priv = &vk_prores_raw_free_frame_priv,
421  .frame_priv_data_size = sizeof(ProResRAWVulkanDecodePicture),
425  .frame_params = &ff_vk_frame_params,
426  .priv_data_size = sizeof(FFVulkanDecodeContext),
428 };
DecodePushData::lin_curve
uint16_t lin_curve[8]
Definition: vulkan_prores_raw.c:55
FFVulkanDecodePicture::slices_size
size_t slices_size
Definition: vulkan_decode.h:100
DecodePushData::pkt_data
VkDeviceAddress pkt_data
Definition: vulkan_prores_raw.c:53
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:359
ff_vk_shader_free
void ff_vk_shader_free(FFVulkanContext *s, FFVulkanShader *shd)
Free a shader.
Definition: vulkan.c:2680
AVBufferPool
The buffer pool.
Definition: buffer_internal.h:88
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
FFVulkanDecodeContext::shared_ctx
FFVulkanDecodeShared * shared_ctx
Definition: vulkan_decode.h:55
RET
#define RET(x)
Definition: vulkan.h:34
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
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:400
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:35
ff_prores_raw_idct_comp_spv_data
const unsigned char ff_prores_raw_idct_comp_spv_data[]
ProResRAWContext::version
int version
Definition: prores_raw.h:53
FFVkBuffer::address
VkDeviceAddress address
Definition: vulkan.h:96
ff_vk_exec_get
FFVkExecContext * ff_vk_exec_get(FFVulkanContext *s, FFVkExecPool *pool)
Retrieve an execution pool.
Definition: vulkan.c:568
FF_VK_REP_NATIVE
@ FF_VK_REP_NATIVE
Definition: vulkan.h:412
init_idct_shader
static int init_idct_shader(AVCodecContext *avctx, FFVulkanContext *s, FFVkExecPool *pool, FFVulkanShader *shd, int version)
Definition: vulkan_prores_raw.c:321
SPEC_LIST_ADD
#define SPEC_LIST_ADD(name, idx, val_bits, val)
Definition: vulkan.h:52
av_float2int
static av_always_inline uint32_t av_float2int(float f)
Reinterpret a float as a 32-bit integer.
Definition: intfloat.h:50
ff_vk_exec_bind_shader
void ff_vk_exec_bind_shader(FFVulkanContext *s, FFVkExecContext *e, const FFVulkanShader *shd)
Bind a shader.
Definition: vulkan.c:2657
FFVulkanDecodeContext
Definition: vulkan_decode.h:54
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:800
TileContext::log2_nb_blocks
int log2_nb_blocks
Definition: prores_raw.h:36
add_desc
static int add_desc(AVCodecContext *avctx, FFVulkanContext *s, FFVulkanShader *shd)
Definition: vulkan_prores_raw.c:279
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:493
ProResRAWVulkanDecodeContext::frame_data_pool
AVBufferPool * frame_data_pool
Definition: vulkan_prores_raw.c:49
ProResRAWVulkanDecodeContext::idct
FFVulkanShader idct
Definition: vulkan_prores_raw.c:47
ProResRAWVulkanDecodePicture::nb_tiles
uint32_t nb_tiles
Definition: vulkan_prores_raw.c:42
FFHWAccel
Definition: hwaccel_internal.h:34
AVVkFrame::img
VkImage img[AV_NUM_DATA_POINTERS]
Vulkan images to which the memory is bound to.
Definition: hwcontext_vulkan.h:266
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:2608
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:2093
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:2473
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:1411
FFVulkanDecodeShared
Definition: vulkan_decode.h:38
AV_CODEC_ID_PRORES_RAW
@ AV_CODEC_ID_PRORES_RAW
Definition: codec_id.h:324
av_unused
#define av_unused
Definition: attributes.h:164
AVHWDeviceContext
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
Definition: hwcontext.h:63
FFVulkanDescriptorSetBinding::type
VkDescriptorType type
Definition: vulkan.h:80
ProResRAWContext::nb_tiles
int nb_tiles
Definition: prores_raw.h:45
ProResRAWVulkanDecodeContext::decode
FFVulkanShader decode
Definition: vulkan_prores_raw.c:46
ProResRAWContext::tiles
TileContext * tiles
Definition: prores_raw.h:43
FFVulkanDecodePicture
Definition: vulkan_decode.h:73
ProResRAWVulkanDecodePicture
Definition: vulkan_prores_raw.c:38
prores_raw.h
vk_prores_raw_end_frame
static int vk_prores_raw_end_frame(AVCodecContext *avctx)
Definition: vulkan_prores_raw.c:133
ctx
static AVFormatContext * ctx
Definition: movenc.c:49
DecodePushData
Definition: vulkan_apv.c:58
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:640
av_mallocz
#define av_mallocz(s)
Definition: tableprint_vlc.h:31
ProResRAWContext::lin_curve
uint16_t lin_curve[8]
Definition: prores_raw.h:61
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:99
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:65
fail
#define fail
Definition: test.h:478
HWACCEL_CAP_ASYNC_SAFE
#define HWACCEL_CAP_ASYNC_SAFE
Header providing the internals of AVHWAccel.
Definition: hwaccel_internal.h:31
NULL
#define NULL
Definition: coverity.c:32
av_buffer_unref
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
Definition: buffer.c:139
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:647
AVCodecContext::internal
struct AVCodecInternal * internal
Private context used for internal data.
Definition: avcodec.h:478
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:1253
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:2333
ProResRAWContext
Definition: prores_raw.h:39
SPEC_LIST_CREATE
#define SPEC_LIST_CREATE(name, max_length, max_size)
Definition: vulkan.h:42
TileData::size
uint32_t size
Definition: vulkan_prores_raw.c:61
AVVkFrame::access
VkAccessFlagBits2 access[AV_NUM_DATA_POINTERS]
Updated after every barrier.
Definition: hwcontext_vulkan.h:290
FFVkBuffer::mapped_mem
uint8_t * mapped_mem
Definition: vulkan.h:100
FFVulkanContext
Definition: vulkan.h:275
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:1112
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:608
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:2647
FFVulkanDescriptorSetBinding
Definition: vulkan.h:78
ProResRAWContext::nb_tw
int nb_tw
Definition: prores_raw.h:47
AVCodecInternal::hwaccel_priv_data
void * hwaccel_priv_data
hwaccel-specific private data
Definition: internal.h:130
AVVkFrame
Definition: hwcontext_vulkan.h:261
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:473
ff_prores_raw_decode_comp_spv_len
const unsigned int ff_prores_raw_decode_comp_spv_len
FFVulkanShader
Definition: vulkan.h:191
ff_prores_raw_idct_comp_spv_len
const unsigned int ff_prores_raw_idct_comp_spv_len
FFVkExecContext
Definition: vulkan.h:111
ProResRAWVulkanDecodeContext
Definition: vulkan_prores_raw.c:45
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:2621
version
version
Definition: libkvazaar.c:313
M_PI
#define M_PI
Definition: mathematics.h:67
AVHWAccel::name
const char * name
Name of the hardware accelerated codec.
Definition: avcodec.h:1954
DecodePushData::qmat
uint8_t qmat[64]
Definition: vulkan_prores_raw.c:54
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:60
ff_vk_exec_start
int ff_vk_exec_start(FFVulkanContext *s, FFVkExecContext *e)
Start/submit/wait an execution.
Definition: vulkan.c:580
ProResRAWVulkanDecodePicture::vp
FFVulkanDecodePicture vp
Definition: vulkan_prores_raw.c:39
s
uint8_t s
Definition: llvidencdsp.c:39
uninit
static av_cold void uninit(AVBitStreamFilterContext *ctx)
Definition: lcevc_merge.c:135
ProResRAWContext::frame
AVFrame * frame
Definition: prores_raw.h:50
ff_prores_raw_decode_comp_spv_data
const unsigned char ff_prores_raw_decode_comp_spv_data[]
ff_vk_shader_add_descriptor_set
void ff_vk_shader_add_descriptor_set(FFVulkanContext *s, FFVulkanShader *shd, const FFVulkanDescriptorSetBinding *desc, int nb, int singular)
Add descriptor to a shader.
Definition: vulkan.c:2439
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:2010
FFVkExecPool
Definition: vulkan.h:253
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:258
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:1509
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:33
AVCodecContext
main external API structure.
Definition: avcodec.h:443
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:59
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:142
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:200
FFVulkanDecodePicture::slices_buf
AVBufferRef * slices_buf
Definition: vulkan_decode.h:99
mem.h
AVVkFrame::layout
VkImageLayout layout[AV_NUM_DATA_POINTERS]
Definition: hwcontext_vulkan.h:291
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:371
vulkan_decode.h
ProResRAWContext::nb_th
int nb_th
Definition: prores_raw.h:47
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:470
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
FFVkBuffer
Definition: vulkan.h:91
TileContext::x
unsigned x
Definition: prores_raw.h:35
int32_t
int32_t
Definition: audioconvert.c:56
ff_vk_exec_submit
int ff_vk_exec_submit(FFVulkanContext *s, FFVkExecContext *e)
Definition: vulkan.c:925
init_decode_shader
static int init_decode_shader(AVCodecContext *avctx, FFVulkanContext *s, FFVkExecPool *pool, FFVulkanShader *shd, int version)
Definition: vulkan_prores_raw.c:298
ff_vk_decode_init
int ff_vk_decode_init(AVCodecContext *avctx)
Initialize decoder.
Definition: vulkan_decode.c:1264
ff_prores_raw_vulkan_hwaccel
const FFHWAccel ff_prores_raw_vulkan_hwaccel
Definition: vulkan_prores_raw.c:412
ProResRAWVulkanDecodePicture::frame_data_buf
AVBufferRef * frame_data_buf
Definition: vulkan_prores_raw.c:41
ProResRAWContext::hwaccel_picture_private
void * hwaccel_picture_private
Definition: prores_raw.h:51
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:2136
TileData
Definition: vulkan_prores_raw.c:58
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:1306
TileData::log2_nb_blocks
uint32_t log2_nb_blocks
Definition: vulkan_prores_raw.c:62
ProResRAWContext::qmat
uint8_t qmat[64]
Definition: prores_raw.h:56