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