26 .extensionName = VK_STD_VULKAN_VIDEO_CODEC_H265_DECODE_EXTENSION_NAME,
27 .specVersion = VK_STD_VULKAN_VIDEO_CODEC_H265_DECODE_SPEC_VERSION,
33 StdVideoH265SequenceParameterSetVui
vui;
34 StdVideoH265ProfileTierLevel
ptl;
35 StdVideoH265DecPicBufMgr
dpbm;
36 StdVideoH265PredictorPaletteEntries
pal;
40 StdVideoH265LongTermRefPicsSps
ltr;
45 StdVideoH265PredictorPaletteEntries
pal;
54 StdVideoH265ProfileTierLevel
ptl;
55 StdVideoH265DecPicBufMgr
dpbm;
80 for (
int i = 0;
i < nb_vps;
i++) {
85 if (buf_size >
s->hevc_headers_size) {
87 s->hevc_headers_size = 0;
91 s->hevc_headers_size = buf_size;
95 hdr =
s->hevc_headers;
96 data_ptr = (uint8_t *)hdr;
99 for (
int i = 0;
i < nb_vps;
i++) {
126 VkVideoReferenceSlotInfoKHR *ref_slot,
127 VkVideoPictureResourceInfoKHR *
ref,
128 VkVideoDecodeH265DpbSlotInfoKHR *vkh265_ref,
129 StdVideoDecodeH265ReferenceInfo *h265_ref,
130 HEVCFrame *pic,
int is_current,
int pic_id)
141 *h265_ref = (StdVideoDecodeH265ReferenceInfo) {
142 .flags = (StdVideoDecodeH265ReferenceInfoFlags) {
144 .unused_for_reference = 0,
146 .PicOrderCntVal = pic->
poc,
149 *vkh265_ref = (VkVideoDecodeH265DpbSlotInfoKHR) {
150 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_DPB_SLOT_INFO_KHR,
151 .pStdReferenceInfo = h265_ref,
154 *
ref = (VkVideoPictureResourceInfoKHR) {
155 .sType = VK_STRUCTURE_TYPE_VIDEO_PICTURE_RESOURCE_INFO_KHR,
156 .codedOffset = (VkOffset2D){ 0, 0 },
162 *ref_slot = (VkVideoReferenceSlotInfoKHR) {
163 .sType = VK_STRUCTURE_TYPE_VIDEO_REFERENCE_SLOT_INFO_KHR,
166 .pPictureResource =
ref,
178 case 10:
return STD_VIDEO_H265_LEVEL_IDC_1_0;
179 case 20:
return STD_VIDEO_H265_LEVEL_IDC_2_0;
180 case 21:
return STD_VIDEO_H265_LEVEL_IDC_2_1;
181 case 30:
return STD_VIDEO_H265_LEVEL_IDC_3_0;
182 case 31:
return STD_VIDEO_H265_LEVEL_IDC_3_1;
183 case 40:
return STD_VIDEO_H265_LEVEL_IDC_4_0;
184 case 41:
return STD_VIDEO_H265_LEVEL_IDC_4_1;
185 case 50:
return STD_VIDEO_H265_LEVEL_IDC_5_0;
186 case 51:
return STD_VIDEO_H265_LEVEL_IDC_5_1;
187 case 60:
return STD_VIDEO_H265_LEVEL_IDC_6_0;
188 case 61:
return STD_VIDEO_H265_LEVEL_IDC_6_1;
190 case 62:
return STD_VIDEO_H265_LEVEL_IDC_6_2;
196 for (
int i = 0;
i < STD_VIDEO_H265_SCALING_LIST_4X4_NUM_LISTS;
i++) {
197 for (
int j = 0; j < STD_VIDEO_H265_SCALING_LIST_4X4_NUM_ELEMENTS; j++) {
199 vksl->ScalingList4x4[
i][j] = sl->
sl[0][
i][
pos];
203 for (
int i = 0;
i < STD_VIDEO_H265_SCALING_LIST_8X8_NUM_LISTS;
i++) {
204 for (
int j = 0; j < STD_VIDEO_H265_SCALING_LIST_8X8_NUM_ELEMENTS; j++) {
206 vksl->ScalingList8x8[
i][j] = sl->
sl[1][
i][
pos];
210 for (
int i = 0;
i < STD_VIDEO_H265_SCALING_LIST_16X16_NUM_LISTS;
i++) {
211 for (
int j = 0; j < STD_VIDEO_H265_SCALING_LIST_16X16_NUM_ELEMENTS; j++) {
213 vksl->ScalingList16x16[
i][j] = sl->
sl[2][
i][
pos];
217 for (
int i = 0;
i < STD_VIDEO_H265_SCALING_LIST_32X32_NUM_LISTS;
i++) {
218 for (
int j = 0; j < STD_VIDEO_H265_SCALING_LIST_32X32_NUM_ELEMENTS; j++) {
220 vksl->ScalingList32x32[
i][j] = sl->
sl[3][
i * 3][
pos];
224 memcpy(vksl->ScalingListDCCoef16x16, sl->
sl_dc[0],
225 STD_VIDEO_H265_SCALING_LIST_16X16_NUM_LISTS *
sizeof(*vksl->ScalingListDCCoef16x16));
227 for (
int i = 0;
i < STD_VIDEO_H265_SCALING_LIST_32X32_NUM_LISTS;
i++)
228 vksl->ScalingListDCCoef32x32[
i] = sl->
sl_dc[1][
i * 3];
232 StdVideoH265ScalingLists *vksps_scaling,
233 StdVideoH265HrdParameters *vksps_vui_header,
234 StdVideoH265SequenceParameterSetVui *vksps_vui,
235 StdVideoH265SequenceParameterSet *vksps,
236 StdVideoH265SubLayerHrdParameters *slhdrnal,
237 StdVideoH265SubLayerHrdParameters *slhdrvcl,
238 StdVideoH265ProfileTierLevel *
ptl,
239 StdVideoH265DecPicBufMgr *dpbm,
240 StdVideoH265PredictorPaletteEntries *pal,
241 StdVideoH265ShortTermRefPicSet *str,
242 StdVideoH265LongTermRefPicsSps *ltr)
246 *vksps_vui_header = (StdVideoH265HrdParameters) {
247 .flags = (StdVideoH265HrdFlags) {
248 .nal_hrd_parameters_present_flag =
sps->hdr.flags.nal_hrd_parameters_present_flag,
249 .vcl_hrd_parameters_present_flag =
sps->hdr.flags.vcl_hrd_parameters_present_flag,
250 .sub_pic_hrd_params_present_flag =
sps->hdr.flags.sub_pic_hrd_params_present_flag,
251 .sub_pic_cpb_params_in_pic_timing_sei_flag =
sps->hdr.flags.sub_pic_cpb_params_in_pic_timing_sei_flag,
252 .fixed_pic_rate_general_flag =
sps->hdr.flags.fixed_pic_rate_general_flag,
253 .fixed_pic_rate_within_cvs_flag =
sps->hdr.flags.fixed_pic_rate_within_cvs_flag,
254 .low_delay_hrd_flag =
sps->hdr.flags.low_delay_hrd_flag,
256 .tick_divisor_minus2 =
sps->hdr.tick_divisor_minus2,
257 .du_cpb_removal_delay_increment_length_minus1 =
sps->hdr.du_cpb_removal_delay_increment_length_minus1,
258 .dpb_output_delay_du_length_minus1 =
sps->hdr.dpb_output_delay_du_length_minus1,
259 .bit_rate_scale =
sps->hdr.bit_rate_scale,
260 .cpb_size_scale =
sps->hdr.cpb_size_scale,
261 .cpb_size_du_scale =
sps->hdr.cpb_size_du_scale,
262 .initial_cpb_removal_delay_length_minus1 =
sps->hdr.initial_cpb_removal_delay_length_minus1,
263 .au_cpb_removal_delay_length_minus1 =
sps->hdr.au_cpb_removal_delay_length_minus1,
264 .dpb_output_delay_length_minus1 =
sps->hdr.dpb_output_delay_length_minus1,
266 .pSubLayerHrdParametersNal = slhdrnal,
267 .pSubLayerHrdParametersVcl = slhdrvcl,
270 memcpy(vksps_vui_header->cpb_cnt_minus1,
sps->hdr.cpb_cnt_minus1,
271 STD_VIDEO_H265_SUBLAYERS_LIST_SIZE*
sizeof(*vksps_vui_header->cpb_cnt_minus1));
272 memcpy(vksps_vui_header->elemental_duration_in_tc_minus1,
sps->hdr.elemental_duration_in_tc_minus1,
273 STD_VIDEO_H265_SUBLAYERS_LIST_SIZE*
sizeof(*vksps_vui_header->elemental_duration_in_tc_minus1));
278 *vksps_vui = (StdVideoH265SequenceParameterSetVui) {
279 .flags = (StdVideoH265SpsVuiFlags) {
280 .aspect_ratio_info_present_flag =
sps->vui.common.aspect_ratio_info_present_flag,
281 .overscan_info_present_flag =
sps->vui.common.overscan_info_present_flag,
282 .overscan_appropriate_flag =
sps->vui.common.overscan_appropriate_flag,
283 .video_signal_type_present_flag =
sps->vui.common.video_signal_type_present_flag,
284 .video_full_range_flag =
sps->vui.common.video_full_range_flag,
285 .colour_description_present_flag =
sps->vui.common.colour_description_present_flag,
286 .chroma_loc_info_present_flag =
sps->vui.common.chroma_loc_info_present_flag,
287 .neutral_chroma_indication_flag =
sps->vui.neutra_chroma_indication_flag,
288 .field_seq_flag =
sps->vui.field_seq_flag,
289 .frame_field_info_present_flag =
sps->vui.frame_field_info_present_flag,
290 .default_display_window_flag =
sps->vui.default_display_window_flag,
291 .vui_timing_info_present_flag =
sps->vui.vui_timing_info_present_flag,
292 .vui_poc_proportional_to_timing_flag =
sps->vui.vui_poc_proportional_to_timing_flag,
293 .vui_hrd_parameters_present_flag =
sps->vui.vui_hrd_parameters_present_flag,
294 .bitstream_restriction_flag =
sps->vui.bitstream_restriction_flag,
295 .tiles_fixed_structure_flag =
sps->vui.tiles_fixed_structure_flag,
296 .motion_vectors_over_pic_boundaries_flag =
sps->vui.motion_vectors_over_pic_boundaries_flag,
297 .restricted_ref_pic_lists_flag =
sps->vui.restricted_ref_pic_lists_flag,
299 .aspect_ratio_idc =
sps->vui.common.aspect_ratio_idc,
300 .sar_width =
sps->vui.common.sar.num,
301 .sar_height =
sps->vui.common.sar.den,
302 .video_format =
sps->vui.common.video_format,
303 .colour_primaries =
sps->vui.common.colour_primaries,
304 .transfer_characteristics =
sps->vui.common.transfer_characteristics,
305 .matrix_coeffs =
sps->vui.common.matrix_coeffs,
306 .chroma_sample_loc_type_top_field =
sps->vui.common.chroma_sample_loc_type_top_field,
307 .chroma_sample_loc_type_bottom_field =
sps->vui.common.chroma_sample_loc_type_bottom_field,
310 .def_disp_win_left_offset =
sps->vui.def_disp_win.left_offset,
311 .def_disp_win_right_offset =
sps->vui.def_disp_win.right_offset,
312 .def_disp_win_top_offset =
sps->vui.def_disp_win.top_offset,
313 .def_disp_win_bottom_offset =
sps->vui.def_disp_win.bottom_offset,
314 .vui_num_units_in_tick =
sps->vui.vui_num_units_in_tick,
315 .vui_time_scale =
sps->vui.vui_time_scale,
316 .vui_num_ticks_poc_diff_one_minus1 =
sps->vui.vui_num_ticks_poc_diff_one_minus1,
317 .min_spatial_segmentation_idc =
sps->vui.min_spatial_segmentation_idc,
318 .max_bytes_per_pic_denom =
sps->vui.max_bytes_per_pic_denom,
319 .max_bits_per_min_cu_denom =
sps->vui.max_bits_per_min_cu_denom,
320 .log2_max_mv_length_horizontal =
sps->vui.log2_max_mv_length_horizontal,
321 .log2_max_mv_length_vertical =
sps->vui.log2_max_mv_length_vertical,
322 .pHrdParameters = vksps_vui_header,
325 *
ptl = (StdVideoH265ProfileTierLevel) {
326 .flags = (StdVideoH265ProfileTierLevelFlags) {
328 .general_progressive_source_flag =
sps->ptl.general_ptl.progressive_source_flag,
329 .general_interlaced_source_flag =
sps->ptl.general_ptl.interlaced_source_flag,
330 .general_non_packed_constraint_flag =
sps->ptl.general_ptl.non_packed_constraint_flag,
331 .general_frame_only_constraint_flag =
sps->ptl.general_ptl.frame_only_constraint_flag,
333 .general_profile_idc =
sps->ptl.general_ptl.profile_idc,
337 for (
int i = 0;
i <
sps->max_sub_layers;
i++) {
338 dpbm->max_latency_increase_plus1[
i] =
sps->temporal_layer[
i].max_latency_increase + 1;
339 dpbm->max_dec_pic_buffering_minus1[
i] =
sps->temporal_layer[
i].max_dec_pic_buffering - 1;
340 dpbm->max_num_reorder_pics[
i] =
sps->temporal_layer[
i].num_reorder_pics;
343 for (
int i = 0;
i < (
sps->chroma_format_idc ? 3 : 1);
i++)
344 for (
int j = 0; j <
sps->sps_num_palette_predictor_initializers; j++)
345 pal->PredictorPaletteEntries[
i][j] =
sps->sps_palette_predictor_initializer[
i][j];
347 for (
int i = 0;
i <
sps->nb_st_rps;
i++) {
348 str[
i] = (StdVideoH265ShortTermRefPicSet) {
349 .flags = (StdVideoH265ShortTermRefPicSetFlags) {
350 .inter_ref_pic_set_prediction_flag =
sps->st_rps[
i].rps_predict,
351 .delta_rps_sign =
sps->st_rps[
i].delta_rps_sign,
353 .delta_idx_minus1 =
sps->st_rps[
i].delta_idx - 1,
354 .use_delta_flag =
sps->st_rps[
i].use_delta_flag,
355 .abs_delta_rps_minus1 =
sps->st_rps[
i].abs_delta_rps - 1,
356 .used_by_curr_pic_flag = 0x0,
357 .used_by_curr_pic_s0_flag = 0x0,
358 .used_by_curr_pic_s1_flag = 0x0,
362 .num_negative_pics =
sps->st_rps[
i].num_negative_pics,
363 .num_positive_pics =
sps->st_rps[
i].num_delta_pocs -
sps->st_rps[
i].num_negative_pics,
368 for (
int j = 0; j <
sps->st_rps[
i].num_delta_pocs; j++)
369 str[
i].used_by_curr_pic_flag |=
sps->st_rps[
i].used[j] << j;
371 for (
int j = 0; j < str[
i].num_negative_pics; j++) {
372 str[
i].delta_poc_s0_minus1[j] =
sps->st_rps[
i].delta_poc_s0[j] - 1;
373 str[
i].used_by_curr_pic_s0_flag |=
sps->st_rps[
i].used[j] << j;
376 for (
int j = 0; j < str[
i].num_positive_pics; j++) {
377 str[
i].delta_poc_s1_minus1[j] =
sps->st_rps[
i].delta_poc_s1[j] - 1;
378 str[
i].used_by_curr_pic_s0_flag |=
sps->st_rps[
i].used[str[
i].num_negative_pics + j] << j;
382 *ltr = (StdVideoH265LongTermRefPicsSps) {
383 .used_by_curr_pic_lt_sps_flag = 0x0,
386 for (
int i = 0;
i <
sps->num_long_term_ref_pics_sps;
i++) {
387 ltr->used_by_curr_pic_lt_sps_flag |=
sps->used_by_curr_pic_lt_sps_flag[
i] <<
i;
388 ltr->lt_ref_pic_poc_lsb_sps[
i] =
sps->lt_ref_pic_poc_lsb_sps[
i];
391 *vksps = (StdVideoH265SequenceParameterSet) {
392 .flags = (StdVideoH265SpsFlags) {
393 .sps_temporal_id_nesting_flag =
sps->temporal_id_nesting_flag,
394 .separate_colour_plane_flag =
sps->separate_colour_plane_flag,
395 .conformance_window_flag =
sps->conformance_window_flag,
396 .sps_sub_layer_ordering_info_present_flag =
sps->sublayer_ordering_info_flag,
397 .scaling_list_enabled_flag =
sps->scaling_list_enable_flag,
398 .sps_scaling_list_data_present_flag =
sps->scaling_list_enable_flag,
399 .amp_enabled_flag =
sps->amp_enabled_flag,
400 .sample_adaptive_offset_enabled_flag =
sps->sao_enabled,
401 .pcm_enabled_flag =
sps->pcm_enabled_flag,
402 .pcm_loop_filter_disabled_flag =
sps->pcm.loop_filter_disable_flag,
403 .long_term_ref_pics_present_flag =
sps->long_term_ref_pics_present_flag,
404 .sps_temporal_mvp_enabled_flag =
sps->sps_temporal_mvp_enabled_flag,
405 .strong_intra_smoothing_enabled_flag =
sps->sps_strong_intra_smoothing_enable_flag,
406 .vui_parameters_present_flag =
sps->vui_present,
407 .sps_extension_present_flag =
sps->sps_extension_present_flag,
408 .sps_range_extension_flag =
sps->sps_range_extension_flag,
409 .transform_skip_rotation_enabled_flag =
sps->transform_skip_rotation_enabled_flag,
410 .transform_skip_context_enabled_flag =
sps->transform_skip_context_enabled_flag,
411 .implicit_rdpcm_enabled_flag =
sps->implicit_rdpcm_enabled_flag,
412 .explicit_rdpcm_enabled_flag =
sps->explicit_rdpcm_enabled_flag,
413 .extended_precision_processing_flag =
sps->extended_precision_processing_flag,
414 .intra_smoothing_disabled_flag =
sps->intra_smoothing_disabled_flag,
415 .high_precision_offsets_enabled_flag =
sps->high_precision_offsets_enabled_flag,
416 .persistent_rice_adaptation_enabled_flag =
sps->persistent_rice_adaptation_enabled_flag,
417 .cabac_bypass_alignment_enabled_flag =
sps->cabac_bypass_alignment_enabled_flag,
418 .sps_scc_extension_flag =
sps->sps_scc_extension_flag,
419 .sps_curr_pic_ref_enabled_flag =
sps->sps_curr_pic_ref_enabled_flag,
420 .palette_mode_enabled_flag =
sps->palette_mode_enabled_flag,
421 .sps_palette_predictor_initializers_present_flag =
sps->sps_palette_predictor_initializers_present_flag,
422 .intra_boundary_filtering_disabled_flag =
sps->intra_boundary_filtering_disabled_flag,
424 .chroma_format_idc =
sps->chroma_format_idc,
425 .pic_width_in_luma_samples =
sps->width,
426 .pic_height_in_luma_samples =
sps->height,
427 .sps_video_parameter_set_id =
sps->vps_id,
428 .sps_max_sub_layers_minus1 =
sps->max_sub_layers - 1,
429 .sps_seq_parameter_set_id = sps_idx,
430 .bit_depth_luma_minus8 =
sps->bit_depth - 8,
431 .bit_depth_chroma_minus8 =
sps->bit_depth_chroma - 8,
432 .log2_max_pic_order_cnt_lsb_minus4 =
sps->log2_max_poc_lsb - 4,
433 .log2_min_luma_coding_block_size_minus3 =
sps->log2_min_cb_size - 3,
434 .log2_diff_max_min_luma_coding_block_size =
sps->log2_diff_max_min_coding_block_size,
435 .log2_min_luma_transform_block_size_minus2 =
sps->log2_min_tb_size - 2,
436 .log2_diff_max_min_luma_transform_block_size =
sps->log2_diff_max_min_transform_block_size,
437 .max_transform_hierarchy_depth_inter =
sps->max_transform_hierarchy_depth_inter,
438 .max_transform_hierarchy_depth_intra =
sps->max_transform_hierarchy_depth_intra,
439 .num_short_term_ref_pic_sets =
sps->nb_st_rps,
440 .num_long_term_ref_pics_sps =
sps->num_long_term_ref_pics_sps,
441 .pcm_sample_bit_depth_luma_minus1 =
sps->pcm.bit_depth - 1,
442 .pcm_sample_bit_depth_chroma_minus1 =
sps->pcm.bit_depth_chroma - 1,
443 .log2_min_pcm_luma_coding_block_size_minus3 =
sps->pcm.log2_min_pcm_cb_size - 3,
444 .log2_diff_max_min_pcm_luma_coding_block_size =
sps->pcm.log2_max_pcm_cb_size -
sps->pcm.log2_min_pcm_cb_size,
447 .palette_max_size =
sps->palette_max_size,
448 .delta_palette_max_predictor_size =
sps->delta_palette_max_predictor_size,
449 .motion_vector_resolution_control_idc =
sps->motion_vector_resolution_control_idc,
450 .sps_num_palette_predictor_initializers_minus1 =
sps->sps_num_palette_predictor_initializers - 1,
451 .conf_win_left_offset =
sps->pic_conf_win.left_offset,
452 .conf_win_right_offset =
sps->pic_conf_win.right_offset,
453 .conf_win_top_offset =
sps->pic_conf_win.top_offset,
454 .conf_win_bottom_offset =
sps->pic_conf_win.bottom_offset,
455 .pProfileTierLevel =
ptl,
456 .pDecPicBufMgr = dpbm,
457 .pScalingLists = vksps_scaling,
458 .pShortTermRefPicSet = str,
459 .pLongTermRefPicsSps = ltr,
460 .pSequenceParameterSetVui = vksps_vui,
461 .pPredictorPaletteEntries = pal,
466 StdVideoH265ScalingLists *vkpps_scaling,
467 StdVideoH265PictureParameterSet *vkpps,
468 StdVideoH265PredictorPaletteEntries *pal)
472 *vkpps = (StdVideoH265PictureParameterSet) {
473 .flags = (StdVideoH265PpsFlags) {
474 .dependent_slice_segments_enabled_flag =
pps->dependent_slice_segments_enabled_flag,
475 .output_flag_present_flag =
pps->output_flag_present_flag,
476 .sign_data_hiding_enabled_flag =
pps->sign_data_hiding_flag,
477 .cabac_init_present_flag =
pps->cabac_init_present_flag,
478 .constrained_intra_pred_flag =
pps->constrained_intra_pred_flag,
479 .transform_skip_enabled_flag =
pps->transform_skip_enabled_flag,
480 .cu_qp_delta_enabled_flag =
pps->cu_qp_delta_enabled_flag,
481 .pps_slice_chroma_qp_offsets_present_flag =
pps->pic_slice_level_chroma_qp_offsets_present_flag,
482 .weighted_pred_flag =
pps->weighted_pred_flag,
483 .weighted_bipred_flag =
pps->weighted_bipred_flag,
484 .transquant_bypass_enabled_flag =
pps->transquant_bypass_enable_flag,
485 .tiles_enabled_flag =
pps->tiles_enabled_flag,
486 .entropy_coding_sync_enabled_flag =
pps->entropy_coding_sync_enabled_flag,
487 .uniform_spacing_flag =
pps->uniform_spacing_flag,
488 .loop_filter_across_tiles_enabled_flag =
pps->loop_filter_across_tiles_enabled_flag,
489 .pps_loop_filter_across_slices_enabled_flag =
pps->seq_loop_filter_across_slices_enabled_flag,
490 .deblocking_filter_control_present_flag =
pps->deblocking_filter_control_present_flag,
491 .deblocking_filter_override_enabled_flag =
pps->deblocking_filter_override_enabled_flag,
492 .pps_deblocking_filter_disabled_flag =
pps->disable_dbf,
493 .pps_scaling_list_data_present_flag =
pps->scaling_list_data_present_flag,
494 .lists_modification_present_flag =
pps->lists_modification_present_flag,
495 .slice_segment_header_extension_present_flag =
pps->slice_header_extension_present_flag,
496 .pps_extension_present_flag =
pps->pps_extension_present_flag,
497 .cross_component_prediction_enabled_flag =
pps->cross_component_prediction_enabled_flag,
498 .chroma_qp_offset_list_enabled_flag =
pps->chroma_qp_offset_list_enabled_flag,
499 .pps_curr_pic_ref_enabled_flag =
pps->pps_curr_pic_ref_enabled_flag,
500 .residual_adaptive_colour_transform_enabled_flag =
pps->residual_adaptive_colour_transform_enabled_flag,
501 .pps_slice_act_qp_offsets_present_flag =
pps->pps_slice_act_qp_offsets_present_flag,
502 .pps_palette_predictor_initializers_present_flag =
pps->pps_palette_predictor_initializers_present_flag,
503 .monochrome_palette_flag =
pps->monochrome_palette_flag,
504 .pps_range_extension_flag =
pps->pps_range_extensions_flag,
506 .pps_pic_parameter_set_id =
pps->pps_id,
507 .pps_seq_parameter_set_id =
pps->sps_id,
508 .sps_video_parameter_set_id =
sps->vps_id,
509 .num_extra_slice_header_bits =
pps->num_extra_slice_header_bits,
510 .num_ref_idx_l0_default_active_minus1 =
pps->num_ref_idx_l0_default_active - 1,
511 .num_ref_idx_l1_default_active_minus1 =
pps->num_ref_idx_l1_default_active - 1,
512 .init_qp_minus26 =
pps->pic_init_qp_minus26,
513 .diff_cu_qp_delta_depth =
pps->diff_cu_qp_delta_depth,
514 .pps_cb_qp_offset =
pps->cb_qp_offset,
515 .pps_cr_qp_offset =
pps->cr_qp_offset,
516 .pps_beta_offset_div2 =
pps->beta_offset >> 1,
517 .pps_tc_offset_div2 =
pps->tc_offset >> 1,
518 .log2_parallel_merge_level_minus2 =
pps->log2_parallel_merge_level - 2,
519 .log2_max_transform_skip_block_size_minus2 =
pps->log2_max_transform_skip_block_size - 2,
520 .diff_cu_chroma_qp_offset_depth =
pps->diff_cu_chroma_qp_offset_depth,
521 .chroma_qp_offset_list_len_minus1 =
pps->chroma_qp_offset_list_len_minus1,
522 .log2_sao_offset_scale_luma =
pps->log2_sao_offset_scale_luma,
523 .log2_sao_offset_scale_chroma =
pps->log2_sao_offset_scale_chroma,
524 .pps_act_y_qp_offset_plus5 =
pps->pps_act_y_qp_offset + 5,
525 .pps_act_cb_qp_offset_plus5 =
pps->pps_act_cb_qp_offset + 5,
526 .pps_act_cr_qp_offset_plus3 =
pps->pps_act_cr_qp_offset + 3,
527 .pps_num_palette_predictor_initializers =
pps->pps_num_palette_predictor_initializers,
528 .luma_bit_depth_entry_minus8 =
pps->luma_bit_depth_entry - 8,
529 .chroma_bit_depth_entry_minus8 =
pps->chroma_bit_depth_entry - 8,
530 .num_tile_columns_minus1 =
pps->num_tile_columns - 1,
531 .num_tile_rows_minus1 =
pps->num_tile_rows - 1,
532 .pScalingLists = vkpps_scaling,
533 .pPredictorPaletteEntries = pal,
536 for (
int i = 0;
i < (
pps->monochrome_palette_flag ? 1 : 3);
i++) {
537 for (
int j = 0; j <
pps->pps_num_palette_predictor_initializers; j++)
538 pal->PredictorPaletteEntries[
i][j] =
pps->pps_palette_predictor_initializer[
i][j];
541 for (
int i = 0;
i <
pps->num_tile_columns - 1;
i++)
542 vkpps->column_width_minus1[
i] =
pps->column_width[
i] - 1;
544 for (
int i = 0;
i <
pps->num_tile_rows - 1;
i++)
545 vkpps->row_height_minus1[
i] =
pps->row_height[
i] - 1;
547 for (
int i = 0;
i <=
pps->chroma_qp_offset_list_len_minus1;
i++) {
548 vkpps->cb_qp_offset_list[
i] =
pps->cb_qp_offset_list[
i];
549 vkpps->cr_qp_offset_list[
i] =
pps->cr_qp_offset_list[
i];
554 StdVideoH265VideoParameterSet *vkvps,
555 StdVideoH265ProfileTierLevel *
ptl,
556 StdVideoH265DecPicBufMgr *dpbm,
557 StdVideoH265HrdParameters *sls_hdr,
560 for (
int i = 0;
i <
vps->vps_num_hrd_parameters;
i++) {
563 sls_hdr[
i] = (StdVideoH265HrdParameters) {
564 .flags = (StdVideoH265HrdFlags) {
565 .nal_hrd_parameters_present_flag =
src->flags.nal_hrd_parameters_present_flag,
566 .vcl_hrd_parameters_present_flag =
src->flags.vcl_hrd_parameters_present_flag,
567 .sub_pic_hrd_params_present_flag =
src->flags.sub_pic_hrd_params_present_flag,
568 .sub_pic_cpb_params_in_pic_timing_sei_flag =
src->flags.sub_pic_cpb_params_in_pic_timing_sei_flag,
569 .fixed_pic_rate_general_flag =
src->flags.fixed_pic_rate_general_flag,
570 .fixed_pic_rate_within_cvs_flag =
src->flags.fixed_pic_rate_within_cvs_flag,
571 .low_delay_hrd_flag =
src->flags.low_delay_hrd_flag,
573 .tick_divisor_minus2 =
src->tick_divisor_minus2,
574 .du_cpb_removal_delay_increment_length_minus1 =
src->du_cpb_removal_delay_increment_length_minus1,
575 .dpb_output_delay_du_length_minus1 =
src->dpb_output_delay_du_length_minus1,
576 .bit_rate_scale =
src->bit_rate_scale,
577 .cpb_size_scale =
src->cpb_size_scale,
578 .cpb_size_du_scale =
src->cpb_size_du_scale,
579 .initial_cpb_removal_delay_length_minus1 =
src->initial_cpb_removal_delay_length_minus1,
580 .au_cpb_removal_delay_length_minus1 =
src->au_cpb_removal_delay_length_minus1,
581 .dpb_output_delay_length_minus1 =
src->dpb_output_delay_length_minus1,
583 .pSubLayerHrdParametersNal = sls[
i].
nal_hdr,
584 .pSubLayerHrdParametersVcl = sls[
i].
vcl_hdr,
587 memcpy(sls_hdr[
i].cpb_cnt_minus1,
src->cpb_cnt_minus1,
588 STD_VIDEO_H265_SUBLAYERS_LIST_SIZE*
sizeof(*sls_hdr[
i].cpb_cnt_minus1));
589 memcpy(sls_hdr[
i].elemental_duration_in_tc_minus1,
src->elemental_duration_in_tc_minus1,
590 STD_VIDEO_H265_SUBLAYERS_LIST_SIZE*
sizeof(*sls_hdr[
i].elemental_duration_in_tc_minus1));
596 *
ptl = (StdVideoH265ProfileTierLevel) {
597 .flags = (StdVideoH265ProfileTierLevelFlags) {
599 .general_progressive_source_flag =
vps->ptl.general_ptl.progressive_source_flag,
600 .general_interlaced_source_flag =
vps->ptl.general_ptl.interlaced_source_flag,
601 .general_non_packed_constraint_flag =
vps->ptl.general_ptl.non_packed_constraint_flag,
602 .general_frame_only_constraint_flag =
vps->ptl.general_ptl.frame_only_constraint_flag,
604 .general_profile_idc =
vps->ptl.general_ptl.profile_idc,
608 for (
int i = 0;
i <
vps->vps_max_sub_layers;
i++) {
609 dpbm->max_latency_increase_plus1[
i] =
vps->vps_max_latency_increase[
i] + 1;
610 dpbm->max_dec_pic_buffering_minus1[
i] =
vps->vps_max_dec_pic_buffering[
i] - 1;
611 dpbm->max_num_reorder_pics[
i] =
vps->vps_num_reorder_pics[
i];
614 *vkvps = (StdVideoH265VideoParameterSet) {
615 .flags = (StdVideoH265VpsFlags) {
616 .vps_temporal_id_nesting_flag =
vps->vps_temporal_id_nesting_flag,
617 .vps_sub_layer_ordering_info_present_flag =
vps->vps_sub_layer_ordering_info_present_flag,
618 .vps_timing_info_present_flag =
vps->vps_timing_info_present_flag,
619 .vps_poc_proportional_to_timing_flag =
vps->vps_poc_proportional_to_timing_flag,
621 .vps_video_parameter_set_id =
vps->vps_id,
622 .vps_max_sub_layers_minus1 =
vps->vps_max_sub_layers - 1,
625 .vps_num_units_in_tick =
vps->vps_num_units_in_tick,
626 .vps_time_scale =
vps->vps_time_scale,
627 .vps_num_ticks_poc_diff_one_minus1 =
vps->vps_num_ticks_poc_diff_one - 1,
629 .pDecPicBufMgr = dpbm,
630 .pHrdParameters = sls_hdr,
631 .pProfileTierLevel =
ptl,
642 VkVideoDecodeH265SessionParametersAddInfoKHR h265_params_info = {
643 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_SESSION_PARAMETERS_ADD_INFO_KHR,
648 VkVideoDecodeH265SessionParametersCreateInfoKHR h265_params = {
649 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_SESSION_PARAMETERS_CREATE_INFO_KHR,
650 .pParametersAddInfo = &h265_params_info,
652 VkVideoSessionParametersCreateInfoKHR session_params_create = {
653 .sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR,
654 .pNext = &h265_params,
655 .videoSession =
ctx->common.session,
656 .videoSessionParametersTemplate =
NULL,
664 if (
h->ps.vps_list[
i])
665 vps_list_idx[nb_vps++] =
i;
673 h265_params_info.pStdSPSs = hdr->
sps;
674 h265_params_info.pStdPPSs = hdr->
pps;
675 h265_params_info.pStdVPSs = hdr->
vps;
679 if (
h->ps.sps_list[
i]) {
680 const HEVCSPS *sps_l =
h->ps.sps_list[
i];
681 int idx = h265_params_info.stdSPSCount++;
691 if (
h->ps.pps_list[
i]) {
692 const HEVCPPS *pps_l =
h->ps.pps_list[
i];
694 int idx = h265_params_info.stdPPSCount++;
701 for (
int i = 0;
i < nb_vps;
i++) {
702 const HEVCVPS *vps_l =
h->ps.vps_list[vps_list_idx[
i]];
705 h265_params_info.stdVPSCount++;
708 h265_params.maxStdSPSCount = h265_params_info.stdSPSCount;
709 h265_params.maxStdPPSCount = h265_params_info.stdPPSCount;
710 h265_params.maxStdVPSCount = h265_params_info.stdVPSCount;
717 h265_params_info.stdSPSCount, h265_params_info.stdPPSCount,
718 h265_params_info.stdVPSCount);
743 hp->
h265pic = (StdVideoDecodeH265PictureInfo) {
744 .flags = (StdVideoDecodeH265PictureInfoFlags) {
747 .IsReference =
h->nal_unit_type < 16 ?
h->nal_unit_type & 1 : 1,
748 .short_term_ref_pic_set_sps_flag =
h->sh.short_term_ref_pic_set_sps_flag,
750 .sps_video_parameter_set_id =
sps->vps_id,
751 .pps_seq_parameter_set_id =
pps->sps_id,
752 .pps_pic_parameter_set_id =
pps->pps_id,
753 .NumDeltaPocsOfRefRpsIdx =
h->sh.short_term_rps ?
h->sh.short_term_rps->rps_idx_num_delta_pocs : 0,
754 .PicOrderCntVal =
h->poc,
755 .NumBitsForSTRefPicSetInSlice = !
h->sh.short_term_ref_pic_set_sps_flag ?
756 h->sh.short_term_ref_pic_set_size : 0,
785 memset(hp->
h265pic.RefPicSetStCurrBefore, 0xff, 8);
791 hp->
h265pic.RefPicSetStCurrBefore[
i] = j;
796 memset(hp->
h265pic.RefPicSetStCurrAfter, 0xff, 8);
802 hp->
h265pic.RefPicSetStCurrAfter[
i] = j;
807 memset(hp->
h265pic.RefPicSetLtCurr, 0xff, 8);
808 for (
int i = 0;
i <
h->rps[
LT_CURR].nb_refs;
i++) {
820 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PICTURE_INFO_KHR,
821 .pStdPictureInfo = &hp->
h265pic,
822 .sliceSegmentCount = 0,
826 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_INFO_KHR,
829 .pSetupReferenceSlot = &vp->
ref_slot,
830 .referenceSlotCount = nb_refs,
832 .dstPictureResource = (VkVideoPictureResourceInfoKHR) {
833 .sType = VK_STRUCTURE_TYPE_VIDEO_PICTURE_RESOURCE_INFO_KHR,
834 .codedOffset = (VkOffset2D){ 0, 0 },
880 unsigned int pps_id =
h->sh.pps_id;
881 if (pps_id < HEVC_MAX_PPS_COUNT && h->ps.pps_list[pps_id] !=
NULL)
882 pps =
h->ps.pps_list[pps_id];
887 "Encountered frame without a valid active PPS reference.\n");
895 hp->
h265pic.sps_video_parameter_set_id =
sps->vps_id;
896 hp->
h265pic.pps_seq_parameter_set_id =
pps->sps_id;
897 hp->
h265pic.pps_pic_parameter_set_id =
pps->pps_id;
922 .
p.
name =
"hevc_vulkan",