29 .decode_op = VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR,
31 .extensionName = VK_STD_VULKAN_VIDEO_CODEC_H265_DECODE_EXTENSION_NAME,
32 .specVersion = VK_STD_VULKAN_VIDEO_CODEC_H265_DECODE_SPEC_VERSION,
39 StdVideoH265SequenceParameterSetVui
vui;
40 StdVideoH265ProfileTierLevel
ptl;
41 StdVideoH265DecPicBufMgr
dpbm;
42 StdVideoH265PredictorPaletteEntries
pal;
46 StdVideoH265LongTermRefPicsSps
ltr;
51 StdVideoH265PredictorPaletteEntries
pal;
60 StdVideoH265ProfileTierLevel
ptl;
61 StdVideoH265DecPicBufMgr
dpbm;
86 for (
int i = 0;
i < nb_vps;
i++) {
91 if (buf_size >
s->hevc_headers_size) {
93 s->hevc_headers_size = 0;
97 s->hevc_headers_size = buf_size;
101 hdr =
s->hevc_headers;
102 data_ptr = (uint8_t *)hdr;
105 for (
int i = 0;
i < nb_vps;
i++) {
132 VkVideoReferenceSlotInfoKHR *ref_slot,
133 VkVideoPictureResourceInfoKHR *
ref,
134 VkVideoDecodeH265DpbSlotInfoKHR *vkh265_ref,
135 StdVideoDecodeH265ReferenceInfo *h265_ref,
136 HEVCFrame *pic,
int is_current,
int pic_id)
147 *h265_ref = (StdVideoDecodeH265ReferenceInfo) {
148 .flags = (StdVideoDecodeH265ReferenceInfoFlags) {
150 .unused_for_reference = 0,
152 .PicOrderCntVal = pic->
poc,
155 *vkh265_ref = (VkVideoDecodeH265DpbSlotInfoKHR) {
156 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_DPB_SLOT_INFO_KHR,
157 .pStdReferenceInfo = h265_ref,
160 *
ref = (VkVideoPictureResourceInfoKHR) {
161 .sType = VK_STRUCTURE_TYPE_VIDEO_PICTURE_RESOURCE_INFO_KHR,
162 .codedOffset = (VkOffset2D){ 0, 0 },
163 .codedExtent = (VkExtent2D){ pic->
f->
width, pic->
f->
height },
168 *ref_slot = (VkVideoReferenceSlotInfoKHR) {
169 .sType = VK_STRUCTURE_TYPE_VIDEO_REFERENCE_SLOT_INFO_KHR,
172 .pPictureResource =
ref,
184 case 10:
return STD_VIDEO_H265_LEVEL_IDC_1_0;
185 case 20:
return STD_VIDEO_H265_LEVEL_IDC_2_0;
186 case 21:
return STD_VIDEO_H265_LEVEL_IDC_2_1;
187 case 30:
return STD_VIDEO_H265_LEVEL_IDC_3_0;
188 case 31:
return STD_VIDEO_H265_LEVEL_IDC_3_1;
189 case 40:
return STD_VIDEO_H265_LEVEL_IDC_4_0;
190 case 41:
return STD_VIDEO_H265_LEVEL_IDC_4_1;
191 case 50:
return STD_VIDEO_H265_LEVEL_IDC_5_0;
192 case 51:
return STD_VIDEO_H265_LEVEL_IDC_5_1;
193 case 60:
return STD_VIDEO_H265_LEVEL_IDC_6_0;
194 case 61:
return STD_VIDEO_H265_LEVEL_IDC_6_1;
196 case 62:
return STD_VIDEO_H265_LEVEL_IDC_6_2;
202 for (
int i = 0;
i < STD_VIDEO_H265_SCALING_LIST_4X4_NUM_LISTS;
i++) {
203 for (
int j = 0; j < STD_VIDEO_H265_SCALING_LIST_4X4_NUM_ELEMENTS; j++) {
205 vksl->ScalingList4x4[
i][j] = sl->
sl[0][
i][
pos];
209 for (
int i = 0;
i < STD_VIDEO_H265_SCALING_LIST_8X8_NUM_LISTS;
i++) {
210 for (
int j = 0; j < STD_VIDEO_H265_SCALING_LIST_8X8_NUM_ELEMENTS; j++) {
212 vksl->ScalingList8x8[
i][j] = sl->
sl[1][
i][
pos];
216 for (
int i = 0;
i < STD_VIDEO_H265_SCALING_LIST_16X16_NUM_LISTS;
i++) {
217 for (
int j = 0; j < STD_VIDEO_H265_SCALING_LIST_16X16_NUM_ELEMENTS; j++) {
219 vksl->ScalingList16x16[
i][j] = sl->
sl[2][
i][
pos];
223 for (
int i = 0;
i < STD_VIDEO_H265_SCALING_LIST_32X32_NUM_LISTS;
i++) {
224 for (
int j = 0; j < STD_VIDEO_H265_SCALING_LIST_32X32_NUM_ELEMENTS; j++) {
226 vksl->ScalingList32x32[
i][j] = sl->
sl[3][
i * 3][
pos];
230 memcpy(vksl->ScalingListDCCoef16x16, sl->
sl_dc[0],
231 STD_VIDEO_H265_SCALING_LIST_16X16_NUM_LISTS *
sizeof(*vksl->ScalingListDCCoef16x16));
233 for (
int i = 0;
i < STD_VIDEO_H265_SCALING_LIST_32X32_NUM_LISTS;
i++)
234 vksl->ScalingListDCCoef32x32[
i] = sl->
sl_dc[1][
i * 3];
238 StdVideoH265ScalingLists *vksps_scaling,
239 StdVideoH265HrdParameters *vksps_vui_header,
240 StdVideoH265SequenceParameterSetVui *vksps_vui,
241 StdVideoH265SequenceParameterSet *vksps,
242 StdVideoH265SubLayerHrdParameters *slhdrnal,
243 StdVideoH265SubLayerHrdParameters *slhdrvcl,
244 StdVideoH265ProfileTierLevel *
ptl,
245 StdVideoH265DecPicBufMgr *dpbm,
246 StdVideoH265PredictorPaletteEntries *pal,
247 StdVideoH265ShortTermRefPicSet *str,
248 StdVideoH265LongTermRefPicsSps *ltr)
252 *vksps_vui_header = (StdVideoH265HrdParameters) {
253 .flags = (StdVideoH265HrdFlags) {
254 .nal_hrd_parameters_present_flag =
sps->hdr.nal_hrd_parameters_present_flag,
255 .vcl_hrd_parameters_present_flag =
sps->hdr.vcl_hrd_parameters_present_flag,
256 .sub_pic_hrd_params_present_flag =
sps->hdr.sub_pic_hrd_params_present_flag,
257 .sub_pic_cpb_params_in_pic_timing_sei_flag =
sps->hdr.sub_pic_cpb_params_in_pic_timing_sei_flag,
258 .fixed_pic_rate_general_flag =
sps->hdr.flags.fixed_pic_rate_general_flag,
259 .fixed_pic_rate_within_cvs_flag =
sps->hdr.flags.fixed_pic_rate_within_cvs_flag,
260 .low_delay_hrd_flag =
sps->hdr.flags.low_delay_hrd_flag,
262 .tick_divisor_minus2 =
sps->hdr.tick_divisor_minus2,
263 .du_cpb_removal_delay_increment_length_minus1 =
sps->hdr.du_cpb_removal_delay_increment_length_minus1,
264 .dpb_output_delay_du_length_minus1 =
sps->hdr.dpb_output_delay_du_length_minus1,
265 .bit_rate_scale =
sps->hdr.bit_rate_scale,
266 .cpb_size_scale =
sps->hdr.cpb_size_scale,
267 .cpb_size_du_scale =
sps->hdr.cpb_size_du_scale,
268 .initial_cpb_removal_delay_length_minus1 =
sps->hdr.initial_cpb_removal_delay_length_minus1,
269 .au_cpb_removal_delay_length_minus1 =
sps->hdr.au_cpb_removal_delay_length_minus1,
270 .dpb_output_delay_length_minus1 =
sps->hdr.dpb_output_delay_length_minus1,
272 .pSubLayerHrdParametersNal = slhdrnal,
273 .pSubLayerHrdParametersVcl = slhdrvcl,
276 memcpy(vksps_vui_header->cpb_cnt_minus1,
sps->hdr.cpb_cnt_minus1,
277 STD_VIDEO_H265_SUBLAYERS_LIST_SIZE*
sizeof(*vksps_vui_header->cpb_cnt_minus1));
278 memcpy(vksps_vui_header->elemental_duration_in_tc_minus1,
sps->hdr.elemental_duration_in_tc_minus1,
279 STD_VIDEO_H265_SUBLAYERS_LIST_SIZE*
sizeof(*vksps_vui_header->elemental_duration_in_tc_minus1));
284 *vksps_vui = (StdVideoH265SequenceParameterSetVui) {
285 .flags = (StdVideoH265SpsVuiFlags) {
286 .aspect_ratio_info_present_flag =
sps->vui.common.aspect_ratio_info_present_flag,
287 .overscan_info_present_flag =
sps->vui.common.overscan_info_present_flag,
288 .overscan_appropriate_flag =
sps->vui.common.overscan_appropriate_flag,
289 .video_signal_type_present_flag =
sps->vui.common.video_signal_type_present_flag,
290 .video_full_range_flag =
sps->vui.common.video_full_range_flag,
291 .colour_description_present_flag =
sps->vui.common.colour_description_present_flag,
292 .chroma_loc_info_present_flag =
sps->vui.common.chroma_loc_info_present_flag,
293 .neutral_chroma_indication_flag =
sps->vui.neutra_chroma_indication_flag,
294 .field_seq_flag =
sps->vui.field_seq_flag,
295 .frame_field_info_present_flag =
sps->vui.frame_field_info_present_flag,
296 .default_display_window_flag =
sps->vui.default_display_window_flag,
297 .vui_timing_info_present_flag =
sps->vui.vui_timing_info_present_flag,
298 .vui_poc_proportional_to_timing_flag =
sps->vui.vui_poc_proportional_to_timing_flag,
299 .vui_hrd_parameters_present_flag =
sps->vui.vui_hrd_parameters_present_flag,
300 .bitstream_restriction_flag =
sps->vui.bitstream_restriction_flag,
301 .tiles_fixed_structure_flag =
sps->vui.tiles_fixed_structure_flag,
302 .motion_vectors_over_pic_boundaries_flag =
sps->vui.motion_vectors_over_pic_boundaries_flag,
303 .restricted_ref_pic_lists_flag =
sps->vui.restricted_ref_pic_lists_flag,
305 .aspect_ratio_idc =
sps->vui.common.aspect_ratio_idc,
306 .sar_width =
sps->vui.common.sar.num,
307 .sar_height =
sps->vui.common.sar.den,
308 .video_format =
sps->vui.common.video_format,
309 .colour_primaries =
sps->vui.common.colour_primaries,
310 .transfer_characteristics =
sps->vui.common.transfer_characteristics,
311 .matrix_coeffs =
sps->vui.common.matrix_coeffs,
312 .chroma_sample_loc_type_top_field =
sps->vui.common.chroma_sample_loc_type_top_field,
313 .chroma_sample_loc_type_bottom_field =
sps->vui.common.chroma_sample_loc_type_bottom_field,
316 .def_disp_win_left_offset =
sps->vui.def_disp_win.left_offset,
317 .def_disp_win_right_offset =
sps->vui.def_disp_win.right_offset,
318 .def_disp_win_top_offset =
sps->vui.def_disp_win.top_offset,
319 .def_disp_win_bottom_offset =
sps->vui.def_disp_win.bottom_offset,
320 .vui_num_units_in_tick =
sps->vui.vui_num_units_in_tick,
321 .vui_time_scale =
sps->vui.vui_time_scale,
322 .vui_num_ticks_poc_diff_one_minus1 =
sps->vui.vui_num_ticks_poc_diff_one_minus1,
323 .min_spatial_segmentation_idc =
sps->vui.min_spatial_segmentation_idc,
324 .max_bytes_per_pic_denom =
sps->vui.max_bytes_per_pic_denom,
325 .max_bits_per_min_cu_denom =
sps->vui.max_bits_per_min_cu_denom,
326 .log2_max_mv_length_horizontal =
sps->vui.log2_max_mv_length_horizontal,
327 .log2_max_mv_length_vertical =
sps->vui.log2_max_mv_length_vertical,
328 .pHrdParameters = vksps_vui_header,
331 *
ptl = (StdVideoH265ProfileTierLevel) {
332 .flags = (StdVideoH265ProfileTierLevelFlags) {
334 .general_progressive_source_flag =
sps->ptl.general_ptl.progressive_source_flag,
335 .general_interlaced_source_flag =
sps->ptl.general_ptl.interlaced_source_flag,
336 .general_non_packed_constraint_flag =
sps->ptl.general_ptl.non_packed_constraint_flag,
337 .general_frame_only_constraint_flag =
sps->ptl.general_ptl.frame_only_constraint_flag,
339 .general_profile_idc =
sps->ptl.general_ptl.profile_idc,
343 for (
int i = 0;
i <
sps->max_sub_layers;
i++) {
344 dpbm->max_latency_increase_plus1[
i] =
sps->temporal_layer[
i].max_latency_increase + 1;
345 dpbm->max_dec_pic_buffering_minus1[
i] =
sps->temporal_layer[
i].max_dec_pic_buffering - 1;
346 dpbm->max_num_reorder_pics[
i] =
sps->temporal_layer[
i].num_reorder_pics;
349 for (
int i = 0;
i < (
sps->chroma_format_idc ? 3 : 1);
i++)
350 for (
int j = 0; j <
sps->sps_num_palette_predictor_initializers; j++)
351 pal->PredictorPaletteEntries[
i][j] =
sps->sps_palette_predictor_initializer[
i][j];
353 for (
int i = 0;
i <
sps->nb_st_rps;
i++) {
356 str[
i] = (StdVideoH265ShortTermRefPicSet) {
357 .flags = (StdVideoH265ShortTermRefPicSetFlags) {
358 .inter_ref_pic_set_prediction_flag =
sps->st_rps[
i].rps_predict,
359 .delta_rps_sign =
sps->st_rps[
i].delta_rps_sign,
361 .delta_idx_minus1 =
sps->st_rps[
i].delta_idx - 1,
362 .use_delta_flag =
sps->st_rps[
i].use_delta,
363 .abs_delta_rps_minus1 =
sps->st_rps[
i].abs_delta_rps - 1,
364 .used_by_curr_pic_flag = 0x0,
365 .used_by_curr_pic_s0_flag = 0x0,
366 .used_by_curr_pic_s1_flag = 0x0,
370 .num_negative_pics =
sps->st_rps[
i].num_negative_pics,
371 .num_positive_pics =
sps->st_rps[
i].num_delta_pocs -
sps->st_rps[
i].num_negative_pics,
376 str[
i].used_by_curr_pic_flag = st_rps->
used;
378 str[
i].used_by_curr_pic_s1_flag = st_rps->
used >> str[
i].num_negative_pics;
380 for (
int j = 0; j < str[
i].num_negative_pics; j++)
381 str[
i].delta_poc_s0_minus1[j] = st_rps->
delta_poc[j] - (j ? st_rps->
delta_poc[j - 1] : 0) - 1;
383 for (
int j = 0; j < str[
i].num_positive_pics; j++)
388 *ltr = (StdVideoH265LongTermRefPicsSps) {
389 .used_by_curr_pic_lt_sps_flag =
sps->used_by_curr_pic_lt,
392 for (
int i = 0;
i <
sps->num_long_term_ref_pics_sps;
i++) {
393 ltr->lt_ref_pic_poc_lsb_sps[
i] =
sps->lt_ref_pic_poc_lsb_sps[
i];
396 *vksps = (StdVideoH265SequenceParameterSet) {
397 .flags = (StdVideoH265SpsFlags) {
398 .sps_temporal_id_nesting_flag =
sps->temporal_id_nesting,
399 .separate_colour_plane_flag =
sps->separate_colour_plane,
400 .conformance_window_flag =
sps->conformance_window,
401 .sps_sub_layer_ordering_info_present_flag =
sps->sublayer_ordering_info,
402 .scaling_list_enabled_flag =
sps->scaling_list_enabled,
403 .sps_scaling_list_data_present_flag =
sps->scaling_list_enabled,
404 .amp_enabled_flag =
sps->amp_enabled,
405 .sample_adaptive_offset_enabled_flag =
sps->sao_enabled,
406 .pcm_enabled_flag =
sps->pcm_enabled,
407 .pcm_loop_filter_disabled_flag =
sps->pcm_loop_filter_disabled,
408 .long_term_ref_pics_present_flag =
sps->long_term_ref_pics_present,
409 .sps_temporal_mvp_enabled_flag =
sps->temporal_mvp_enabled,
410 .strong_intra_smoothing_enabled_flag =
sps->strong_intra_smoothing_enabled,
411 .vui_parameters_present_flag =
sps->vui_present,
412 .sps_extension_present_flag =
sps->extension_present,
413 .sps_range_extension_flag =
sps->range_extension,
414 .transform_skip_rotation_enabled_flag =
sps->transform_skip_rotation_enabled,
415 .transform_skip_context_enabled_flag =
sps->transform_skip_context_enabled,
416 .implicit_rdpcm_enabled_flag =
sps->implicit_rdpcm_enabled,
417 .explicit_rdpcm_enabled_flag =
sps->explicit_rdpcm_enabled,
418 .extended_precision_processing_flag =
sps->extended_precision_processing,
419 .intra_smoothing_disabled_flag =
sps->intra_smoothing_disabled,
420 .high_precision_offsets_enabled_flag =
sps->high_precision_offsets_enabled,
421 .persistent_rice_adaptation_enabled_flag =
sps->persistent_rice_adaptation_enabled,
422 .cabac_bypass_alignment_enabled_flag =
sps->cabac_bypass_alignment_enabled,
423 .sps_scc_extension_flag =
sps->scc_extension,
424 .sps_curr_pic_ref_enabled_flag =
sps->curr_pic_ref_enabled,
425 .palette_mode_enabled_flag =
sps->palette_mode_enabled,
426 .sps_palette_predictor_initializers_present_flag =
sps->palette_predictor_initializers_present,
427 .intra_boundary_filtering_disabled_flag =
sps->intra_boundary_filtering_disabled,
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,
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,
471 StdVideoH265ScalingLists *vkpps_scaling,
472 StdVideoH265PictureParameterSet *vkpps,
473 StdVideoH265PredictorPaletteEntries *pal)
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,
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,
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];
546 for (
int i = 0;
i <
pps->num_tile_columns - 1;
i++)
547 vkpps->column_width_minus1[
i] =
pps->column_width[
i] - 1;
549 for (
int i = 0;
i <
pps->num_tile_rows - 1;
i++)
550 vkpps->row_height_minus1[
i] =
pps->row_height[
i] - 1;
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];
559 StdVideoH265VideoParameterSet *vkvps,
560 StdVideoH265ProfileTierLevel *
ptl,
561 StdVideoH265DecPicBufMgr *dpbm,
562 StdVideoH265HrdParameters *sls_hdr,
565 for (
int i = 0;
i <
vps->vps_num_hrd_parameters;
i++) {
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,
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,
588 .pSubLayerHrdParametersNal = sls[
i].
nal_hdr,
589 .pSubLayerHrdParametersVcl = sls[
i].
vcl_hdr,
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));
601 *
ptl = (StdVideoH265ProfileTierLevel) {
602 .flags = (StdVideoH265ProfileTierLevelFlags) {
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,
609 .general_profile_idc =
vps->ptl.general_ptl.profile_idc,
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];
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,
626 .vps_video_parameter_set_id =
vps->vps_id,
627 .vps_max_sub_layers_minus1 =
vps->vps_max_sub_layers - 1,
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,
634 .pDecPicBufMgr = dpbm,
635 .pHrdParameters = sls_hdr,
636 .pProfileTierLevel =
ptl,
647 VkVideoDecodeH265SessionParametersAddInfoKHR h265_params_info = {
648 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_SESSION_PARAMETERS_ADD_INFO_KHR,
653 VkVideoDecodeH265SessionParametersCreateInfoKHR h265_params = {
654 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_SESSION_PARAMETERS_CREATE_INFO_KHR,
655 .pParametersAddInfo = &h265_params_info,
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,
669 if (
h->ps.vps_list[
i])
670 vps_list_idx[nb_vps++] =
i;
678 h265_params_info.pStdSPSs = hdr->
sps;
679 h265_params_info.pStdPPSs = hdr->
pps;
680 h265_params_info.pStdVPSs = hdr->
vps;
684 if (
h->ps.sps_list[
i]) {
685 const HEVCSPS *sps_l =
h->ps.sps_list[
i];
686 int idx = h265_params_info.stdSPSCount++;
696 if (
h->ps.pps_list[
i]) {
697 const HEVCPPS *pps_l =
h->ps.pps_list[
i];
699 int idx = h265_params_info.stdPPSCount++;
706 for (
int i = 0;
i < nb_vps;
i++) {
707 const HEVCVPS *vps_l =
h->ps.vps_list[vps_list_idx[
i]];
710 h265_params_info.stdVPSCount++;
713 h265_params.maxStdSPSCount = h265_params_info.stdSPSCount;
714 h265_params.maxStdPPSCount = h265_params_info.stdPPSCount;
715 h265_params.maxStdVPSCount = h265_params_info.stdVPSCount;
722 h265_params_info.stdSPSCount, h265_params_info.stdPPSCount,
723 h265_params_info.stdVPSCount);
749 hp->
h265pic = (StdVideoDecodeH265PictureInfo) {
750 .flags = (StdVideoDecodeH265PictureInfoFlags) {
753 .IsReference =
h->nal_unit_type < 16 ?
h->nal_unit_type & 1 : 1,
754 .short_term_ref_pic_set_sps_flag =
h->sh.short_term_ref_pic_set_sps_flag,
756 .sps_video_parameter_set_id =
sps->vps_id,
757 .pps_seq_parameter_set_id =
pps->sps_id,
758 .pps_pic_parameter_set_id =
pps->pps_id,
759 .NumDeltaPocsOfRefRpsIdx =
h->sh.short_term_rps ?
h->sh.short_term_rps->rps_idx_num_delta_pocs : 0,
760 .PicOrderCntVal =
h->poc,
761 .NumBitsForSTRefPicSetInSlice = !
h->sh.short_term_ref_pic_set_sps_flag ?
762 h->sh.short_term_ref_pic_set_size : 0,
791 memset(hp->
h265pic.RefPicSetStCurrBefore, 0xff, 8);
797 hp->
h265pic.RefPicSetStCurrBefore[
i] = j;
802 memset(hp->
h265pic.RefPicSetStCurrAfter, 0xff, 8);
808 hp->
h265pic.RefPicSetStCurrAfter[
i] = j;
813 memset(hp->
h265pic.RefPicSetLtCurr, 0xff, 8);
814 for (
int i = 0;
i <
h->rps[
LT_CURR].nb_refs;
i++) {
826 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PICTURE_INFO_KHR,
827 .pStdPictureInfo = &hp->
h265pic,
828 .sliceSegmentCount = 0,
832 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_INFO_KHR,
835 .pSetupReferenceSlot = &vp->
ref_slot,
836 .referenceSlotCount = nb_refs,
838 .dstPictureResource = (VkVideoPictureResourceInfoKHR) {
839 .sType = VK_STRUCTURE_TYPE_VIDEO_PICTURE_RESOURCE_INFO_KHR,
840 .codedOffset = (VkOffset2D){ 0, 0 },
841 .codedExtent = (VkExtent2D){ pic->
f->
width, pic->
f->
height },
886 unsigned int pps_id =
h->sh.pps_id;
887 if (pps_id < HEVC_MAX_PPS_COUNT && h->ps.pps_list[pps_id] !=
NULL)
888 pps =
h->ps.pps_list[pps_id];
893 "Encountered frame without a valid active PPS reference.\n");
901 hp->
h265pic.sps_video_parameter_set_id =
sps->vps_id;
902 hp->
h265pic.pps_seq_parameter_set_id =
pps->sps_id;
903 hp->
h265pic.pps_pic_parameter_set_id =
pps->pps_id;
928 .
p.
name =
"hevc_vulkan",