28 .decode_op = VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR,
30 .extensionName = VK_STD_VULKAN_VIDEO_CODEC_H265_DECODE_EXTENSION_NAME,
31 .specVersion = VK_STD_VULKAN_VIDEO_CODEC_H265_DECODE_SPEC_VERSION,
38 StdVideoH265SequenceParameterSetVui
vui;
39 StdVideoH265ProfileTierLevel
ptl;
40 StdVideoH265DecPicBufMgr
dpbm;
41 StdVideoH265PredictorPaletteEntries
pal;
45 StdVideoH265LongTermRefPicsSps
ltr;
50 StdVideoH265PredictorPaletteEntries
pal;
59 StdVideoH265ProfileTierLevel
ptl;
60 StdVideoH265DecPicBufMgr
dpbm;
85 for (
int i = 0;
i < nb_vps;
i++) {
90 if (buf_size >
s->hevc_headers_size) {
92 s->hevc_headers_size = 0;
96 s->hevc_headers_size = buf_size;
100 hdr =
s->hevc_headers;
101 data_ptr = (uint8_t *)hdr;
104 for (
int i = 0;
i < nb_vps;
i++) {
131 VkVideoReferenceSlotInfoKHR *ref_slot,
132 VkVideoPictureResourceInfoKHR *
ref,
133 VkVideoDecodeH265DpbSlotInfoKHR *vkh265_ref,
134 StdVideoDecodeH265ReferenceInfo *h265_ref,
135 HEVCFrame *pic,
int is_current,
int pic_id)
146 *h265_ref = (StdVideoDecodeH265ReferenceInfo) {
147 .flags = (StdVideoDecodeH265ReferenceInfoFlags) {
149 .unused_for_reference = 0,
151 .PicOrderCntVal = pic->
poc,
154 *vkh265_ref = (VkVideoDecodeH265DpbSlotInfoKHR) {
155 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_DPB_SLOT_INFO_KHR,
156 .pStdReferenceInfo = h265_ref,
159 *
ref = (VkVideoPictureResourceInfoKHR) {
160 .sType = VK_STRUCTURE_TYPE_VIDEO_PICTURE_RESOURCE_INFO_KHR,
161 .codedOffset = (VkOffset2D){ 0, 0 },
167 *ref_slot = (VkVideoReferenceSlotInfoKHR) {
168 .sType = VK_STRUCTURE_TYPE_VIDEO_REFERENCE_SLOT_INFO_KHR,
171 .pPictureResource =
ref,
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;
195 case 62:
return STD_VIDEO_H265_LEVEL_IDC_6_2;
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++) {
204 vksl->ScalingList4x4[
i][j] = sl->
sl[0][
i][
pos];
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++) {
211 vksl->ScalingList8x8[
i][j] = sl->
sl[1][
i][
pos];
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++) {
218 vksl->ScalingList16x16[
i][j] = sl->
sl[2][
i][
pos];
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++) {
225 vksl->ScalingList32x32[
i][j] = sl->
sl[3][
i * 3][
pos];
229 memcpy(vksl->ScalingListDCCoef16x16, sl->
sl_dc[0],
230 STD_VIDEO_H265_SCALING_LIST_16X16_NUM_LISTS *
sizeof(*vksl->ScalingListDCCoef16x16));
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];
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)
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,
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,
271 .pSubLayerHrdParametersNal = slhdrnal,
272 .pSubLayerHrdParametersVcl = slhdrvcl,
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));
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,
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,
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,
330 *
ptl = (StdVideoH265ProfileTierLevel) {
331 .flags = (StdVideoH265ProfileTierLevelFlags) {
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,
338 .general_profile_idc =
sps->ptl.general_ptl.profile_idc,
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;
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];
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,
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,
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,
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;
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;
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;
387 *ltr = (StdVideoH265LongTermRefPicsSps) {
388 .used_by_curr_pic_lt_sps_flag = 0x0,
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];
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,
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);
748 hp->
h265pic = (StdVideoDecodeH265PictureInfo) {
749 .flags = (StdVideoDecodeH265PictureInfoFlags) {
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,
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,
790 memset(hp->
h265pic.RefPicSetStCurrBefore, 0xff, 8);
796 hp->
h265pic.RefPicSetStCurrBefore[
i] = j;
801 memset(hp->
h265pic.RefPicSetStCurrAfter, 0xff, 8);
807 hp->
h265pic.RefPicSetStCurrAfter[
i] = j;
812 memset(hp->
h265pic.RefPicSetLtCurr, 0xff, 8);
813 for (
int i = 0;
i <
h->rps[
LT_CURR].nb_refs;
i++) {
825 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PICTURE_INFO_KHR,
826 .pStdPictureInfo = &hp->
h265pic,
827 .sliceSegmentCount = 0,
831 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_INFO_KHR,
834 .pSetupReferenceSlot = &vp->
ref_slot,
835 .referenceSlotCount = nb_refs,
837 .dstPictureResource = (VkVideoPictureResourceInfoKHR) {
838 .sType = VK_STRUCTURE_TYPE_VIDEO_PICTURE_RESOURCE_INFO_KHR,
839 .codedOffset = (VkOffset2D){ 0, 0 },
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];
892 "Encountered frame without a valid active PPS reference.\n");
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;
927 .
p.
name =
"hevc_vulkan",