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