FFmpeg
vulkan_ffv1.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2024 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 "ffv1.h"
25 #include "ffv1_vulkan.h"
26 #include "libavutil/vulkan_spirv.h"
27 #include "libavutil/mem.h"
28 
29 extern const char *ff_source_common_comp;
30 extern const char *ff_source_rangecoder_comp;
31 extern const char *ff_source_ffv1_vlc_comp;
32 extern const char *ff_source_ffv1_common_comp;
33 extern const char *ff_source_ffv1_dec_setup_comp;
34 extern const char *ff_source_ffv1_reset_comp;
35 extern const char *ff_source_ffv1_dec_comp;
36 
39  .decode_extension = FF_VK_EXT_PUSH_DESCRIPTOR,
40  .queue_flags = VK_QUEUE_COMPUTE_BIT,
41 };
42 
43 typedef struct FFv1VulkanDecodePicture {
45 
47  uint32_t plane_state_size;
48  uint32_t slice_state_size;
49  uint32_t slice_data_size;
50 
52  uint32_t *slice_offset;
53  int slice_num;
54 
58 
59 typedef struct FFv1VulkanDecodeContext {
60  AVBufferRef *intermediate_frames_ref[2]; /* 16/32 bit */
61 
63  FFVulkanShader reset[2]; /* AC/Golomb */
64  FFVulkanShader decode[2][2][2]; /* 16/32 bit, AC/Golomb, Normal/RGB */
65 
69 
74 
75 typedef struct FFv1VkParameters {
76  VkDeviceAddress slice_data;
77  VkDeviceAddress slice_state;
78 
79  int fmt_lut[4];
80  uint32_t img_size[2];
81  uint32_t chroma_shift[2];
82 
83  uint32_t plane_state_size;
84  uint32_t crcref;
86 
87  uint8_t extend_lookup[8];
88  uint8_t bits_per_raw_sample;
90  uint8_t version;
91  uint8_t micro_version;
92  uint8_t key_frame;
93  uint8_t planes;
94  uint8_t codec_planes;
95  uint8_t color_planes;
96  uint8_t transparency;
97  uint8_t planar_rgb;
98  uint8_t colorspace;
99  uint8_t ec;
100  uint8_t golomb;
101  uint8_t check_crc;
102  uint8_t padding[3];
104 
105 static void add_push_data(FFVulkanShader *shd)
106 {
107  GLSLC(0, layout(push_constant, scalar) uniform pushConstants { );
108  GLSLC(1, u8buf slice_data; );
109  GLSLC(1, u8buf slice_state; );
110  GLSLC(0, );
111  GLSLC(1, ivec4 fmt_lut; );
112  GLSLC(1, uvec2 img_size; );
113  GLSLC(1, uvec2 chroma_shift; );
114  GLSLC(0, );
115  GLSLC(1, uint plane_state_size; );
116  GLSLC(1, uint32_t crcref; );
117  GLSLC(1, int rct_offset; );
118  GLSLC(0, );
119  GLSLC(1, uint8_t extend_lookup[8]; );
120  GLSLC(1, uint8_t bits_per_raw_sample; );
121  GLSLC(1, uint8_t quant_table_count; );
122  GLSLC(1, uint8_t version; );
123  GLSLC(1, uint8_t micro_version; );
124  GLSLC(1, uint8_t key_frame; );
125  GLSLC(1, uint8_t planes; );
126  GLSLC(1, uint8_t codec_planes; );
127  GLSLC(1, uint8_t color_planes; );
128  GLSLC(1, uint8_t transparency; );
129  GLSLC(1, uint8_t planar_rgb; );
130  GLSLC(1, uint8_t colorspace; );
131  GLSLC(1, uint8_t ec; );
132  GLSLC(1, uint8_t golomb; );
133  GLSLC(1, uint8_t check_crc; );
134  GLSLC(1, uint8_t padding[3]; );
135  GLSLC(0, }; );
137  VK_SHADER_STAGE_COMPUTE_BIT);
138 }
139 
141  const AVBufferRef *buffer_ref,
142  av_unused const uint8_t *buffer,
143  av_unused uint32_t size)
144 {
145  int err;
148  FFv1VulkanDecodeContext *fv = ctx->sd_ctx;
149  FFV1Context *f = avctx->priv_data;
150 
151  FFv1VulkanDecodePicture *fp = f->hwaccel_picture_private;
152  FFVulkanDecodePicture *vp = &fp->vp;
153 
155  enum AVPixelFormat sw_format = hwfc->sw_format;
156 
157  int max_contexts;
158  int is_rgb = !(f->colorspace == 0 && sw_format != AV_PIX_FMT_YA8) &&
159  !(sw_format == AV_PIX_FMT_YA8);
160 
161  fp->slice_num = 0;
162 
163  max_contexts = 0;
164  for (int i = 0; i < f->quant_table_count; i++)
165  max_contexts = FFMAX(f->context_count[i], max_contexts);
166 
167  /* Allocate slice buffer data */
168  if (f->ac == AC_GOLOMB_RICE)
169  fp->plane_state_size = 8;
170  else
172 
173  fp->plane_state_size *= max_contexts;
174  fp->slice_state_size = fp->plane_state_size*f->plane_count;
175 
176  fp->slice_data_size = 256; /* Overestimation for the SliceContext struct */
179 
180  fp->crc_checked = f->ec && (avctx->err_recognition & AV_EF_CRCCHECK);
181 
182  /* Host map the input slices data if supported */
183  if (ctx->s.extensions & FF_VK_EXT_EXTERNAL_HOST_MEMORY)
184  ff_vk_host_map_buffer(&ctx->s, &vp->slices_buf, buffer_ref->data,
185  buffer_ref,
186  VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
187  VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT);
188 
189  /* Allocate slice state data */
190  if (f->picture.f->flags & AV_FRAME_FLAG_KEY) {
192  &fp->slice_state,
193  VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
194  VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT,
195  NULL, f->slice_count*fp->slice_state_size,
196  VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
197  if (err < 0)
198  return err;
199  } else {
200  FFv1VulkanDecodePicture *fpl = f->hwaccel_last_picture_private;
202  if (!fp->slice_state)
203  return AVERROR(ENOMEM);
204  }
205 
206  /* Allocate slice offsets buffer */
208  &fp->slice_offset_buf,
209  VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
210  VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT,
211  NULL, 2*f->slice_count*sizeof(uint32_t),
212  VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
213  VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT);
214  if (err < 0)
215  return err;
216 
217  /* Allocate slice status buffer */
219  &fp->slice_status_buf,
220  VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
221  VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT,
222  NULL, f->slice_count*sizeof(uint32_t),
223  VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
224  VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT);
225  if (err < 0)
226  return err;
227 
228  /* Prepare frame to be used */
229  err = ff_vk_decode_prepare_frame_sdr(dec, f->picture.f, vp, 1,
230  FF_VK_REP_NATIVE, 0);
231  if (err < 0)
232  return err;
233 
234  /* Create a temporaty frame for RGB */
235  if (is_rgb) {
236  vp->dpb_frame = av_frame_alloc();
237  if (!vp->dpb_frame)
238  return AVERROR(ENOMEM);
239 
240  err = av_hwframe_get_buffer(fv->intermediate_frames_ref[f->use32bit],
241  vp->dpb_frame, 0);
242  if (err < 0)
243  return err;
244  }
245 
246  return 0;
247 }
248 
250  const uint8_t *data,
251  uint32_t size)
252 {
253  FFV1Context *f = avctx->priv_data;
254 
255  FFv1VulkanDecodePicture *fp = f->hwaccel_picture_private;
256  FFVulkanDecodePicture *vp = &fp->vp;
257 
258  FFVkBuffer *slice_offset = (FFVkBuffer *)fp->slice_offset_buf->data;
259  FFVkBuffer *slices_buf = vp->slices_buf ? (FFVkBuffer *)vp->slices_buf->data : NULL;
260 
261  if (slices_buf && slices_buf->host_ref) {
262  AV_WN32(slice_offset->mapped_mem + (2*fp->slice_num + 0)*sizeof(uint32_t),
263  data - slices_buf->mapped_mem);
264  AV_WN32(slice_offset->mapped_mem + (2*fp->slice_num + 1)*sizeof(uint32_t),
265  size);
266 
267  fp->slice_num++;
268  } else {
269  int err = ff_vk_decode_add_slice(avctx, vp, data, size, 0,
270  &fp->slice_num,
271  (const uint32_t **)&fp->slice_offset);
272  if (err < 0)
273  return err;
274 
275  AV_WN32(slice_offset->mapped_mem + (2*(fp->slice_num - 1) + 0)*sizeof(uint32_t),
276  fp->slice_offset[fp->slice_num - 1]);
277  AV_WN32(slice_offset->mapped_mem + (2*(fp->slice_num - 1) + 1)*sizeof(uint32_t),
278  size);
279  }
280 
281  return 0;
282 }
283 
285 {
286  int err;
289  FFVulkanFunctions *vk = &ctx->s.vkfn;
290 
291  FFV1Context *f = avctx->priv_data;
292  FFv1VulkanDecodeContext *fv = ctx->sd_ctx;
293  FFv1VkParameters pd;
294  FFv1VkResetParameters pd_reset;
295 
297  enum AVPixelFormat sw_format = hwfc->sw_format;
298 
299  int bits = f->avctx->bits_per_raw_sample > 0 ? f->avctx->bits_per_raw_sample : 8;
300  int is_rgb = !(f->colorspace == 0 && sw_format != AV_PIX_FMT_YA8) &&
301  !(sw_format == AV_PIX_FMT_YA8);
302  int color_planes = av_pix_fmt_desc_get(avctx->sw_pix_fmt)->nb_components;
303 
304  FFVulkanShader *reset_shader;
305  FFVulkanShader *decode_shader;
306 
307  FFv1VulkanDecodePicture *fp = f->hwaccel_picture_private;
308  FFVulkanDecodePicture *vp = &fp->vp;
309 
310  FFVkBuffer *slices_buf = (FFVkBuffer *)vp->slices_buf->data;
311  FFVkBuffer *slice_state = (FFVkBuffer *)fp->slice_state->data;
312  FFVkBuffer *slice_offset = (FFVkBuffer *)fp->slice_offset_buf->data;
313  FFVkBuffer *slice_status = (FFVkBuffer *)fp->slice_status_buf->data;
314 
315  VkImageView rct_image_views[AV_NUM_DATA_POINTERS];
316 
317  AVFrame *decode_dst = is_rgb ? vp->dpb_frame : f->picture.f;
318  VkImageView *decode_dst_view = is_rgb ? rct_image_views : vp->view.out;
319 
320  VkImageMemoryBarrier2 img_bar[37];
321  int nb_img_bar = 0;
322  VkBufferMemoryBarrier2 buf_bar[8];
323  int nb_buf_bar = 0;
324 
325  FFVkExecContext *exec = ff_vk_exec_get(&ctx->s, &ctx->exec_pool);
326  ff_vk_exec_start(&ctx->s, exec);
327 
328  /* Prepare deps */
329  RET(ff_vk_exec_add_dep_frame(&ctx->s, exec, f->picture.f,
330  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
331  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
332 
333  err = ff_vk_exec_mirror_sem_value(&ctx->s, exec, &vp->sem, &vp->sem_value,
334  f->picture.f);
335  if (err < 0)
336  return err;
337 
338  if (is_rgb) {
339  RET(ff_vk_create_imageviews(&ctx->s, exec, rct_image_views,
341  RET(ff_vk_exec_add_dep_frame(&ctx->s, exec, vp->dpb_frame,
342  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
343  VK_PIPELINE_STAGE_2_CLEAR_BIT));
344  ff_vk_frame_barrier(&ctx->s, exec, decode_dst, img_bar, &nb_img_bar,
345  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
346  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
347  VK_ACCESS_2_TRANSFER_WRITE_BIT,
348  VK_IMAGE_LAYOUT_GENERAL,
349  VK_QUEUE_FAMILY_IGNORED);
350  }
351 
352  if (!(f->picture.f->flags & AV_FRAME_FLAG_KEY)) {
353  FFv1VulkanDecodePicture *fpl = f->hwaccel_last_picture_private;
354  FFVulkanDecodePicture *vpl = &fpl->vp;
355 
356  /* Wait on the previous frame */
357  RET(ff_vk_exec_add_dep_wait_sem(&ctx->s, exec, vpl->sem, vpl->sem_value,
358  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT));
359  }
360 
361  RET(ff_vk_exec_add_dep_buf(&ctx->s, exec, &fp->slice_state, 1, 1));
362  RET(ff_vk_exec_add_dep_buf(&ctx->s, exec, &fp->slice_status_buf, 1, 1));
363  RET(ff_vk_exec_add_dep_buf(&ctx->s, exec, &vp->slices_buf, 1, 0));
364  vp->slices_buf = NULL;
365  RET(ff_vk_exec_add_dep_buf(&ctx->s, exec, &fp->slice_offset_buf, 1, 0));
366  fp->slice_offset_buf = NULL;
367 
368  /* Entry barrier for the slice state */
369  buf_bar[nb_buf_bar++] = (VkBufferMemoryBarrier2) {
370  .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2,
371  .srcStageMask = slice_state->stage,
372  .dstStageMask = VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
373  .srcAccessMask = slice_state->access,
374  .dstAccessMask = VK_ACCESS_2_SHADER_STORAGE_READ_BIT |
375  VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT,
376  .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
377  .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
378  .buffer = slice_state->buf,
379  .offset = 0,
380  .size = fp->slice_data_size*f->slice_count,
381  };
382 
383  vk->CmdPipelineBarrier2(exec->buf, &(VkDependencyInfo) {
384  .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
385  .pImageMemoryBarriers = img_bar,
386  .imageMemoryBarrierCount = nb_img_bar,
387  .pBufferMemoryBarriers = buf_bar,
388  .bufferMemoryBarrierCount = nb_buf_bar,
389  });
390  slice_state->stage = buf_bar[0].dstStageMask;
391  slice_state->access = buf_bar[0].dstAccessMask;
392  nb_buf_bar = 0;
393  nb_img_bar = 0;
394 
395  /* Setup shader */
396  ff_vk_shader_update_desc_buffer(&ctx->s, exec, &fv->setup,
397  1, 0, 0,
398  slice_state,
399  0, fp->slice_data_size*f->slice_count,
400  VK_FORMAT_UNDEFINED);
401  ff_vk_shader_update_desc_buffer(&ctx->s, exec, &fv->setup,
402  1, 1, 0,
403  slice_offset,
404  0, 2*f->slice_count*sizeof(uint32_t),
405  VK_FORMAT_UNDEFINED);
406  ff_vk_shader_update_desc_buffer(&ctx->s, exec, &fv->setup,
407  1, 2, 0,
408  slice_status,
409  0, f->slice_count*sizeof(uint32_t),
410  VK_FORMAT_UNDEFINED);
411 
412  ff_vk_exec_bind_shader(&ctx->s, exec, &fv->setup);
413  pd = (FFv1VkParameters) {
414  .slice_data = slices_buf->address,
415  .slice_state = slice_state->address + f->slice_count*fp->slice_data_size,
416 
417  .img_size[0] = f->picture.f->width,
418  .img_size[1] = f->picture.f->height,
419  .chroma_shift[0] = f->chroma_h_shift,
420  .chroma_shift[1] = f->chroma_v_shift,
421 
422  .plane_state_size = fp->plane_state_size,
423  .crcref = f->crcref,
424  .rct_offset = 1 << bits,
425 
426  .bits_per_raw_sample = bits,
427  .quant_table_count = f->quant_table_count,
428  .version = f->version,
429  .micro_version = f->micro_version,
430  .key_frame = f->picture.f->flags & AV_FRAME_FLAG_KEY,
431  .planes = av_pix_fmt_count_planes(sw_format),
432  .codec_planes = f->plane_count,
433  .color_planes = color_planes,
434  .transparency = f->transparency,
435  .planar_rgb = ff_vk_mt_is_np_rgb(sw_format) &&
436  (ff_vk_count_images((AVVkFrame *)f->picture.f->data[0]) > 1),
437  .colorspace = f->colorspace,
438  .ec = f->ec,
439  .golomb = f->ac == AC_GOLOMB_RICE,
440  .check_crc = !!(avctx->err_recognition & AV_EF_CRCCHECK),
441  };
442  for (int i = 0; i < f->quant_table_count; i++)
443  pd.extend_lookup[i] = (f->quant_tables[i][3][127] != 0) ||
444  (f->quant_tables[i][4][127] != 0);
445 
446 
447  /* For some reason the C FFv1 encoder/decoder treats these differently */
448  if (sw_format == AV_PIX_FMT_GBRP10 || sw_format == AV_PIX_FMT_GBRP12 ||
449  sw_format == AV_PIX_FMT_GBRP14)
450  memcpy(pd.fmt_lut, (int [4]) { 2, 1, 0, 3 }, 4*sizeof(int));
451  else if (sw_format == AV_PIX_FMT_X2BGR10)
452  memcpy(pd.fmt_lut, (int [4]) { 0, 2, 1, 3 }, 4*sizeof(int));
453  else
454  ff_vk_set_perm(sw_format, pd.fmt_lut, 0);
455 
456  ff_vk_shader_update_push_const(&ctx->s, exec, &fv->setup,
457  VK_SHADER_STAGE_COMPUTE_BIT,
458  0, sizeof(pd), &pd);
459 
460  vk->CmdDispatch(exec->buf, f->num_h_slices, f->num_v_slices, 1);
461 
462  if (is_rgb) {
463  AVVkFrame *vkf = (AVVkFrame *)vp->dpb_frame->data[0];
464  for (int i = 0; i < color_planes; i++)
465  vk->CmdClearColorImage(exec->buf, vkf->img[i], VK_IMAGE_LAYOUT_GENERAL,
466  &((VkClearColorValue) { 0 }),
467  1, &((VkImageSubresourceRange) {
468  .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
469  .levelCount = 1,
470  .layerCount = 1,
471  }));
472  }
473 
474  /* Reset shader */
475  reset_shader = &fv->reset[f->ac == AC_GOLOMB_RICE];
476  ff_vk_shader_update_desc_buffer(&ctx->s, exec, reset_shader,
477  1, 0, 0,
478  slice_state,
479  0, fp->slice_data_size*f->slice_count,
480  VK_FORMAT_UNDEFINED);
481 
482  ff_vk_exec_bind_shader(&ctx->s, exec, reset_shader);
483 
484  pd_reset = (FFv1VkResetParameters) {
485  .slice_state = slice_state->address + f->slice_count*fp->slice_data_size,
486  .plane_state_size = fp->plane_state_size,
487  .codec_planes = f->plane_count,
488  .key_frame = f->picture.f->flags & AV_FRAME_FLAG_KEY,
489  .version = f->version,
490  .micro_version = f->micro_version,
491  };
492  for (int i = 0; i < f->quant_table_count; i++)
493  pd_reset.context_count[i] = f->context_count[i];
494 
495  ff_vk_shader_update_push_const(&ctx->s, exec, reset_shader,
496  VK_SHADER_STAGE_COMPUTE_BIT,
497  0, sizeof(pd_reset), &pd_reset);
498 
499  /* Sync between setup and reset shaders */
500  buf_bar[nb_buf_bar++] = (VkBufferMemoryBarrier2) {
501  .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2,
502  .srcStageMask = slice_state->stage,
503  .dstStageMask = VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
504  .srcAccessMask = slice_state->access,
505  .dstAccessMask = VK_ACCESS_2_SHADER_STORAGE_READ_BIT,
506  .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
507  .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
508  .buffer = slice_state->buf,
509  .offset = 0,
510  .size = fp->slice_data_size*f->slice_count,
511  };
512  vk->CmdPipelineBarrier2(exec->buf, &(VkDependencyInfo) {
513  .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
514  .pImageMemoryBarriers = img_bar,
515  .imageMemoryBarrierCount = nb_img_bar,
516  .pBufferMemoryBarriers = buf_bar,
517  .bufferMemoryBarrierCount = nb_buf_bar,
518  });
519  slice_state->stage = buf_bar[0].dstStageMask;
520  slice_state->access = buf_bar[0].dstAccessMask;
521  nb_buf_bar = 0;
522  nb_img_bar = 0;
523 
524  vk->CmdDispatch(exec->buf, f->num_h_slices, f->num_v_slices,
525  f->plane_count);
526 
527  /* Decode */
528  decode_shader = &fv->decode[f->use32bit][f->ac == AC_GOLOMB_RICE][is_rgb];
529  ff_vk_shader_update_desc_buffer(&ctx->s, exec, decode_shader,
530  1, 0, 0,
531  slice_state,
532  0, fp->slice_data_size*f->slice_count,
533  VK_FORMAT_UNDEFINED);
534  ff_vk_shader_update_img_array(&ctx->s, exec, decode_shader,
535  decode_dst, decode_dst_view,
536  1, 1,
537  VK_IMAGE_LAYOUT_GENERAL,
538  VK_NULL_HANDLE);
539  if (is_rgb)
540  ff_vk_shader_update_img_array(&ctx->s, exec, decode_shader,
541  f->picture.f, vp->view.out,
542  1, 2,
543  VK_IMAGE_LAYOUT_GENERAL,
544  VK_NULL_HANDLE);
545 
546  ff_vk_exec_bind_shader(&ctx->s, exec, decode_shader);
547  ff_vk_shader_update_push_const(&ctx->s, exec, decode_shader,
548  VK_SHADER_STAGE_COMPUTE_BIT,
549  0, sizeof(pd), &pd);
550 
551  /* Sync between reset and decode shaders */
552  buf_bar[nb_buf_bar++] = (VkBufferMemoryBarrier2) {
553  .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2,
554  .srcStageMask = slice_state->stage,
555  .dstStageMask = VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
556  .srcAccessMask = slice_state->access,
557  .dstAccessMask = VK_ACCESS_2_SHADER_STORAGE_READ_BIT |
558  VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT,
559  .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
560  .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
561  .buffer = slice_state->buf,
562  .offset = fp->slice_data_size*f->slice_count,
563  .size = f->slice_count*(fp->slice_state_size - fp->slice_data_size),
564  };
565 
566  /* Input frame barrier */
567  ff_vk_frame_barrier(&ctx->s, exec, f->picture.f, img_bar, &nb_img_bar,
568  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
569  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
570  VK_ACCESS_SHADER_WRITE_BIT |
571  (!is_rgb ? VK_ACCESS_SHADER_READ_BIT : 0),
572  VK_IMAGE_LAYOUT_GENERAL,
573  VK_QUEUE_FAMILY_IGNORED);
574  if (is_rgb)
575  ff_vk_frame_barrier(&ctx->s, exec, vp->dpb_frame, img_bar, &nb_img_bar,
576  VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
577  VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
578  VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT,
579  VK_IMAGE_LAYOUT_GENERAL,
580  VK_QUEUE_FAMILY_IGNORED);
581 
582  vk->CmdPipelineBarrier2(exec->buf, &(VkDependencyInfo) {
583  .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
584  .pImageMemoryBarriers = img_bar,
585  .imageMemoryBarrierCount = nb_img_bar,
586  .pBufferMemoryBarriers = buf_bar,
587  .bufferMemoryBarrierCount = nb_buf_bar,
588  });
589  slice_state->stage = buf_bar[0].dstStageMask;
590  slice_state->access = buf_bar[0].dstAccessMask;
591  nb_img_bar = 0;
592  nb_buf_bar = 0;
593 
594  vk->CmdDispatch(exec->buf, f->num_h_slices, f->num_v_slices, 1);
595 
596  err = ff_vk_exec_submit(&ctx->s, exec);
597  if (err < 0)
598  return err;
599 
600  /* We don't need the temporary frame after decoding */
601  av_frame_free(&vp->dpb_frame);
602 
603 fail:
604  return 0;
605 }
606 
607 static void define_shared_code(FFVulkanShader *shd, int use32bit)
608 {
609  int smp_bits = use32bit ? 32 : 16;
610 
611  GLSLC(0, #define DECODE );
612 
613  av_bprintf(&shd->src, "#define CONTEXT_SIZE %i\n" ,CONTEXT_SIZE);
614  av_bprintf(&shd->src, "#define MAX_QUANT_TABLE_MASK 0x%x\n" ,MAX_QUANT_TABLE_MASK);
615 
616  GLSLF(0, #define TYPE int%i_t ,smp_bits);
617  GLSLF(0, #define VTYPE2 i%ivec2 ,smp_bits);
618  GLSLF(0, #define VTYPE3 i%ivec3 ,smp_bits);
621 }
622 
624  FFVkExecPool *pool, FFVkSPIRVCompiler *spv,
625  FFVulkanShader *shd)
626 {
627  int err;
629 
630  uint8_t *spv_data;
631  size_t spv_len;
632  void *spv_opaque = NULL;
633 
634  RET(ff_vk_shader_init(s, shd, "ffv1_dec_setup",
635  VK_SHADER_STAGE_COMPUTE_BIT,
636  (const char *[]) { "GL_EXT_buffer_reference",
637  "GL_EXT_buffer_reference2" }, 2,
638  1, 1, 1,
639  0));
640 
641  /* Common codec header */
643 
644  add_push_data(shd);
645 
646  av_bprintf(&shd->src, "#define MAX_QUANT_TABLES %i\n", MAX_QUANT_TABLES);
647  av_bprintf(&shd->src, "#define MAX_CONTEXT_INPUTS %i\n", MAX_CONTEXT_INPUTS);
648  av_bprintf(&shd->src, "#define MAX_QUANT_TABLE_SIZE %i\n", MAX_QUANT_TABLE_SIZE);
649 
650  desc_set = (FFVulkanDescriptorSetBinding []) {
651  {
652  .name = "rangecoder_static_buf",
653  .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
654  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
655  .mem_layout = "scalar",
656  .buf_content = "uint8_t zero_one_state[512];",
657  },
658  {
659  .name = "crc_ieee_buf",
660  .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
661  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
662  .mem_layout = "scalar",
663  .buf_content = "uint32_t crc_ieee[256];",
664  },
665  {
666  .name = "quant_buf",
667  .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
668  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
669  .mem_layout = "scalar",
670  .buf_content = "int16_t quant_table[MAX_QUANT_TABLES]"
671  "[MAX_CONTEXT_INPUTS][MAX_QUANT_TABLE_SIZE];",
672  },
673  };
674 
675  RET(ff_vk_shader_add_descriptor_set(s, shd, desc_set, 3, 1, 0));
676 
677  define_shared_code(shd, 0 /* Irrelevant */);
678 
679  desc_set = (FFVulkanDescriptorSetBinding []) {
680  {
681  .name = "slice_data_buf",
682  .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
683  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
684  .buf_content = "SliceContext slice_ctx",
685  .buf_elems = f->max_slice_count,
686  },
687  {
688  .name = "slice_offsets_buf",
689  .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
690  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
691  .mem_quali = "readonly",
692  .buf_content = "uint32_t slice_offsets",
693  .buf_elems = 2*f->max_slice_count,
694  },
695  {
696  .name = "slice_status_buf",
697  .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
698  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
699  .mem_quali = "writeonly",
700  .buf_content = "uint32_t slice_crc_mismatch",
701  .buf_elems = f->max_slice_count,
702  },
703  };
704  RET(ff_vk_shader_add_descriptor_set(s, shd, desc_set, 3, 0, 0));
705 
707 
708  RET(spv->compile_shader(s, spv, shd, &spv_data, &spv_len, "main",
709  &spv_opaque));
710  RET(ff_vk_shader_link(s, shd, spv_data, spv_len, "main"));
711 
712  RET(ff_vk_shader_register_exec(s, pool, shd));
713 
714 fail:
715  if (spv_opaque)
716  spv->free_shader(spv, &spv_opaque);
717 
718  return err;
719 }
720 
722  FFVkExecPool *pool, FFVkSPIRVCompiler *spv,
723  FFVulkanShader *shd, int ac)
724 {
725  int err;
727 
728  uint8_t *spv_data;
729  size_t spv_len;
730  void *spv_opaque = NULL;
731  int wg_dim = FFMIN(s->props.properties.limits.maxComputeWorkGroupSize[0], 1024);
732 
733  RET(ff_vk_shader_init(s, shd, "ffv1_dec_reset",
734  VK_SHADER_STAGE_COMPUTE_BIT,
735  (const char *[]) { "GL_EXT_buffer_reference",
736  "GL_EXT_buffer_reference2" }, 2,
737  wg_dim, 1, 1,
738  0));
739 
740  if (ac == AC_GOLOMB_RICE)
741  av_bprintf(&shd->src, "#define GOLOMB\n");
742 
743  /* Common codec header */
745 
746  GLSLC(0, layout(push_constant, scalar) uniform pushConstants { );
747  GLSLF(1, uint context_count[%i]; ,MAX_QUANT_TABLES);
748  GLSLC(1, u8buf slice_state; );
749  GLSLC(1, uint plane_state_size; );
750  GLSLC(1, uint8_t codec_planes; );
751  GLSLC(1, uint8_t key_frame; );
752  GLSLC(1, uint8_t version; );
753  GLSLC(1, uint8_t micro_version; );
754  GLSLC(1, uint8_t padding[1]; );
755  GLSLC(0, }; );
757  VK_SHADER_STAGE_COMPUTE_BIT);
758 
759  av_bprintf(&shd->src, "#define MAX_QUANT_TABLES %i\n", MAX_QUANT_TABLES);
760  av_bprintf(&shd->src, "#define MAX_CONTEXT_INPUTS %i\n", MAX_CONTEXT_INPUTS);
761  av_bprintf(&shd->src, "#define MAX_QUANT_TABLE_SIZE %i\n", MAX_QUANT_TABLE_SIZE);
762 
763  desc_set = (FFVulkanDescriptorSetBinding []) {
764  {
765  .name = "rangecoder_static_buf",
766  .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
767  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
768  .mem_layout = "scalar",
769  .buf_content = "uint8_t zero_one_state[512];",
770  },
771  {
772  .name = "quant_buf",
773  .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
774  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
775  .mem_layout = "scalar",
776  .buf_content = "int16_t quant_table[MAX_QUANT_TABLES]"
777  "[MAX_CONTEXT_INPUTS][MAX_QUANT_TABLE_SIZE];",
778  },
779  };
780  RET(ff_vk_shader_add_descriptor_set(s, shd, desc_set, 2, 1, 0));
781 
782  define_shared_code(shd, 0 /* Bit depth irrelevant for the reset shader */);
783  if (ac == AC_GOLOMB_RICE)
785 
786  desc_set = (FFVulkanDescriptorSetBinding []) {
787  {
788  .name = "slice_data_buf",
789  .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
790  .mem_quali = "readonly",
791  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
792  .buf_content = "SliceContext slice_ctx",
793  .buf_elems = f->max_slice_count,
794  },
795  };
796  RET(ff_vk_shader_add_descriptor_set(s, shd, desc_set, 1, 0, 0));
797 
799 
800  RET(spv->compile_shader(s, spv, shd, &spv_data, &spv_len, "main",
801  &spv_opaque));
802  RET(ff_vk_shader_link(s, shd, spv_data, spv_len, "main"));
803 
804  RET(ff_vk_shader_register_exec(s, pool, shd));
805 
806 fail:
807  if (spv_opaque)
808  spv->free_shader(spv, &spv_opaque);
809 
810  return err;
811 }
812 
814  FFVkExecPool *pool, FFVkSPIRVCompiler *spv,
815  FFVulkanShader *shd,
816  AVHWFramesContext *dec_frames_ctx,
817  AVHWFramesContext *out_frames_ctx,
818  int use32bit, int ac, int rgb)
819 {
820  int err;
822 
823  uint8_t *spv_data;
824  size_t spv_len;
825  void *spv_opaque = NULL;
826  int use_cached_reader = ac != AC_GOLOMB_RICE &&
827  s->driver_props.driverID == VK_DRIVER_ID_MESA_RADV;
828 
829  RET(ff_vk_shader_init(s, shd, "ffv1_dec",
830  VK_SHADER_STAGE_COMPUTE_BIT,
831  (const char *[]) { "GL_EXT_buffer_reference",
832  "GL_EXT_buffer_reference2" }, 2,
833  use_cached_reader ? CONTEXT_SIZE : 1, 1, 1,
834  0));
835 
836  if (ac == AC_GOLOMB_RICE)
837  av_bprintf(&shd->src, "#define GOLOMB\n");
838 
839  if (rgb)
840  av_bprintf(&shd->src, "#define RGB\n");
841 
842  if (use_cached_reader)
843  av_bprintf(&shd->src, "#define CACHED_SYMBOL_READER 1\n");
844 
845  /* Common codec header */
847 
848  add_push_data(shd);
849 
850  av_bprintf(&shd->src, "#define MAX_QUANT_TABLES %i\n", MAX_QUANT_TABLES);
851  av_bprintf(&shd->src, "#define MAX_CONTEXT_INPUTS %i\n", MAX_CONTEXT_INPUTS);
852  av_bprintf(&shd->src, "#define MAX_QUANT_TABLE_SIZE %i\n", MAX_QUANT_TABLE_SIZE);
853 
854  desc_set = (FFVulkanDescriptorSetBinding []) {
855  {
856  .name = "rangecoder_static_buf",
857  .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
858  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
859  .mem_layout = "scalar",
860  .buf_content = "uint8_t zero_one_state[512];",
861  },
862  {
863  .name = "quant_buf",
864  .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
865  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
866  .mem_layout = "scalar",
867  .buf_content = "int16_t quant_table[MAX_QUANT_TABLES]"
868  "[MAX_CONTEXT_INPUTS][MAX_QUANT_TABLE_SIZE];",
869  },
870  };
871 
872  RET(ff_vk_shader_add_descriptor_set(s, shd, desc_set, 2, 1, 0));
873 
874  define_shared_code(shd, use32bit);
875  if (ac == AC_GOLOMB_RICE)
877 
878  desc_set = (FFVulkanDescriptorSetBinding []) {
879  {
880  .name = "slice_data_buf",
881  .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
882  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
883  .buf_content = "SliceContext slice_ctx",
884  .buf_elems = f->max_slice_count,
885  },
886  {
887  .name = "dec",
888  .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
889  .dimensions = 2,
890  .mem_layout = ff_vk_shader_rep_fmt(dec_frames_ctx->sw_format,
892  .elems = av_pix_fmt_count_planes(dec_frames_ctx->sw_format),
893  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
894  },
895  {
896  .name = "dst",
897  .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
898  .dimensions = 2,
899  .mem_layout = ff_vk_shader_rep_fmt(out_frames_ctx->sw_format,
901  .mem_quali = "writeonly",
902  .elems = av_pix_fmt_count_planes(out_frames_ctx->sw_format),
903  .stages = VK_SHADER_STAGE_COMPUTE_BIT,
904  },
905  };
906  RET(ff_vk_shader_add_descriptor_set(s, shd, desc_set, 2 + rgb, 0, 0));
907 
909 
910  RET(spv->compile_shader(s, spv, shd, &spv_data, &spv_len, "main",
911  &spv_opaque));
912  RET(ff_vk_shader_link(s, shd, spv_data, spv_len, "main"));
913 
914  RET(ff_vk_shader_register_exec(s, pool, shd));
915 
916 fail:
917  if (spv_opaque)
918  spv->free_shader(spv, &spv_opaque);
919 
920  return err;
921 }
922 
924  AVBufferRef **dst, enum AVPixelFormat sw_format)
925 {
926  int err;
927  AVHWFramesContext *frames_ctx;
928  AVVulkanFramesContext *vk_frames;
929  FFV1Context *f = avctx->priv_data;
930 
931  *dst = av_hwframe_ctx_alloc(s->device_ref);
932  if (!(*dst))
933  return AVERROR(ENOMEM);
934 
935  frames_ctx = (AVHWFramesContext *)((*dst)->data);
936  frames_ctx->format = AV_PIX_FMT_VULKAN;
937  frames_ctx->sw_format = sw_format;
938  frames_ctx->width = s->frames->width;
939  frames_ctx->height = f->num_v_slices*2;
940 
941  vk_frames = frames_ctx->hwctx;
942  vk_frames->tiling = VK_IMAGE_TILING_OPTIMAL;
943  vk_frames->img_flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
944  vk_frames->usage = VK_IMAGE_USAGE_STORAGE_BIT |
945  VK_IMAGE_USAGE_TRANSFER_DST_BIT;
946 
947  err = av_hwframe_ctx_init(*dst);
948  if (err < 0) {
949  av_log(avctx, AV_LOG_ERROR, "Unable to initialize frame pool with format %s: %s\n",
950  av_get_pix_fmt_name(sw_format), av_err2str(err));
952  return err;
953  }
954 
955  return 0;
956 }
957 
959 {
960  FFv1VulkanDecodeContext *fv = ctx->sd_ctx;
961 
962  ff_vk_shader_free(&ctx->s, &fv->setup);
963 
964  for (int i = 0; i < 2; i++) /* 16/32 bit */
966 
967  for (int i = 0; i < 2; i++) /* AC/Golomb */
968  ff_vk_shader_free(&ctx->s, &fv->reset[i]);
969 
970  for (int i = 0; i < 2; i++) /* 16/32 bit */
971  for (int j = 0; j < 2; j++) /* AC/Golomb */
972  for (int k = 0; k < 2; k++) /* Normal/RGB */
973  ff_vk_shader_free(&ctx->s, &fv->decode[i][j][k]);
974 
975  ff_vk_free_buf(&ctx->s, &fv->quant_buf);
977  ff_vk_free_buf(&ctx->s, &fv->crc_tab_buf);
978 
982 }
983 
985 {
986  int err;
987  FFV1Context *f = avctx->priv_data;
991  FFVkSPIRVCompiler *spv;
992 
993  if (f->version < 3 ||
994  (f->version == 4 && f->micro_version > 3))
995  return AVERROR(ENOTSUP);
996 
997  spv = ff_vk_spirv_init();
998  if (!spv) {
999  av_log(avctx, AV_LOG_ERROR, "Unable to initialize SPIR-V compiler!\n");
1000  return AVERROR_EXTERNAL;
1001  }
1002 
1003  err = ff_vk_decode_init(avctx);
1004  if (err < 0)
1005  return err;
1006  ctx = dec->shared_ctx;
1007 
1008  fv = ctx->sd_ctx = av_mallocz(sizeof(*fv));
1009  if (!fv) {
1010  err = AVERROR(ENOMEM);
1011  goto fail;
1012  }
1013 
1014  ctx->sd_ctx_free = &vk_decode_ffv1_uninit;
1015 
1016  /* Intermediate frame pool for RCT */
1017  for (int i = 0; i < 2; i++) { /* 16/32 bit */
1018  err = init_indirect(avctx, &ctx->s, &fv->intermediate_frames_ref[i],
1020  if (err < 0)
1021  return err;
1022  }
1023 
1024  /* Setup shader */
1025  err = init_setup_shader(f, &ctx->s, &ctx->exec_pool, spv, &fv->setup);
1026  if (err < 0)
1027  return err;
1028 
1029  /* Reset shaders */
1030  for (int i = 0; i < 2; i++) { /* AC/Golomb */
1031  err = init_reset_shader(f, &ctx->s, &ctx->exec_pool,
1032  spv, &fv->reset[i], !i ? AC_RANGE_CUSTOM_TAB : 0);
1033  if (err < 0)
1034  return err;
1035  }
1036 
1037  /* Decode shaders */
1038  for (int i = 0; i < 2; i++) { /* 16/32 bit */
1039  for (int j = 0; j < 2; j++) { /* AC/Golomb */
1040  for (int k = 0; k < 2; k++) { /* Normal/RGB */
1041  AVHWFramesContext *dec_frames_ctx;
1042  dec_frames_ctx = k ? (AVHWFramesContext *)fv->intermediate_frames_ref[i]->data :
1044  err = init_decode_shader(f, &ctx->s, &ctx->exec_pool,
1045  spv, &fv->decode[i][j][k],
1046  dec_frames_ctx,
1048  i,
1050  k);
1051  if (err < 0)
1052  return err;
1053  }
1054  }
1055  }
1056 
1057  /* Range coder data */
1059  &fv->rangecoder_static_buf,
1060  f);
1061  if (err < 0)
1062  return err;
1063 
1064  /* Quantization table data */
1066  &fv->quant_buf,
1067  f);
1068  if (err < 0)
1069  return err;
1070 
1071  /* CRC table buffer */
1073  &fv->crc_tab_buf,
1074  f);
1075  if (err < 0)
1076  return err;
1077 
1078  /* Update setup global descriptors */
1079  RET(ff_vk_shader_update_desc_buffer(&ctx->s, &ctx->exec_pool.contexts[0],
1080  &fv->setup, 0, 0, 0,
1081  &fv->rangecoder_static_buf,
1082  0, fv->rangecoder_static_buf.size,
1083  VK_FORMAT_UNDEFINED));
1084  RET(ff_vk_shader_update_desc_buffer(&ctx->s, &ctx->exec_pool.contexts[0],
1085  &fv->setup, 0, 1, 0,
1086  &fv->crc_tab_buf,
1087  0, fv->crc_tab_buf.size,
1088  VK_FORMAT_UNDEFINED));
1089 
1090  /* Update decode global descriptors */
1091  for (int i = 0; i < 2; i++) { /* 16/32 bit */
1092  for (int j = 0; j < 2; j++) { /* AC/Golomb */
1093  for (int k = 0; k < 2; k++) { /* Normal/RGB */
1094  RET(ff_vk_shader_update_desc_buffer(&ctx->s, &ctx->exec_pool.contexts[0],
1095  &fv->decode[i][j][k], 0, 0, 0,
1096  &fv->rangecoder_static_buf,
1097  0, fv->rangecoder_static_buf.size,
1098  VK_FORMAT_UNDEFINED));
1099  RET(ff_vk_shader_update_desc_buffer(&ctx->s, &ctx->exec_pool.contexts[0],
1100  &fv->decode[i][j][k], 0, 1, 0,
1101  &fv->quant_buf,
1102  0, fv->quant_buf.size,
1103  VK_FORMAT_UNDEFINED));
1104  }
1105  }
1106  }
1107 
1108 fail:
1109  return err;
1110 }
1111 
1113 {
1114  AVHWDeviceContext *hwctx = _hwctx.nc;
1115 
1117  FFVulkanDecodePicture *vp = &fp->vp;
1118 
1119  ff_vk_decode_free_frame(hwctx, vp);
1120 
1121  if (fp->crc_checked) {
1122  FFVkBuffer *slice_status = (FFVkBuffer *)fp->slice_status_buf->data;
1123  for (int i = 0; i < fp->slice_num; i++) {
1124  uint32_t crc_res;
1125  crc_res = AV_RN32(slice_status->mapped_mem + i*sizeof(uint32_t));
1126  if (crc_res != 0)
1127  av_log(hwctx, AV_LOG_ERROR, "CRC mismatch in slice %i, res: 0x%x\n",
1128  i, crc_res);
1129  }
1130  }
1131 
1136 }
1137 
1139  .p.name = "ffv1_vulkan",
1140  .p.type = AVMEDIA_TYPE_VIDEO,
1141  .p.id = AV_CODEC_ID_FFV1,
1142  .p.pix_fmt = AV_PIX_FMT_VULKAN,
1143  .start_frame = &vk_ffv1_start_frame,
1144  .decode_slice = &vk_ffv1_decode_slice,
1145  .end_frame = &vk_ffv1_end_frame,
1146  .free_frame_priv = &vk_ffv1_free_frame_priv,
1147  .frame_priv_data_size = sizeof(FFv1VulkanDecodePicture),
1150  .decode_params = &ff_vk_params_invalidate,
1153  .frame_params = &ff_vk_frame_params,
1154  .priv_data_size = sizeof(FFVulkanDecodeContext),
1156 };
AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:551
FFv1VkResetParameters::context_count
uint32_t context_count[MAX_QUANT_TABLES]
Definition: ffv1_vulkan.h:52
FFv1VkParameters::planes
uint8_t planes
Definition: ffv1enc_vulkan.c:144
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
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
AV_PIX_FMT_YA8
@ AV_PIX_FMT_YA8
8 bits gray, 8 bits alpha
Definition: pixfmt.h:140
ff_source_ffv1_dec_setup_comp
const char * ff_source_ffv1_dec_setup_comp
ff_vk_shader_free
void ff_vk_shader_free(FFVulkanContext *s, FFVulkanShader *shd)
Free a shader.
Definition: vulkan.c:2860
FFv1VulkanDecodeContext::rangecoder_static_buf
FFVkBuffer rangecoder_static_buf
Definition: vulkan_ffv1.c:66
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:1993
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:204
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3341
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
FFVulkanDecodeContext::shared_ctx
FFVulkanDecodeShared * shared_ctx
Definition: vulkan_decode.h:66
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
AVHWFramesContext::format
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
Definition: hwcontext.h:198
AVCodecContext::err_recognition
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
Definition: avcodec.h:1398
FFv1VkParameters::slice_data
VkDeviceAddress slice_data
Definition: vulkan_ffv1.c:76
AVRefStructOpaque::nc
void * nc
Definition: refstruct.h:59
av_unused
#define av_unused
Definition: attributes.h:131
FFHWAccel::p
AVHWAccel p
The public AVHWAccel.
Definition: hwaccel_internal.h:38
FFv1VulkanDecodeContext::reset
FFVulkanShader reset[2]
Definition: vulkan_ffv1.c:63
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:63
FFv1VkParameters::key_frame
uint8_t key_frame
Definition: ffv1enc_vulkan.c:143
av_hwframe_ctx_init
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
Definition: hwcontext.c:333
ff_ffv1_vk_init_quant_table_data
int ff_ffv1_vk_init_quant_table_data(FFVulkanContext *s, FFVkBuffer *vkb, FFV1Context *f)
Definition: ffv1_vulkan.c:72
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:410
FFv1VkParameters::slice_state
VkDeviceAddress slice_state
Definition: ffv1enc_vulkan.c:126
av_hwframe_ctx_alloc
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
Allocate an AVHWFramesContext tied to a given device context.
Definition: hwcontext.c:259
FFv1VulkanDecodePicture::slice_data_size
uint32_t slice_data_size
Definition: vulkan_ffv1.c:49
FFVulkanShader::src
AVBPrint src
Definition: vulkan.h:195
MAX_QUANT_TABLE_SIZE
#define MAX_QUANT_TABLE_SIZE
Definition: ffv1.h:48
ff_source_ffv1_vlc_comp
const char * ff_source_ffv1_vlc_comp
data
const char data[16]
Definition: mxf.c:149
FFVulkanDecodeDescriptor::codec_id
enum AVCodecID codec_id
Definition: vulkan_decode.h:30
FFv1VkResetParameters::slice_state
VkDeviceAddress slice_state
Definition: ffv1_vulkan.h:53
FFv1VkParameters::fmt_lut
int fmt_lut[4]
Definition: vulkan_ffv1.c:79
FFVkBuffer::address
VkDeviceAddress address
Definition: vulkan.h:92
ff_source_ffv1_common_comp
const char * ff_source_ffv1_common_comp
ff_vk_exec_get
FFVkExecContext * ff_vk_exec_get(FFVulkanContext *s, FFVkExecPool *pool)
Retrieve an execution pool.
Definition: vulkan.c:509
FF_VK_REP_NATIVE
@ FF_VK_REP_NATIVE
Definition: vulkan.h:404
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
av_buffer_ref
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition: buffer.c:103
AVHWFramesContext::width
int width
The allocated dimensions of the frames in this pool.
Definition: hwcontext.h:218
AC_RANGE_CUSTOM_TAB
#define AC_RANGE_CUSTOM_TAB
Definition: ffv1.h:54
FFv1VkParameters::micro_version
uint8_t micro_version
Definition: ffv1enc_vulkan.c:141
FFv1VulkanDecodePicture::slice_status_buf
AVBufferRef * slice_status_buf
Definition: vulkan_ffv1.c:55
FFv1VkParameters::golomb
uint8_t golomb
Definition: vulkan_ffv1.c:100
FFVulkanDecodeContext
Definition: vulkan_decode.h:65
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:741
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:431
FFv1VulkanDecodeContext::slice_state_pool
AVBufferPool * slice_state_pool
Definition: vulkan_ffv1.c:70
FFv1VkParameters::color_planes
uint8_t color_planes
Definition: vulkan_ffv1.c:95
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3381
rgb
Definition: rpzaenc.c:60
MAX_QUANT_TABLE_MASK
#define MAX_QUANT_TABLE_MASK
Definition: ffv1.h:49
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:546
FFHWAccel
Definition: hwaccel_internal.h:34
AVVkFrame::img
VkImage img[AV_NUM_DATA_POINTERS]
Vulkan images to which the memory is bound to.
Definition: hwcontext_vulkan.h:302
fail
#define fail()
Definition: checkasm.h:194
FFVulkanDecodePicture::sem_value
uint64_t sem_value
Definition: vulkan_decode.h:97
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:544
init_indirect
static int init_indirect(AVCodecContext *avctx, FFVulkanContext *s, AVBufferRef **dst, enum AVPixelFormat sw_format)
Definition: vulkan_ffv1.c:923
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:2737
AVVulkanFramesContext
Allocated as AVHWFramesContext.hwctx, used to set pool-specific options.
Definition: hwcontext_vulkan.h:208
FFv1VkParameters::transparency
uint8_t transparency
Definition: ffv1enc_vulkan.c:146
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:2500
init_setup_shader
static int init_setup_shader(FFV1Context *f, FFVulkanContext *s, FFVkExecPool *pool, FFVkSPIRVCompiler *spv, FFVulkanShader *shd)
Definition: vulkan_ffv1.c:623
FFv1VkParameters::plane_state_size
uint32_t plane_state_size
Definition: ffv1enc_vulkan.c:133
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:1313
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:2365
CONTEXT_SIZE
#define CONTEXT_SIZE
Definition: ffv1.h:45
add_push_data
static void add_push_data(FFVulkanShader *shd)
Definition: vulkan_ffv1.c:105
FFVulkanDecodeShared
Definition: vulkan_decode.h:47
FFv1VkParameters::extend_lookup
uint8_t extend_lookup[8]
Definition: vulkan_ffv1.c:87
AVHWDeviceContext
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
Definition: hwcontext.h:61
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:51
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
FFv1VulkanDecodeContext::slice_status_pool
AVBufferPool * slice_status_pool
Definition: vulkan_ffv1.c:72
AVHWFramesContext::height
int height
Definition: hwcontext.h:218
AV_FRAME_FLAG_KEY
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
Definition: frame.h:625
FFv1VkParameters::codec_planes
uint8_t codec_planes
Definition: ffv1enc_vulkan.c:145
define_shared_code
static void define_shared_code(FFVulkanShader *shd, int use32bit)
Definition: vulkan_ffv1.c:607
s
#define s(width, name)
Definition: cbs_vp9.c:198
FFVulkanDecodePicture
Definition: vulkan_decode.h:85
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:840
FFv1VulkanDecodeContext
Definition: vulkan_ffv1.c:59
FFv1VkParameters::bits_per_raw_sample
uint8_t bits_per_raw_sample
Definition: ffv1enc_vulkan.c:138
ff_vk_set_perm
void ff_vk_set_perm(enum AVPixelFormat pix_fmt, int lut[4], int inv)
Since storage images may not be swizzled, we have to do this in the shader itself.
Definition: vulkan.c:1501
bits
uint8_t bits
Definition: vp3data.h:128
AVVulkanFramesContext::img_flags
VkImageCreateFlags img_flags
Flags to set during image creation.
Definition: hwcontext_vulkan.h:260
AV_PIX_FMT_GBRAP32
#define AV_PIX_FMT_GBRAP32
Definition: pixfmt.h:552
ctx
AVFormatContext * ctx
Definition: movenc.c:49
FFv1VulkanDecodePicture::vp
FFVulkanDecodePicture vp
Definition: vulkan_ffv1.c:44
vk_ffv1_decode_slice
static int vk_ffv1_decode_slice(AVCodecContext *avctx, const uint8_t *data, uint32_t size)
Definition: vulkan_ffv1.c:249
FFv1VulkanDecodePicture
Definition: vulkan_ffv1.c:43
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:581
GLSLD
#define GLSLD(D)
Definition: vulkan.h:58
FFv1VkParameters::crcref
uint32_t crcref
Definition: ffv1enc_vulkan.c:135
vk_decode_ffv1_uninit
static void vk_decode_ffv1_uninit(FFVulkanDecodeShared *ctx)
Definition: vulkan_ffv1.c:958
init_reset_shader
static int init_reset_shader(FFV1Context *f, FFVulkanContext *s, FFVkExecPool *pool, FFVkSPIRVCompiler *spv, FFVulkanShader *shd, int ac)
Definition: vulkan_ffv1.c:721
FFv1VulkanDecodePicture::slice_state
AVBufferRef * slice_state
Definition: vulkan_ffv1.c:46
FFv1VulkanDecodePicture::plane_state_size
uint32_t plane_state_size
Definition: vulkan_ffv1.c:47
ff_vk_exec_add_dep_wait_sem
int ff_vk_exec_add_dep_wait_sem(FFVulkanContext *s, FFVkExecContext *e, VkSemaphore sem, uint64_t val, VkPipelineStageFlagBits2 stage)
Definition: vulkan.c:658
FFv1VkParameters::chroma_shift
uint32_t chroma_shift[2]
Definition: ffv1enc_vulkan.c:131
TYPE
#define TYPE
Definition: ffv1dec.c:91
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:1539
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:211
AC_GOLOMB_RICE
#define AC_GOLOMB_RICE
Definition: ffv1.h:52
av_buffer_unref
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
Definition: buffer.c:139
AVPixFmtDescriptor::nb_components
uint8_t nb_components
The number of components each pixel has, (1-4)
Definition: pixdesc.h:71
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:574
ff_source_rangecoder_comp
const char * ff_source_rangecoder_comp
AVCodecContext::internal
struct AVCodecInternal * internal
Private context used for internal data.
Definition: avcodec.h:466
FFv1VkParameters::version
uint8_t version
Definition: ffv1enc_vulkan.c:140
vk_ffv1_end_frame
static int vk_ffv1_end_frame(AVCodecContext *avctx)
Definition: vulkan_ffv1.c:284
AV_RN32
#define AV_RN32(p)
Definition: intreadwrite.h:360
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:1132
flush
void(* flush)(AVBSFContext *ctx)
Definition: dts2pts.c:370
FFVkBuffer::size
size_t size
Definition: vulkan.h:91
AVVulkanFramesContext::usage
VkImageUsageFlagBits usage
Defines extra usage of output frames.
Definition: hwcontext_vulkan.h:227
ff_source_ffv1_dec_comp
const char * ff_source_ffv1_dec_comp
ffv1_vulkan.h
FFVkBuffer::mapped_mem
uint8_t * mapped_mem
Definition: vulkan.h:100
FFv1VulkanDecodeContext::slice_offset_pool
AVBufferPool * slice_offset_pool
Definition: vulkan_ffv1.c:71
FFVulkanContext
Definition: vulkan.h:274
FFv1VulkanDecodeContext::quant_buf
FFVkBuffer quant_buf
Definition: vulkan_ffv1.c:67
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:1016
AV_EF_CRCCHECK
#define AV_EF_CRCCHECK
Verify checksums embedded in the bitstream (could be of either encoded or decoded data,...
Definition: defs.h:48
FFv1VkParameters::planar_rgb
uint8_t planar_rgb
Definition: vulkan_ffv1.c:97
AV_PIX_FMT_X2BGR10
#define AV_PIX_FMT_X2BGR10
Definition: pixfmt.h:597
FFv1VulkanDecodeContext::crc_tab_buf
FFVkBuffer crc_tab_buf
Definition: vulkan_ffv1.c:68
AV_CODEC_ID_FFV1
@ AV_CODEC_ID_FFV1
Definition: codec_id.h:85
f
f
Definition: af_crystalizer.c:122
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
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:2816
FFVulkanDescriptorSetBinding
Definition: vulkan.h:74
FFv1VkParameters::padding
uint8_t padding[2]
Definition: ffv1enc_vulkan.c:152
AV_WN32
#define AV_WN32(p, v)
Definition: intreadwrite.h:372
AVCodecInternal::hwaccel_priv_data
void * hwaccel_priv_data
hwaccel-specific private data
Definition: internal.h:130
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
AVVkFrame
Definition: hwcontext_vulkan.h:297
av_err2str
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition: error.h:122
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:424
vk_ffv1_free_frame_priv
static void vk_ffv1_free_frame_priv(AVRefStructOpaque _hwctx, void *data)
Definition: vulkan_ffv1.c:1112
size
int size
Definition: twinvq_data.h:10344
AV_NUM_DATA_POINTERS
#define AV_NUM_DATA_POINTERS
Definition: frame.h:411
FFv1VkParameters::quant_table_count
uint8_t quant_table_count
Definition: vulkan_ffv1.c:89
FF_VK_EXT_PUSH_DESCRIPTOR
#define FF_VK_EXT_PUSH_DESCRIPTOR
Definition: vulkan_functions.h:48
FFVulkanShader
Definition: vulkan.h:190
ff_source_ffv1_reset_comp
const char * ff_source_ffv1_reset_comp
ff_ffv1_vk_init_crc_table_data
int ff_ffv1_vk_init_crc_table_data(FFVulkanContext *s, FFVkBuffer *vkb, FFV1Context *f)
Definition: ffv1_vulkan.c:100
DECODE
#define DECODE(size, endian, src, dst, n, shift, offset)
Read PCM samples macro.
Definition: pcm.c:360
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
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
FFVkExecContext
Definition: vulkan.h:111
init_decode_shader
static int init_decode_shader(FFV1Context *f, FFVulkanContext *s, FFVkExecPool *pool, FFVkSPIRVCompiler *spv, FFVulkanShader *shd, AVHWFramesContext *dec_frames_ctx, AVHWFramesContext *out_frames_ctx, int use32bit, int ac, int rgb)
Definition: vulkan_ffv1.c:813
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:2750
FFVulkanDescriptorSetBinding::name
const char * name
Definition: vulkan.h:75
version
version
Definition: libkvazaar.c:315
ff_vk_mt_is_np_rgb
int ff_vk_mt_is_np_rgb(enum AVPixelFormat pix_fmt)
Returns 1 if pixfmt is a usable RGB format.
Definition: vulkan.c:1480
FFv1VulkanDecodeContext::intermediate_frames_ref
AVBufferRef * intermediate_frames_ref[2]
Definition: vulkan_ffv1.c:60
FFVkSPIRVCompiler
Definition: vulkan_spirv.h:26
AVHWAccel::name
const char * name
Name of the hardware accelerated codec.
Definition: avcodec.h:1942
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
uninit
static void uninit(AVBSFContext *ctx)
Definition: pcm_rechunk.c:68
FFVulkanDecodePicture::out
VkImageView out[AV_NUM_DATA_POINTERS]
Definition: vulkan_decode.h:90
ff_vk_exec_start
int ff_vk_exec_start(FFVulkanContext *s, FFVkExecContext *e)
Start/submit/wait an execution.
Definition: vulkan.c:521
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
FFv1VulkanDecodePicture::slice_state_size
uint32_t slice_state_size
Definition: vulkan_ffv1.c:48
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:545
ff_vk_frame_barrier
void ff_vk_frame_barrier(FFVulkanContext *s, FFVkExecContext *e, AVFrame *pic, VkImageMemoryBarrier2 *bar, int *nb_bar, VkPipelineStageFlags src_stage, VkPipelineStageFlags dst_stage, VkAccessFlagBits new_access, VkImageLayout new_layout, uint32_t new_qf)
Definition: vulkan.c:1950
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
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:2290
ffv1.h
FFVulkanDecodePicture::sem
VkSemaphore sem
Definition: vulkan_decode.h:96
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 @493 planes[]
vulkan_spirv.h
ff_vk_free_buf
void ff_vk_free_buf(FFVulkanContext *s, FFVkBuffer *buf)
Definition: vulkan.c:1164
MAX_CONTEXT_INPUTS
#define MAX_CONTEXT_INPUTS
Definition: ffv1.h:50
FFVkSPIRVCompiler::free_shader
void(* free_shader)(struct FFVkSPIRVCompiler *ctx, void **opaque)
Definition: vulkan_spirv.h:31
ff_vk_exec_bind_shader
void ff_vk_exec_bind_shader(FFVulkanContext *s, FFVkExecContext *e, FFVulkanShader *shd)
Bind a shader.
Definition: vulkan.c:2826
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:116
ff_vk_decode_flush
void ff_vk_decode_flush(AVCodecContext *avctx)
Flush decoder.
Definition: vulkan_decode.c:332
ff_ffv1_vulkan_hwaccel
const FFHWAccel ff_ffv1_vulkan_hwaccel
Definition: vulkan_ffv1.c:1138
ff_vk_create_imageviews
int ff_vk_create_imageviews(FFVulkanContext *s, FFVkExecContext *e, VkImageView views[AV_NUM_DATA_POINTERS], AVFrame *f, enum FFVkShaderRepFormat rep_fmt)
Create an imageview and add it as a dependency to an execution.
Definition: vulkan.c:1867
AVHWFramesContext::hwctx
void * hwctx
The format-specific data, allocated and freed automatically along with this context.
Definition: hwcontext.h:151
FFVulkanDecodePicture::view
struct FFVulkanDecodePicture::@302 view
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:251
av_bprintf
void av_bprintf(AVBPrint *buf, const char *fmt,...)
Definition: bprint.c:99
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:1410
FFVkExecContext::buf
VkCommandBuffer buf
Definition: vulkan.h:122
AVCodecContext
main external API structure.
Definition: avcodec.h:431
ff_ffv1_vk_init_state_transition_data
int ff_ffv1_vk_init_state_transition_data(FFVulkanContext *s, FFVkBuffer *vkb, FFV1Context *f)
Definition: ffv1_vulkan.c:65
FFv1VkParameters::img_size
uint32_t img_size[2]
Definition: vulkan_ffv1.c:80
ff_vk_dec_ffv1_desc
const FFVulkanDecodeDescriptor ff_vk_dec_ffv1_desc
Definition: vulkan_ffv1.c:37
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
FFv1VkParameters::rct_offset
int rct_offset
Definition: vulkan_ffv1.c:85
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
FFv1VulkanDecodePicture::slice_offset
uint32_t * slice_offset
Definition: vulkan_ffv1.c:52
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:110
FFv1VulkanDecodeContext::decode
FFVulkanShader decode[2][2][2]
Definition: vulkan_ffv1.c:64
FFVulkanDecodePicture::dpb_frame
AVFrame * dpb_frame
Definition: vulkan_decode.h:86
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:91
AVVulkanFramesContext::tiling
VkImageTiling tiling
Controls the tiling of allocated frames.
Definition: hwcontext_vulkan.h:217
FFv1VkResetParameters
Definition: ffv1_vulkan.h:51
FFv1VkParameters::colorspace
uint8_t colorspace
Definition: ffv1enc_vulkan.c:147
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
FFVulkanDecodePicture::slices_buf
AVBufferRef * slices_buf
Definition: vulkan_decode.h:111
mem.h
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
MAX_QUANT_TABLES
#define MAX_QUANT_TABLES
Definition: ffv1.h:47
vulkan_decode.h
FFV1Context
Definition: ffv1.h:122
ff_vk_count_images
static int ff_vk_count_images(AVVkFrame *f)
Definition: vulkan.h:321
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:458
FFv1VulkanDecodeContext::setup
FFVulkanShader setup
Definition: vulkan_ffv1.c:62
FFVkBuffer
Definition: vulkan.h:87
ff_vk_exec_submit
int ff_vk_exec_submit(FFVulkanContext *s, FFVkExecContext *e)
Definition: vulkan.c:866
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:1181
FFv1VkParameters
Definition: ffv1enc_vulkan.c:125
AVCodecContext::sw_pix_fmt
enum AVPixelFormat sw_pix_fmt
Nominal unaccelerated pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:638
FFv1VulkanDecodePicture::slice_offset_buf
AVBufferRef * slice_offset_buf
Definition: vulkan_ffv1.c:51
FFv1VulkanDecodePicture::crc_checked
int crc_checked
Definition: vulkan_ffv1.c:56
av_hwframe_get_buffer
int av_hwframe_get_buffer(AVBufferRef *hwframe_ref, AVFrame *frame, int flags)
Allocate a new frame attached to the given AVHWFramesContext.
Definition: hwcontext.c:502
FFv1VkParameters::check_crc
uint8_t check_crc
Definition: vulkan_ffv1.c:101
FFVulkanFunctions
Definition: vulkan_functions.h:267
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:1206
ff_source_common_comp
const char * ff_source_common_comp
vk_ffv1_start_frame
static int vk_ffv1_start_frame(AVCodecContext *avctx, const AVBufferRef *buffer_ref, av_unused const uint8_t *buffer, av_unused uint32_t size)
Definition: vulkan_ffv1.c:140
vk_decode_ffv1_init
static int vk_decode_ffv1_init(AVCodecContext *avctx)
Definition: vulkan_ffv1.c:984
av_get_pix_fmt_name
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
Definition: pixdesc.c:3261
FFv1VkParameters::ec
uint8_t ec
Definition: ffv1enc_vulkan.c:149
FFv1VulkanDecodePicture::slice_num
int slice_num
Definition: vulkan_ffv1.c:53