FFmpeg
vulkan_hevc.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 "hevcdec.h"
20 #include "hevc_data.h"
21 #include "hevc_ps.h"
22 
23 #include "vulkan_decode.h"
24 
25 const VkExtensionProperties ff_vk_dec_hevc_ext = {
26  .extensionName = VK_STD_VULKAN_VIDEO_CODEC_H265_DECODE_EXTENSION_NAME,
27  .specVersion = VK_STD_VULKAN_VIDEO_CODEC_H265_DECODE_SPEC_VERSION,
28 };
29 
30 typedef struct HEVCHeaderSPS {
31  StdVideoH265ScalingLists scaling;
32  StdVideoH265HrdParameters vui_header;
33  StdVideoH265SequenceParameterSetVui vui;
34  StdVideoH265ProfileTierLevel ptl;
35  StdVideoH265DecPicBufMgr dpbm;
36  StdVideoH265PredictorPaletteEntries pal;
37  StdVideoH265SubLayerHrdParameters nal_hdr[HEVC_MAX_SUB_LAYERS];
38  StdVideoH265SubLayerHrdParameters vcl_hdr[HEVC_MAX_SUB_LAYERS];
39  StdVideoH265ShortTermRefPicSet str[HEVC_MAX_SHORT_TERM_REF_PIC_SETS];
40  StdVideoH265LongTermRefPicsSps ltr;
42 
43 typedef struct HEVCHeaderPPS {
44  StdVideoH265ScalingLists scaling;
45  StdVideoH265PredictorPaletteEntries pal;
47 
48 typedef struct HEVCHeaderVPSSet {
49  StdVideoH265SubLayerHrdParameters nal_hdr[HEVC_MAX_SUB_LAYERS];
50  StdVideoH265SubLayerHrdParameters vcl_hdr[HEVC_MAX_SUB_LAYERS];
52 
53 typedef struct HEVCHeaderVPS {
54  StdVideoH265ProfileTierLevel ptl;
55  StdVideoH265DecPicBufMgr dpbm;
56  StdVideoH265HrdParameters hdr[HEVC_MAX_LAYER_SETS];
59 
60 typedef struct HEVCHeaderSet {
61  StdVideoH265SequenceParameterSet sps[HEVC_MAX_SPS_COUNT];
63 
64  StdVideoH265PictureParameterSet pps[HEVC_MAX_PPS_COUNT];
66 
67  StdVideoH265VideoParameterSet vps[HEVC_MAX_PPS_COUNT];
70 
72  int nb_vps,
73  const int vps_list_idx[HEVC_MAX_VPS_COUNT],
74  const HEVCVPS * const vps_list[HEVC_MAX_VPS_COUNT])
75 {
76  uint8_t *data_ptr;
77  HEVCHeaderSet *hdr;
78 
79  size_t buf_size = sizeof(HEVCHeaderSet) + nb_vps*sizeof(HEVCHeaderVPS);
80  for (int i = 0; i < nb_vps; i++) {
81  const HEVCVPS *vps = vps_list[vps_list_idx[i]];
82  buf_size += sizeof(HEVCHeaderVPSSet)*vps->vps_num_hrd_parameters;
83  }
84 
85  if (buf_size > s->hevc_headers_size) {
86  av_freep(&s->hevc_headers);
87  s->hevc_headers_size = 0;
88  s->hevc_headers = av_mallocz(buf_size);
89  if (!s->hevc_headers)
90  return AVERROR(ENOMEM);
91  s->hevc_headers_size = buf_size;
92  }
93 
94  /* Setup struct pointers */
95  hdr = s->hevc_headers;
96  data_ptr = (uint8_t *)hdr;
97  hdr->hvps = (HEVCHeaderVPS *)(data_ptr + sizeof(HEVCHeaderSet));
98  data_ptr += sizeof(HEVCHeaderSet) + nb_vps*sizeof(HEVCHeaderVPS);
99  for (int i = 0; i < nb_vps; i++) {
100  const HEVCVPS *vps = vps_list[vps_list_idx[i]];
101  hdr->hvps[i].sls = (HEVCHeaderVPSSet *)data_ptr;
102  data_ptr += sizeof(HEVCHeaderVPSSet)*vps->vps_num_hrd_parameters;
103  }
104 
105  return 0;
106 }
107 
108 typedef struct HEVCVulkanDecodePicture {
110 
111  /* Current picture */
112  StdVideoDecodeH265ReferenceInfo h265_ref;
113  VkVideoDecodeH265DpbSlotInfoKHR vkh265_ref;
114 
115  /* Picture refs */
117  StdVideoDecodeH265ReferenceInfo h265_refs [HEVC_MAX_REFS];
118  VkVideoDecodeH265DpbSlotInfoKHR vkh265_refs[HEVC_MAX_REFS];
119 
120  /* Current picture (contd.) */
121  StdVideoDecodeH265PictureInfo h265pic;
122  VkVideoDecodeH265PictureInfoKHR h265_pic_info;
124 
125 static int vk_hevc_fill_pict(AVCodecContext *avctx, HEVCFrame **ref_src,
126  VkVideoReferenceSlotInfoKHR *ref_slot, /* Main structure */
127  VkVideoPictureResourceInfoKHR *ref, /* Goes in ^ */
128  VkVideoDecodeH265DpbSlotInfoKHR *vkh265_ref, /* Goes in ^ */
129  StdVideoDecodeH265ReferenceInfo *h265_ref, /* Goes in ^ */
130  HEVCFrame *pic, int is_current, int pic_id)
131 {
134  FFVulkanDecodePicture *vkpic = &hp->vp;
135 
136  int err = ff_vk_decode_prepare_frame(dec, pic->frame, vkpic, is_current,
137  dec->dedicated_dpb);
138  if (err < 0)
139  return err;
140 
141  *h265_ref = (StdVideoDecodeH265ReferenceInfo) {
142  .flags = (StdVideoDecodeH265ReferenceInfoFlags) {
143  .used_for_long_term_reference = pic->flags & HEVC_FRAME_FLAG_LONG_REF,
144  .unused_for_reference = 0,
145  },
146  .PicOrderCntVal = pic->poc,
147  };
148 
149  *vkh265_ref = (VkVideoDecodeH265DpbSlotInfoKHR) {
150  .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_DPB_SLOT_INFO_KHR,
151  .pStdReferenceInfo = h265_ref,
152  };
153 
154  *ref = (VkVideoPictureResourceInfoKHR) {
155  .sType = VK_STRUCTURE_TYPE_VIDEO_PICTURE_RESOURCE_INFO_KHR,
156  .codedOffset = (VkOffset2D){ 0, 0 },
157  .codedExtent = (VkExtent2D){ pic->frame->width, pic->frame->height },
158  .baseArrayLayer = dec->layered_dpb ? pic_id : 0,
159  .imageViewBinding = vkpic->img_view_ref,
160  };
161 
162  *ref_slot = (VkVideoReferenceSlotInfoKHR) {
163  .sType = VK_STRUCTURE_TYPE_VIDEO_REFERENCE_SLOT_INFO_KHR,
164  .pNext = vkh265_ref,
165  .slotIndex = pic_id,
166  .pPictureResource = ref,
167  };
168 
169  if (ref_src)
170  *ref_src = pic;
171 
172  return 0;
173 }
174 
175 static StdVideoH265LevelIdc convert_to_vk_level_idc(int level_idc)
176 {
177  switch (level_idc) {
178  case 10: return STD_VIDEO_H265_LEVEL_IDC_1_0;
179  case 20: return STD_VIDEO_H265_LEVEL_IDC_2_0;
180  case 21: return STD_VIDEO_H265_LEVEL_IDC_2_1;
181  case 30: return STD_VIDEO_H265_LEVEL_IDC_3_0;
182  case 31: return STD_VIDEO_H265_LEVEL_IDC_3_1;
183  case 40: return STD_VIDEO_H265_LEVEL_IDC_4_0;
184  case 41: return STD_VIDEO_H265_LEVEL_IDC_4_1;
185  case 50: return STD_VIDEO_H265_LEVEL_IDC_5_0;
186  case 51: return STD_VIDEO_H265_LEVEL_IDC_5_1;
187  case 60: return STD_VIDEO_H265_LEVEL_IDC_6_0;
188  case 61: return STD_VIDEO_H265_LEVEL_IDC_6_1;
189  default:
190  case 62: return STD_VIDEO_H265_LEVEL_IDC_6_2;
191  }
192 }
193 
194 static void copy_scaling_list(const ScalingList *sl, StdVideoH265ScalingLists *vksl)
195 {
196  for (int i = 0; i < STD_VIDEO_H265_SCALING_LIST_4X4_NUM_LISTS; i++) {
197  for (int j = 0; j < STD_VIDEO_H265_SCALING_LIST_4X4_NUM_ELEMENTS; j++) {
198  uint8_t pos = 4 * ff_hevc_diag_scan4x4_y[j] + ff_hevc_diag_scan4x4_x[j];
199  vksl->ScalingList4x4[i][j] = sl->sl[0][i][pos];
200  }
201  }
202 
203  for (int i = 0; i < STD_VIDEO_H265_SCALING_LIST_8X8_NUM_LISTS; i++) {
204  for (int j = 0; j < STD_VIDEO_H265_SCALING_LIST_8X8_NUM_ELEMENTS; j++) {
205  uint8_t pos = 8 * ff_hevc_diag_scan8x8_y[j] + ff_hevc_diag_scan8x8_x[j];
206  vksl->ScalingList8x8[i][j] = sl->sl[1][i][pos];
207  }
208  }
209 
210  for (int i = 0; i < STD_VIDEO_H265_SCALING_LIST_16X16_NUM_LISTS; i++) {
211  for (int j = 0; j < STD_VIDEO_H265_SCALING_LIST_16X16_NUM_ELEMENTS; j++) {
212  uint8_t pos = 8 * ff_hevc_diag_scan8x8_y[j] + ff_hevc_diag_scan8x8_x[j];
213  vksl->ScalingList16x16[i][j] = sl->sl[2][i][pos];
214  }
215  }
216 
217  for (int i = 0; i < STD_VIDEO_H265_SCALING_LIST_32X32_NUM_LISTS; i++) {
218  for (int j = 0; j < STD_VIDEO_H265_SCALING_LIST_32X32_NUM_ELEMENTS; j++) {
219  uint8_t pos = 8 * ff_hevc_diag_scan8x8_y[j] + ff_hevc_diag_scan8x8_x[j];
220  vksl->ScalingList32x32[i][j] = sl->sl[3][i * 3][pos];
221  }
222  }
223 
224  memcpy(vksl->ScalingListDCCoef16x16, sl->sl_dc[0],
225  STD_VIDEO_H265_SCALING_LIST_16X16_NUM_LISTS * sizeof(*vksl->ScalingListDCCoef16x16));
226 
227  for (int i = 0; i < STD_VIDEO_H265_SCALING_LIST_32X32_NUM_LISTS; i++)
228  vksl->ScalingListDCCoef32x32[i] = sl->sl_dc[1][i * 3];
229 }
230 
231 static void set_sps(const HEVCSPS *sps, int sps_idx,
232  StdVideoH265ScalingLists *vksps_scaling,
233  StdVideoH265HrdParameters *vksps_vui_header,
234  StdVideoH265SequenceParameterSetVui *vksps_vui,
235  StdVideoH265SequenceParameterSet *vksps,
236  StdVideoH265SubLayerHrdParameters *slhdrnal,
237  StdVideoH265SubLayerHrdParameters *slhdrvcl,
238  StdVideoH265ProfileTierLevel *ptl,
239  StdVideoH265DecPicBufMgr *dpbm,
240  StdVideoH265PredictorPaletteEntries *pal,
241  StdVideoH265ShortTermRefPicSet *str,
242  StdVideoH265LongTermRefPicsSps *ltr)
243 {
244  copy_scaling_list(&sps->scaling_list, vksps_scaling);
245 
246  *vksps_vui_header = (StdVideoH265HrdParameters) {
247  .flags = (StdVideoH265HrdFlags) {
248  .nal_hrd_parameters_present_flag = sps->hdr.flags.nal_hrd_parameters_present_flag,
249  .vcl_hrd_parameters_present_flag = sps->hdr.flags.vcl_hrd_parameters_present_flag,
250  .sub_pic_hrd_params_present_flag = sps->hdr.flags.sub_pic_hrd_params_present_flag,
251  .sub_pic_cpb_params_in_pic_timing_sei_flag = sps->hdr.flags.sub_pic_cpb_params_in_pic_timing_sei_flag,
252  .fixed_pic_rate_general_flag = sps->hdr.flags.fixed_pic_rate_general_flag,
253  .fixed_pic_rate_within_cvs_flag = sps->hdr.flags.fixed_pic_rate_within_cvs_flag,
254  .low_delay_hrd_flag = sps->hdr.flags.low_delay_hrd_flag,
255  },
256  .tick_divisor_minus2 = sps->hdr.tick_divisor_minus2,
257  .du_cpb_removal_delay_increment_length_minus1 = sps->hdr.du_cpb_removal_delay_increment_length_minus1,
258  .dpb_output_delay_du_length_minus1 = sps->hdr.dpb_output_delay_du_length_minus1,
259  .bit_rate_scale = sps->hdr.bit_rate_scale,
260  .cpb_size_scale = sps->hdr.cpb_size_scale,
261  .cpb_size_du_scale = sps->hdr.cpb_size_du_scale,
262  .initial_cpb_removal_delay_length_minus1 = sps->hdr.initial_cpb_removal_delay_length_minus1,
263  .au_cpb_removal_delay_length_minus1 = sps->hdr.au_cpb_removal_delay_length_minus1,
264  .dpb_output_delay_length_minus1 = sps->hdr.dpb_output_delay_length_minus1,
265  /* Reserved - 3*16 bits */
266  .pSubLayerHrdParametersNal = slhdrnal,
267  .pSubLayerHrdParametersVcl = slhdrvcl,
268  };
269 
270  memcpy(vksps_vui_header->cpb_cnt_minus1, sps->hdr.cpb_cnt_minus1,
271  STD_VIDEO_H265_SUBLAYERS_LIST_SIZE*sizeof(*vksps_vui_header->cpb_cnt_minus1));
272  memcpy(vksps_vui_header->elemental_duration_in_tc_minus1, sps->hdr.elemental_duration_in_tc_minus1,
273  STD_VIDEO_H265_SUBLAYERS_LIST_SIZE*sizeof(*vksps_vui_header->elemental_duration_in_tc_minus1));
274 
275  memcpy(slhdrnal, sps->hdr.nal_params, HEVC_MAX_SUB_LAYERS*sizeof(*slhdrnal));
276  memcpy(slhdrvcl, sps->hdr.vcl_params, HEVC_MAX_SUB_LAYERS*sizeof(*slhdrvcl));
277 
278  *vksps_vui = (StdVideoH265SequenceParameterSetVui) {
279  .flags = (StdVideoH265SpsVuiFlags) {
280  .aspect_ratio_info_present_flag = sps->vui.common.aspect_ratio_info_present_flag,
281  .overscan_info_present_flag = sps->vui.common.overscan_info_present_flag,
282  .overscan_appropriate_flag = sps->vui.common.overscan_appropriate_flag,
283  .video_signal_type_present_flag = sps->vui.common.video_signal_type_present_flag,
284  .video_full_range_flag = sps->vui.common.video_full_range_flag,
285  .colour_description_present_flag = sps->vui.common.colour_description_present_flag,
286  .chroma_loc_info_present_flag = sps->vui.common.chroma_loc_info_present_flag,
287  .neutral_chroma_indication_flag = sps->vui.neutra_chroma_indication_flag,
288  .field_seq_flag = sps->vui.field_seq_flag,
289  .frame_field_info_present_flag = sps->vui.frame_field_info_present_flag,
290  .default_display_window_flag = sps->vui.default_display_window_flag,
291  .vui_timing_info_present_flag = sps->vui.vui_timing_info_present_flag,
292  .vui_poc_proportional_to_timing_flag = sps->vui.vui_poc_proportional_to_timing_flag,
293  .vui_hrd_parameters_present_flag = sps->vui.vui_hrd_parameters_present_flag,
294  .bitstream_restriction_flag = sps->vui.bitstream_restriction_flag,
295  .tiles_fixed_structure_flag = sps->vui.tiles_fixed_structure_flag,
296  .motion_vectors_over_pic_boundaries_flag = sps->vui.motion_vectors_over_pic_boundaries_flag,
297  .restricted_ref_pic_lists_flag = sps->vui.restricted_ref_pic_lists_flag,
298  },
299  .aspect_ratio_idc = sps->vui.common.aspect_ratio_idc,
300  .sar_width = sps->vui.common.sar.num,
301  .sar_height = sps->vui.common.sar.den,
302  .video_format = sps->vui.common.video_format,
303  .colour_primaries = sps->vui.common.colour_primaries,
304  .transfer_characteristics = sps->vui.common.transfer_characteristics,
305  .matrix_coeffs = sps->vui.common.matrix_coeffs,
306  .chroma_sample_loc_type_top_field = sps->vui.common.chroma_sample_loc_type_top_field,
307  .chroma_sample_loc_type_bottom_field = sps->vui.common.chroma_sample_loc_type_bottom_field,
308  /* Reserved */
309  /* Reserved */
310  .def_disp_win_left_offset = sps->vui.def_disp_win.left_offset,
311  .def_disp_win_right_offset = sps->vui.def_disp_win.right_offset,
312  .def_disp_win_top_offset = sps->vui.def_disp_win.top_offset,
313  .def_disp_win_bottom_offset = sps->vui.def_disp_win.bottom_offset,
314  .vui_num_units_in_tick = sps->vui.vui_num_units_in_tick,
315  .vui_time_scale = sps->vui.vui_time_scale,
316  .vui_num_ticks_poc_diff_one_minus1 = sps->vui.vui_num_ticks_poc_diff_one_minus1,
317  .min_spatial_segmentation_idc = sps->vui.min_spatial_segmentation_idc,
318  .max_bytes_per_pic_denom = sps->vui.max_bytes_per_pic_denom,
319  .max_bits_per_min_cu_denom = sps->vui.max_bits_per_min_cu_denom,
320  .log2_max_mv_length_horizontal = sps->vui.log2_max_mv_length_horizontal,
321  .log2_max_mv_length_vertical = sps->vui.log2_max_mv_length_vertical,
322  .pHrdParameters = vksps_vui_header,
323  };
324 
325  *ptl = (StdVideoH265ProfileTierLevel) {
326  .flags = (StdVideoH265ProfileTierLevelFlags) {
327  .general_tier_flag = sps->ptl.general_ptl.tier_flag,
328  .general_progressive_source_flag = sps->ptl.general_ptl.progressive_source_flag,
329  .general_interlaced_source_flag = sps->ptl.general_ptl.interlaced_source_flag,
330  .general_non_packed_constraint_flag = sps->ptl.general_ptl.non_packed_constraint_flag,
331  .general_frame_only_constraint_flag = sps->ptl.general_ptl.frame_only_constraint_flag,
332  },
333  .general_profile_idc = sps->ptl.general_ptl.profile_idc,
334  .general_level_idc = convert_to_vk_level_idc(sps->ptl.general_ptl.level_idc),
335  };
336 
337  for (int i = 0; i < sps->max_sub_layers; i++) {
338  dpbm->max_latency_increase_plus1[i] = sps->temporal_layer[i].max_latency_increase + 1;
339  dpbm->max_dec_pic_buffering_minus1[i] = sps->temporal_layer[i].max_dec_pic_buffering - 1;
340  dpbm->max_num_reorder_pics[i] = sps->temporal_layer[i].num_reorder_pics;
341  }
342 
343  for (int i = 0; i < (sps->chroma_format_idc ? 3 : 1); i++)
344  for (int j = 0; j < sps->sps_num_palette_predictor_initializers; j++)
345  pal->PredictorPaletteEntries[i][j] = sps->sps_palette_predictor_initializer[i][j];
346 
347  for (int i = 0; i < sps->nb_st_rps; i++) {
348  str[i] = (StdVideoH265ShortTermRefPicSet) {
349  .flags = (StdVideoH265ShortTermRefPicSetFlags) {
350  .inter_ref_pic_set_prediction_flag = sps->st_rps[i].rps_predict,
351  .delta_rps_sign = sps->st_rps[i].delta_rps_sign,
352  },
353  .delta_idx_minus1 = sps->st_rps[i].delta_idx - 1,
354  .use_delta_flag = sps->st_rps[i].use_delta_flag,
355  .abs_delta_rps_minus1 = sps->st_rps[i].abs_delta_rps - 1,
356  .used_by_curr_pic_flag = 0x0,
357  .used_by_curr_pic_s0_flag = 0x0,
358  .used_by_curr_pic_s1_flag = 0x0,
359  /* Reserved */
360  /* Reserved */
361  /* Reserved */
362  .num_negative_pics = sps->st_rps[i].num_negative_pics,
363  .num_positive_pics = sps->st_rps[i].num_delta_pocs - sps->st_rps[i].num_negative_pics,
364  };
365 
366  /* NOTE: This is the predicted, and *reordered* version.
367  * Probably incorrect, but the spec doesn't say which version to use. */
368  for (int j = 0; j < sps->st_rps[i].num_delta_pocs; j++)
369  str[i].used_by_curr_pic_flag |= sps->st_rps[i].used[j] << j;
370 
371  for (int j = 0; j < str[i].num_negative_pics; j++) {
372  str[i].delta_poc_s0_minus1[j] = sps->st_rps[i].delta_poc_s0[j] - 1;
373  str[i].used_by_curr_pic_s0_flag |= sps->st_rps[i].used[j] << j;
374  }
375 
376  for (int j = 0; j < str[i].num_positive_pics; j++) {
377  str[i].delta_poc_s1_minus1[j] = sps->st_rps[i].delta_poc_s1[j] - 1;
378  str[i].used_by_curr_pic_s0_flag |= sps->st_rps[i].used[str[i].num_negative_pics + j] << j;
379  }
380  }
381 
382  *ltr = (StdVideoH265LongTermRefPicsSps) {
383  .used_by_curr_pic_lt_sps_flag = 0x0,
384  };
385 
386  for (int i = 0; i < sps->num_long_term_ref_pics_sps; i++) {
387  ltr->used_by_curr_pic_lt_sps_flag |= sps->used_by_curr_pic_lt_sps_flag[i] << i;
388  ltr->lt_ref_pic_poc_lsb_sps[i] = sps->lt_ref_pic_poc_lsb_sps[i];
389  }
390 
391  *vksps = (StdVideoH265SequenceParameterSet) {
392  .flags = (StdVideoH265SpsFlags) {
393  .sps_temporal_id_nesting_flag = sps->temporal_id_nesting_flag,
394  .separate_colour_plane_flag = sps->separate_colour_plane_flag,
395  .conformance_window_flag = sps->conformance_window_flag,
396  .sps_sub_layer_ordering_info_present_flag = sps->sublayer_ordering_info_flag,
397  .scaling_list_enabled_flag = sps->scaling_list_enable_flag,
398  .sps_scaling_list_data_present_flag = sps->scaling_list_enable_flag,
399  .amp_enabled_flag = sps->amp_enabled_flag,
400  .sample_adaptive_offset_enabled_flag = sps->sao_enabled,
401  .pcm_enabled_flag = sps->pcm_enabled_flag,
402  .pcm_loop_filter_disabled_flag = sps->pcm.loop_filter_disable_flag,
403  .long_term_ref_pics_present_flag = sps->long_term_ref_pics_present_flag,
404  .sps_temporal_mvp_enabled_flag = sps->sps_temporal_mvp_enabled_flag,
405  .strong_intra_smoothing_enabled_flag = sps->sps_strong_intra_smoothing_enable_flag,
406  .vui_parameters_present_flag = sps->vui_present,
407  .sps_extension_present_flag = sps->sps_extension_present_flag,
408  .sps_range_extension_flag = sps->sps_range_extension_flag,
409  .transform_skip_rotation_enabled_flag = sps->transform_skip_rotation_enabled_flag,
410  .transform_skip_context_enabled_flag = sps->transform_skip_context_enabled_flag,
411  .implicit_rdpcm_enabled_flag = sps->implicit_rdpcm_enabled_flag,
412  .explicit_rdpcm_enabled_flag = sps->explicit_rdpcm_enabled_flag,
413  .extended_precision_processing_flag = sps->extended_precision_processing_flag,
414  .intra_smoothing_disabled_flag = sps->intra_smoothing_disabled_flag,
415  .high_precision_offsets_enabled_flag = sps->high_precision_offsets_enabled_flag,
416  .persistent_rice_adaptation_enabled_flag = sps->persistent_rice_adaptation_enabled_flag,
417  .cabac_bypass_alignment_enabled_flag = sps->cabac_bypass_alignment_enabled_flag,
418  .sps_scc_extension_flag = sps->sps_scc_extension_flag,
419  .sps_curr_pic_ref_enabled_flag = sps->sps_curr_pic_ref_enabled_flag,
420  .palette_mode_enabled_flag = sps->palette_mode_enabled_flag,
421  .sps_palette_predictor_initializers_present_flag = sps->sps_palette_predictor_initializers_present_flag,
422  .intra_boundary_filtering_disabled_flag = sps->intra_boundary_filtering_disabled_flag,
423  },
424  .chroma_format_idc = sps->chroma_format_idc,
425  .pic_width_in_luma_samples = sps->width,
426  .pic_height_in_luma_samples = sps->height,
427  .sps_video_parameter_set_id = sps->vps_id,
428  .sps_max_sub_layers_minus1 = sps->max_sub_layers - 1,
429  .sps_seq_parameter_set_id = sps_idx,
430  .bit_depth_luma_minus8 = sps->bit_depth - 8,
431  .bit_depth_chroma_minus8 = sps->bit_depth_chroma - 8,
432  .log2_max_pic_order_cnt_lsb_minus4 = sps->log2_max_poc_lsb - 4,
433  .log2_min_luma_coding_block_size_minus3 = sps->log2_min_cb_size - 3,
434  .log2_diff_max_min_luma_coding_block_size = sps->log2_diff_max_min_coding_block_size,
435  .log2_min_luma_transform_block_size_minus2 = sps->log2_min_tb_size - 2,
436  .log2_diff_max_min_luma_transform_block_size = sps->log2_diff_max_min_transform_block_size,
437  .max_transform_hierarchy_depth_inter = sps->max_transform_hierarchy_depth_inter,
438  .max_transform_hierarchy_depth_intra = sps->max_transform_hierarchy_depth_intra,
439  .num_short_term_ref_pic_sets = sps->nb_st_rps,
440  .num_long_term_ref_pics_sps = sps->num_long_term_ref_pics_sps,
441  .pcm_sample_bit_depth_luma_minus1 = sps->pcm.bit_depth - 1,
442  .pcm_sample_bit_depth_chroma_minus1 = sps->pcm.bit_depth_chroma - 1,
443  .log2_min_pcm_luma_coding_block_size_minus3 = sps->pcm.log2_min_pcm_cb_size - 3,
444  .log2_diff_max_min_pcm_luma_coding_block_size = sps->pcm.log2_max_pcm_cb_size - sps->pcm.log2_min_pcm_cb_size,
445  /* Reserved */
446  /* Reserved */
447  .palette_max_size = sps->palette_max_size,
448  .delta_palette_max_predictor_size = sps->delta_palette_max_predictor_size,
449  .motion_vector_resolution_control_idc = sps->motion_vector_resolution_control_idc,
450  .sps_num_palette_predictor_initializers_minus1 = sps->sps_num_palette_predictor_initializers - 1,
451  .conf_win_left_offset = sps->pic_conf_win.left_offset,
452  .conf_win_right_offset = sps->pic_conf_win.right_offset,
453  .conf_win_top_offset = sps->pic_conf_win.top_offset,
454  .conf_win_bottom_offset = sps->pic_conf_win.bottom_offset,
455  .pProfileTierLevel = ptl,
456  .pDecPicBufMgr = dpbm,
457  .pScalingLists = vksps_scaling,
458  .pShortTermRefPicSet = str,
459  .pLongTermRefPicsSps = ltr,
460  .pSequenceParameterSetVui = vksps_vui,
461  .pPredictorPaletteEntries = pal,
462  };
463 }
464 
465 static void set_pps(const HEVCPPS *pps, const HEVCSPS *sps,
466  StdVideoH265ScalingLists *vkpps_scaling,
467  StdVideoH265PictureParameterSet *vkpps,
468  StdVideoH265PredictorPaletteEntries *pal)
469 {
470  copy_scaling_list(&pps->scaling_list, vkpps_scaling);
471 
472  *vkpps = (StdVideoH265PictureParameterSet) {
473  .flags = (StdVideoH265PpsFlags) {
474  .dependent_slice_segments_enabled_flag = pps->dependent_slice_segments_enabled_flag,
475  .output_flag_present_flag = pps->output_flag_present_flag,
476  .sign_data_hiding_enabled_flag = pps->sign_data_hiding_flag,
477  .cabac_init_present_flag = pps->cabac_init_present_flag,
478  .constrained_intra_pred_flag = pps->constrained_intra_pred_flag,
479  .transform_skip_enabled_flag = pps->transform_skip_enabled_flag,
480  .cu_qp_delta_enabled_flag = pps->cu_qp_delta_enabled_flag,
481  .pps_slice_chroma_qp_offsets_present_flag = pps->pic_slice_level_chroma_qp_offsets_present_flag,
482  .weighted_pred_flag = pps->weighted_pred_flag,
483  .weighted_bipred_flag = pps->weighted_bipred_flag,
484  .transquant_bypass_enabled_flag = pps->transquant_bypass_enable_flag,
485  .tiles_enabled_flag = pps->tiles_enabled_flag,
486  .entropy_coding_sync_enabled_flag = pps->entropy_coding_sync_enabled_flag,
487  .uniform_spacing_flag = pps->uniform_spacing_flag,
488  .loop_filter_across_tiles_enabled_flag = pps->loop_filter_across_tiles_enabled_flag,
489  .pps_loop_filter_across_slices_enabled_flag = pps->seq_loop_filter_across_slices_enabled_flag,
490  .deblocking_filter_control_present_flag = pps->deblocking_filter_control_present_flag,
491  .deblocking_filter_override_enabled_flag = pps->deblocking_filter_override_enabled_flag,
492  .pps_deblocking_filter_disabled_flag = pps->disable_dbf,
493  .pps_scaling_list_data_present_flag = pps->scaling_list_data_present_flag,
494  .lists_modification_present_flag = pps->lists_modification_present_flag,
495  .slice_segment_header_extension_present_flag = pps->slice_header_extension_present_flag,
496  .pps_extension_present_flag = pps->pps_extension_present_flag,
497  .cross_component_prediction_enabled_flag = pps->cross_component_prediction_enabled_flag,
498  .chroma_qp_offset_list_enabled_flag = pps->chroma_qp_offset_list_enabled_flag,
499  .pps_curr_pic_ref_enabled_flag = pps->pps_curr_pic_ref_enabled_flag,
500  .residual_adaptive_colour_transform_enabled_flag = pps->residual_adaptive_colour_transform_enabled_flag,
501  .pps_slice_act_qp_offsets_present_flag = pps->pps_slice_act_qp_offsets_present_flag,
502  .pps_palette_predictor_initializers_present_flag = pps->pps_palette_predictor_initializers_present_flag,
503  .monochrome_palette_flag = pps->monochrome_palette_flag,
504  .pps_range_extension_flag = pps->pps_range_extensions_flag,
505  },
506  .pps_pic_parameter_set_id = pps->pps_id,
507  .pps_seq_parameter_set_id = pps->sps_id,
508  .sps_video_parameter_set_id = sps->vps_id,
509  .num_extra_slice_header_bits = pps->num_extra_slice_header_bits,
510  .num_ref_idx_l0_default_active_minus1 = pps->num_ref_idx_l0_default_active - 1,
511  .num_ref_idx_l1_default_active_minus1 = pps->num_ref_idx_l1_default_active - 1,
512  .init_qp_minus26 = pps->pic_init_qp_minus26,
513  .diff_cu_qp_delta_depth = pps->diff_cu_qp_delta_depth,
514  .pps_cb_qp_offset = pps->cb_qp_offset,
515  .pps_cr_qp_offset = pps->cr_qp_offset,
516  .pps_beta_offset_div2 = pps->beta_offset >> 1,
517  .pps_tc_offset_div2 = pps->tc_offset >> 1,
518  .log2_parallel_merge_level_minus2 = pps->log2_parallel_merge_level - 2,
519  .log2_max_transform_skip_block_size_minus2 = pps->log2_max_transform_skip_block_size - 2,
520  .diff_cu_chroma_qp_offset_depth = pps->diff_cu_chroma_qp_offset_depth,
521  .chroma_qp_offset_list_len_minus1 = pps->chroma_qp_offset_list_len_minus1,
522  .log2_sao_offset_scale_luma = pps->log2_sao_offset_scale_luma,
523  .log2_sao_offset_scale_chroma = pps->log2_sao_offset_scale_chroma,
524  .pps_act_y_qp_offset_plus5 = pps->pps_act_y_qp_offset + 5,
525  .pps_act_cb_qp_offset_plus5 = pps->pps_act_cb_qp_offset + 5,
526  .pps_act_cr_qp_offset_plus3 = pps->pps_act_cr_qp_offset + 3,
527  .pps_num_palette_predictor_initializers = pps->pps_num_palette_predictor_initializers,
528  .luma_bit_depth_entry_minus8 = pps->luma_bit_depth_entry - 8,
529  .chroma_bit_depth_entry_minus8 = pps->chroma_bit_depth_entry - 8,
530  .num_tile_columns_minus1 = pps->num_tile_columns - 1,
531  .num_tile_rows_minus1 = pps->num_tile_rows - 1,
532  .pScalingLists = vkpps_scaling,
533  .pPredictorPaletteEntries = pal,
534  };
535 
536  for (int i = 0; i < (pps->monochrome_palette_flag ? 1 : 3); i++) {
537  for (int j = 0; j < pps->pps_num_palette_predictor_initializers; j++)
538  pal->PredictorPaletteEntries[i][j] = pps->pps_palette_predictor_initializer[i][j];
539  }
540 
541  for (int i = 0; i < pps->num_tile_columns - 1; i++)
542  vkpps->column_width_minus1[i] = pps->column_width[i] - 1;
543 
544  for (int i = 0; i < pps->num_tile_rows - 1; i++)
545  vkpps->row_height_minus1[i] = pps->row_height[i] - 1;
546 
547  for (int i = 0; i <= pps->chroma_qp_offset_list_len_minus1; i++) {
548  vkpps->cb_qp_offset_list[i] = pps->cb_qp_offset_list[i];
549  vkpps->cr_qp_offset_list[i] = pps->cr_qp_offset_list[i];
550  }
551 }
552 
553 static void set_vps(const HEVCVPS *vps,
554  StdVideoH265VideoParameterSet *vkvps,
555  StdVideoH265ProfileTierLevel *ptl,
556  StdVideoH265DecPicBufMgr *dpbm,
557  StdVideoH265HrdParameters *sls_hdr,
558  HEVCHeaderVPSSet sls[])
559 {
560  for (int i = 0; i < vps->vps_num_hrd_parameters; i++) {
561  const HEVCHdrParams *src = &vps->hdr[i];
562 
563  sls_hdr[i] = (StdVideoH265HrdParameters) {
564  .flags = (StdVideoH265HrdFlags) {
565  .nal_hrd_parameters_present_flag = src->flags.nal_hrd_parameters_present_flag,
566  .vcl_hrd_parameters_present_flag = src->flags.vcl_hrd_parameters_present_flag,
567  .sub_pic_hrd_params_present_flag = src->flags.sub_pic_hrd_params_present_flag,
568  .sub_pic_cpb_params_in_pic_timing_sei_flag = src->flags.sub_pic_cpb_params_in_pic_timing_sei_flag,
569  .fixed_pic_rate_general_flag = src->flags.fixed_pic_rate_general_flag,
570  .fixed_pic_rate_within_cvs_flag = src->flags.fixed_pic_rate_within_cvs_flag,
571  .low_delay_hrd_flag = src->flags.low_delay_hrd_flag,
572  },
573  .tick_divisor_minus2 = src->tick_divisor_minus2,
574  .du_cpb_removal_delay_increment_length_minus1 = src->du_cpb_removal_delay_increment_length_minus1,
575  .dpb_output_delay_du_length_minus1 = src->dpb_output_delay_du_length_minus1,
576  .bit_rate_scale = src->bit_rate_scale,
577  .cpb_size_scale = src->cpb_size_scale,
578  .cpb_size_du_scale = src->cpb_size_du_scale,
579  .initial_cpb_removal_delay_length_minus1 = src->initial_cpb_removal_delay_length_minus1,
580  .au_cpb_removal_delay_length_minus1 = src->au_cpb_removal_delay_length_minus1,
581  .dpb_output_delay_length_minus1 = src->dpb_output_delay_length_minus1,
582  /* Reserved - 3*16 bits */
583  .pSubLayerHrdParametersNal = sls[i].nal_hdr,
584  .pSubLayerHrdParametersVcl = sls[i].vcl_hdr,
585  };
586 
587  memcpy(sls_hdr[i].cpb_cnt_minus1, src->cpb_cnt_minus1,
588  STD_VIDEO_H265_SUBLAYERS_LIST_SIZE*sizeof(*sls_hdr[i].cpb_cnt_minus1));
589  memcpy(sls_hdr[i].elemental_duration_in_tc_minus1, src->elemental_duration_in_tc_minus1,
590  STD_VIDEO_H265_SUBLAYERS_LIST_SIZE*sizeof(*sls_hdr[i].elemental_duration_in_tc_minus1));
591 
592  memcpy(sls[i].nal_hdr, src->nal_params, HEVC_MAX_SUB_LAYERS*sizeof(*sls[i].nal_hdr));
593  memcpy(sls[i].vcl_hdr, src->vcl_params, HEVC_MAX_SUB_LAYERS*sizeof(*sls[i].vcl_hdr));
594  }
595 
596  *ptl = (StdVideoH265ProfileTierLevel) {
597  .flags = (StdVideoH265ProfileTierLevelFlags) {
598  .general_tier_flag = vps->ptl.general_ptl.tier_flag,
599  .general_progressive_source_flag = vps->ptl.general_ptl.progressive_source_flag,
600  .general_interlaced_source_flag = vps->ptl.general_ptl.interlaced_source_flag,
601  .general_non_packed_constraint_flag = vps->ptl.general_ptl.non_packed_constraint_flag,
602  .general_frame_only_constraint_flag = vps->ptl.general_ptl.frame_only_constraint_flag,
603  },
604  .general_profile_idc = vps->ptl.general_ptl.profile_idc,
605  .general_level_idc = convert_to_vk_level_idc(vps->ptl.general_ptl.level_idc),
606  };
607 
608  for (int i = 0; i < vps->vps_max_sub_layers; i++) {
609  dpbm->max_latency_increase_plus1[i] = vps->vps_max_latency_increase[i] + 1;
610  dpbm->max_dec_pic_buffering_minus1[i] = vps->vps_max_dec_pic_buffering[i] - 1;
611  dpbm->max_num_reorder_pics[i] = vps->vps_num_reorder_pics[i];
612  }
613 
614  *vkvps = (StdVideoH265VideoParameterSet) {
615  .flags = (StdVideoH265VpsFlags) {
616  .vps_temporal_id_nesting_flag = vps->vps_temporal_id_nesting_flag,
617  .vps_sub_layer_ordering_info_present_flag = vps->vps_sub_layer_ordering_info_present_flag,
618  .vps_timing_info_present_flag = vps->vps_timing_info_present_flag,
619  .vps_poc_proportional_to_timing_flag = vps->vps_poc_proportional_to_timing_flag,
620  },
621  .vps_video_parameter_set_id = vps->vps_id,
622  .vps_max_sub_layers_minus1 = vps->vps_max_sub_layers - 1,
623  /* Reserved */
624  /* Reserved */
625  .vps_num_units_in_tick = vps->vps_num_units_in_tick,
626  .vps_time_scale = vps->vps_time_scale,
627  .vps_num_ticks_poc_diff_one_minus1 = vps->vps_num_ticks_poc_diff_one - 1,
628  /* Reserved */
629  .pDecPicBufMgr = dpbm,
630  .pHrdParameters = sls_hdr,
631  .pProfileTierLevel = ptl,
632  };
633 }
634 
636 {
637  int err;
638  const HEVCContext *h = avctx->priv_data;
641 
642  VkVideoDecodeH265SessionParametersAddInfoKHR h265_params_info = {
643  .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_SESSION_PARAMETERS_ADD_INFO_KHR,
644  .stdSPSCount = 0,
645  .stdPPSCount = 0,
646  .stdVPSCount = 0,
647  };
648  VkVideoDecodeH265SessionParametersCreateInfoKHR h265_params = {
649  .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_SESSION_PARAMETERS_CREATE_INFO_KHR,
650  .pParametersAddInfo = &h265_params_info,
651  };
652  VkVideoSessionParametersCreateInfoKHR session_params_create = {
653  .sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR,
654  .pNext = &h265_params,
655  .videoSession = ctx->common.session,
656  .videoSessionParametersTemplate = NULL,
657  };
658 
659  HEVCHeaderSet *hdr;
660  int nb_vps = 0;
661  int vps_list_idx[HEVC_MAX_VPS_COUNT];
662 
663  for (int i = 0; i < HEVC_MAX_VPS_COUNT; i++)
664  if (h->ps.vps_list[i])
665  vps_list_idx[nb_vps++] = i;
666 
667  err = alloc_hevc_header_structs(dec, nb_vps, vps_list_idx, h->ps.vps_list);
668  if (err < 0)
669  return err;
670 
671  hdr = dec->hevc_headers;
672 
673  h265_params_info.pStdSPSs = hdr->sps;
674  h265_params_info.pStdPPSs = hdr->pps;
675  h265_params_info.pStdVPSs = hdr->vps;
676 
677  /* SPS list */
678  for (int i = 0; i < HEVC_MAX_SPS_COUNT; i++) {
679  if (h->ps.sps_list[i]) {
680  const HEVCSPS *sps_l = h->ps.sps_list[i];
681  int idx = h265_params_info.stdSPSCount++;
682  set_sps(sps_l, i, &hdr->hsps[idx].scaling, &hdr->hsps[idx].vui_header,
683  &hdr->hsps[idx].vui, &hdr->sps[idx], hdr->hsps[idx].nal_hdr,
684  hdr->hsps[idx].vcl_hdr, &hdr->hsps[idx].ptl, &hdr->hsps[idx].dpbm,
685  &hdr->hsps[idx].pal, hdr->hsps[idx].str, &hdr->hsps[idx].ltr);
686  }
687  }
688 
689  /* PPS list */
690  for (int i = 0; i < HEVC_MAX_PPS_COUNT; i++) {
691  if (h->ps.pps_list[i]) {
692  const HEVCPPS *pps_l = h->ps.pps_list[i];
693  const HEVCSPS *sps_l = h->ps.sps_list[pps_l->sps_id];
694  int idx = h265_params_info.stdPPSCount++;
695  set_pps(pps_l, sps_l, &hdr->hpps[idx].scaling,
696  &hdr->pps[idx], &hdr->hpps[idx].pal);
697  }
698  }
699 
700  /* VPS list */
701  for (int i = 0; i < nb_vps; i++) {
702  const HEVCVPS *vps_l = h->ps.vps_list[vps_list_idx[i]];
703  set_vps(vps_l, &hdr->vps[i], &hdr->hvps[i].ptl, &hdr->hvps[i].dpbm,
704  hdr->hvps[i].hdr, hdr->hvps[i].sls);
705  h265_params_info.stdVPSCount++;
706  }
707 
708  h265_params.maxStdSPSCount = h265_params_info.stdSPSCount;
709  h265_params.maxStdPPSCount = h265_params_info.stdPPSCount;
710  h265_params.maxStdVPSCount = h265_params_info.stdVPSCount;
711 
712  err = ff_vk_decode_create_params(buf, avctx, ctx, &session_params_create);
713  if (err < 0)
714  return err;
715 
716  av_log(avctx, AV_LOG_DEBUG, "Created frame parameters: %i SPS %i PPS %i VPS\n",
717  h265_params_info.stdSPSCount, h265_params_info.stdPPSCount,
718  h265_params_info.stdVPSCount);
719 
720  return 0;
721 }
722 
724  av_unused const uint8_t *buffer,
725  av_unused uint32_t size)
726 {
727  int err;
728  HEVCContext *h = avctx->priv_data;
729  HEVCFrame *pic = h->ref;
732  FFVulkanDecodePicture *vp = &hp->vp;
733  const HEVCSPS *sps = h->ps.sps;
734  const HEVCPPS *pps = h->ps.pps;
735  int nb_refs = 0;
736 
737  if (!dec->session_params) {
738  err = vk_hevc_create_params(avctx, &dec->session_params);
739  if (err < 0)
740  return err;
741  }
742 
743  hp->h265pic = (StdVideoDecodeH265PictureInfo) {
744  .flags = (StdVideoDecodeH265PictureInfoFlags) {
745  .IrapPicFlag = IS_IRAP(h),
746  .IdrPicFlag = IS_IDR(h),
747  .IsReference = h->nal_unit_type < 16 ? h->nal_unit_type & 1 : 1,
748  .short_term_ref_pic_set_sps_flag = h->sh.short_term_ref_pic_set_sps_flag,
749  },
750  .sps_video_parameter_set_id = sps->vps_id,
751  .pps_seq_parameter_set_id = pps->sps_id,
752  .pps_pic_parameter_set_id = pps->pps_id,
753  .NumDeltaPocsOfRefRpsIdx = h->sh.short_term_rps ? h->sh.short_term_rps->rps_idx_num_delta_pocs : 0,
754  .PicOrderCntVal = h->poc,
755  .NumBitsForSTRefPicSetInSlice = !h->sh.short_term_ref_pic_set_sps_flag ?
756  h->sh.short_term_ref_pic_set_size : 0,
757  };
758 
759  /* Fill in references */
760  for (int i = 0; i < FF_ARRAY_ELEMS(h->DPB); i++) {
761  const HEVCFrame *ref = &h->DPB[i];
762  int idx = nb_refs;
763 
765  continue;
766 
767  if (ref == pic) {
768  err = vk_hevc_fill_pict(avctx, NULL, &vp->ref_slot, &vp->ref,
769  &hp->vkh265_ref, &hp->h265_ref, pic, 1, i);
770  if (err < 0)
771  return err;
772 
773  continue;
774  }
775 
776  err = vk_hevc_fill_pict(avctx, &hp->ref_src[idx], &vp->ref_slots[idx],
777  &vp->refs[idx], &hp->vkh265_refs[idx],
778  &hp->h265_refs[idx], (HEVCFrame *)ref, 0, i);
779  if (err < 0)
780  return err;
781 
782  nb_refs++;
783  }
784 
785  memset(hp->h265pic.RefPicSetStCurrBefore, 0xff, 8);
786  for (int i = 0; i < h->rps[ST_CURR_BEF].nb_refs; i++) {
787  HEVCFrame *frame = h->rps[ST_CURR_BEF].ref[i];
788  for (int j = 0; j < FF_ARRAY_ELEMS(h->DPB); j++) {
789  const HEVCFrame *ref = &h->DPB[j];
790  if (ref == frame) {
791  hp->h265pic.RefPicSetStCurrBefore[i] = j;
792  break;
793  }
794  }
795  }
796  memset(hp->h265pic.RefPicSetStCurrAfter, 0xff, 8);
797  for (int i = 0; i < h->rps[ST_CURR_AFT].nb_refs; i++) {
798  HEVCFrame *frame = h->rps[ST_CURR_AFT].ref[i];
799  for (int j = 0; j < FF_ARRAY_ELEMS(h->DPB); j++) {
800  const HEVCFrame *ref = &h->DPB[j];
801  if (ref == frame) {
802  hp->h265pic.RefPicSetStCurrAfter[i] = j;
803  break;
804  }
805  }
806  }
807  memset(hp->h265pic.RefPicSetLtCurr, 0xff, 8);
808  for (int i = 0; i < h->rps[LT_CURR].nb_refs; i++) {
809  HEVCFrame *frame = h->rps[LT_CURR].ref[i];
810  for (int j = 0; j < FF_ARRAY_ELEMS(h->DPB); j++) {
811  const HEVCFrame *ref = &h->DPB[j];
812  if (ref == frame) {
813  hp->h265pic.RefPicSetLtCurr[i] = j;
814  break;
815  }
816  }
817  }
818 
819  hp->h265_pic_info = (VkVideoDecodeH265PictureInfoKHR) {
820  .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PICTURE_INFO_KHR,
821  .pStdPictureInfo = &hp->h265pic,
822  .sliceSegmentCount = 0,
823  };
824 
825  vp->decode_info = (VkVideoDecodeInfoKHR) {
826  .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_INFO_KHR,
827  .pNext = &hp->h265_pic_info,
828  .flags = 0x0,
829  .pSetupReferenceSlot = &vp->ref_slot,
830  .referenceSlotCount = nb_refs,
831  .pReferenceSlots = vp->ref_slots,
832  .dstPictureResource = (VkVideoPictureResourceInfoKHR) {
833  .sType = VK_STRUCTURE_TYPE_VIDEO_PICTURE_RESOURCE_INFO_KHR,
834  .codedOffset = (VkOffset2D){ 0, 0 },
835  .codedExtent = (VkExtent2D){ pic->frame->width, pic->frame->height },
836  .baseArrayLayer = 0,
837  .imageViewBinding = vp->img_view_out,
838  },
839  };
840 
841  return 0;
842 }
843 
845  const uint8_t *data,
846  uint32_t size)
847 {
848  const HEVCContext *h = avctx->priv_data;
849  HEVCVulkanDecodePicture *hp = h->ref->hwaccel_picture_private;
850  FFVulkanDecodePicture *vp = &hp->vp;
851 
852  int err = ff_vk_decode_add_slice(avctx, vp, data, size, 1,
853  &hp->h265_pic_info.sliceSegmentCount,
854  &hp->h265_pic_info.pSliceSegmentOffsets);
855  if (err < 0)
856  return err;
857 
858  return 0;
859 }
860 
862 {
863  const HEVCContext *h = avctx->priv_data;
865  HEVCFrame *pic = h->ref;
867  FFVulkanDecodePicture *vp = &hp->vp;
868  FFVulkanDecodePicture *rvp[HEVC_MAX_REFS] = { 0 };
869  AVFrame *rav[HEVC_MAX_REFS] = { 0 };
870  int err;
871 
872  if (!hp->h265_pic_info.sliceSegmentCount)
873  return 0;
874 
875  if (!dec->session_params) {
876  const HEVCSPS *sps = h->ps.sps;
877  const HEVCPPS *pps = h->ps.pps;
878 
879  if (!pps) {
880  unsigned int pps_id = h->sh.pps_id;
881  if (pps_id < HEVC_MAX_PPS_COUNT && h->ps.pps_list[pps_id] != NULL)
882  pps = h->ps.pps_list[pps_id];
883  }
884 
885  if (!pps) {
886  av_log(avctx, AV_LOG_ERROR,
887  "Encountered frame without a valid active PPS reference.\n");
888  return AVERROR_INVALIDDATA;
889  }
890 
891  err = vk_hevc_create_params(avctx, &dec->session_params);
892  if (err < 0)
893  return err;
894 
895  hp->h265pic.sps_video_parameter_set_id = sps->vps_id;
896  hp->h265pic.pps_seq_parameter_set_id = pps->sps_id;
897  hp->h265pic.pps_pic_parameter_set_id = pps->pps_id;
898  }
899 
900  for (int i = 0; i < vp->decode_info.referenceSlotCount; i++) {
902  rav[i] = hp->ref_src[i]->frame;
903  rvp[i] = &rfhp->vp;
904  }
905 
906  av_log(avctx, AV_LOG_VERBOSE, "Decoding frame, %"SIZE_SPECIFIER" bytes, %i slices\n",
907  vp->slices_size, hp->h265_pic_info.sliceSegmentCount);
908 
909  return ff_vk_decode_frame(avctx, pic->frame, vp, rav, rvp);
910 }
911 
913 {
914  AVHWDeviceContext *hwctx = _hwctx.nc;
916 
917  /* Free frame resources */
918  ff_vk_decode_free_frame(hwctx, &hp->vp);
919 }
920 
922  .p.name = "hevc_vulkan",
923  .p.type = AVMEDIA_TYPE_VIDEO,
924  .p.id = AV_CODEC_ID_HEVC,
925  .p.pix_fmt = AV_PIX_FMT_VULKAN,
926  .start_frame = &vk_hevc_start_frame,
927  .decode_slice = &vk_hevc_decode_slice,
928  .end_frame = &vk_hevc_end_frame,
929  .free_frame_priv = &vk_hevc_free_frame_priv,
930  .frame_priv_data_size = sizeof(HEVCVulkanDecodePicture),
933  .decode_params = &ff_vk_params_invalidate,
936  .frame_params = &ff_vk_frame_params,
937  .priv_data_size = sizeof(FFVulkanDecodeContext),
939 };
HEVCHeaderSPS::vui_header
StdVideoH265HrdParameters vui_header
Definition: vulkan_hevc.c:32
FFVulkanDecodePicture::slices_size
size_t slices_size
Definition: vulkan_decode.h:99
HEVCFrame::flags
uint8_t flags
A combination of HEVC_FRAME_FLAG_*.
Definition: hevcdec.h:433
HEVC_MAX_REFS
@ HEVC_MAX_REFS
Definition: hevc.h:119
HEVCHeaderSet::hvps
HEVCHeaderVPS * hvps
Definition: vulkan_hevc.c:68
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
HEVCHeaderSPS::dpbm
StdVideoH265DecPicBufMgr dpbm
Definition: vulkan_hevc.c:35
HEVCHeaderSPS::pal
StdVideoH265PredictorPaletteEntries pal
Definition: vulkan_hevc.c:36
HEVCHeaderVPSSet::nal_hdr
StdVideoH265SubLayerHrdParameters nal_hdr[HEVC_MAX_SUB_LAYERS]
Definition: vulkan_hevc.c:49
HEVCHeaderVPS::sls
HEVCHeaderVPSSet * sls
Definition: vulkan_hevc.c:57
ff_hevc_diag_scan8x8_y
const uint8_t ff_hevc_diag_scan8x8_y[64]
Definition: hevc_data.c:58
HEVCHeaderSPS::scaling
StdVideoH265ScalingLists scaling
Definition: vulkan_hevc.c:31
FFVulkanDecodeContext::shared_ctx
FFVulkanDecodeShared * shared_ctx
Definition: vulkan_decode.h:57
HEVCHeaderSet::hsps
HEVCHeaderSPS hsps[HEVC_MAX_SPS_COUNT]
Definition: vulkan_hevc.c:62
HEVCHeaderVPSSet
Definition: vulkan_hevc.c:48
av_unused
#define av_unused
Definition: attributes.h:131
FFHWAccel::p
AVHWAccel p
The public AVHWAccel.
Definition: hwaccel_internal.h:38
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:340
AVFrame::width
int width
Definition: frame.h:412
HEVCFrame::hwaccel_picture_private
void * hwaccel_picture_private
RefStruct reference.
Definition: hevcdec.h:422
level_idc
int level_idc
Definition: h264_levels.c:29
vk_hevc_fill_pict
static int vk_hevc_fill_pict(AVCodecContext *avctx, HEVCFrame **ref_src, VkVideoReferenceSlotInfoKHR *ref_slot, VkVideoPictureResourceInfoKHR *ref, VkVideoDecodeH265DpbSlotInfoKHR *vkh265_ref, StdVideoDecodeH265ReferenceInfo *h265_ref, HEVCFrame *pic, int is_current, int pic_id)
Definition: vulkan_hevc.c:125
HEVCHeaderSPS::ltr
StdVideoH265LongTermRefPicsSps ltr
Definition: vulkan_hevc.c:40
data
const char data[16]
Definition: mxf.c:148
ff_hevc_vulkan_hwaccel
const FFHWAccel ff_hevc_vulkan_hwaccel
Definition: vulkan_hevc.c:921
ScalingList::sl
uint8_t sl[4][6][64]
Definition: hevc_ps.h:182
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
FFRefStructOpaque
RefStruct is an API for creating reference-counted objects with minimal overhead.
Definition: refstruct.h:58
vk_hevc_decode_slice
static int vk_hevc_decode_slice(AVCodecContext *avctx, const uint8_t *data, uint32_t size)
Definition: vulkan_hevc.c:844
HEVC_MAX_LAYER_SETS
@ HEVC_MAX_LAYER_SETS
Definition: hevc.h:107
alloc_hevc_header_structs
static int alloc_hevc_header_structs(FFVulkanDecodeContext *s, int nb_vps, const int vps_list_idx[HEVC_MAX_VPS_COUNT], const HEVCVPS *const vps_list[HEVC_MAX_VPS_COUNT])
Definition: vulkan_hevc.c:71
ff_vk_dec_hevc_ext
const VkExtensionProperties ff_vk_dec_hevc_ext
Definition: vulkan_hevc.c:25
HEVCHdrParams
Definition: hevc_ps.h:52
FFVulkanDecodeContext
Definition: vulkan_decode.h:56
AV_PIX_FMT_VULKAN
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition: pixfmt.h:376
vk_hevc_end_frame
static int vk_hevc_end_frame(AVCodecContext *avctx)
Definition: vulkan_hevc.c:861
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:175
FFVulkanDecodePicture::ref
VkVideoPictureResourceInfoKHR ref
Definition: vulkan_decode.h:87
FFVulkanDecodeContext::session_params
AVBufferRef * session_params
Definition: vulkan_decode.h:58
HEVC_FRAME_FLAG_LONG_REF
#define HEVC_FRAME_FLAG_LONG_REF
Definition: hevcdec.h:400
FFHWAccel
Definition: hwaccel_internal.h:34
HEVC_MAX_SPS_COUNT
@ HEVC_MAX_SPS_COUNT
Definition: hevc.h:112
HEVCVulkanDecodePicture::ref_src
HEVCFrame * ref_src[HEVC_MAX_REFS]
Definition: vulkan_hevc.c:116
HEVCHeaderPPS
Definition: vulkan_hevc.c:43
HWACCEL_CAP_THREAD_SAFE
#define HWACCEL_CAP_THREAD_SAFE
Definition: hwaccel_internal.h:32
HEVCHeaderSPS
Definition: vulkan_hevc.c:30
HEVCHeaderPPS::scaling
StdVideoH265ScalingLists scaling
Definition: vulkan_hevc.c:44
HEVCHeaderVPS
Definition: vulkan_hevc.c:53
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:331
FFVulkanDecodeShared
Definition: vulkan_decode.h:37
vk_hevc_start_frame
static int vk_hevc_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
Definition: vulkan_hevc.c:723
AVHWDeviceContext
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
Definition: hwcontext.h:61
HEVCHeaderSPS::nal_hdr
StdVideoH265SubLayerHrdParameters nal_hdr[HEVC_MAX_SUB_LAYERS]
Definition: vulkan_hevc.c:37
HEVCVulkanDecodePicture::vkh265_refs
VkVideoDecodeH265DpbSlotInfoKHR vkh265_refs[HEVC_MAX_REFS]
Definition: vulkan_hevc.c:118
FFVulkanDecodePicture::img_view_out
VkImageView img_view_out
Definition: vulkan_decode.h:78
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
FFVulkanDecodePicture::refs
VkVideoPictureResourceInfoKHR refs[36]
Definition: vulkan_decode.h:91
ptl
const H265RawProfileTierLevel * ptl
Definition: h265_levels.c:170
HEVCHeaderSet::hpps
HEVCHeaderPPS hpps[HEVC_MAX_PPS_COUNT]
Definition: vulkan_hevc.c:65
HEVCHeaderSPS::vui
StdVideoH265SequenceParameterSetVui vui
Definition: vulkan_hevc.c:33
s
#define s(width, name)
Definition: cbs_vp9.c:198
FFVulkanDecodePicture
Definition: vulkan_decode.h:74
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:1061
ff_hevc_diag_scan8x8_x
const uint8_t ff_hevc_diag_scan8x8_x[64]
Definition: hevc_data.c:39
HEVCHeaderSet::pps
StdVideoH265PictureParameterSet pps[HEVC_MAX_PPS_COUNT]
Definition: vulkan_hevc.c:64
copy_scaling_list
static void copy_scaling_list(const ScalingList *sl, StdVideoH265ScalingLists *vksl)
Definition: vulkan_hevc.c:194
vk_hevc_free_frame_priv
static void vk_hevc_free_frame_priv(FFRefStructOpaque _hwctx, void *data)
Definition: vulkan_hevc.c:912
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts_bsf.c:365
HEVCVulkanDecodePicture::h265_refs
StdVideoDecodeH265ReferenceInfo h265_refs[HEVC_MAX_REFS]
Definition: vulkan_hevc.c:117
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:48
IS_IDR
#define IS_IDR(s)
Definition: hevcdec.h:75
HEVC_FRAME_FLAG_SHORT_REF
#define HEVC_FRAME_FLAG_SHORT_REF
Definition: hevcdec.h:399
HEVCVulkanDecodePicture::h265_ref
StdVideoDecodeH265ReferenceInfo h265_ref
Definition: vulkan_hevc.c:112
ScalingList
Definition: hevc_ps.h:179
frame
static AVFrame * frame
Definition: demux_decode.c:54
ff_hevc_diag_scan4x4_y
const uint8_t ff_hevc_diag_scan4x4_y[16]
Definition: hevc_data.c:32
HWACCEL_CAP_ASYNC_SAFE
#define HWACCEL_CAP_ASYNC_SAFE
Header providing the internals of AVHWAccel.
Definition: hwaccel_internal.h:31
set_sps
static void set_sps(const HEVCSPS *sps, int sps_idx, StdVideoH265ScalingLists *vksps_scaling, StdVideoH265HrdParameters *vksps_vui_header, StdVideoH265SequenceParameterSetVui *vksps_vui, StdVideoH265SequenceParameterSet *vksps, StdVideoH265SubLayerHrdParameters *slhdrnal, StdVideoH265SubLayerHrdParameters *slhdrvcl, StdVideoH265ProfileTierLevel *ptl, StdVideoH265DecPicBufMgr *dpbm, StdVideoH265PredictorPaletteEntries *pal, StdVideoH265ShortTermRefPicSet *str, StdVideoH265LongTermRefPicsSps *ltr)
Definition: vulkan_hevc.c:231
FFVulkanDecodePicture::img_view_ref
VkImageView img_view_ref
Definition: vulkan_decode.h:77
NULL
#define NULL
Definition: coverity.c:32
ScalingList::sl_dc
uint8_t sl_dc[2][6]
Definition: hevc_ps.h:183
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:561
HEVC_MAX_SUB_LAYERS
@ HEVC_MAX_SUB_LAYERS
Definition: hevc.h:105
HEVCVulkanDecodePicture
Definition: vulkan_hevc.c:108
HEVC_MAX_SHORT_TERM_REF_PIC_SETS
@ HEVC_MAX_SHORT_TERM_REF_PIC_SETS
Definition: hevc.h:122
AVCodecContext::internal
struct AVCodecInternal * internal
Private context used for internal data.
Definition: avcodec.h:476
ff_vk_decode_uninit
int ff_vk_decode_uninit(AVCodecContext *avctx)
Free decoder.
Definition: vulkan_decode.c:1090
vk_hevc_create_params
static int vk_hevc_create_params(AVCodecContext *avctx, AVBufferRef **buf)
Definition: vulkan_hevc.c:635
vps
static int FUNC() vps(CodedBitstreamContext *ctx, RWContext *rw, H265RawVPS *current)
Definition: cbs_h265_syntax_template.c:423
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:1004
H265RawProfileTierLevel::general_tier_flag
uint8_t general_tier_flag
Definition: cbs_h265.h:37
HEVCVulkanDecodePicture::vp
FFVulkanDecodePicture vp
Definition: vulkan_hevc.c:109
hevc_data.h
IS_IRAP
#define IS_IRAP(s)
Definition: hevcdec.h:78
HEVCHeaderVPSSet::vcl_hdr
StdVideoH265SubLayerHrdParameters vcl_hdr[HEVC_MAX_SUB_LAYERS]
Definition: vulkan_hevc.c:50
HEVCHeaderPPS::pal
StdVideoH265PredictorPaletteEntries pal
Definition: vulkan_hevc.c:45
set_pps
static void set_pps(const HEVCPPS *pps, const HEVCSPS *sps, StdVideoH265ScalingLists *vkpps_scaling, StdVideoH265PictureParameterSet *vkpps, StdVideoH265PredictorPaletteEntries *pal)
Definition: vulkan_hevc.c:465
HEVCHeaderSPS::ptl
StdVideoH265ProfileTierLevel ptl
Definition: vulkan_hevc.c:34
pps
static int FUNC() pps(CodedBitstreamContext *ctx, RWContext *rw, H264RawPPS *current)
Definition: cbs_h264_syntax_template.c:404
hevcdec.h
HEVCVulkanDecodePicture::h265pic
StdVideoDecodeH265PictureInfo h265pic
Definition: vulkan_hevc.c:121
convert_to_vk_level_idc
static StdVideoH265LevelIdc convert_to_vk_level_idc(int level_idc)
Definition: vulkan_hevc.c:175
AVCodecInternal::hwaccel_priv_data
void * hwaccel_priv_data
hwaccel-specific private data
Definition: internal.h:124
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
size
int size
Definition: twinvq_data.h:10344
FFRefStructOpaque::nc
void * nc
Definition: refstruct.h:59
HEVCVulkanDecodePicture::vkh265_ref
VkVideoDecodeH265DpbSlotInfoKHR vkh265_ref
Definition: vulkan_hevc.c:113
HEVC_MAX_VPS_COUNT
@ HEVC_MAX_VPS_COUNT
Definition: hevc.h:110
HEVCHeaderSet
Definition: vulkan_hevc.c:60
AVHWAccel::name
const char * name
Name of the hardware accelerated codec.
Definition: avcodec.h:2135
HEVCFrame::frame
AVFrame * frame
Definition: hevcdec.h:407
hevc_ps.h
set_vps
static void set_vps(const HEVCVPS *vps, StdVideoH265VideoParameterSet *vkvps, StdVideoH265ProfileTierLevel *ptl, StdVideoH265DecPicBufMgr *dpbm, StdVideoH265HrdParameters *sls_hdr, HEVCHeaderVPSSet sls[])
Definition: vulkan_hevc.c:553
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
HEVCFrame
Definition: hevcdec.h:406
AV_CODEC_ID_HEVC
@ AV_CODEC_ID_HEVC
Definition: codec_id.h:226
FFVulkanDecodePicture::ref_slot
VkVideoReferenceSlotInfoKHR ref_slot
Definition: vulkan_decode.h:88
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:254
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. If there are inter-frame dependencies
FFVulkanDecodePicture::ref_slots
VkVideoReferenceSlotInfoKHR ref_slots[36]
Definition: vulkan_decode.h:92
HEVCFrame::poc
int poc
Definition: hevcdec.h:415
ff_vk_decode_flush
void ff_vk_decode_flush(AVCodecContext *avctx)
Flush decoder.
Definition: vulkan_decode.c:301
HEVCHeaderSPS::str
StdVideoH265ShortTermRefPicSet str[HEVC_MAX_SHORT_TERM_REF_PIC_SETS]
Definition: vulkan_hevc.c:39
ST_CURR_BEF
@ ST_CURR_BEF
Definition: hevcdec.h:81
HEVCVulkanDecodePicture::h265_pic_info
VkVideoDecodeH265PictureInfoKHR h265_pic_info
Definition: vulkan_hevc.c:122
sps
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
Definition: cbs_h264_syntax_template.c:260
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:239
HEVCHeaderVPS::dpbm
StdVideoH265DecPicBufMgr dpbm
Definition: vulkan_hevc.c:55
pos
unsigned int pos
Definition: spdifenc.c:413
HEVCHeaderVPS::hdr
StdVideoH265HrdParameters hdr[HEVC_MAX_LAYER_SETS]
Definition: vulkan_hevc.c:56
FFVulkanDecodeContext::hevc_headers
struct HEVCHeaderSet * hevc_headers
Definition: vulkan_decode.h:67
SIZE_SPECIFIER
#define SIZE_SPECIFIER
Definition: internal.h:141
LT_CURR
@ LT_CURR
Definition: hevcdec.h:84
AVCodecContext
main external API structure.
Definition: avcodec.h:441
AVFrame::height
int height
Definition: frame.h:412
FFVulkanDecodeContext::dedicated_dpb
int dedicated_dpb
Definition: vulkan_decode.h:61
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
HEVCContext
Definition: hevcdec.h:494
ref
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:112
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:109
ff_hevc_diag_scan4x4_x
const uint8_t ff_hevc_diag_scan4x4_x[16]
Definition: hevc_data.c:25
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:68
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
flush
void(* flush)(AVBSFContext *ctx)
Definition: dts2pts_bsf.c:367
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
HEVCVPS
Definition: hevc_ps.h:153
HEVCSPS
Definition: hevc_ps.h:186
HEVCPPS
Definition: hevc_ps.h:303
vulkan_decode.h
ST_CURR_AFT
@ ST_CURR_AFT
Definition: hevcdec.h:82
HEVCPPS::sps_id
unsigned int sps_id
seq_parameter_set_id
Definition: hevc_ps.h:305
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:468
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
FFVulkanDecodeContext::layered_dpb
int layered_dpb
Definition: vulkan_decode.h:62
HEVCHeaderSPS::vcl_hdr
StdVideoH265SubLayerHrdParameters vcl_hdr[HEVC_MAX_SUB_LAYERS]
Definition: vulkan_hevc.c:38
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
ff_vk_decode_init
int ff_vk_decode_init(AVCodecContext *avctx)
Initialize decoder.
Definition: vulkan_decode.c:1105
uninit
static av_cold int uninit(AVCodecContext *avctx)
Definition: crystalhd.c:285
h
h
Definition: vp9dsp_template.c:2038
FFVulkanDecodePicture::decode_info
VkVideoDecodeInfoKHR decode_info
Definition: vulkan_decode.h:95
HEVCHeaderSet::vps
StdVideoH265VideoParameterSet vps[HEVC_MAX_PPS_COUNT]
Definition: vulkan_hevc.c:67
HEVC_MAX_PPS_COUNT
@ HEVC_MAX_PPS_COUNT
Definition: hevc.h:114
HEVCHeaderVPS::ptl
StdVideoH265ProfileTierLevel ptl
Definition: vulkan_hevc.c:54
HEVCHeaderSet::sps
StdVideoH265SequenceParameterSet sps[HEVC_MAX_SPS_COUNT]
Definition: vulkan_hevc.c:61