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 memcpy(metadata->mapped_mem + pp->qmat_off,
198 pr->qmat_luma, sizeof(pr->qmat_luma));
199 memcpy(metadata->mapped_mem + pp->qmat_off + sizeof(pr->qmat_luma),
200 pr->qmat_chroma, sizeof(pr->qmat_chroma));
201
202 FFVkExecContext *exec = ff_vk_exec_get(&ctx->s, &ctx->exec_pool);
203 err = ff_vk_exec_start(&ctx->s, exec);
204 if (err < 0)
205 return err;
206
207 /* Prepare deps */
209 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
210 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
211
212 /* Exec-owned output views: freed on exec recycle, so releasing a picture
213 * needs no blocking wait. No mirror_sem: nothing consumes vp->sem here. */
214 VkImageView views[AV_NUM_DATA_POINTERS];
215 RET(ff_vk_create_imageviews(&ctx->s, exec, views, f, FF_VK_REP_NATIVE));
216
219
220 vkf->layout[0] = VK_IMAGE_LAYOUT_UNDEFINED;
221 vkf->access[0] = VK_ACCESS_2_NONE;
222
223 nb_imgs = ff_vk_count_images(vkf);
224
225 if (pr->first_field) {
226 /* Input barrier */
227 ff_vk_frame_barrier(&ctx->s, exec, f, img_bar, &nb_img_bar,
228 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
229 VK_PIPELINE_STAGE_2_CLEAR_BIT,
230 VK_ACCESS_2_TRANSFER_WRITE_BIT,
231 VK_IMAGE_LAYOUT_GENERAL,
232 VK_QUEUE_FAMILY_IGNORED);
233 vk->CmdPipelineBarrier2(exec->buf, &(VkDependencyInfo) {
234 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
235 .pBufferMemoryBarriers = buf_bar,
236 .bufferMemoryBarrierCount = nb_buf_bar,
237 .pImageMemoryBarriers = img_bar,
238 .imageMemoryBarrierCount = nb_img_bar,
239 });
240 nb_img_bar = nb_buf_bar = 0;
241
242 /* Clear the input image since the vld shader does sparse writes, except for alpha */
243 for (i = 0; i < FFMIN(nb_imgs, 3); ++i) {
244 vk->CmdClearColorImage(exec->buf, vkf->img[i],
245 VK_IMAGE_LAYOUT_GENERAL,
246 &((VkClearColorValue) { 0 }),
247 1, &((VkImageSubresourceRange) {
248 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
249 .levelCount = 1,
250 .layerCount = 1,
251 }));
252 }
253 }
254
255 /* Input barrier, or synchronization between clear and vld shader */
256 ff_vk_frame_barrier(&ctx->s, exec, f, img_bar, &nb_img_bar,
257 pr->first_field ? VK_PIPELINE_STAGE_2_CLEAR_BIT :
258 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
259 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
260 VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT,
261 VK_IMAGE_LAYOUT_GENERAL,
262 VK_QUEUE_FAMILY_IGNORED);
263 ff_vk_buf_barrier(buf_bar[nb_buf_bar++], metadata,
264 ALL_COMMANDS_BIT, NONE_KHR, NONE_KHR,
265 COMPUTE_SHADER_BIT, SHADER_WRITE_BIT, NONE_KHR,
267 vk->CmdPipelineBarrier2(exec->buf, &(VkDependencyInfo) {
268 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
269 .pBufferMemoryBarriers = buf_bar,
270 .bufferMemoryBarrierCount = nb_buf_bar,
271 .pImageMemoryBarriers = img_bar,
272 .imageMemoryBarrierCount = nb_img_bar,
273 });
274 nb_img_bar = nb_buf_bar = 0;
275
276 /* Entropy decode */
278 0, 0, 0,
279 metadata,
282 VK_FORMAT_UNDEFINED);
284 0, 1, 0,
285 metadata,
286 pp->mb_params_off,
287 pp->mb_params_sz,
288 VK_FORMAT_UNDEFINED);
289 ff_vk_shader_update_img_array(&ctx->s, exec, &pv->vld,
290 f, views,
291 0, 2,
292 VK_IMAGE_LAYOUT_GENERAL,
293 VK_NULL_HANDLE);
294
295 ff_vk_exec_bind_shader(&ctx->s, exec, &pv->vld);
296 ff_vk_shader_update_push_const(&ctx->s, exec, &pv->vld,
297 VK_SHADER_STAGE_COMPUTE_BIT,
298 0, sizeof(pd), &pd);
299
300 vk->CmdDispatch(exec->buf, AV_CEIL_RSHIFT(pr->slice_count / pr->mb_height, 3),
302 3 + !!pr->alpha_info);
303
304 /* Synchronize vld and idct shaders */
305 ff_vk_frame_barrier(&ctx->s, exec, f, img_bar, &nb_img_bar,
306 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
307 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
308 VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT,
309 VK_IMAGE_LAYOUT_GENERAL,
310 VK_QUEUE_FAMILY_IGNORED);
311 ff_vk_buf_barrier(buf_bar[nb_buf_bar++], metadata,
312 COMPUTE_SHADER_BIT, SHADER_WRITE_BIT, NONE_KHR,
313 COMPUTE_SHADER_BIT, SHADER_READ_BIT, NONE_KHR,
315 vk->CmdPipelineBarrier2(exec->buf, &(VkDependencyInfo) {
316 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
317 .pBufferMemoryBarriers = buf_bar,
318 .bufferMemoryBarrierCount = nb_buf_bar,
319 .pImageMemoryBarriers = img_bar,
320 .imageMemoryBarrierCount = nb_img_bar,
321 });
322 nb_img_bar = nb_buf_bar = 0;
323
324 /* Inverse transform */
326 0, 0, 0,
327 metadata,
328 pp->mb_params_off,
329 pp->mb_params_sz,
330 VK_FORMAT_UNDEFINED);
332 0, 1, 0,
333 metadata,
334 pp->qmat_off,
335 pp->qmat_sz,
336 VK_FORMAT_UNDEFINED);
337 ff_vk_shader_update_img_array(&ctx->s, exec, &pv->idct,
338 f, views,
339 0, 2,
340 VK_IMAGE_LAYOUT_GENERAL,
341 VK_NULL_HANDLE);
342
343 ff_vk_exec_bind_shader(&ctx->s, exec, &pv->idct);
345 VK_SHADER_STAGE_COMPUTE_BIT,
346 0, sizeof(pd), &pd);
347
348 vk->CmdDispatch(exec->buf, AV_CEIL_RSHIFT(pr->mb_width, 1), pr->mb_height, 3);
349
350 err = ff_vk_exec_submit(&ctx->s, exec);
351 if (err < 0)
352 return err;
353
354 return 0;
355
356fail:
357 ff_vk_exec_discard(&ctx->s, exec);
358 return err;
359}
360
362 FFVkExecPool *pool, FFVulkanShader *shd,
363 int max_num_mbs, int interlaced)
364{
365 int err;
366 AVHWFramesContext *dec_frames_ctx;
367 dec_frames_ctx = (AVHWFramesContext *)avctx->hw_frames_ctx->data;
368
369 SPEC_LIST_CREATE(sl, 1, 1*sizeof(uint32_t))
370 SPEC_LIST_ADD(sl, 0, 32, interlaced);
371
373 VK_SHADER_STAGE_COMPUTE_BIT, sl,
374 (uint32_t []) { 8, 8, 1 }, 0);
375
377 VK_SHADER_STAGE_COMPUTE_BIT);
378
379 const FFVulkanDescriptorSetBinding desc_set[] = {
380 { /* slice_offsets_buf */
381 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
382 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
383 },
384 { /* quant_idx_buf */
385 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
386 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
387 },
388 { /* dst */
389 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
390 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
391 .elems = av_pix_fmt_count_planes(dec_frames_ctx->sw_format),
392 },
393 };
394 ff_vk_shader_add_descriptor_set(s, shd, desc_set, 3, 0);
395
399
400 RET(ff_vk_shader_register_exec(s, pool, shd));
401
402fail:
403 return 0;
404}
405
407 FFVkExecPool *pool, FFVulkanShader *shd,
408 int max_num_mbs, int interlaced)
409{
410 int err;
411 AVHWFramesContext *dec_frames_ctx;
412 dec_frames_ctx = (AVHWFramesContext *)avctx->hw_frames_ctx->data;
413
414 SPEC_LIST_CREATE(sl, 2 + 64, (2 + 64)*sizeof(uint32_t))
415 SPEC_LIST_ADD(sl, 0, 32, interlaced);
416 SPEC_LIST_ADD(sl, 16, 32, 4*2); /* nb_blocks */
417
418 const double idct_8_scales[8] = {
419 cos(4.0*M_PI/16.0) / 2.0, cos(1.0*M_PI/16.0) / 2.0,
420 cos(2.0*M_PI/16.0) / 2.0, cos(3.0*M_PI/16.0) / 2.0,
421 cos(4.0*M_PI/16.0) / 2.0, cos(5.0*M_PI/16.0) / 2.0,
422 cos(6.0*M_PI/16.0) / 2.0, cos(7.0*M_PI/16.0) / 2.0,
423 };
424 for (int i = 0; i < 64; i++)
425 SPEC_LIST_ADD(sl, 18 + i, 32,
426 av_float2int(idct_8_scales[i >> 3]*idct_8_scales[i & 7]));
427
429 VK_SHADER_STAGE_COMPUTE_BIT, sl,
430 (uint32_t []) { 32, 2, 1 }, 0);
431
433 VK_SHADER_STAGE_COMPUTE_BIT);
434
435 const FFVulkanDescriptorSetBinding desc_set[] = {
436 { /* quant_idx_buf */
437 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
438 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
439 },
440 { /* qmat_buf */
441 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
442 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
443 },
444 { /* dst */
445 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
446 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
447 .elems = av_pix_fmt_count_planes(dec_frames_ctx->sw_format),
448 },
449 };
450 ff_vk_shader_add_descriptor_set(s, shd, desc_set, 3, 0);
451
455
456 RET(ff_vk_shader_register_exec(s, pool, shd));
457
458fail:
459 return 0;
460}
461
463{
464 ProresVulkanDecodeContext *pv = ctx->sd_ctx;
465
466 ff_vk_shader_free(&ctx->s, &pv->vld);
467 ff_vk_shader_free(&ctx->s, &pv->idct);
468
470
471 av_freep(&pv);
472}
473
475{
478 ProresContext *pr = avctx->priv_data;
479
481 int max_num_mbs, err;
482
483 max_num_mbs = (avctx->coded_width >> 4) * (avctx->coded_height >> 4);
484
485 err = ff_vk_decode_init(avctx);
486 if (err < 0)
487 return err;
488 ctx = dec->shared_ctx;
489
490 pv = ctx->sd_ctx = av_mallocz(sizeof(*pv));
491 if (!pv) {
492 err = AVERROR(ENOMEM);
493 goto fail;
494 }
495
496 ctx->sd_ctx_free = vk_decode_prores_uninit;
497
498 RET(init_decode_shader(avctx, &ctx->s, &ctx->exec_pool,
499 &pv->vld, max_num_mbs, pr->frame_type != 0));
500 RET(init_idct_shader(avctx, &ctx->s, &ctx->exec_pool,
501 &pv->idct, max_num_mbs, pr->frame_type != 0));
502
503fail:
504 return err;
505}
506
508{
509 AVHWDeviceContext *dev_ctx = _hwctx.nc;
511
512 ff_vk_decode_free_frame(dev_ctx, &pp->vp);
513
515}
516
518 .p.name = "prores_vulkan",
519 .p.type = AVMEDIA_TYPE_VIDEO,
520 .p.id = AV_CODEC_ID_PRORES,
521 .p.pix_fmt = AV_PIX_FMT_VULKAN,
522 .start_frame = &vk_prores_start_frame,
523 .decode_slice = &vk_prores_decode_slice,
524 .end_frame = &vk_prores_end_frame,
525 .free_frame_priv = &vk_prores_free_frame_priv,
526 .frame_priv_data_size = sizeof(ProresVulkanDecodePicture),
528 .update_thread_context = &ff_vk_update_thread_context,
530 .frame_params = &ff_vk_frame_params,
531 .priv_data_size = sizeof(FFVulkanDecodeContext),
533};
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
#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:2734
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:2255
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:2565
int ff_vk_shader_add_push_const(FFVulkanShader *shd, int offset, int size, VkShaderStageFlagBits stage)
Add/update push constants for execution.
Definition vulkan.c:1627
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:2212
int ff_vk_exec_start(FFVulkanContext *s, FFVkExecContext *e)
Start/submit/wait an execution.
Definition vulkan.c:660
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:2143
void ff_vk_shader_free(FFVulkanContext *s, FFVulkanShader *shd)
Free a shader.
Definition vulkan.c:2806
int ff_vk_shader_register_exec(FFVulkanContext *s, FFVkExecPool *pool, FFVulkanShader *shd)
Register a shader with an exec pool.
Definition vulkan.c:2599
FFVkExecContext * ff_vk_exec_get(FFVulkanContext *s, FFVkExecPool *pool)
Retrieve an execution pool.
Definition vulkan.c:622
int ff_vk_exec_submit(FFVulkanContext *s, FFVkExecContext *e)
Definition vulkan.c:983
void ff_vk_exec_bind_shader(FFVulkanContext *s, FFVkExecContext *e, const FFVulkanShader *shd)
Bind a shader.
Definition vulkan.c:2783
void ff_vk_exec_move_dep_refstruct(FFVulkanContext *s, FFVkExecContext *e, void *obj)
Definition vulkan.c:786
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:2747
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:1536
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:1440
void ff_vk_exec_discard(FFVulkanContext *s, FFVkExecContext *e)
Definition vulkan.c:763
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:2459
int ff_vk_exec_add_dep_frame(FFVulkanContext *s, FFVkExecContext *e, AVFrame *f, VkPipelineStageFlagBits2 wait_stage, VkPipelineStageFlagBits2 signal_stage)
Definition vulkan.c:881
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:2773
#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:120
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:1572
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:183
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
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:578
@ FF_VK_REP_NATIVE
Definition vulkan.h:439
#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:356
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[]