FFmpeg
Loading...
Searching...
No Matches
vulkan_prores.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 "proresdec.h"
20#include "vulkan_decode.h"
21#include "hwaccel_internal.h"
22#include "libavutil/mem.h"
23#include "libavutil/vulkan.h"
24
25extern const unsigned char ff_prores_vld_comp_spv_data[];
26extern const unsigned int ff_prores_vld_comp_spv_len;
27
28extern const unsigned char ff_prores_idct_comp_spv_data[];
29extern const unsigned int ff_prores_idct_comp_spv_len;
30
32 .codec_id = AV_CODEC_ID_PRORES,
33 .queue_flags = VK_QUEUE_COMPUTE_BIT,
34};
35
48
55
56typedef struct ProresVkParameters {
57 VkDeviceAddress slice_data;
59
60 uint16_t width;
61 uint16_t height;
62 uint16_t mb_width;
63 uint16_t mb_height;
64 uint16_t slice_width;
65 uint16_t slice_height;
68 uint8_t depth;
69 uint8_t alpha_info;
70 uint8_t bottom_field;
72
74 const AVBufferRef *buffer_ref,
75 av_unused const uint8_t *buffer,
76 av_unused uint32_t size)
77{
78 ProresContext *pr = avctx->priv_data;
81 ProresVulkanDecodeContext *pv = ctx->sd_ctx;
83 FFVulkanDecodePicture *vp = &pp->vp;
84
85 int err;
86
87 pp->slice_offsets_sz = (pr->slice_count + 1) * sizeof(uint32_t);
88 pp->qmat_sz = sizeof(pr->qmat_luma) + sizeof(pr->qmat_chroma);
89 pp->mb_params_sz = pr->mb_width * pr->mb_height * sizeof(uint8_t);
90
91 pp->slice_offsets_off = 0;
93 ctx->s.props.properties.limits.minStorageBufferOffsetAlignment);
94 pp->mb_params_off = FFALIGN(pp->qmat_off + pp->qmat_sz,
95 ctx->s.props.properties.limits.minStorageBufferOffsetAlignment);
96
97 /* Host map the input slices data if supported */
98 if (!vp->slices_buf && ctx->s.extensions & FF_VK_EXT_EXTERNAL_HOST_MEMORY)
99 RET(ff_vk_host_map_buffer(&ctx->s, &vp->slices_buf, buffer_ref->data,
100 VK_WHOLE_SIZE, buffer_ref,
101 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
102 VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT));
103
104 /* Allocate metadata buffer */
106 &pp->metadata_buf,
107 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
109 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
110 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT));
111
112 pp->slice_num = 0;
113 pp->bitstream_start = pp->bitstream_size = 0;
114
115fail:
116 return err;
117}
118
120 const uint8_t *data,
121 uint32_t size)
122{
123 ProresContext *pr = avctx->priv_data;
125 FFVulkanDecodePicture *vp = &pp->vp;
126
127 FFVkBuffer *slice_offset = pp->metadata_buf;
128 FFVkBuffer *slices_buf = vp->slices_buf;
129
130 /* Skip picture header */
131 if (slices_buf && slices_buf->host_ref && !pp->slice_num)
132 pp->bitstream_size = data - slices_buf->mapped_mem;
133
134 AV_WN32(slice_offset->mapped_mem + (pp->slice_num + 0) * sizeof(uint32_t),
135 pp->bitstream_size);
136 AV_WN32(slice_offset->mapped_mem + (pp->slice_num + 1) * sizeof(uint32_t),
137 pp->bitstream_size += size);
138
139 if (!slices_buf || !slices_buf->host_ref) {
140 int err = ff_vk_decode_add_slice(avctx, vp, data, size, 0,
141 &pp->slice_num, NULL);
142 if (err < 0)
143 return err;
144 } else {
145 pp->slice_num++;
146 }
147
148 return 0;
149}
150
152{
153 ProresContext *pr = avctx->priv_data;
156 FFVulkanFunctions *vk = &ctx->s.vkfn;
157 ProresVulkanDecodeContext *pv = ctx->sd_ctx;
159 FFVulkanDecodePicture *vp = &pp->vp;
160 AVFrame *f = pr->frame;
161 AVVkFrame *vkf = (AVVkFrame *)f->data[0];
162
164 FFVkBuffer *slice_data, *metadata;
165 VkImageMemoryBarrier2 img_bar[AV_NUM_DATA_POINTERS];
166 VkBufferMemoryBarrier2 buf_bar[2];
167 int nb_img_bar = 0, nb_buf_bar = 0, nb_imgs, i, err;
168 const AVPixFmtDescriptor *pix_desc;
169
170 if (!pp->slice_num)
171 return 0;
172
173 pix_desc = av_pix_fmt_desc_get(avctx->sw_pix_fmt);
174 if (!pix_desc)
175 return AVERROR(EINVAL);
176
177 slice_data = vp->slices_buf;
179
180 pd = (ProresVkParameters) {
181 .slice_data = slice_data->address,
182 .bitstream_size = pp->bitstream_size,
183
184 .width = avctx->width,
185 .height = avctx->height,
186 .mb_width = pr->mb_width,
187 .mb_height = pr->mb_height,
188 .slice_width = pr->slice_count / pr->mb_height,
189 .slice_height = pr->mb_height,
190 .log2_slice_width = av_log2(pr->slice_mb_width),
191 .log2_chroma_w = pix_desc->log2_chroma_w,
192 .depth = avctx->bits_per_raw_sample,
193 .alpha_info = pr->alpha_info,
194 .bottom_field = pr->first_field ^ (pr->frame_type == 1),
195 };
196
197 /* The decoder permutes the quantization matrices to match the layout
198 * expected by its IDCT (transposed on x86), undo it here. */
199 {
200 uint8_t *qmat_luma = metadata->mapped_mem + pp->qmat_off;
201 uint8_t *qmat_chroma = qmat_luma + sizeof(pr->qmat_luma);
202 const uint8_t *perm = pr->prodsp.idct_permutation;
203
204 for (i = 0; i < 64; i++) {
205 qmat_luma [perm[i]] = pr->qmat_luma [i];
206 qmat_chroma[perm[i]] = pr->qmat_chroma[i];
207 }
208 }
209
210 FFVkExecContext *exec = ff_vk_exec_get(&ctx->s, &ctx->exec_pool);
211 err = ff_vk_exec_start(&ctx->s, exec);
212 if (err < 0)
213 return err;
214
215 /* Prepare deps */
217 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
218 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
219
220 /* Exec-owned output views: freed on exec recycle, so releasing a picture
221 * needs no blocking wait. No mirror_sem: nothing consumes vp->sem here. */
222 VkImageView views[AV_NUM_DATA_POINTERS];
223 RET(ff_vk_create_imageviews(&ctx->s, exec, views, f, FF_VK_REP_NATIVE));
224
227
228 vkf->layout[0] = VK_IMAGE_LAYOUT_UNDEFINED;
229 vkf->access[0] = VK_ACCESS_2_NONE;
230
231 nb_imgs = ff_vk_count_images(vkf);
232
233 if (pr->first_field) {
234 /* Input barrier */
235 ff_vk_frame_barrier(&ctx->s, exec, f, img_bar, &nb_img_bar,
236 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
237 VK_PIPELINE_STAGE_2_CLEAR_BIT,
238 VK_ACCESS_2_TRANSFER_WRITE_BIT,
239 VK_IMAGE_LAYOUT_GENERAL,
240 VK_QUEUE_FAMILY_IGNORED);
241 vk->CmdPipelineBarrier2(exec->buf, &(VkDependencyInfo) {
242 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
243 .pBufferMemoryBarriers = buf_bar,
244 .bufferMemoryBarrierCount = nb_buf_bar,
245 .pImageMemoryBarriers = img_bar,
246 .imageMemoryBarrierCount = nb_img_bar,
247 });
248 nb_img_bar = nb_buf_bar = 0;
249
250 /* Clear the input image since the vld shader does sparse writes, except for alpha */
251 for (i = 0; i < FFMIN(nb_imgs, 3); ++i) {
252 vk->CmdClearColorImage(exec->buf, vkf->img[i],
253 VK_IMAGE_LAYOUT_GENERAL,
254 &((VkClearColorValue) { 0 }),
255 1, &((VkImageSubresourceRange) {
256 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
257 .levelCount = 1,
258 .layerCount = 1,
259 }));
260 }
261 }
262
263 /* Input barrier, or synchronization between clear and vld shader */
264 ff_vk_frame_barrier(&ctx->s, exec, f, img_bar, &nb_img_bar,
265 pr->first_field ? VK_PIPELINE_STAGE_2_CLEAR_BIT :
266 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
267 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
268 VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT,
269 VK_IMAGE_LAYOUT_GENERAL,
270 VK_QUEUE_FAMILY_IGNORED);
271 ff_vk_buf_barrier(buf_bar[nb_buf_bar++], metadata,
272 ALL_COMMANDS_BIT, NONE_KHR, NONE_KHR,
273 COMPUTE_SHADER_BIT, SHADER_WRITE_BIT, NONE_KHR,
275 vk->CmdPipelineBarrier2(exec->buf, &(VkDependencyInfo) {
276 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
277 .pBufferMemoryBarriers = buf_bar,
278 .bufferMemoryBarrierCount = nb_buf_bar,
279 .pImageMemoryBarriers = img_bar,
280 .imageMemoryBarrierCount = nb_img_bar,
281 });
282 nb_img_bar = nb_buf_bar = 0;
283
284 /* Entropy decode */
286 0, 0, 0,
287 metadata,
290 VK_FORMAT_UNDEFINED);
292 0, 1, 0,
293 metadata,
294 pp->mb_params_off,
295 pp->mb_params_sz,
296 VK_FORMAT_UNDEFINED);
297 ff_vk_shader_update_img_array(&ctx->s, exec, &pv->vld,
298 f, views,
299 0, 2,
300 VK_IMAGE_LAYOUT_GENERAL,
301 VK_NULL_HANDLE);
302
303 ff_vk_exec_bind_shader(&ctx->s, exec, &pv->vld);
304 ff_vk_shader_update_push_const(&ctx->s, exec, &pv->vld,
305 VK_SHADER_STAGE_COMPUTE_BIT,
306 0, sizeof(pd), &pd);
307
308 vk->CmdDispatch(exec->buf, AV_CEIL_RSHIFT(pr->slice_count / pr->mb_height, 3),
310 3 + !!pr->alpha_info);
311
312 /* Synchronize vld and idct shaders */
313 ff_vk_frame_barrier(&ctx->s, exec, f, img_bar, &nb_img_bar,
314 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
315 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
316 VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT,
317 VK_IMAGE_LAYOUT_GENERAL,
318 VK_QUEUE_FAMILY_IGNORED);
319 ff_vk_buf_barrier(buf_bar[nb_buf_bar++], metadata,
320 COMPUTE_SHADER_BIT, SHADER_WRITE_BIT, NONE_KHR,
321 COMPUTE_SHADER_BIT, SHADER_READ_BIT, NONE_KHR,
323 vk->CmdPipelineBarrier2(exec->buf, &(VkDependencyInfo) {
324 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
325 .pBufferMemoryBarriers = buf_bar,
326 .bufferMemoryBarrierCount = nb_buf_bar,
327 .pImageMemoryBarriers = img_bar,
328 .imageMemoryBarrierCount = nb_img_bar,
329 });
330 nb_img_bar = nb_buf_bar = 0;
331
332 /* Inverse transform */
334 0, 0, 0,
335 metadata,
336 pp->mb_params_off,
337 pp->mb_params_sz,
338 VK_FORMAT_UNDEFINED);
340 0, 1, 0,
341 metadata,
342 pp->qmat_off,
343 pp->qmat_sz,
344 VK_FORMAT_UNDEFINED);
345 ff_vk_shader_update_img_array(&ctx->s, exec, &pv->idct,
346 f, views,
347 0, 2,
348 VK_IMAGE_LAYOUT_GENERAL,
349 VK_NULL_HANDLE);
350
351 ff_vk_exec_bind_shader(&ctx->s, exec, &pv->idct);
353 VK_SHADER_STAGE_COMPUTE_BIT,
354 0, sizeof(pd), &pd);
355
356 vk->CmdDispatch(exec->buf, AV_CEIL_RSHIFT(pr->mb_width, 1), pr->mb_height, 3);
357
358 err = ff_vk_exec_submit(&ctx->s, exec);
359 if (err < 0)
360 return err;
361
362 return 0;
363
364fail:
365 ff_vk_exec_discard(&ctx->s, exec);
366 return err;
367}
368
370 FFVkExecPool *pool, FFVulkanShader *shd,
371 int max_num_mbs, int interlaced)
372{
373 int err;
374 AVHWFramesContext *dec_frames_ctx;
375 dec_frames_ctx = (AVHWFramesContext *)avctx->hw_frames_ctx->data;
376
377 /* Discrete GPUs read host-mapped packets over the bus; prefetch more
378 * to hide the latency. 32 lines (32 KB for the 8x8 workgroup) measured
379 * best; integrated GPUs get slower with every extra line. Clamp to the
380 * shared memory limit, leaving 1 KB for the tables. */
381 int smem_lines = 4;
382 if (s->props.properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU &&
383 (s->extensions & FF_VK_EXT_EXTERNAL_HOST_MEMORY)) {
384 uint32_t max_smem = s->props.properties.limits.maxComputeSharedMemorySize;
385 smem_lines = FFMIN(32, (max_smem - 1024) / (8*8*16));
386 }
387 SPEC_LIST_CREATE(sl, 2, 2*sizeof(uint32_t))
388 SPEC_LIST_ADD(sl, 0, 32, interlaced);
389 SPEC_LIST_ADD(sl, 1, 32, smem_lines);
390
392 VK_SHADER_STAGE_COMPUTE_BIT, sl,
393 (uint32_t []) { 8, 8, 1 }, 0);
394
396 VK_SHADER_STAGE_COMPUTE_BIT);
397
398 const FFVulkanDescriptorSetBinding desc_set[] = {
399 { /* slice_offsets_buf */
400 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
401 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
402 },
403 { /* quant_idx_buf */
404 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
405 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
406 },
407 { /* dst */
408 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
409 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
410 .elems = av_pix_fmt_count_planes(dec_frames_ctx->sw_format),
411 },
412 };
413 ff_vk_shader_add_descriptor_set(s, shd, desc_set, 3, 0);
414
418
419 RET(ff_vk_shader_register_exec(s, pool, shd));
420
421fail:
422 return 0;
423}
424
426 FFVkExecPool *pool, FFVulkanShader *shd,
427 int max_num_mbs, int interlaced)
428{
429 int err;
430 AVHWFramesContext *dec_frames_ctx;
431 dec_frames_ctx = (AVHWFramesContext *)avctx->hw_frames_ctx->data;
432
433 SPEC_LIST_CREATE(sl, 2 + 8, (2 + 8)*sizeof(uint32_t))
434 SPEC_LIST_ADD(sl, 0, 32, interlaced);
435 SPEC_LIST_ADD(sl, 16, 32, 4*2); /* nb_blocks */
436
437 const double idct_8_scales[8] = {
438 cos(4.0*M_PI/16.0) / 2.0, cos(1.0*M_PI/16.0) / 2.0,
439 cos(2.0*M_PI/16.0) / 2.0, cos(3.0*M_PI/16.0) / 2.0,
440 cos(4.0*M_PI/16.0) / 2.0, cos(5.0*M_PI/16.0) / 2.0,
441 cos(6.0*M_PI/16.0) / 2.0, cos(7.0*M_PI/16.0) / 2.0,
442 };
443 for (int i = 0; i < 8; i++)
444 SPEC_LIST_ADD(sl, 18 + i, 32, av_float2int(idct_8_scales[i]));
445
447 VK_SHADER_STAGE_COMPUTE_BIT, sl,
448 (uint32_t []) { 32, 2, 1 }, 0);
449
451 VK_SHADER_STAGE_COMPUTE_BIT);
452
453 const FFVulkanDescriptorSetBinding desc_set[] = {
454 { /* quant_idx_buf */
455 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
456 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
457 },
458 { /* qmat_buf */
459 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
460 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
461 },
462 { /* dst */
463 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
464 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
465 .elems = av_pix_fmt_count_planes(dec_frames_ctx->sw_format),
466 },
467 };
468 ff_vk_shader_add_descriptor_set(s, shd, desc_set, 3, 0);
469
473
474 RET(ff_vk_shader_register_exec(s, pool, shd));
475
476fail:
477 return 0;
478}
479
481{
482 ProresVulkanDecodeContext *pv = ctx->sd_ctx;
483
484 ff_vk_shader_free(&ctx->s, &pv->vld);
485 ff_vk_shader_free(&ctx->s, &pv->idct);
486
488
489 av_freep(&pv);
490}
491
493{
496 ProresContext *pr = avctx->priv_data;
497
499 int max_num_mbs, err;
500
501 max_num_mbs = (avctx->coded_width >> 4) * (avctx->coded_height >> 4);
502
503 err = ff_vk_decode_init(avctx);
504 if (err < 0)
505 return err;
506 ctx = dec->shared_ctx;
507
508 pv = ctx->sd_ctx = av_mallocz(sizeof(*pv));
509 if (!pv) {
510 err = AVERROR(ENOMEM);
511 goto fail;
512 }
513
514 ctx->sd_ctx_free = vk_decode_prores_uninit;
515
516 RET(init_decode_shader(avctx, &ctx->s, &ctx->exec_pool,
517 &pv->vld, max_num_mbs, pr->frame_type != 0));
518 RET(init_idct_shader(avctx, &ctx->s, &ctx->exec_pool,
519 &pv->idct, max_num_mbs, pr->frame_type != 0));
520
521fail:
522 return err;
523}
524
526{
527 AVHWDeviceContext *dev_ctx = _hwctx.nc;
529
530 ff_vk_decode_free_frame(dev_ctx, &pp->vp);
531
533}
534
536 .p.name = "prores_vulkan",
537 .p.type = AVMEDIA_TYPE_VIDEO,
538 .p.id = AV_CODEC_ID_PRORES,
539 .p.pix_fmt = AV_PIX_FMT_VULKAN,
540 .start_frame = &vk_prores_start_frame,
541 .decode_slice = &vk_prores_decode_slice,
542 .end_frame = &vk_prores_end_frame,
543 .free_frame_priv = &vk_prores_free_frame_priv,
544 .frame_priv_data_size = sizeof(ProresVulkanDecodePicture),
546 .update_thread_context = &ff_vk_update_thread_context,
548 .frame_params = &ff_vk_frame_params,
549 .priv_data_size = sizeof(FFVulkanDecodeContext),
551};
static AVFormatContext * ctx
static int FUNC metadata(CodedBitstreamContext *ctx, RWContext *rw, APVRawMetadata *current)
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define f(width, name)
Definition cbs_vp8.c:236
#define s(width, name)
Definition cbs_vp9.c:198
#define AV_CEIL_RSHIFT(a, b)
Definition common.h:60
#define NULL
Definition coverity.c:32
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
perm
Definition f_perms.c:75
#define AV_NUM_DATA_POINTERS
Definition frame.h:473
#define fail
Definition test.h:479
@ AV_CODEC_ID_PRORES
Definition codec_id.h:198
#define AVERROR(e)
Definition error.h:45
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
#define HWACCEL_CAP_ASYNC_SAFE
Header providing the internals of AVHWAccel.
#define HWACCEL_CAP_THREAD_SAFE
const struct FFHWAccel ff_prores_vulkan_hwaccel
static av_always_inline uint32_t av_float2int(float f)
Reinterpret a float as a 32-bit integer.
Definition intfloat.h:50
#define av_log2
Definition intmath.h:84
#define AV_WN32(p, v)
static av_cold void uninit(AVBitStreamFilterContext *ctx)
#define av_unused
Definition attributes.h:164
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:2690
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:2262
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:2521
int ff_vk_shader_add_push_const(FFVulkanShader *shd, int offset, int size, VkShaderStageFlagBits stage)
Add/update push constants for execution.
Definition vulkan.c:1631
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:2216
int ff_vk_exec_start(FFVulkanContext *s, FFVkExecContext *e)
Start/submit/wait an execution.
Definition vulkan.c:664
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:2147
void ff_vk_shader_free(FFVulkanContext *s, FFVulkanShader *shd)
Free a shader.
Definition vulkan.c:2757
int ff_vk_shader_register_exec(FFVulkanContext *s, FFVkExecPool *pool, FFVulkanShader *shd)
Register a shader with an exec pool.
Definition vulkan.c:2555
FFVkExecContext * ff_vk_exec_get(FFVulkanContext *s, FFVkExecPool *pool)
Retrieve an execution pool.
Definition vulkan.c:626
int ff_vk_exec_submit(FFVulkanContext *s, FFVkExecContext *e)
Definition vulkan.c:987
void ff_vk_exec_bind_shader(FFVulkanContext *s, FFVkExecContext *e, const FFVulkanShader *shd)
Bind a shader.
Definition vulkan.c:2739
void ff_vk_exec_move_dep_refstruct(FFVulkanContext *s, FFVkExecContext *e, void *obj)
Definition vulkan.c:790
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:2703
int ff_vk_host_map_buffer(FFVulkanContext *s, FFVkBuffer **dst, uint8_t *src_data, VkDeviceSize size, const AVBufferRef *src_buf, VkBufferUsageFlags usage)
Maps a system RAM buffer into a Vulkan buffer.
Definition vulkan.c:1540
int ff_vk_get_pooled_buffer(FFVulkanContext *ctx, AVRefStructPool **buf_pool, FFVkBuffer **buf, VkBufferUsageFlags usage, void *create_pNext, size_t size, VkMemoryPropertyFlagBits mem_props)
Initialize a pool and create AVBufferRefs containing FFVkBuffer.
Definition vulkan.c:1444
void ff_vk_exec_discard(FFVulkanContext *s, FFVkExecContext *e)
Definition vulkan.c:767
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:2425
int ff_vk_exec_add_dep_frame(FFVulkanContext *s, FFVkExecContext *e, AVFrame *f, VkPipelineStageFlagBits2 wait_stage, VkPipelineStageFlagBits2 signal_stage)
Definition vulkan.c:885
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:2729
#define FFMIN(a, b)
Definition macros.h:49
#define FFALIGN(x, a)
Definition macros.h:78
#define M_PI
Definition mathematics.h:67
Memory handling functions.
const char data[16]
Definition mxf.c:149
uint8_t interlaced
Definition mxfenc.c:2336
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition pixdesc.c:3500
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition pixdesc.c:3460
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition pixfmt.h:379
void av_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
Definition refstruct.c:121
static void av_refstruct_pool_uninit(AVRefStructPool **poolp)
Mark the pool as being available for freeing.
Definition refstruct.h:292
A reference to a data buffer.
Definition buffer.h:82
uint8_t * data
The data buffer.
Definition buffer.h:90
main external API structure.
Definition avcodec.h:443
int width
picture width / height.
Definition avcodec.h:604
enum AVPixelFormat sw_pix_fmt
Nominal unaccelerated pixel format, see AV_PIX_FMT_xxx.
Definition avcodec.h:650
AVBufferRef * hw_frames_ctx
A reference to the AVHWFramesContext describing the input (for encoding) or output (decoding) frames.
Definition avcodec.h:1472
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
Definition avcodec.h:1576
int coded_width
Bitstream width / height, may be different from width/height e.g.
Definition avcodec.h:619
struct AVCodecInternal * internal
Private context used for internal data.
Definition avcodec.h:478
void * priv_data
Definition avcodec.h:470
void * hwaccel_priv_data
hwaccel-specific private data
Definition internal.h:130
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
Definition hwcontext.h:63
This struct describes a set or pool of "hardware" frames (i.e.
Definition hwcontext.h:118
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
Definition hwcontext.h:213
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition pixdesc.h:69
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition pixdesc.h:80
AVRefStructPool is an API for a thread-safe pool of objects managed via the RefStruct API.
Definition refstruct.c:184
VkImageLayout layout[AV_NUM_DATA_POINTERS]
VkAccessFlagBits2 access[AV_NUM_DATA_POINTERS]
Updated after every barrier.
VkImage img[AV_NUM_DATA_POINTERS]
Vulkan images to which the memory is bound to.
VkDeviceAddress address
Definition vulkan.h:99
AVBufferRef * host_ref
Definition vulkan.h:111
uint8_t * mapped_mem
Definition vulkan.h:103
VkCommandBuffer buf
Definition vulkan.h:142
FFVulkanDecodeShared * shared_ctx
unsigned mb_height
height of the current picture in mb
Definition proresdec.h:54
int slice_count
number of slices in the current picture
Definition proresdec.h:52
unsigned slice_mb_width
maximum width of a slice in mb
Definition proresdec.h:55
uint8_t qmat_luma[64]
Definition proresdec.h:49
AVFrame * frame
Definition proresdec.h:46
int frame_type
0 = progressive, 1 = tff, 2 = bff
Definition proresdec.h:48
uint8_t qmat_chroma[64]
Definition proresdec.h:50
unsigned mb_width
width of the current picture in mb
Definition proresdec.h:53
void * hwaccel_picture_private
Definition proresdec.h:47
ProresDSPContext prodsp
Definition proresdec.h:45
uint8_t idct_permutation[64]
Definition proresdsp.h:31
VkDeviceAddress slice_data
AVRefStructPool * metadata_pool
FFVulkanDecodePicture vp
#define av_mallocz(s)
#define av_freep(p)
static char buffer[20]
Definition seek.c:32
int size
RefStruct is an API for creating reference-counted objects with minimal overhead.
Definition refstruct.h:58
#define ff_vk_buf_barrier(dst, vkb, s_stage, s_access, s_access2, d_stage, d_access, d_access2, offs, bsz)
Definition vulkan.h:579
@ FF_VK_REP_NATIVE
Definition vulkan.h:440
#define RET(x)
Definition vulkan.h:37
#define SPEC_LIST_ADD(name, idx, val_bits, val)
Definition vulkan.h:55
#define SPEC_LIST_CREATE(name, max_length, max_size)
Definition vulkan.h:45
static int ff_vk_count_images(AVVkFrame *f)
Definition vulkan.h:357
int ff_vk_update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
Synchronize the contexts between 2 threads.
int ff_vk_decode_init(AVCodecContext *avctx)
Initialize decoder.
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...
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.
void ff_vk_decode_free_frame(AVHWDeviceContext *dev_ctx, FFVulkanDecodePicture *vp)
Free a frame and its state.
int ff_vk_decode_uninit(AVCodecContext *avctx)
Free decoder.
#define FF_VK_EXT_EXTERNAL_HOST_MEMORY
static void vk_prores_free_frame_priv(AVRefStructOpaque _hwctx, void *data)
static int vk_prores_end_frame(AVCodecContext *avctx)
static int init_decode_shader(AVCodecContext *avctx, FFVulkanContext *s, FFVkExecPool *pool, FFVulkanShader *shd, int max_num_mbs, int interlaced)
static int vk_decode_prores_init(AVCodecContext *avctx)
const unsigned char ff_prores_vld_comp_spv_data[]
static int vk_prores_decode_slice(AVCodecContext *avctx, const uint8_t *data, uint32_t size)
static int init_idct_shader(AVCodecContext *avctx, FFVulkanContext *s, FFVkExecPool *pool, FFVulkanShader *shd, int max_num_mbs, int interlaced)
const unsigned int ff_prores_vld_comp_spv_len
static int vk_prores_start_frame(AVCodecContext *avctx, const AVBufferRef *buffer_ref, av_unused const uint8_t *buffer, av_unused uint32_t size)
const unsigned int ff_prores_idct_comp_spv_len
static void vk_decode_prores_uninit(FFVulkanDecodeShared *ctx)
const FFVulkanDecodeDescriptor ff_vk_dec_prores_desc
const unsigned char ff_prores_idct_comp_spv_data[]