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