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