FFmpeg
vulkan_av1.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #include "av1dec.h"
20 
21 #include "vulkan_decode.h"
22 
23 /* Maximum number of tiles specified by any defined level */
24 #define MAX_TILES 256
25 
28  .decode_extension = FF_VK_EXT_VIDEO_DECODE_AV1,
29  .decode_op = VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR,
30  .ext_props = {
31  .extensionName = VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_EXTENSION_NAME,
32  .specVersion = VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_SPEC_VERSION,
33  },
34 };
35 
36 typedef struct AV1VulkanDecodePicture {
38 
39  /* TODO: investigate if this can be removed to make decoding completely
40  * independent. */
42 
43  uint32_t tile_sizes[MAX_TILES];
44 
45  /* Current picture */
46  StdVideoDecodeAV1ReferenceInfo std_ref;
47  VkVideoDecodeAV1DpbSlotInfoKHR vkav1_ref;
48  uint16_t width_in_sbs_minus1[64];
49  uint16_t height_in_sbs_minus1[64];
50  uint16_t mi_col_starts[64];
51  uint16_t mi_row_starts[64];
52  StdVideoAV1TileInfo tile_info;
53  StdVideoAV1Quantization quantization;
54  StdVideoAV1Segmentation segmentation;
55  StdVideoAV1LoopFilter loop_filter;
56  StdVideoAV1CDEF cdef;
57  StdVideoAV1LoopRestoration loop_restoration;
58  StdVideoAV1GlobalMotion global_motion;
59  StdVideoAV1FilmGrain film_grain;
60  StdVideoDecodeAV1PictureInfo std_pic_info;
61  VkVideoDecodeAV1PictureInfoKHR av1_pic_info;
62 
63  /* Picture refs */
65  StdVideoDecodeAV1ReferenceInfo std_refs [AV1_NUM_REF_FRAMES];
66  VkVideoDecodeAV1DpbSlotInfoKHR vkav1_refs[AV1_NUM_REF_FRAMES];
67 
68  uint8_t frame_id_set;
69  uint8_t frame_id;
72 
73 static int vk_av1_fill_pict(AVCodecContext *avctx, const AV1Frame **ref_src,
74  VkVideoReferenceSlotInfoKHR *ref_slot, /* Main structure */
75  VkVideoPictureResourceInfoKHR *ref, /* Goes in ^ */
76  StdVideoDecodeAV1ReferenceInfo *vkav1_std_ref,
77  VkVideoDecodeAV1DpbSlotInfoKHR *vkav1_ref, /* Goes in ^ */
78  const AV1Frame *pic, int is_current, int has_grain,
79  const uint8_t *saved_order_hints)
80 {
83  FFVulkanDecodePicture *vkpic = &hp->vp;
84 
85  int err = ff_vk_decode_prepare_frame(dec, pic->f, vkpic, is_current,
86  has_grain || dec->dedicated_dpb);
87  if (err < 0)
88  return err;
89 
90  *vkav1_std_ref = (StdVideoDecodeAV1ReferenceInfo) {
91  .flags = (StdVideoDecodeAV1ReferenceInfoFlags) {
92  .disable_frame_end_update_cdf = pic->raw_frame_header->disable_frame_end_update_cdf,
93  .segmentation_enabled = pic->raw_frame_header->segmentation_enabled,
94  },
95  .frame_type = pic->raw_frame_header->frame_type,
96  .OrderHint = pic->raw_frame_header->order_hint,
97  .RefFrameSignBias = hp->ref_frame_sign_bias_mask,
98  };
99 
100  if (saved_order_hints) {
101  if (dec->quirk_av1_offset)
102  for (int i = 1; i < STD_VIDEO_AV1_TOTAL_REFS_PER_FRAME; i++)
103  vkav1_std_ref->SavedOrderHints[i - 1] = saved_order_hints[i];
104  else
105  for (int i = 0; i < STD_VIDEO_AV1_TOTAL_REFS_PER_FRAME; i++)
106  vkav1_std_ref->SavedOrderHints[i] = saved_order_hints[i];
107  }
108 
109  *vkav1_ref = (VkVideoDecodeAV1DpbSlotInfoKHR) {
110  .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_DPB_SLOT_INFO_KHR,
111  .pStdReferenceInfo = vkav1_std_ref,
112  };
113 
114  vkav1_std_ref->flags.disable_frame_end_update_cdf = pic->raw_frame_header->disable_frame_end_update_cdf;
115  vkav1_std_ref->flags.segmentation_enabled = pic->raw_frame_header->segmentation_enabled;
116  vkav1_std_ref->frame_type = pic->raw_frame_header->frame_type;
117 
118  *ref = (VkVideoPictureResourceInfoKHR) {
119  .sType = VK_STRUCTURE_TYPE_VIDEO_PICTURE_RESOURCE_INFO_KHR,
120  .codedOffset = (VkOffset2D){ 0, 0 },
121  .codedExtent = (VkExtent2D){ pic->f->width, pic->f->height },
122  .baseArrayLayer = ((has_grain || dec->dedicated_dpb) && dec->layered_dpb) ?
123  hp->frame_id : 0,
124  .imageViewBinding = vkpic->img_view_ref,
125  };
126 
127  *ref_slot = (VkVideoReferenceSlotInfoKHR) {
128  .sType = VK_STRUCTURE_TYPE_VIDEO_REFERENCE_SLOT_INFO_KHR,
129  .pNext = vkav1_ref,
130  .slotIndex = hp->frame_id,
131  .pPictureResource = ref,
132  };
133 
134  if (ref_src)
135  *ref_src = pic;
136 
137  return 0;
138 }
139 
141 {
142  const AV1DecContext *s = avctx->priv_data;
145 
146  const AV1RawSequenceHeader *seq = s->raw_seq;
147 
148  StdVideoAV1SequenceHeader av1_sequence_header;
149  StdVideoAV1TimingInfo av1_timing_info;
150  StdVideoAV1ColorConfig av1_color_config;
151  VkVideoDecodeAV1SessionParametersCreateInfoKHR av1_params;
152  VkVideoSessionParametersCreateInfoKHR session_params_create;
153 
154  int err;
155 
156  av1_timing_info = (StdVideoAV1TimingInfo) {
157  .flags = (StdVideoAV1TimingInfoFlags) {
158  .equal_picture_interval = seq->timing_info.equal_picture_interval,
159  },
160  .num_units_in_display_tick = seq->timing_info.num_units_in_display_tick,
161  .time_scale = seq->timing_info.time_scale,
162  .num_ticks_per_picture_minus_1 = seq->timing_info.num_ticks_per_picture_minus_1,
163  };
164 
165  av1_color_config = (StdVideoAV1ColorConfig) {
166  .flags = (StdVideoAV1ColorConfigFlags) {
167  .mono_chrome = seq->color_config.mono_chrome,
168  .color_range = seq->color_config.color_range,
169  .separate_uv_delta_q = seq->color_config.separate_uv_delta_q,
170  },
171  .BitDepth = seq->color_config.twelve_bit ? 12 :
172  seq->color_config.high_bitdepth ? 10 : 8,
173  .subsampling_x = seq->color_config.subsampling_x,
174  .subsampling_y = seq->color_config.subsampling_y,
175  .color_primaries = seq->color_config.color_primaries,
176  .transfer_characteristics = seq->color_config.transfer_characteristics,
177  .matrix_coefficients = seq->color_config.matrix_coefficients,
178  };
179 
180  av1_sequence_header = (StdVideoAV1SequenceHeader) {
181  .flags = (StdVideoAV1SequenceHeaderFlags) {
182  .still_picture = seq->still_picture,
183  .reduced_still_picture_header = seq->reduced_still_picture_header,
184  .use_128x128_superblock = seq->use_128x128_superblock,
185  .enable_filter_intra = seq->enable_filter_intra,
186  .enable_intra_edge_filter = seq->enable_intra_edge_filter,
187  .enable_interintra_compound = seq->enable_interintra_compound,
188  .enable_masked_compound = seq->enable_masked_compound,
189  .enable_warped_motion = seq->enable_warped_motion,
190  .enable_dual_filter = seq->enable_dual_filter,
191  .enable_order_hint = seq->enable_order_hint,
192  .enable_jnt_comp = seq->enable_jnt_comp,
193  .enable_ref_frame_mvs = seq->enable_ref_frame_mvs,
194  .frame_id_numbers_present_flag = seq->frame_id_numbers_present_flag,
195  .enable_superres = seq->enable_superres,
196  .enable_cdef = seq->enable_cdef,
197  .enable_restoration = seq->enable_restoration,
198  .film_grain_params_present = seq->film_grain_params_present,
199  .timing_info_present_flag = seq->timing_info_present_flag,
200  .initial_display_delay_present_flag = seq->initial_display_delay_present_flag,
201  },
202  .seq_profile = seq->seq_profile,
203  .frame_width_bits_minus_1 = seq->frame_width_bits_minus_1,
204  .frame_height_bits_minus_1 = seq->frame_height_bits_minus_1,
205  .max_frame_width_minus_1 = seq->max_frame_width_minus_1,
206  .max_frame_height_minus_1 = seq->max_frame_height_minus_1,
207  .delta_frame_id_length_minus_2 = seq->delta_frame_id_length_minus_2,
208  .additional_frame_id_length_minus_1 = seq->additional_frame_id_length_minus_1,
209  .order_hint_bits_minus_1 = seq->order_hint_bits_minus_1,
210  .seq_force_integer_mv = seq->seq_force_integer_mv,
211  .seq_force_screen_content_tools = seq->seq_force_screen_content_tools,
212  .pTimingInfo = &av1_timing_info,
213  .pColorConfig = &av1_color_config,
214  };
215 
216  av1_params = (VkVideoDecodeAV1SessionParametersCreateInfoKHR) {
217  .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_SESSION_PARAMETERS_CREATE_INFO_KHR,
218  .pStdSequenceHeader = &av1_sequence_header,
219  };
220  session_params_create = (VkVideoSessionParametersCreateInfoKHR) {
221  .sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR,
222  .pNext = &av1_params,
223  .videoSession = ctx->common.session,
224  .videoSessionParametersTemplate = VK_NULL_HANDLE,
225  };
226 
227  err = ff_vk_decode_create_params(buf, avctx, ctx, &session_params_create);
228  if (err < 0)
229  return err;
230 
231  av_log(avctx, AV_LOG_DEBUG, "Created frame parameters\n");
232 
233  return 0;
234 }
235 
237  av_unused const uint8_t *buffer,
238  av_unused uint32_t size)
239 {
240  int err;
241  int ref_count = 0;
242  AV1DecContext *s = avctx->priv_data;
243  const AV1Frame *pic = &s->cur_frame;
246  FFVulkanDecodePicture *vp = &ap->vp;
247 
248  const AV1RawFrameHeader *frame_header = s->raw_frame_header;
249  const AV1RawFilmGrainParams *film_grain = &s->cur_frame.film_grain;
250 
251  const int apply_grain = !(avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN) &&
252  film_grain->apply_grain;
253  StdVideoAV1FrameRestorationType remap_lr_type[4] = { STD_VIDEO_AV1_FRAME_RESTORATION_TYPE_NONE,
254  STD_VIDEO_AV1_FRAME_RESTORATION_TYPE_SWITCHABLE,
255  STD_VIDEO_AV1_FRAME_RESTORATION_TYPE_WIENER,
256  STD_VIDEO_AV1_FRAME_RESTORATION_TYPE_SGRPROJ };
257 
258  if (!dec->session_params) {
259  err = vk_av1_create_params(avctx, &dec->session_params);
260  if (err < 0)
261  return err;
262  }
263 
264  if (!ap->frame_id_set) {
265  unsigned slot_idx = 0;
266  for (unsigned i = 0; i < 32; i++) {
267  if (!(dec->frame_id_alloc_mask & (1 << i))) {
268  slot_idx = i;
269  break;
270  }
271  }
272  ap->frame_id = slot_idx;
273  ap->frame_id_set = 1;
274  dec->frame_id_alloc_mask |= (1 << slot_idx);
275  }
276 
277  ap->ref_frame_sign_bias_mask = 0x0;
278  for (int i = 0; i < STD_VIDEO_AV1_TOTAL_REFS_PER_FRAME; i++)
279  ap->ref_frame_sign_bias_mask |= pic->ref_frame_sign_bias[i] << i;
280 
281  for (int i = 0; i < STD_VIDEO_AV1_REFS_PER_FRAME; i++) {
282  const int idx = pic->raw_frame_header->ref_frame_idx[i];
283  const AV1Frame *ref_frame = &s->ref[idx];
284  AV1VulkanDecodePicture *hp = ref_frame->hwaccel_picture_private;
285  int found = 0;
286 
287  if (!ref_frame->f)
288  continue;
289 
290  for (int j = 0; j < ref_count; j++) {
291  if (vp->ref_slots[j].slotIndex == hp->frame_id) {
292  found = 1;
293  break;
294  }
295  }
296  if (found)
297  continue;
298 
299  err = vk_av1_fill_pict(avctx, &ap->ref_src[ref_count], &vp->ref_slots[ref_count],
300  &vp->refs[ref_count], &ap->std_refs[ref_count], &ap->vkav1_refs[ref_count],
301  ref_frame, 0, 0, ref_frame->order_hints);
302  if (err < 0)
303  return err;
304 
305  ref_count++;
306  }
307 
308  err = vk_av1_fill_pict(avctx, NULL, &vp->ref_slot, &vp->ref,
309  &ap->std_ref,
310  &ap->vkav1_ref,
311  pic, 1, apply_grain, NULL);
312  if (err < 0)
313  return err;
314 
315  ap->av1_pic_info = (VkVideoDecodeAV1PictureInfoKHR) {
316  .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_PICTURE_INFO_KHR,
317  .pStdPictureInfo = &ap->std_pic_info,
318  .frameHeaderOffset = 0,
319  .tileCount = 0,
320  .pTileOffsets = NULL,
321  .pTileSizes = ap->tile_sizes,
322  };
323 
324  for (int i = 0; i < STD_VIDEO_AV1_REFS_PER_FRAME; i++) {
325  const int idx = pic->raw_frame_header->ref_frame_idx[i];
326  const AV1Frame *ref_frame = &s->ref[idx];
327  AV1VulkanDecodePicture *hp = ref_frame->hwaccel_picture_private;
328 
329  if (!ref_frame->f)
330  ap->av1_pic_info.referenceNameSlotIndices[i] = AV1_REF_FRAME_NONE;
331  else
332  ap->av1_pic_info.referenceNameSlotIndices[i] = hp->frame_id;
333  }
334 
335  vp->decode_info = (VkVideoDecodeInfoKHR) {
336  .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_INFO_KHR,
337  .pNext = &ap->av1_pic_info,
338  .flags = 0x0,
339  .pSetupReferenceSlot = &vp->ref_slot,
340  .referenceSlotCount = ref_count,
341  .pReferenceSlots = vp->ref_slots,
342  .dstPictureResource = (VkVideoPictureResourceInfoKHR) {
343  .sType = VK_STRUCTURE_TYPE_VIDEO_PICTURE_RESOURCE_INFO_KHR,
344  .codedOffset = (VkOffset2D){ 0, 0 },
345  .codedExtent = (VkExtent2D){ pic->f->width, pic->f->height },
346  .baseArrayLayer = 0,
347  .imageViewBinding = vp->img_view_out,
348  },
349  };
350 
351  ap->tile_info = (StdVideoAV1TileInfo) {
352  .flags = (StdVideoAV1TileInfoFlags) {
353  .uniform_tile_spacing_flag = frame_header->uniform_tile_spacing_flag,
354  },
355  .TileCols = frame_header->tile_cols,
356  .TileRows = frame_header->tile_rows,
357  .context_update_tile_id = frame_header->context_update_tile_id,
358  .tile_size_bytes_minus_1 = frame_header->tile_size_bytes_minus1,
359  .pWidthInSbsMinus1 = ap->width_in_sbs_minus1,
360  .pHeightInSbsMinus1 = ap->height_in_sbs_minus1,
361  .pMiColStarts = ap->mi_col_starts,
362  .pMiRowStarts = ap->mi_row_starts,
363  };
364 
365  ap->quantization = (StdVideoAV1Quantization) {
366  .flags.using_qmatrix = frame_header->using_qmatrix,
367  .flags.diff_uv_delta = frame_header->diff_uv_delta,
368  .base_q_idx = frame_header->base_q_idx,
369  .DeltaQYDc = frame_header->delta_q_y_dc,
370  .DeltaQUDc = frame_header->delta_q_u_dc,
371  .DeltaQUAc = frame_header->delta_q_u_ac,
372  .DeltaQVDc = frame_header->delta_q_v_dc,
373  .DeltaQVAc = frame_header->delta_q_v_ac,
374  .qm_y = frame_header->qm_y,
375  .qm_u = frame_header->qm_u,
376  .qm_v = frame_header->qm_v,
377  };
378 
379  ap->loop_filter = (StdVideoAV1LoopFilter) {
380  .flags = (StdVideoAV1LoopFilterFlags) {
381  .loop_filter_delta_enabled = frame_header->loop_filter_delta_enabled,
382  .loop_filter_delta_update = frame_header->loop_filter_delta_update,
383  },
384  .loop_filter_sharpness = frame_header->loop_filter_sharpness,
385  };
386 
387  for (int i = 0; i < STD_VIDEO_AV1_MAX_LOOP_FILTER_STRENGTHS; i++)
388  ap->loop_filter.loop_filter_level[i] = frame_header->loop_filter_level[i];
389  for (int i = 0; i < STD_VIDEO_AV1_LOOP_FILTER_ADJUSTMENTS; i++)
390  ap->loop_filter.loop_filter_mode_deltas[i] = frame_header->loop_filter_mode_deltas[i];
391 
392  ap->cdef = (StdVideoAV1CDEF) {
393  .cdef_damping_minus_3 = frame_header->cdef_damping_minus_3,
394  .cdef_bits = frame_header->cdef_bits,
395  };
396 
397  ap->loop_restoration = (StdVideoAV1LoopRestoration) {
398  .FrameRestorationType[0] = remap_lr_type[frame_header->lr_type[0]],
399  .FrameRestorationType[1] = remap_lr_type[frame_header->lr_type[1]],
400  .FrameRestorationType[2] = remap_lr_type[frame_header->lr_type[2]],
401  .LoopRestorationSize[0] = 1 + frame_header->lr_unit_shift,
402  .LoopRestorationSize[1] = 1 + frame_header->lr_unit_shift - frame_header->lr_uv_shift,
403  .LoopRestorationSize[2] = 1 + frame_header->lr_unit_shift - frame_header->lr_uv_shift,
404  };
405 
406  ap->film_grain = (StdVideoAV1FilmGrain) {
407  .flags = (StdVideoAV1FilmGrainFlags) {
408  .chroma_scaling_from_luma = film_grain->chroma_scaling_from_luma,
409  .overlap_flag = film_grain->overlap_flag,
410  .clip_to_restricted_range = film_grain->clip_to_restricted_range,
411  },
412  .grain_scaling_minus_8 = film_grain->grain_scaling_minus_8,
413  .ar_coeff_lag = film_grain->ar_coeff_lag,
414  .ar_coeff_shift_minus_6 = film_grain->ar_coeff_shift_minus_6,
415  .grain_scale_shift = film_grain->grain_scale_shift,
416  .grain_seed = film_grain->grain_seed,
417  .film_grain_params_ref_idx = film_grain->film_grain_params_ref_idx,
418  .num_y_points = film_grain->num_y_points,
419  .num_cb_points = film_grain->num_cb_points,
420  .num_cr_points = film_grain->num_cr_points,
421  .cb_mult = film_grain->cb_mult,
422  .cb_luma_mult = film_grain->cb_luma_mult,
423  .cb_offset = film_grain->cb_offset,
424  .cr_mult = film_grain->cr_mult,
425  .cr_luma_mult = film_grain->cr_luma_mult,
426  .cr_offset = film_grain->cr_offset,
427  };
428 
429  /* Setup frame header */
430  ap->std_pic_info = (StdVideoDecodeAV1PictureInfo) {
431  .flags = (StdVideoDecodeAV1PictureInfoFlags) {
432  .error_resilient_mode = frame_header->error_resilient_mode,
433  .disable_cdf_update = frame_header->disable_cdf_update,
434  .use_superres = frame_header->use_superres,
435  .render_and_frame_size_different = frame_header->render_and_frame_size_different,
436  .allow_screen_content_tools = frame_header->allow_screen_content_tools,
437  .is_filter_switchable = frame_header->is_filter_switchable,
438  .force_integer_mv = pic->force_integer_mv,
439  .frame_size_override_flag = frame_header->frame_size_override_flag,
440  .buffer_removal_time_present_flag = frame_header->buffer_removal_time_present_flag,
441  .allow_intrabc = frame_header->allow_intrabc,
442  .frame_refs_short_signaling = frame_header->frame_refs_short_signaling,
443  .allow_high_precision_mv = frame_header->allow_high_precision_mv,
444  .is_motion_mode_switchable = frame_header->is_motion_mode_switchable,
445  .use_ref_frame_mvs = frame_header->use_ref_frame_mvs,
446  .disable_frame_end_update_cdf = frame_header->disable_frame_end_update_cdf,
447  .allow_warped_motion = frame_header->allow_warped_motion,
448  .reduced_tx_set = frame_header->reduced_tx_set,
449  .reference_select = frame_header->reference_select,
450  .skip_mode_present = frame_header->skip_mode_present,
451  .delta_q_present = frame_header->delta_q_present,
452  .delta_lf_present = frame_header->delta_lf_present,
453  .delta_lf_multi = frame_header->delta_lf_multi,
454  .segmentation_enabled = frame_header->segmentation_enabled,
455  .segmentation_update_map = frame_header->segmentation_update_map,
456  .segmentation_temporal_update = frame_header->segmentation_temporal_update,
457  .segmentation_update_data = frame_header->segmentation_update_data,
458  .UsesLr = frame_header->lr_type[0] || frame_header->lr_type[1] || frame_header->lr_type[2],
459  .apply_grain = apply_grain,
460  },
461  .frame_type = frame_header->frame_type,
462  .current_frame_id = frame_header->current_frame_id,
463  .OrderHint = frame_header->order_hint,
464  .primary_ref_frame = frame_header->primary_ref_frame,
465  .refresh_frame_flags = frame_header->refresh_frame_flags,
466  .interpolation_filter = frame_header->interpolation_filter,
467  .TxMode = frame_header->tx_mode,
468  .delta_q_res = frame_header->delta_q_res,
469  .delta_lf_res = frame_header->delta_lf_res,
470  .SkipModeFrame[0] = s->cur_frame.skip_mode_frame_idx[0],
471  .SkipModeFrame[1] = s->cur_frame.skip_mode_frame_idx[1],
472  .coded_denom = frame_header->coded_denom,
473  .pTileInfo = &ap->tile_info,
474  .pQuantization = &ap->quantization,
475  .pSegmentation = &ap->segmentation,
476  .pLoopFilter = &ap->loop_filter,
477  .pCDEF = &ap->cdef,
478  .pLoopRestoration = &ap->loop_restoration,
479  .pGlobalMotion = &ap->global_motion,
480  .pFilmGrain = apply_grain ? &ap->film_grain : NULL,
481  };
482 
483  for (int i = 0; i < 64; i++) {
484  ap->width_in_sbs_minus1[i] = frame_header->width_in_sbs_minus_1[i];
485  ap->height_in_sbs_minus1[i] = frame_header->height_in_sbs_minus_1[i];
486  ap->mi_col_starts[i] = frame_header->tile_start_col_sb[i];
487  ap->mi_row_starts[i] = frame_header->tile_start_row_sb[i];
488  }
489 
490  for (int i = 0; i < STD_VIDEO_AV1_MAX_SEGMENTS; i++) {
491  ap->segmentation.FeatureEnabled[i] = 0x0;
492  for (int j = 0; j < STD_VIDEO_AV1_SEG_LVL_MAX; j++) {
493  ap->segmentation.FeatureEnabled[i] |= (frame_header->feature_enabled[i][j] << j);
494  ap->segmentation.FeatureData[i][j] = frame_header->feature_value[i][j];
495  }
496  }
497 
498  if (dec->quirk_av1_offset)
499  for (int i = 1; i < STD_VIDEO_AV1_TOTAL_REFS_PER_FRAME; i++)
500  ap->std_pic_info.OrderHints[i - 1] = pic->order_hints[i];
501  else
502  for (int i = 0; i < STD_VIDEO_AV1_TOTAL_REFS_PER_FRAME; i++)
503  ap->std_pic_info.OrderHints[i] = pic->order_hints[i];
504 
505  for (int i = 0; i < STD_VIDEO_AV1_TOTAL_REFS_PER_FRAME; i++) {
506  ap->loop_filter.loop_filter_ref_deltas[i] = frame_header->loop_filter_ref_deltas[i];
507  ap->global_motion.GmType[i] = s->cur_frame.gm_type[i];
508  for (int j = 0; j < STD_VIDEO_AV1_GLOBAL_MOTION_PARAMS; j++) {
509  ap->global_motion.gm_params[i][j] = s->cur_frame.gm_params[i][j];
510  }
511  }
512 
513  for (int i = 0; i < STD_VIDEO_AV1_MAX_CDEF_FILTER_STRENGTHS; i++) {
514  ap->cdef.cdef_y_pri_strength[i] = frame_header->cdef_y_pri_strength[i];
515  ap->cdef.cdef_y_sec_strength[i] = frame_header->cdef_y_sec_strength[i];
516  ap->cdef.cdef_uv_pri_strength[i] = frame_header->cdef_uv_pri_strength[i];
517  ap->cdef.cdef_uv_sec_strength[i] = frame_header->cdef_uv_sec_strength[i];
518  }
519 
520  if (apply_grain) {
521  for (int i = 0; i < STD_VIDEO_AV1_MAX_NUM_Y_POINTS; i++) {
522  ap->film_grain.point_y_value[i] = film_grain->point_y_value[i];
523  ap->film_grain.point_y_scaling[i] = film_grain->point_y_scaling[i];
524  }
525 
526  for (int i = 0; i < STD_VIDEO_AV1_MAX_NUM_CB_POINTS; i++) {
527  ap->film_grain.point_cb_value[i] = film_grain->point_cb_value[i];
528  ap->film_grain.point_cb_scaling[i] = film_grain->point_cb_scaling[i];
529  ap->film_grain.point_cr_value[i] = film_grain->point_cr_value[i];
530  ap->film_grain.point_cr_scaling[i] = film_grain->point_cr_scaling[i];
531  }
532 
533  for (int i = 0; i < STD_VIDEO_AV1_MAX_NUM_POS_LUMA; i++)
534  ap->film_grain.ar_coeffs_y_plus_128[i] = film_grain->ar_coeffs_y_plus_128[i];
535 
536  for (int i = 0; i < STD_VIDEO_AV1_MAX_NUM_POS_CHROMA; i++) {
537  ap->film_grain.ar_coeffs_cb_plus_128[i] = film_grain->ar_coeffs_cb_plus_128[i];
538  ap->film_grain.ar_coeffs_cr_plus_128[i] = film_grain->ar_coeffs_cr_plus_128[i];
539  }
540  }
541 
542  ap->dec = dec;
543 
544  return 0;
545 }
546 
548  const uint8_t *data,
549  uint32_t size)
550 {
551  int err;
552  const AV1DecContext *s = avctx->priv_data;
553  AV1VulkanDecodePicture *ap = s->cur_frame.hwaccel_picture_private;
554  FFVulkanDecodePicture *vp = &ap->vp;
555 
556  /* Too many tiles, exceeding all defined levels in the AV1 spec */
557  if (ap->av1_pic_info.tileCount > MAX_TILES)
558  return AVERROR(ENOSYS);
559 
560  for (int i = s->tg_start; i <= s->tg_end; i++) {
561  ap->tile_sizes[ap->av1_pic_info.tileCount] = s->tile_group_info[i].tile_size;
562 
563  err = ff_vk_decode_add_slice(avctx, vp,
564  data + s->tile_group_info[i].tile_offset,
565  s->tile_group_info[i].tile_size, 0,
566  &ap->av1_pic_info.tileCount,
567  &ap->av1_pic_info.pTileOffsets);
568  if (err < 0)
569  return err;
570  }
571 
572  return 0;
573 }
574 
576 {
577  const AV1DecContext *s = avctx->priv_data;
579  const AV1Frame *pic = &s->cur_frame;
581  FFVulkanDecodePicture *vp = &ap->vp;
583  AVFrame *rav[AV1_NUM_REF_FRAMES] = { 0 };
584 
585  if (!ap->av1_pic_info.tileCount)
586  return 0;
587 
588  if (!dec->session_params) {
589  int err = vk_av1_create_params(avctx, &dec->session_params);
590  if (err < 0)
591  return err;
592  }
593 
594  for (int i = 0; i < vp->decode_info.referenceSlotCount; i++) {
595  const AV1Frame *rp = ap->ref_src[i];
597 
598  rvp[i] = &rhp->vp;
599  rav[i] = ap->ref_src[i]->f;
600  }
601 
602  av_log(avctx, AV_LOG_VERBOSE, "Decoding frame, %"SIZE_SPECIFIER" bytes, %i tiles\n",
603  vp->slices_size, ap->av1_pic_info.tileCount);
604 
605  return ff_vk_decode_frame(avctx, pic->f, vp, rav, rvp);
606 }
607 
609 {
610  AVHWDeviceContext *hwctx = _hwctx.nc;
612 
613  /* Workaround for a spec issue. */
614  if (ap->frame_id_set)
615  ap->dec->frame_id_alloc_mask &= ~(1 << ap->frame_id);
616 
617  /* Free frame resources, this also destroys the session parameters. */
618  ff_vk_decode_free_frame(hwctx, &ap->vp);
619 }
620 
622  .p.name = "av1_vulkan",
623  .p.type = AVMEDIA_TYPE_VIDEO,
624  .p.id = AV_CODEC_ID_AV1,
625  .p.pix_fmt = AV_PIX_FMT_VULKAN,
626  .start_frame = &vk_av1_start_frame,
627  .decode_slice = &vk_av1_decode_slice,
628  .end_frame = &vk_av1_end_frame,
629  .free_frame_priv = &vk_av1_free_frame_priv,
630  .frame_priv_data_size = sizeof(AV1VulkanDecodePicture),
633  .decode_params = &ff_vk_params_invalidate,
636  .frame_params = &ff_vk_frame_params,
637  .priv_data_size = sizeof(FFVulkanDecodeContext),
638 
639  /* NOTE: Threading is intentionally disabled here. Due to the design of Vulkan,
640  * where frames are opaque to users, and mostly opaque for driver developers,
641  * there's an issue with current hardware accelerator implementations of AV1,
642  * where they require an internal index. With regular hwaccel APIs, this index
643  * is given to users as an opaque handle directly. With Vulkan, due to increased
644  * flexibility, this index cannot be present anywhere.
645  * The current implementation tracks the index for the driver and submits it
646  * as necessary information. Due to needing to modify the decoding context,
647  * which is not thread-safe, on frame free, threading is disabled. */
648  .caps_internal = HWACCEL_CAP_ASYNC_SAFE,
649 };
ff_av1_vulkan_hwaccel
const FFHWAccel ff_av1_vulkan_hwaccel
Definition: vulkan_av1.c:621
AV1RawTimingInfo::num_units_in_display_tick
uint32_t num_units_in_display_tick
Definition: cbs_av1.h:59
AV1RawTimingInfo::time_scale
uint32_t time_scale
Definition: cbs_av1.h:60
AV1RawSequenceHeader::seq_force_integer_mv
uint8_t seq_force_integer_mv
Definition: cbs_av1.h:120
FFVulkanDecodePicture::slices_size
size_t slices_size
Definition: vulkan_decode.h:112
AV1RawColorConfig::color_primaries
uint8_t color_primaries
Definition: cbs_av1.h:47
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
AV1RawSequenceHeader::timing_info_present_flag
uint8_t timing_info_present_flag
Definition: cbs_av1.h:78
AV1RawSequenceHeader
Definition: cbs_av1.h:73
AV1RawColorConfig::color_range
uint8_t color_range
Definition: cbs_av1.h:51
FFVulkanDecodeContext::shared_ctx
FFVulkanDecodeShared * shared_ctx
Definition: vulkan_decode.h:66
MAX_TILES
#define MAX_TILES
Definition: vulkan_av1.c:24
AV1RawFilmGrainParams::apply_grain
uint8_t apply_grain
Definition: cbs_av1.h:134
AV1VulkanDecodePicture::cdef
StdVideoAV1CDEF cdef
Definition: vulkan_av1.c:56
av_unused
#define av_unused
Definition: attributes.h:131
FFHWAccel::p
AVHWAccel p
The public AVHWAccel.
Definition: hwaccel_internal.h:38
AV1VulkanDecodePicture::height_in_sbs_minus1
uint16_t height_in_sbs_minus1[64]
Definition: vulkan_av1.c:49
FF_VK_EXT_VIDEO_DECODE_AV1
@ FF_VK_EXT_VIDEO_DECODE_AV1
Definition: vulkan_functions.h:46
AV1VulkanDecodePicture::loop_filter
StdVideoAV1LoopFilter loop_filter
Definition: vulkan_av1.c:55
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:374
AVFrame::width
int width
Definition: frame.h:446
ff_vk_dec_av1_desc
const FFVulkanDecodeDescriptor ff_vk_dec_av1_desc
Definition: vulkan_av1.c:26
AV1Frame::raw_frame_header
AV1RawFrameHeader * raw_frame_header
Definition: av1dec.h:48
data
const char data[16]
Definition: mxf.c:148
AV1RawFrameHeader::disable_frame_end_update_cdf
uint8_t disable_frame_end_update_cdf
Definition: cbs_av1.h:213
FFVulkanDecodeDescriptor::codec_id
enum AVCodecID codec_id
Definition: vulkan_decode.h:30
AV1RawSequenceHeader::timing_info
AV1RawTimingInfo timing_info
Definition: cbs_av1.h:83
FFVulkanDecodeContext::frame_id_alloc_mask
uint32_t frame_id_alloc_mask
Definition: vulkan_decode.h:73
vk_av1_start_frame
static int vk_av1_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
Definition: vulkan_av1.c:236
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
AV1RawSequenceHeader::frame_id_numbers_present_flag
uint8_t frame_id_numbers_present_flag
Definition: cbs_av1.h:101
FFRefStructOpaque
RefStruct is an API for creating reference-counted objects with minimal overhead.
Definition: refstruct.h:58
vk_av1_create_params
static int vk_av1_create_params(AVCodecContext *avctx, AVBufferRef **buf)
Definition: vulkan_av1.c:140
AV1VulkanDecodePicture::tile_info
StdVideoAV1TileInfo tile_info
Definition: vulkan_av1.c:52
FFVulkanDecodeContext
Definition: vulkan_decode.h:65
AV_PIX_FMT_VULKAN
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition: pixfmt.h:379
ff_vk_decode_prepare_frame
int ff_vk_decode_prepare_frame(FFVulkanDecodeContext *dec, AVFrame *pic, FFVulkanDecodePicture *vkpic, int is_current, int alloc_dpb)
Prepare a frame, creates the image view, and sets up the dpb fields.
Definition: vulkan_decode.c:187
AV1RawSequenceHeader::seq_profile
uint8_t seq_profile
Definition: cbs_av1.h:74
AV1RawColorConfig::subsampling_y
uint8_t subsampling_y
Definition: cbs_av1.h:53
AV1RawColorConfig::separate_uv_delta_q
uint8_t separate_uv_delta_q
Definition: cbs_av1.h:55
FFVulkanDecodeContext::session_params
AVBufferRef * session_params
Definition: vulkan_decode.h:67
AV1RawSequenceHeader::film_grain_params_present
uint8_t film_grain_params_present
Definition: cbs_av1.h:130
FFHWAccel
Definition: hwaccel_internal.h:34
ref_frame
static int ref_frame(VVCFrame *dst, const VVCFrame *src)
Definition: dec.c:558
AV1RawSequenceHeader::enable_ref_frame_mvs
uint8_t enable_ref_frame_mvs
Definition: cbs_av1.h:115
AV1RawSequenceHeader::enable_filter_intra
uint8_t enable_filter_intra
Definition: cbs_av1.h:106
AV1VulkanDecodePicture::quantization
StdVideoAV1Quantization quantization
Definition: vulkan_av1.c:53
vk_av1_end_frame
static int vk_av1_end_frame(AVCodecContext *avctx)
Definition: vulkan_av1.c:575
AV1RawSequenceHeader::delta_frame_id_length_minus_2
uint8_t delta_frame_id_length_minus_2
Definition: cbs_av1.h:102
ff_vk_decode_frame
int ff_vk_decode_frame(AVCodecContext *avctx, AVFrame *pic, FFVulkanDecodePicture *vp, AVFrame *rpic[], FFVulkanDecodePicture *rvkp[])
Decode a frame.
Definition: vulkan_decode.c:343
FFVulkanDecodeShared
Definition: vulkan_decode.h:46
AVHWDeviceContext
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
Definition: hwcontext.h:60
AV1Frame
Definition: av1dec.h:37
AV1RawSequenceHeader::enable_masked_compound
uint8_t enable_masked_compound
Definition: cbs_av1.h:109
AV1VulkanDecodePicture::std_pic_info
StdVideoDecodeAV1PictureInfo std_pic_info
Definition: vulkan_av1.c:60
s
#define s(width, name)
Definition: cbs_vp9.c:198
FFVulkanDecodePicture
Definition: vulkan_decode.h:87
ff_vk_decode_create_params
int ff_vk_decode_create_params(AVBufferRef **par_ref, void *logctx, FFVulkanDecodeShared *ctx, const VkVideoSessionParametersCreateInfoKHR *session_params_create)
Create VkVideoSessionParametersKHR wrapped in an AVBufferRef.
Definition: vulkan_decode.c:1064
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
ctx
AVFormatContext * ctx
Definition: movenc.c:49
AV1VulkanDecodePicture::std_ref
StdVideoDecodeAV1ReferenceInfo std_ref
Definition: vulkan_av1.c:46
AV1RawColorConfig::transfer_characteristics
uint8_t transfer_characteristics
Definition: cbs_av1.h:48
AV1RawFrameHeader::segmentation_enabled
uint8_t segmentation_enabled
Definition: cbs_av1.h:242
av1dec.h
AV1Frame::f
struct AVFrame * f
Definition: av1dec.h:40
HWACCEL_CAP_ASYNC_SAFE
#define HWACCEL_CAP_ASYNC_SAFE
Header providing the internals of AVHWAccel.
Definition: hwaccel_internal.h:31
FFVulkanDecodePicture::img_view_ref
VkImageView img_view_ref
Definition: vulkan_decode.h:90
NULL
#define NULL
Definition: coverity.c:32
AV1_REF_FRAME_NONE
@ AV1_REF_FRAME_NONE
Definition: av1.h:61
AV_CODEC_ID_AV1
@ AV_CODEC_ID_AV1
Definition: codec_id.h:280
AV1RawFrameHeader
Definition: cbs_av1.h:165
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:573
AVCodecContext::internal
struct AVCodecInternal * internal
Private context used for internal data.
Definition: avcodec.h:480
ff_vk_decode_uninit
int ff_vk_decode_uninit(AVCodecContext *avctx)
Free decoder.
Definition: vulkan_decode.c:1093
flush
void(* flush)(AVBSFContext *ctx)
Definition: dts2pts.c:368
AV1RawSequenceHeader::enable_jnt_comp
uint8_t enable_jnt_comp
Definition: cbs_av1.h:114
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:1007
AV1RawSequenceHeader::seq_force_screen_content_tools
uint8_t seq_force_screen_content_tools
Definition: cbs_av1.h:118
AV1VulkanDecodePicture::ref_frame_sign_bias_mask
uint8_t ref_frame_sign_bias_mask
Definition: vulkan_av1.c:70
AV1RawSequenceHeader::max_frame_height_minus_1
uint16_t max_frame_height_minus_1
Definition: cbs_av1.h:99
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:366
AV1VulkanDecodePicture::loop_restoration
StdVideoAV1LoopRestoration loop_restoration
Definition: vulkan_av1.c:57
AV1RawTimingInfo::num_ticks_per_picture_minus_1
uint32_t num_ticks_per_picture_minus_1
Definition: cbs_av1.h:63
AVCodecInternal::hwaccel_priv_data
void * hwaccel_priv_data
hwaccel-specific private data
Definition: internal.h:123
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
AV1VulkanDecodePicture::mi_col_starts
uint16_t mi_col_starts[64]
Definition: vulkan_av1.c:50
size
int size
Definition: twinvq_data.h:10344
AV1DecContext
Definition: av1dec.h:85
AV1RawSequenceHeader::use_128x128_superblock
uint8_t use_128x128_superblock
Definition: cbs_av1.h:105
AV1RawSequenceHeader::frame_height_bits_minus_1
uint8_t frame_height_bits_minus_1
Definition: cbs_av1.h:97
FFRefStructOpaque::nc
void * nc
Definition: refstruct.h:59
AV1RawSequenceHeader::still_picture
uint8_t still_picture
Definition: cbs_av1.h:75
AV1RawSequenceHeader::initial_display_delay_present_flag
uint8_t initial_display_delay_present_flag
Definition: cbs_av1.h:80
AV1RawSequenceHeader::enable_interintra_compound
uint8_t enable_interintra_compound
Definition: cbs_av1.h:108
AV1RawFrameHeader::order_hint
uint8_t order_hint
Definition: cbs_av1.h:182
AVHWAccel::name
const char * name
Name of the hardware accelerated codec.
Definition: avcodec.h:2095
uninit
static void uninit(AVBSFContext *ctx)
Definition: pcm_rechunk.c:68
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
AV1RawSequenceHeader::enable_dual_filter
uint8_t enable_dual_filter
Definition: cbs_av1.h:111
AV1VulkanDecodePicture::vkav1_refs
VkVideoDecodeAV1DpbSlotInfoKHR vkav1_refs[AV1_NUM_REF_FRAMES]
Definition: vulkan_av1.c:66
AV1RawSequenceHeader::enable_superres
uint8_t enable_superres
Definition: cbs_av1.h:124
AV1Frame::hwaccel_picture_private
void * hwaccel_picture_private
RefStruct reference.
Definition: av1dec.h:45
AV1_NUM_REF_FRAMES
@ AV1_NUM_REF_FRAMES
Definition: av1.h:84
AV1RawTimingInfo::equal_picture_interval
uint8_t equal_picture_interval
Definition: cbs_av1.h:62
AV1RawSequenceHeader::enable_intra_edge_filter
uint8_t enable_intra_edge_filter
Definition: cbs_av1.h:107
AV1RawSequenceHeader::max_frame_width_minus_1
uint16_t max_frame_width_minus_1
Definition: cbs_av1.h:98
AV1VulkanDecodePicture::av1_pic_info
VkVideoDecodeAV1PictureInfoKHR av1_pic_info
Definition: vulkan_av1.c:61
AV1RawSequenceHeader::color_config
AV1RawColorConfig color_config
Definition: cbs_av1.h:128
AV1VulkanDecodePicture::tile_sizes
uint32_t tile_sizes[MAX_TILES]
Definition: vulkan_av1.c:43
AV1VulkanDecodePicture::segmentation
StdVideoAV1Segmentation segmentation
Definition: vulkan_av1.c:54
AV1RawSequenceHeader::enable_order_hint
uint8_t enable_order_hint
Definition: cbs_av1.h:113
AV1VulkanDecodePicture::width_in_sbs_minus1
uint16_t width_in_sbs_minus1[64]
Definition: vulkan_av1.c:48
ff_vk_decode_flush
void ff_vk_decode_flush(AVCodecContext *avctx)
Flush decoder.
Definition: vulkan_decode.c:313
AV1RawColorConfig::subsampling_x
uint8_t subsampling_x
Definition: cbs_av1.h:52
AV1VulkanDecodePicture::global_motion
StdVideoAV1GlobalMotion global_motion
Definition: vulkan_av1.c:58
AV1VulkanDecodePicture::film_grain
StdVideoAV1FilmGrain film_grain
Definition: vulkan_av1.c:59
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
AV1RawColorConfig::high_bitdepth
uint8_t high_bitdepth
Definition: cbs_av1.h:42
AV1VulkanDecodePicture::ref_src
const AV1Frame * ref_src[AV1_NUM_REF_FRAMES]
Definition: vulkan_av1.c:64
SIZE_SPECIFIER
#define SIZE_SPECIFIER
Definition: internal.h:129
AV1VulkanDecodePicture::mi_row_starts
uint16_t mi_row_starts[64]
Definition: vulkan_av1.c:51
AV1RawSequenceHeader::frame_width_bits_minus_1
uint8_t frame_width_bits_minus_1
Definition: cbs_av1.h:96
AV1RawSequenceHeader::enable_warped_motion
uint8_t enable_warped_motion
Definition: cbs_av1.h:110
AVCodecContext
main external API structure.
Definition: avcodec.h:445
AVFrame::height
int height
Definition: frame.h:446
FFVulkanDecodeContext::dedicated_dpb
int dedicated_dpb
Definition: vulkan_decode.h:70
frame_header
Definition: truemotion1.c:88
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
AV1RawColorConfig::mono_chrome
uint8_t mono_chrome
Definition: cbs_av1.h:44
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
ref
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:112
AVCodecContext::export_side_data
int export_side_data
Bit set of AV_CODEC_EXPORT_DATA_* flags, which affects the kind of metadata exported in frame,...
Definition: avcodec.h:1927
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:121
AV1VulkanDecodePicture::vkav1_ref
VkVideoDecodeAV1DpbSlotInfoKHR vkav1_ref
Definition: vulkan_av1.c:47
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:80
AV1RawSequenceHeader::order_hint_bits_minus_1
uint8_t order_hint_bits_minus_1
Definition: cbs_av1.h:122
AV1RawColorConfig::matrix_coefficients
uint8_t matrix_coefficients
Definition: cbs_av1.h:49
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
frame_header::flags
uint8_t flags
Definition: truemotion1.c:98
AV1RawSequenceHeader::enable_restoration
uint8_t enable_restoration
Definition: cbs_av1.h:126
vulkan_decode.h
AV1RawColorConfig::twelve_bit
uint8_t twelve_bit
Definition: cbs_av1.h:43
AV1VulkanDecodePicture::vp
FFVulkanDecodePicture vp
Definition: vulkan_av1.c:37
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:472
FFVulkanDecodeContext::layered_dpb
int layered_dpb
Definition: vulkan_decode.h:71
AV1RawSequenceHeader::additional_frame_id_length_minus_1
uint8_t additional_frame_id_length_minus_1
Definition: cbs_av1.h:103
AV1RawSequenceHeader::enable_cdef
uint8_t enable_cdef
Definition: cbs_av1.h:125
AV1RawSequenceHeader::reduced_still_picture_header
uint8_t reduced_still_picture_header
Definition: cbs_av1.h:76
AV1RawFilmGrainParams
Definition: cbs_av1.h:133
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AV1VulkanDecodePicture::std_refs
StdVideoDecodeAV1ReferenceInfo std_refs[AV1_NUM_REF_FRAMES]
Definition: vulkan_av1.c:65
ff_vk_decode_init
int ff_vk_decode_init(AVCodecContext *avctx)
Initialize decoder.
Definition: vulkan_decode.c:1108
FFVulkanDecodePicture::decode_info
VkVideoDecodeInfoKHR decode_info
Definition: vulkan_decode.h:108
AV1VulkanDecodePicture
Definition: vulkan_av1.c:36
AV1VulkanDecodePicture::frame_id
uint8_t frame_id
Definition: vulkan_av1.c:69
vk_av1_fill_pict
static int vk_av1_fill_pict(AVCodecContext *avctx, const AV1Frame **ref_src, VkVideoReferenceSlotInfoKHR *ref_slot, VkVideoPictureResourceInfoKHR *ref, StdVideoDecodeAV1ReferenceInfo *vkav1_std_ref, VkVideoDecodeAV1DpbSlotInfoKHR *vkav1_ref, const AV1Frame *pic, int is_current, int has_grain, const uint8_t *saved_order_hints)
Definition: vulkan_av1.c:73
AV1VulkanDecodePicture::dec
FFVulkanDecodeContext * dec
Definition: vulkan_av1.c:41
AV1VulkanDecodePicture::frame_id_set
uint8_t frame_id_set
Definition: vulkan_av1.c:68
vk_av1_decode_slice
static int vk_av1_decode_slice(AVCodecContext *avctx, const uint8_t *data, uint32_t size)
Definition: vulkan_av1.c:547
FFVulkanDecodeContext::quirk_av1_offset
int quirk_av1_offset
Definition: vulkan_decode.h:77
AV_CODEC_EXPORT_DATA_FILM_GRAIN
#define AV_CODEC_EXPORT_DATA_FILM_GRAIN
Decoding only.
Definition: avcodec.h:420
vk_av1_free_frame_priv
static void vk_av1_free_frame_priv(FFRefStructOpaque _hwctx, void *data)
Definition: vulkan_av1.c:608
AV1RawFrameHeader::frame_type
uint8_t frame_type
Definition: cbs_av1.h:171