FFmpeg
vulkan_dpx.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 "dpx.h"
25 #include "libavutil/vulkan_spirv.h"
26 #include "libavutil/mem.h"
27 
28 extern const char *ff_source_common_comp;
29 extern const char *ff_source_dpx_unpack_comp;
30 extern const char *ff_source_dpx_copy_comp;
31 
34  .decode_extension = FF_VK_EXT_PUSH_DESCRIPTOR,
35  .queue_flags = VK_QUEUE_COMPUTE_BIT,
36 };
37 
38 typedef struct DPXVulkanDecodePicture {
41 
42 typedef struct DPXVulkanDecodeContext {
46 
47 typedef struct DecodePushData {
48  int stride;
52 
55  const uint8_t *src, uint32_t size)
56 {
57  int err;
58  VkImage temp;
59 
61  DPXVulkanDecodeContext *dxv = ctx->sd_ctx;
62  VkPhysicalDeviceLimits *limits = &ctx->s.props.properties.limits;
63  FFVulkanFunctions *vk = &ctx->s.vkfn;
64 
66  FFVulkanDecodePicture *vp = &pp->vp;
67 
68  int unpack = (avctx->bits_per_raw_sample == 12 && !dpx->packing) ||
69  avctx->bits_per_raw_sample == 10;
70  if (unpack)
71  return 0;
72 
73  VkImageCreateInfo create_info = {
74  .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
75  .imageType = VK_IMAGE_TYPE_2D,
76  .format = avctx->bits_per_raw_sample == 8 ? VK_FORMAT_R8_UINT :
77  avctx->bits_per_raw_sample == 32 ? VK_FORMAT_R32_UINT :
78  VK_FORMAT_R16_UINT,
79  .extent.width = dpx->frame->width*dpx->components,
80  .extent.height = dpx->frame->height,
81  .extent.depth = 1,
82  .mipLevels = 1,
83  .arrayLayers = 1,
84  .tiling = VK_IMAGE_TILING_LINEAR,
85  .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
86  .usage = VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT,
87  .samples = VK_SAMPLE_COUNT_1_BIT,
88  .pQueueFamilyIndices = &ctx->qf[0].idx,
89  .queueFamilyIndexCount = 1,
90  .sharingMode = VK_SHARING_MODE_EXCLUSIVE,
91  };
92 
93  if (create_info.extent.width >= limits->maxImageDimension2D ||
94  create_info.extent.height >= limits->maxImageDimension2D)
95  return 0;
96 
97  vk->CreateImage(ctx->s.hwctx->act_dev, &create_info, ctx->s.hwctx->alloc,
98  &temp);
99 
101  &vp->slices_buf,
102  VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
103  VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT,
104  NULL, size,
105  VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
106  VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT);
107  if (err < 0)
108  return err;
109 
110  FFVkBuffer *vkb = (FFVkBuffer *)vp->slices_buf->data;
111  VkBindImageMemoryInfo bind_info = {
112  .sType = VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO,
113  .image = temp,
114  .memory = vkb->mem,
115  };
116  vk->BindImageMemory2(ctx->s.hwctx->act_dev, 1, &bind_info);
117 
118  VkHostImageLayoutTransitionInfo layout_change = {
119  .sType = VK_STRUCTURE_TYPE_HOST_IMAGE_LAYOUT_TRANSITION_INFO,
120  .image = temp,
121  .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
122  .newLayout = VK_IMAGE_LAYOUT_GENERAL,
123  .subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
124  .subresourceRange.layerCount = 1,
125  .subresourceRange.levelCount = 1,
126  };
127  vk->TransitionImageLayoutEXT(ctx->s.hwctx->act_dev, 1, &layout_change);
128 
129  VkMemoryToImageCopy copy_region = {
130  .sType = VK_STRUCTURE_TYPE_MEMORY_TO_IMAGE_COPY,
131  .pHostPointer = src,
132  .imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
133  .imageSubresource.layerCount = 1,
134  .imageExtent = (VkExtent3D){ dpx->frame->width*dpx->components,
135  dpx->frame->height,
136  1 },
137  };
138  VkCopyMemoryToImageInfo copy_info = {
139  .sType = VK_STRUCTURE_TYPE_COPY_MEMORY_TO_IMAGE_INFO,
140  .flags = VK_HOST_IMAGE_COPY_MEMCPY_EXT,
141  .dstImage = temp,
142  .dstImageLayout = VK_IMAGE_LAYOUT_GENERAL,
143  .regionCount = 1,
144  .pRegions = &copy_region,
145  };
146  vk->CopyMemoryToImageEXT(ctx->s.hwctx->act_dev, &copy_info);
147 
148  vk->DestroyImage(ctx->s.hwctx->act_dev, temp, ctx->s.hwctx->alloc);
149 
150  return 0;
151 }
152 
154  const AVBufferRef *buffer_ref,
155  av_unused const uint8_t *buffer,
156  av_unused uint32_t size)
157 {
158  int err;
161  DPXDecContext *dpx = avctx->priv_data;
162 
164  FFVulkanDecodePicture *vp = &pp->vp;
165 
166  if (ctx->s.extensions & FF_VK_EXT_HOST_IMAGE_COPY)
167  host_upload_image(avctx, dec, dpx, buffer, size);
168 
169  /* Host map the frame data if supported */
170  if (!vp->slices_buf &&
171  ctx->s.extensions & FF_VK_EXT_EXTERNAL_HOST_MEMORY)
172  ff_vk_host_map_buffer(&ctx->s, &vp->slices_buf, (uint8_t *)buffer,
173  buffer_ref,
174  VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
175  VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT);
176 
177  /* Prepare frame to be used */
178  err = ff_vk_decode_prepare_frame_sdr(dec, dpx->frame, vp, 1,
179  FF_VK_REP_NATIVE, 0);
180  if (err < 0)
181  return err;
182 
183  return 0;
184 }
185 
187  const uint8_t *data,
188  uint32_t size)
189 {
190  DPXDecContext *dpx = avctx->priv_data;
191 
193  FFVulkanDecodePicture *vp = &pp->vp;
194 
195  if (!vp->slices_buf) {
196  int err = ff_vk_decode_add_slice(avctx, vp, data, size, 0,
197  NULL, NULL);
198  if (err < 0)
199  return err;
200  }
201 
202  return 0;
203 }
204 
206 {
207  int err;
210  FFVulkanFunctions *vk = &ctx->s.vkfn;
211 
212  DPXDecContext *dpx = avctx->priv_data;
213  DPXVulkanDecodeContext *dxv = ctx->sd_ctx;
214 
216  FFVulkanDecodePicture *vp = &pp->vp;
217 
218  FFVkBuffer *slices_buf = (FFVkBuffer *)vp->slices_buf->data;
219 
220  VkImageMemoryBarrier2 img_bar[8];
221  int nb_img_bar = 0;
222 
223  FFVkExecContext *exec = ff_vk_exec_get(&ctx->s, &ctx->exec_pool);
224  ff_vk_exec_start(&ctx->s, exec);
225 
226  /* Prepare deps */
227  RET(ff_vk_exec_add_dep_frame(&ctx->s, exec, dpx->frame,
228  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
229  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
230 
231  err = ff_vk_exec_mirror_sem_value(&ctx->s, exec, &vp->sem, &vp->sem_value,
232  dpx->frame);
233  if (err < 0)
234  return err;
235 
236  RET(ff_vk_exec_add_dep_buf(&ctx->s, exec, &vp->slices_buf, 1, 0));
237  vp->slices_buf = NULL;
238 
239  AVVkFrame *vkf = (AVVkFrame *)dpx->frame->data[0];
240  for (int i = 0; i < 4; i++) {
241  vkf->layout[i] = VK_IMAGE_LAYOUT_UNDEFINED;
242  vkf->access[i] = VK_ACCESS_2_NONE;
243  }
244 
245  ff_vk_frame_barrier(&ctx->s, exec, dpx->frame, img_bar, &nb_img_bar,
246  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
247  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
248  VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT,
249  VK_IMAGE_LAYOUT_GENERAL,
250  VK_QUEUE_FAMILY_IGNORED);
251 
252  vk->CmdPipelineBarrier2(exec->buf, &(VkDependencyInfo) {
253  .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
254  .pImageMemoryBarriers = img_bar,
255  .imageMemoryBarrierCount = nb_img_bar,
256  });
257  nb_img_bar = 0;
258 
259  FFVulkanShader *shd = &dxv->shader;
260  ff_vk_shader_update_img_array(&ctx->s, exec, shd,
261  dpx->frame, vp->view.out,
262  0, 0,
263  VK_IMAGE_LAYOUT_GENERAL,
264  VK_NULL_HANDLE);
265  ff_vk_shader_update_desc_buffer(&ctx->s, exec, shd,
266  0, 1, 0,
267  slices_buf,
268  0, slices_buf->size,
269  VK_FORMAT_UNDEFINED);
270 
271  ff_vk_exec_bind_shader(&ctx->s, exec, shd);
272 
273  /* Update push data */
275  .stride = dpx->stride,
276  .need_align = dpx->need_align,
277  .padded_10bit = !dpx->unpadded_10bit,
278  };
279 
280  ff_vk_shader_update_push_const(&ctx->s, exec, shd,
281  VK_SHADER_STAGE_COMPUTE_BIT,
282  0, sizeof(pd), &pd);
283 
284  vk->CmdDispatch(exec->buf,
285  FFALIGN(dpx->frame->width, shd->lg_size[0])/shd->lg_size[0],
286  FFALIGN(dpx->frame->height, shd->lg_size[1])/shd->lg_size[1],
287  1);
288 
289  err = ff_vk_exec_submit(&ctx->s, exec);
290  if (err < 0)
291  return err;
292 
293 fail:
294  return 0;
295 }
296 
298  FFVkExecPool *pool, FFVkSPIRVCompiler *spv,
299  FFVulkanShader *shd, int bits)
300 {
301  int err;
302  DPXDecContext *dpx = avctx->priv_data;
304  AVHWFramesContext *dec_frames_ctx;
305  dec_frames_ctx = (AVHWFramesContext *)avctx->hw_frames_ctx->data;
306  int planes = av_pix_fmt_count_planes(dec_frames_ctx->sw_format);
307 
308  uint8_t *spv_data;
309  size_t spv_len;
310  void *spv_opaque = NULL;
311 
312  RET(ff_vk_shader_init(s, shd, "dpx",
313  VK_SHADER_STAGE_COMPUTE_BIT,
314  (const char *[]) { "GL_EXT_buffer_reference",
315  "GL_EXT_buffer_reference2" }, 2,
316  512, 1, 1,
317  0));
318 
319  /* Common codec header */
321 
322  GLSLC(0, layout(push_constant, scalar) uniform pushConstants { );
323  GLSLC(1, int stride; );
324  GLSLC(1, int need_align; );
325  GLSLC(1, int padded_10bit; );
326  GLSLC(0, }; );
327  GLSLC(0, );
329  VK_SHADER_STAGE_COMPUTE_BIT);
330 
331  int unpack = (avctx->bits_per_raw_sample == 12 && !dpx->packing) ||
332  avctx->bits_per_raw_sample == 10;
333 
334  desc_set = (FFVulkanDescriptorSetBinding []) {
335  {
336  .name = "dst",
337  .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
338  .dimensions = 2,
339  .mem_quali = "writeonly",
340  .mem_layout = ff_vk_shader_rep_fmt(dec_frames_ctx->sw_format,
342  .elems = planes,
343  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
344  },
345  {
346  .name = "data_buf",
347  .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
348  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
349  .mem_quali = "readonly",
350  .buf_content = (unpack || bits == 32) ? "uint32_t data[];" :
351  bits == 8 ? "uint8_t data[];" : "uint16_t data[];",
352  },
353  };
354  RET(ff_vk_shader_add_descriptor_set(s, shd, desc_set, 2, 0, 0));
355 
356  if (dpx->endian)
357  GLSLC(0, #define BIG_ENDIAN );
358  GLSLF(0, #define COMPONENTS (%i) ,dpx->components);
359  GLSLF(0, #define BITS_PER_COMP (%i) ,bits);
360  GLSLF(0, #define NB_IMAGES (%i) ,planes);
361  if (unpack) {
362  if (bits == 10)
363  GLSLC(0, #define PACKED_10BIT );
365  } else {
366  GLSLF(0, #define SHIFT (%i) ,FFALIGN(bits, 8) - bits);
367  GLSLF(0, #define TYPE uint%i_t ,FFALIGN(bits, 8));
368  GLSLF(0, #define TYPE_VEC u%ivec4 ,FFALIGN(bits, 8));
369  GLSLF(0, #define TYPE_REVERSE(x) (reverse%i(x)), FFALIGN(bits, 8)/8);
371  }
372 
373  RET(spv->compile_shader(s, spv, shd, &spv_data, &spv_len, "main",
374  &spv_opaque));
375  RET(ff_vk_shader_link(s, shd, spv_data, spv_len, "main"));
376 
377  RET(ff_vk_shader_register_exec(s, pool, shd));
378 
379 fail:
380  if (spv_opaque)
381  spv->free_shader(spv, &spv_opaque);
382 
383  return err;
384 }
385 
387 {
388  DPXVulkanDecodeContext *fv = ctx->sd_ctx;
389 
390  ff_vk_shader_free(&ctx->s, &fv->shader);
391 
393 
394  av_freep(&fv);
395 }
396 
398 {
399  int err;
400  DPXDecContext *dpx = avctx->priv_data;
402 
403  switch (dpx->pix_fmt) {
404  case AV_PIX_FMT_GRAY10:
405  case AV_PIX_FMT_GRAY12:
406  case AV_PIX_FMT_GBRAP10:
407  case AV_PIX_FMT_GBRAP12:
408  case AV_PIX_FMT_UYVY422:
409  case AV_PIX_FMT_YUV444P:
410  case AV_PIX_FMT_YUVA444P:
411  return AVERROR(ENOTSUP);
412  case AV_PIX_FMT_GBRP10:
413  if (dpx->unpadded_10bit)
414  return AVERROR(ENOTSUP);
415  /* fallthrough */
416  default:
417  break;
418  }
419 
420  FFVkSPIRVCompiler *spv = ff_vk_spirv_init();
421  if (!spv) {
422  av_log(avctx, AV_LOG_ERROR, "Unable to initialize SPIR-V compiler!\n");
423  return AVERROR_EXTERNAL;
424  }
425 
426  err = ff_vk_decode_init(avctx);
427  if (err < 0)
428  return err;
429 
431  DPXVulkanDecodeContext *dxv = ctx->sd_ctx = av_mallocz(sizeof(*dxv));
432  if (!dxv) {
433  err = AVERROR(ENOMEM);
434  goto fail;
435  }
436 
437  ctx->sd_ctx_free = &vk_decode_dpx_uninit;
438 
439  RET(init_shader(avctx, &ctx->s, &ctx->exec_pool,
440  spv, &dxv->shader, avctx->bits_per_raw_sample));
441 
442 fail:
443  spv->uninit(&spv);
444 
445  return err;
446 }
447 
449 {
450  AVHWDeviceContext *dev_ctx = _hwctx.nc;
451 
453  FFVulkanDecodePicture *vp = &pp->vp;
454 
455  ff_vk_decode_free_frame(dev_ctx, vp);
456 }
457 
459  .p.name = "dpx_vulkan",
460  .p.type = AVMEDIA_TYPE_VIDEO,
461  .p.id = AV_CODEC_ID_DPX,
462  .p.pix_fmt = AV_PIX_FMT_VULKAN,
463  .start_frame = &vk_dpx_start_frame,
464  .decode_slice = &vk_dpx_decode_slice,
465  .end_frame = &vk_dpx_end_frame,
466  .free_frame_priv = &vk_dpx_free_frame_priv,
467  .frame_priv_data_size = sizeof(DPXVulkanDecodePicture),
470  .decode_params = &ff_vk_params_invalidate,
473  .frame_params = &ff_vk_frame_params,
474  .priv_data_size = sizeof(FFVulkanDecodeContext),
476 };
AV_CODEC_ID_DPX
@ AV_CODEC_ID_DPX
Definition: codec_id.h:180
init_shader
static int init_shader(AVCodecContext *avctx, FFVulkanContext *s, FFVkExecPool *pool, FFVkSPIRVCompiler *spv, FFVulkanShader *shd, int bits)
Definition: vulkan_dpx.c:297
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
DPXVulkanDecodePicture::vp
FFVulkanDecodePicture vp
Definition: vulkan_dpx.c:39
ff_vk_shader_free
void ff_vk_shader_free(FFVulkanContext *s, FFVulkanShader *shd)
Free a shader.
Definition: vulkan.c:2961
DPXDecContext::packing
int packing
Definition: dpx.h:65
ff_vk_shader_init
int ff_vk_shader_init(FFVulkanContext *s, FFVulkanShader *shd, const char *name, VkPipelineStageFlags stage, const char *extensions[], int nb_extensions, int lg_x, int lg_y, int lg_z, uint32_t required_subgroup_size)
Initialize a shader object, with a specific set of extensions, type+bind, local group size,...
Definition: vulkan.c:2093
AVBufferPool
The buffer pool.
Definition: buffer_internal.h:88
ff_vk_decode_prepare_frame_sdr
int ff_vk_decode_prepare_frame_sdr(FFVulkanDecodeContext *dec, AVFrame *pic, FFVulkanDecodePicture *vkpic, int is_current, enum FFVkShaderRepFormat rep_fmt, int alloc_dpb)
Software-defined decoder version of ff_vk_decode_prepare_frame.
Definition: vulkan_decode.c:247
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
FFVulkanDecodeContext::shared_ctx
FFVulkanDecodeShared * shared_ctx
Definition: vulkan_decode.h:57
RET
#define RET(x)
Definition: vulkan.h:66
AVRefStructOpaque
RefStruct is an API for creating reference-counted objects with minimal overhead.
Definition: refstruct.h:58
DPXDecContext::hwaccel_picture_private
void * hwaccel_picture_private
Definition: dpx.h:62
AVRefStructOpaque::nc
void * nc
Definition: refstruct.h:59
dpx.h
av_unused
#define av_unused
Definition: attributes.h:151
FFHWAccel::p
AVHWAccel p
The public AVHWAccel.
Definition: hwaccel_internal.h:38
AVFrame::width
int width
Definition: frame.h:499
u
#define u(width, name, range_min, range_max)
Definition: cbs_apv.c:68
data
const char data[16]
Definition: mxf.c:149
FFVulkanDecodeDescriptor::codec_id
enum AVCodecID codec_id
Definition: vulkan_decode.h:30
SHIFT
#define SHIFT
Definition: median_template.c:40
ff_vk_exec_get
FFVkExecContext * ff_vk_exec_get(FFVulkanContext *s, FFVkExecPool *pool)
Retrieve an execution pool.
Definition: vulkan.c:547
FF_VK_REP_NATIVE
@ FF_VK_REP_NATIVE
Definition: vulkan.h:406
FFVkSPIRVCompiler::uninit
void(* uninit)(struct FFVkSPIRVCompiler **ctx)
Definition: vulkan_spirv.h:32
FFVulkanDecodeContext
Definition: vulkan_decode.h:56
AV_PIX_FMT_VULKAN
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition: pixfmt.h:379
ff_vk_exec_add_dep_frame
int ff_vk_exec_add_dep_frame(FFVulkanContext *s, FFVkExecContext *e, AVFrame *f, VkPipelineStageFlagBits2 wait_stage, VkPipelineStageFlagBits2 signal_stage)
Definition: vulkan.c:779
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:448
FF_VK_EXT_HOST_IMAGE_COPY
#define FF_VK_EXT_HOST_IMAGE_COPY
Definition: vulkan_functions.h:52
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3496
vk_decode_dpx_uninit
static void vk_decode_dpx_uninit(FFVulkanDecodeShared *ctx)
Definition: vulkan_dpx.c:386
FFHWAccel
Definition: hwaccel_internal.h:34
fail
#define fail()
Definition: checkasm.h:208
FFVulkanDecodePicture::sem_value
uint64_t sem_value
Definition: vulkan_decode.h:87
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:558
DPXDecContext::stride
int stride
Definition: dpx.h:66
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:2838
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:2050
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:2601
ff_source_dpx_unpack_comp
const char * ff_source_dpx_unpack_comp
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:1392
DecodePushData::stride
int stride
Definition: vulkan_dpx.c:48
ff_vk_shader_add_descriptor_set
int ff_vk_shader_add_descriptor_set(FFVulkanContext *s, FFVulkanShader *shd, FFVulkanDescriptorSetBinding *desc, int nb, int singular, int print_to_shader_only)
Add descriptor to a shader.
Definition: vulkan.c:2465
FFVulkanDecodeShared
Definition: vulkan_decode.h:38
DPXVulkanDecodeContext
Definition: vulkan_dpx.c:42
AVHWDeviceContext
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
Definition: hwcontext.h:63
GLSLC
#define GLSLC(N, S)
Definition: vulkan.h:43
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:210
vk_dpx_decode_slice
static int vk_dpx_decode_slice(AVCodecContext *avctx, const uint8_t *data, uint32_t size)
Definition: vulkan_dpx.c:186
AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:562
s
#define s(width, name)
Definition: cbs_vp9.c:198
FFVulkanDecodePicture
Definition: vulkan_decode.h:75
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:563
ff_vk_exec_mirror_sem_value
int ff_vk_exec_mirror_sem_value(FFVulkanContext *s, FFVkExecContext *e, VkSemaphore *dst, uint64_t *dst_val, AVFrame *f)
Definition: vulkan.c:878
FFVulkanDecodePicture::view
struct FFVulkanDecodePicture::@326 view
bits
uint8_t bits
Definition: vp3data.h:128
DPXVulkanDecodeContext::shader
FFVulkanShader shader
Definition: vulkan_dpx.c:43
ff_vk_dec_dpx_desc
const FFVulkanDecodeDescriptor ff_vk_dec_dpx_desc
Definition: vulkan_dpx.c:32
AVCodecContext::bits_per_raw_sample
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
Definition: avcodec.h:1553
ctx
AVFormatContext * ctx
Definition: movenc.c:49
DecodePushData
Definition: vulkan_dpx.c:47
ff_vk_exec_add_dep_buf
int ff_vk_exec_add_dep_buf(FFVulkanContext *s, FFVkExecContext *e, AVBufferRef **deps, int nb_deps, int ref)
Execution dependency management.
Definition: vulkan.c:619
DPXDecContext::components
int components
Definition: dpx.h:68
GLSLD
#define GLSLD(D)
Definition: vulkan.h:58
DPXDecContext::endian
int endian
Definition: dpx.h:67
AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:519
if
if(ret)
Definition: filter_design.txt:179
TYPE
#define TYPE
Definition: ffv1dec.c:96
HWACCEL_CAP_ASYNC_SAFE
#define HWACCEL_CAP_ASYNC_SAFE
Header providing the internals of AVHWAccel.
Definition: hwaccel_internal.h:31
ff_vk_shader_rep_fmt
const char * ff_vk_shader_rep_fmt(enum AVPixelFormat pix_fmt, enum FFVkShaderRepFormat rep_fmt)
Definition: vulkan.c:1626
NULL
#define NULL
Definition: coverity.c:32
AVHWFramesContext::sw_format
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
Definition: hwcontext.h:213
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:617
vk_dpx_free_frame_priv
static void vk_dpx_free_frame_priv(AVRefStructOpaque _hwctx, void *data)
Definition: vulkan_dpx.c:448
AVCodecContext::internal
struct AVCodecInternal * internal
Private context used for internal data.
Definition: avcodec.h:466
av_buffer_pool_uninit
void av_buffer_pool_uninit(AVBufferPool **ppool)
Mark the pool as being available for freeing.
Definition: buffer.c:328
ff_vk_decode_uninit
int ff_vk_decode_uninit(AVCodecContext *avctx)
Free decoder.
Definition: vulkan_decode.c:1215
flush
void(* flush)(AVBSFContext *ctx)
Definition: dts2pts.c:552
FFVkBuffer::size
size_t size
Definition: vulkan.h:91
FFVulkanContext
Definition: vulkan.h:274
ff_vk_frame_params
int ff_vk_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx)
Initialize hw_frames_ctx with the parameters needed to decode the stream using the parameters from av...
Definition: vulkan_decode.c:1089
DecodePushData::padded_10bit
int padded_10bit
Definition: vulkan_dpx.c:50
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:550
AVVkFrame::access
VkAccessFlagBits access[AV_NUM_DATA_POINTERS]
Updated after every barrier.
Definition: hwcontext_vulkan.h:327
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:2917
ff_source_common_comp
const char * ff_source_common_comp
FFVulkanDescriptorSetBinding
Definition: vulkan.h:74
AVCodecInternal::hwaccel_priv_data
void * hwaccel_priv_data
hwaccel-specific private data
Definition: internal.h:130
AVVkFrame
Definition: hwcontext_vulkan.h:298
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:424
size
int size
Definition: twinvq_data.h:10344
FF_VK_EXT_PUSH_DESCRIPTOR
#define FF_VK_EXT_PUSH_DESCRIPTOR
Definition: vulkan_functions.h:48
FFVulkanShader
Definition: vulkan.h:190
FFVkSPIRVCompiler::compile_shader
int(* compile_shader)(FFVulkanContext *s, struct FFVkSPIRVCompiler *ctx, FFVulkanShader *shd, uint8_t **data, size_t *size, const char *entrypoint, void **opaque)
Definition: vulkan_spirv.h:28
AV_PIX_FMT_YUVA444P
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:174
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
FFVkExecContext
Definition: vulkan.h:111
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:2851
FFVulkanDescriptorSetBinding::name
const char * name
Definition: vulkan.h:75
FFVkSPIRVCompiler
Definition: vulkan_spirv.h:26
AVHWAccel::name
const char * name
Name of the hardware accelerated codec.
Definition: avcodec.h:1949
layout
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel layout
Definition: filter_design.txt:18
FF_VK_EXT_EXTERNAL_HOST_MEMORY
#define FF_VK_EXT_EXTERNAL_HOST_MEMORY
Definition: vulkan_functions.h:36
DPXDecContext::need_align
int need_align
Definition: dpx.h:70
uninit
static void uninit(AVBSFContext *ctx)
Definition: pcm_rechunk.c:68
unpack
static int unpack(const uint8_t *src, const uint8_t *src_end, uint8_t *dst, int width, int height)
Unpack buffer.
Definition: eatgv.c:73
FFVulkanDecodePicture::out
VkImageView out[AV_NUM_DATA_POINTERS]
Definition: vulkan_decode.h:80
ff_vk_exec_start
int ff_vk_exec_start(FFVulkanContext *s, FFVkExecContext *e)
Start/submit/wait an execution.
Definition: vulkan.c:559
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
vk_decode_dpx_init
static int vk_decode_dpx_init(AVCodecContext *avctx)
Definition: vulkan_dpx.c:397
ff_vk_shader_link
int ff_vk_shader_link(FFVulkanContext *s, FFVulkanShader *shd, uint8_t *spirv, size_t spirv_len, const char *entrypoint)
Link a shader into an executable.
Definition: vulkan.c:2390
DPXVulkanDecodeContext::frame_data_pool
AVBufferPool * frame_data_pool
Definition: vulkan_dpx.c:44
FFVkBuffer::mem
VkDeviceMemory mem
Definition: vulkan.h:89
FFVulkanDecodePicture::sem
VkSemaphore sem
Definition: vulkan_decode.h:86
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:256
planes
static const struct @546 planes[]
vulkan_spirv.h
ff_dpx_vulkan_hwaccel
const FFHWAccel ff_dpx_vulkan_hwaccel
Definition: vulkan_dpx.c:458
FFVkSPIRVCompiler::free_shader
void(* free_shader)(struct FFVkSPIRVCompiler *ctx, void **opaque)
Definition: vulkan_spirv.h:31
ff_source_dpx_copy_comp
const char * ff_source_dpx_copy_comp
ff_vk_exec_bind_shader
void ff_vk_exec_bind_shader(FFVulkanContext *s, FFVkExecContext *e, FFVulkanShader *shd)
Bind a shader.
Definition: vulkan.c:2927
AVCodecContext::hw_frames_ctx
AVBufferRef * hw_frames_ctx
A reference to the AVHWFramesContext describing the input (for encoding) or output (decoding) frames.
Definition: avcodec.h:1453
AVHWFramesContext
This struct describes a set or pool of "hardware" frames (i.e.
Definition: hwcontext.h:118
ff_vk_decode_flush
void ff_vk_decode_flush(AVCodecContext *avctx)
Flush decoder.
Definition: vulkan_decode.c:375
DecodePushData::need_align
int need_align
Definition: vulkan_dpx.c:49
FFVkExecPool
Definition: vulkan.h:252
ff_vk_decode_add_slice
int ff_vk_decode_add_slice(AVCodecContext *avctx, FFVulkanDecodePicture *vp, const uint8_t *data, size_t size, int add_startcode, uint32_t *nb_slices, const uint32_t **offsets)
Add slice data to frame.
Definition: vulkan_decode.c:294
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:1490
AV_PIX_FMT_UYVY422
@ AV_PIX_FMT_UYVY422
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
Definition: pixfmt.h:88
DPXDecContext::pix_fmt
enum AVPixelFormat pix_fmt
Definition: dpx.h:63
AVCodecContext
main external API structure.
Definition: avcodec.h:431
AVFrame::height
int height
Definition: frame.h:499
DPXDecContext::unpadded_10bit
int unpadded_10bit
Definition: dpx.h:69
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
GLSLF
#define GLSLF(N, S,...)
Definition: vulkan.h:53
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
temp
else temp
Definition: vf_mcdeint.c:271
ff_vk_params_invalidate
int ff_vk_params_invalidate(AVCodecContext *avctx, int t, const uint8_t *b, uint32_t s)
Removes current session parameters to recreate them.
Definition: vulkan_decode.c:152
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:134
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:78
DPXVulkanDecodePicture
Definition: vulkan_dpx.c:38
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:200
FFVulkanDecodePicture::slices_buf
AVBufferRef * slices_buf
Definition: vulkan_decode.h:101
mem.h
AVVkFrame::layout
VkImageLayout layout[AV_NUM_DATA_POINTERS]
Definition: hwcontext_vulkan.h:328
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
DPXDecContext
Definition: dpx.h:60
vulkan_decode.h
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
vk_dpx_end_frame
static int vk_dpx_end_frame(AVCodecContext *avctx)
Definition: vulkan_dpx.c:205
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:458
DPXDecContext::frame
AVFrame * frame
Definition: dpx.h:61
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
FFVkBuffer
Definition: vulkan.h:87
ff_vk_exec_submit
int ff_vk_exec_submit(FFVulkanContext *s, FFVkExecContext *e)
Definition: vulkan.c:904
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
ff_vk_decode_init
int ff_vk_decode_init(AVCodecContext *avctx)
Initialize decoder.
Definition: vulkan_decode.c:1267
stride
#define stride
Definition: h264pred_template.c:536
AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:520
host_upload_image
static int host_upload_image(AVCodecContext *avctx, FFVulkanDecodeContext *dec, DPXDecContext *dpx, const uint8_t *src, uint32_t size)
Definition: vulkan_dpx.c:53
FFVulkanFunctions
Definition: vulkan_functions.h:277
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:1285
src
#define src
Definition: vp8dsp.c:248
FFVulkanShader::lg_size
int lg_size[3]
Definition: vulkan.h:198
vk_dpx_start_frame
static int vk_dpx_start_frame(AVCodecContext *avctx, const AVBufferRef *buffer_ref, av_unused const uint8_t *buffer, av_unused uint32_t size)
Definition: vulkan_dpx.c:153