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)
148 *h265_ref = (StdVideoDecodeH265ReferenceInfo) {
149 .flags = (StdVideoDecodeH265ReferenceInfoFlags) {
151 .unused_for_reference = 0,
153 .PicOrderCntVal = pic->
poc,
156 *vkh265_ref = (VkVideoDecodeH265DpbSlotInfoKHR) {
157 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_DPB_SLOT_INFO_KHR,
158 .pStdReferenceInfo = h265_ref,
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,
169 *ref_slot = (VkVideoReferenceSlotInfoKHR) {
170 .sType = VK_STRUCTURE_TYPE_VIDEO_REFERENCE_SLOT_INFO_KHR,
173 .pPictureResource =
ref,
185 case 10:
return STD_VIDEO_H265_LEVEL_IDC_1_0;
186 case 20:
return STD_VIDEO_H265_LEVEL_IDC_2_0;
187 case 21:
return STD_VIDEO_H265_LEVEL_IDC_2_1;
188 case 30:
return STD_VIDEO_H265_LEVEL_IDC_3_0;
189 case 31:
return STD_VIDEO_H265_LEVEL_IDC_3_1;
190 case 40:
return STD_VIDEO_H265_LEVEL_IDC_4_0;
191 case 41:
return STD_VIDEO_H265_LEVEL_IDC_4_1;
192 case 50:
return STD_VIDEO_H265_LEVEL_IDC_5_0;
193 case 51:
return STD_VIDEO_H265_LEVEL_IDC_5_1;
194 case 60:
return STD_VIDEO_H265_LEVEL_IDC_6_0;
195 case 61:
return STD_VIDEO_H265_LEVEL_IDC_6_1;
197 case 62:
return STD_VIDEO_H265_LEVEL_IDC_6_2;
203 for (
int i = 0;
i < STD_VIDEO_H265_SCALING_LIST_4X4_NUM_LISTS;
i++) {
204 for (
int j = 0; j < STD_VIDEO_H265_SCALING_LIST_4X4_NUM_ELEMENTS; j++) {
206 vksl->ScalingList4x4[
i][j] = sl->
sl[0][
i][
pos];
210 for (
int i = 0;
i < STD_VIDEO_H265_SCALING_LIST_8X8_NUM_LISTS;
i++) {
211 for (
int j = 0; j < STD_VIDEO_H265_SCALING_LIST_8X8_NUM_ELEMENTS; j++) {
213 vksl->ScalingList8x8[
i][j] = sl->
sl[1][
i][
pos];
217 for (
int i = 0;
i < STD_VIDEO_H265_SCALING_LIST_16X16_NUM_LISTS;
i++) {
218 for (
int j = 0; j < STD_VIDEO_H265_SCALING_LIST_16X16_NUM_ELEMENTS; j++) {
220 vksl->ScalingList16x16[
i][j] = sl->
sl[2][
i][
pos];
224 for (
int i = 0;
i < STD_VIDEO_H265_SCALING_LIST_32X32_NUM_LISTS;
i++) {
225 for (
int j = 0; j < STD_VIDEO_H265_SCALING_LIST_32X32_NUM_ELEMENTS; j++) {
227 vksl->ScalingList32x32[
i][j] = sl->
sl[3][
i * 3][
pos];
231 memcpy(vksl->ScalingListDCCoef16x16, sl->
sl_dc[0],
232 STD_VIDEO_H265_SCALING_LIST_16X16_NUM_LISTS *
sizeof(*vksl->ScalingListDCCoef16x16));
234 for (
int i = 0;
i < STD_VIDEO_H265_SCALING_LIST_32X32_NUM_LISTS;
i++)
235 vksl->ScalingListDCCoef32x32[
i] = sl->
sl_dc[1][
i * 3];
239 StdVideoH265ScalingLists *vksps_scaling,
240 StdVideoH265HrdParameters *vksps_vui_header,
241 StdVideoH265SequenceParameterSetVui *vksps_vui,
242 StdVideoH265SequenceParameterSet *vksps,
243 StdVideoH265SubLayerHrdParameters *slhdrnal,
244 StdVideoH265SubLayerHrdParameters *slhdrvcl,
245 StdVideoH265ProfileTierLevel *
ptl,
246 StdVideoH265DecPicBufMgr *dpbm,
247 StdVideoH265PredictorPaletteEntries *pal,
248 StdVideoH265ShortTermRefPicSet *str,
249 StdVideoH265LongTermRefPicsSps *ltr)
253 *vksps_vui_header = (StdVideoH265HrdParameters) {
254 .flags = (StdVideoH265HrdFlags) {
255 .nal_hrd_parameters_present_flag =
sps->hdr.nal_hrd_parameters_present_flag,
256 .vcl_hrd_parameters_present_flag =
sps->hdr.vcl_hrd_parameters_present_flag,
257 .sub_pic_hrd_params_present_flag =
sps->hdr.sub_pic_hrd_params_present_flag,
258 .sub_pic_cpb_params_in_pic_timing_sei_flag =
sps->hdr.sub_pic_cpb_params_in_pic_timing_sei_flag,
259 .fixed_pic_rate_general_flag =
sps->hdr.flags.fixed_pic_rate_general_flag,
260 .fixed_pic_rate_within_cvs_flag =
sps->hdr.flags.fixed_pic_rate_within_cvs_flag,
261 .low_delay_hrd_flag =
sps->hdr.flags.low_delay_hrd_flag,
263 .tick_divisor_minus2 =
sps->hdr.tick_divisor_minus2,
264 .du_cpb_removal_delay_increment_length_minus1 =
sps->hdr.du_cpb_removal_delay_increment_length_minus1,
265 .dpb_output_delay_du_length_minus1 =
sps->hdr.dpb_output_delay_du_length_minus1,
266 .bit_rate_scale =
sps->hdr.bit_rate_scale,
267 .cpb_size_scale =
sps->hdr.cpb_size_scale,
268 .cpb_size_du_scale =
sps->hdr.cpb_size_du_scale,
269 .initial_cpb_removal_delay_length_minus1 =
sps->hdr.initial_cpb_removal_delay_length_minus1,
270 .au_cpb_removal_delay_length_minus1 =
sps->hdr.au_cpb_removal_delay_length_minus1,
271 .dpb_output_delay_length_minus1 =
sps->hdr.dpb_output_delay_length_minus1,
273 .pSubLayerHrdParametersNal = slhdrnal,
274 .pSubLayerHrdParametersVcl = slhdrvcl,
277 memcpy(vksps_vui_header->cpb_cnt_minus1,
sps->hdr.cpb_cnt_minus1,
278 STD_VIDEO_H265_SUBLAYERS_LIST_SIZE*
sizeof(*vksps_vui_header->cpb_cnt_minus1));
279 memcpy(vksps_vui_header->elemental_duration_in_tc_minus1,
sps->hdr.elemental_duration_in_tc_minus1,
280 STD_VIDEO_H265_SUBLAYERS_LIST_SIZE*
sizeof(*vksps_vui_header->elemental_duration_in_tc_minus1));
285 *vksps_vui = (StdVideoH265SequenceParameterSetVui) {
286 .flags = (StdVideoH265SpsVuiFlags) {
287 .aspect_ratio_info_present_flag =
sps->vui.common.aspect_ratio_info_present_flag,
288 .overscan_info_present_flag =
sps->vui.common.overscan_info_present_flag,
289 .overscan_appropriate_flag =
sps->vui.common.overscan_appropriate_flag,
290 .video_signal_type_present_flag =
sps->vui.common.video_signal_type_present_flag,
291 .video_full_range_flag =
sps->vui.common.video_full_range_flag,
292 .colour_description_present_flag =
sps->vui.common.colour_description_present_flag,
293 .chroma_loc_info_present_flag =
sps->vui.common.chroma_loc_info_present_flag,
294 .neutral_chroma_indication_flag =
sps->vui.neutra_chroma_indication_flag,
295 .field_seq_flag =
sps->vui.field_seq_flag,
296 .frame_field_info_present_flag =
sps->vui.frame_field_info_present_flag,
297 .default_display_window_flag =
sps->vui.default_display_window_flag,
298 .vui_timing_info_present_flag =
sps->vui.vui_timing_info_present_flag,
299 .vui_poc_proportional_to_timing_flag =
sps->vui.vui_poc_proportional_to_timing_flag,
300 .vui_hrd_parameters_present_flag =
sps->vui.vui_hrd_parameters_present_flag,
301 .bitstream_restriction_flag =
sps->vui.bitstream_restriction_flag,
302 .tiles_fixed_structure_flag =
sps->vui.tiles_fixed_structure_flag,
303 .motion_vectors_over_pic_boundaries_flag =
sps->vui.motion_vectors_over_pic_boundaries_flag,
304 .restricted_ref_pic_lists_flag =
sps->vui.restricted_ref_pic_lists_flag,
306 .aspect_ratio_idc =
sps->vui.common.aspect_ratio_idc,
307 .sar_width =
sps->vui.common.sar.num,
308 .sar_height =
sps->vui.common.sar.den,
309 .video_format =
sps->vui.common.video_format,
310 .colour_primaries =
sps->vui.common.colour_primaries,
311 .transfer_characteristics =
sps->vui.common.transfer_characteristics,
312 .matrix_coeffs =
sps->vui.common.matrix_coeffs,
313 .chroma_sample_loc_type_top_field =
sps->vui.common.chroma_sample_loc_type_top_field,
314 .chroma_sample_loc_type_bottom_field =
sps->vui.common.chroma_sample_loc_type_bottom_field,
317 .def_disp_win_left_offset =
sps->vui.def_disp_win.left_offset,
318 .def_disp_win_right_offset =
sps->vui.def_disp_win.right_offset,
319 .def_disp_win_top_offset =
sps->vui.def_disp_win.top_offset,
320 .def_disp_win_bottom_offset =
sps->vui.def_disp_win.bottom_offset,
321 .vui_num_units_in_tick =
sps->vui.vui_num_units_in_tick,
322 .vui_time_scale =
sps->vui.vui_time_scale,
323 .vui_num_ticks_poc_diff_one_minus1 =
sps->vui.vui_num_ticks_poc_diff_one_minus1,
324 .min_spatial_segmentation_idc =
sps->vui.min_spatial_segmentation_idc,
325 .max_bytes_per_pic_denom =
sps->vui.max_bytes_per_pic_denom,
326 .max_bits_per_min_cu_denom =
sps->vui.max_bits_per_min_cu_denom,
327 .log2_max_mv_length_horizontal =
sps->vui.log2_max_mv_length_horizontal,
328 .log2_max_mv_length_vertical =
sps->vui.log2_max_mv_length_vertical,
329 .pHrdParameters = vksps_vui_header,
332 *
ptl = (StdVideoH265ProfileTierLevel) {
333 .flags = (StdVideoH265ProfileTierLevelFlags) {
335 .general_progressive_source_flag =
sps->ptl.general_ptl.progressive_source_flag,
336 .general_interlaced_source_flag =
sps->ptl.general_ptl.interlaced_source_flag,
337 .general_non_packed_constraint_flag =
sps->ptl.general_ptl.non_packed_constraint_flag,
338 .general_frame_only_constraint_flag =
sps->ptl.general_ptl.frame_only_constraint_flag,
340 .general_profile_idc =
sps->ptl.general_ptl.profile_idc,
344 for (
int i = 0;
i <
sps->max_sub_layers;
i++) {
345 dpbm->max_latency_increase_plus1[
i] =
sps->temporal_layer[
i].max_latency_increase + 1;
346 dpbm->max_dec_pic_buffering_minus1[
i] =
sps->temporal_layer[
i].max_dec_pic_buffering - 1;
347 dpbm->max_num_reorder_pics[
i] =
sps->temporal_layer[
i].num_reorder_pics;
350 for (
int i = 0;
i < (
sps->chroma_format_idc ? 3 : 1);
i++)
351 for (
int j = 0; j <
sps->sps_num_palette_predictor_initializers; j++)
352 pal->PredictorPaletteEntries[
i][j] =
sps->sps_palette_predictor_initializer[
i][j];
354 for (
int i = 0;
i <
sps->nb_st_rps;
i++) {
357 str[
i] = (StdVideoH265ShortTermRefPicSet) {
358 .flags = (StdVideoH265ShortTermRefPicSetFlags) {
359 .inter_ref_pic_set_prediction_flag =
sps->st_rps[
i].rps_predict,
360 .delta_rps_sign =
sps->st_rps[
i].delta_rps_sign,
362 .delta_idx_minus1 =
sps->st_rps[
i].delta_idx - 1,
363 .use_delta_flag =
sps->st_rps[
i].use_delta,
364 .abs_delta_rps_minus1 =
sps->st_rps[
i].abs_delta_rps - 1,
365 .used_by_curr_pic_flag = 0x0,
366 .used_by_curr_pic_s0_flag = 0x0,
367 .used_by_curr_pic_s1_flag = 0x0,
371 .num_negative_pics =
sps->st_rps[
i].num_negative_pics,
372 .num_positive_pics =
sps->st_rps[
i].num_delta_pocs -
sps->st_rps[
i].num_negative_pics,
377 str[
i].used_by_curr_pic_flag = st_rps->
used;
379 str[
i].used_by_curr_pic_s1_flag = st_rps->
used >> str[
i].num_negative_pics;
381 for (
int j = 0; j < str[
i].num_negative_pics; j++)
382 str[
i].delta_poc_s0_minus1[j] = st_rps->
delta_poc[j] - (j ? st_rps->
delta_poc[j - 1] : 0) - 1;
384 for (
int j = 0; j < str[
i].num_positive_pics; j++)
389 *ltr = (StdVideoH265LongTermRefPicsSps) {
390 .used_by_curr_pic_lt_sps_flag =
sps->used_by_curr_pic_lt,
393 for (
int i = 0;
i <
sps->num_long_term_ref_pics_sps;
i++) {
394 ltr->lt_ref_pic_poc_lsb_sps[
i] =
sps->lt_ref_pic_poc_lsb_sps[
i];
397 *vksps = (StdVideoH265SequenceParameterSet) {
398 .flags = (StdVideoH265SpsFlags) {
399 .sps_temporal_id_nesting_flag =
sps->temporal_id_nesting,
400 .separate_colour_plane_flag =
sps->separate_colour_plane,
401 .conformance_window_flag =
sps->conformance_window,
402 .sps_sub_layer_ordering_info_present_flag =
sps->sublayer_ordering_info,
403 .scaling_list_enabled_flag =
sps->scaling_list_enabled,
404 .sps_scaling_list_data_present_flag =
sps->scaling_list_enabled,
405 .amp_enabled_flag =
sps->amp_enabled,
406 .sample_adaptive_offset_enabled_flag =
sps->sao_enabled,
407 .pcm_enabled_flag =
sps->pcm_enabled,
408 .pcm_loop_filter_disabled_flag =
sps->pcm_loop_filter_disabled,
409 .long_term_ref_pics_present_flag =
sps->long_term_ref_pics_present,
410 .sps_temporal_mvp_enabled_flag =
sps->temporal_mvp_enabled,
411 .strong_intra_smoothing_enabled_flag =
sps->strong_intra_smoothing_enabled,
412 .vui_parameters_present_flag =
sps->vui_present,
413 .sps_extension_present_flag =
sps->extension_present,
414 .sps_range_extension_flag =
sps->range_extension,
415 .transform_skip_rotation_enabled_flag =
sps->transform_skip_rotation_enabled,
416 .transform_skip_context_enabled_flag =
sps->transform_skip_context_enabled,
417 .implicit_rdpcm_enabled_flag =
sps->implicit_rdpcm_enabled,
418 .explicit_rdpcm_enabled_flag =
sps->explicit_rdpcm_enabled,
419 .extended_precision_processing_flag =
sps->extended_precision_processing,
420 .intra_smoothing_disabled_flag =
sps->intra_smoothing_disabled,
421 .high_precision_offsets_enabled_flag =
sps->high_precision_offsets_enabled,
422 .persistent_rice_adaptation_enabled_flag =
sps->persistent_rice_adaptation_enabled,
423 .cabac_bypass_alignment_enabled_flag =
sps->cabac_bypass_alignment_enabled,
424 .sps_scc_extension_flag =
sps->scc_extension,
425 .sps_curr_pic_ref_enabled_flag =
sps->curr_pic_ref_enabled,
426 .palette_mode_enabled_flag =
sps->palette_mode_enabled,
427 .sps_palette_predictor_initializers_present_flag =
sps->palette_predictor_initializers_present,
428 .intra_boundary_filtering_disabled_flag =
sps->intra_boundary_filtering_disabled,
430 .chroma_format_idc =
sps->chroma_format_idc,
431 .pic_width_in_luma_samples =
sps->width,
432 .pic_height_in_luma_samples =
sps->height,
433 .sps_video_parameter_set_id =
sps->vps_id,
434 .sps_max_sub_layers_minus1 =
sps->max_sub_layers - 1,
435 .sps_seq_parameter_set_id = sps_idx,
436 .bit_depth_luma_minus8 =
sps->bit_depth - 8,
437 .bit_depth_chroma_minus8 =
sps->bit_depth_chroma - 8,
438 .log2_max_pic_order_cnt_lsb_minus4 =
sps->log2_max_poc_lsb - 4,
439 .log2_min_luma_coding_block_size_minus3 =
sps->log2_min_cb_size - 3,
440 .log2_diff_max_min_luma_coding_block_size =
sps->log2_diff_max_min_coding_block_size,
441 .log2_min_luma_transform_block_size_minus2 =
sps->log2_min_tb_size - 2,
442 .log2_diff_max_min_luma_transform_block_size =
sps->log2_diff_max_min_transform_block_size,
443 .max_transform_hierarchy_depth_inter =
sps->max_transform_hierarchy_depth_inter,
444 .max_transform_hierarchy_depth_intra =
sps->max_transform_hierarchy_depth_intra,
445 .num_short_term_ref_pic_sets =
sps->nb_st_rps,
446 .num_long_term_ref_pics_sps =
sps->num_long_term_ref_pics_sps,
447 .pcm_sample_bit_depth_luma_minus1 =
sps->pcm.bit_depth - 1,
448 .pcm_sample_bit_depth_chroma_minus1 =
sps->pcm.bit_depth_chroma - 1,
449 .log2_min_pcm_luma_coding_block_size_minus3 =
sps->pcm.log2_min_pcm_cb_size - 3,
450 .log2_diff_max_min_pcm_luma_coding_block_size =
sps->pcm.log2_max_pcm_cb_size -
sps->pcm.log2_min_pcm_cb_size,
453 .palette_max_size =
sps->palette_max_size,
454 .delta_palette_max_predictor_size =
sps->delta_palette_max_predictor_size,
455 .motion_vector_resolution_control_idc =
sps->motion_vector_resolution_control_idc,
456 .sps_num_palette_predictor_initializers_minus1 =
sps->sps_num_palette_predictor_initializers - 1,
457 .conf_win_left_offset =
sps->pic_conf_win.left_offset,
458 .conf_win_right_offset =
sps->pic_conf_win.right_offset,
459 .conf_win_top_offset =
sps->pic_conf_win.top_offset,
460 .conf_win_bottom_offset =
sps->pic_conf_win.bottom_offset,
461 .pProfileTierLevel =
ptl,
462 .pDecPicBufMgr = dpbm,
463 .pScalingLists = vksps_scaling,
464 .pShortTermRefPicSet = str,
465 .pLongTermRefPicsSps = ltr,
466 .pSequenceParameterSetVui = vksps_vui,
467 .pPredictorPaletteEntries = pal,
472 StdVideoH265ScalingLists *vkpps_scaling,
473 StdVideoH265PictureParameterSet *vkpps,
474 StdVideoH265PredictorPaletteEntries *pal)
478 *vkpps = (StdVideoH265PictureParameterSet) {
479 .flags = (StdVideoH265PpsFlags) {
480 .dependent_slice_segments_enabled_flag =
pps->dependent_slice_segments_enabled_flag,
481 .output_flag_present_flag =
pps->output_flag_present_flag,
482 .sign_data_hiding_enabled_flag =
pps->sign_data_hiding_flag,
483 .cabac_init_present_flag =
pps->cabac_init_present_flag,
484 .constrained_intra_pred_flag =
pps->constrained_intra_pred_flag,
485 .transform_skip_enabled_flag =
pps->transform_skip_enabled_flag,
486 .cu_qp_delta_enabled_flag =
pps->cu_qp_delta_enabled_flag,
487 .pps_slice_chroma_qp_offsets_present_flag =
pps->pic_slice_level_chroma_qp_offsets_present_flag,
488 .weighted_pred_flag =
pps->weighted_pred_flag,
489 .weighted_bipred_flag =
pps->weighted_bipred_flag,
490 .transquant_bypass_enabled_flag =
pps->transquant_bypass_enable_flag,
491 .tiles_enabled_flag =
pps->tiles_enabled_flag,
492 .entropy_coding_sync_enabled_flag =
pps->entropy_coding_sync_enabled_flag,
493 .uniform_spacing_flag =
pps->uniform_spacing_flag,
494 .loop_filter_across_tiles_enabled_flag =
pps->loop_filter_across_tiles_enabled_flag,
495 .pps_loop_filter_across_slices_enabled_flag =
pps->seq_loop_filter_across_slices_enabled_flag,
496 .deblocking_filter_control_present_flag =
pps->deblocking_filter_control_present_flag,
497 .deblocking_filter_override_enabled_flag =
pps->deblocking_filter_override_enabled_flag,
498 .pps_deblocking_filter_disabled_flag =
pps->disable_dbf,
499 .pps_scaling_list_data_present_flag =
pps->scaling_list_data_present_flag,
500 .lists_modification_present_flag =
pps->lists_modification_present_flag,
501 .slice_segment_header_extension_present_flag =
pps->slice_header_extension_present_flag,
502 .pps_extension_present_flag =
pps->pps_extension_present_flag,
503 .cross_component_prediction_enabled_flag =
pps->cross_component_prediction_enabled_flag,
504 .chroma_qp_offset_list_enabled_flag =
pps->chroma_qp_offset_list_enabled_flag,
505 .pps_curr_pic_ref_enabled_flag =
pps->pps_curr_pic_ref_enabled_flag,
506 .residual_adaptive_colour_transform_enabled_flag =
pps->residual_adaptive_colour_transform_enabled_flag,
507 .pps_slice_act_qp_offsets_present_flag =
pps->pps_slice_act_qp_offsets_present_flag,
508 .pps_palette_predictor_initializers_present_flag =
pps->pps_palette_predictor_initializers_present_flag,
509 .monochrome_palette_flag =
pps->monochrome_palette_flag,
510 .pps_range_extension_flag =
pps->pps_range_extensions_flag,
512 .pps_pic_parameter_set_id =
pps->pps_id,
513 .pps_seq_parameter_set_id =
pps->sps_id,
514 .sps_video_parameter_set_id =
sps->vps_id,
515 .num_extra_slice_header_bits =
pps->num_extra_slice_header_bits,
516 .num_ref_idx_l0_default_active_minus1 =
pps->num_ref_idx_l0_default_active - 1,
517 .num_ref_idx_l1_default_active_minus1 =
pps->num_ref_idx_l1_default_active - 1,
518 .init_qp_minus26 =
pps->pic_init_qp_minus26,
519 .diff_cu_qp_delta_depth =
pps->diff_cu_qp_delta_depth,
520 .pps_cb_qp_offset =
pps->cb_qp_offset,
521 .pps_cr_qp_offset =
pps->cr_qp_offset,
522 .pps_beta_offset_div2 =
pps->beta_offset >> 1,
523 .pps_tc_offset_div2 =
pps->tc_offset >> 1,
524 .log2_parallel_merge_level_minus2 =
pps->log2_parallel_merge_level - 2,
525 .log2_max_transform_skip_block_size_minus2 =
pps->log2_max_transform_skip_block_size - 2,
526 .diff_cu_chroma_qp_offset_depth =
pps->diff_cu_chroma_qp_offset_depth,
527 .chroma_qp_offset_list_len_minus1 =
pps->chroma_qp_offset_list_len_minus1,
528 .log2_sao_offset_scale_luma =
pps->log2_sao_offset_scale_luma,
529 .log2_sao_offset_scale_chroma =
pps->log2_sao_offset_scale_chroma,
530 .pps_act_y_qp_offset_plus5 =
pps->pps_act_y_qp_offset + 5,
531 .pps_act_cb_qp_offset_plus5 =
pps->pps_act_cb_qp_offset + 5,
532 .pps_act_cr_qp_offset_plus3 =
pps->pps_act_cr_qp_offset + 3,
533 .pps_num_palette_predictor_initializers =
pps->pps_num_palette_predictor_initializers,
534 .luma_bit_depth_entry_minus8 =
pps->luma_bit_depth_entry - 8,
535 .chroma_bit_depth_entry_minus8 =
pps->chroma_bit_depth_entry - 8,
536 .num_tile_columns_minus1 =
pps->num_tile_columns - 1,
537 .num_tile_rows_minus1 =
pps->num_tile_rows - 1,
538 .pScalingLists = vkpps_scaling,
539 .pPredictorPaletteEntries = pal,
542 for (
int i = 0;
i < (
pps->monochrome_palette_flag ? 1 : 3);
i++) {
543 for (
int j = 0; j <
pps->pps_num_palette_predictor_initializers; j++)
544 pal->PredictorPaletteEntries[
i][j] =
pps->pps_palette_predictor_initializer[
i][j];
547 for (
int i = 0;
i <
pps->num_tile_columns - 1;
i++)
548 vkpps->column_width_minus1[
i] =
pps->column_width[
i] - 1;
550 for (
int i = 0;
i <
pps->num_tile_rows - 1;
i++)
551 vkpps->row_height_minus1[
i] =
pps->row_height[
i] - 1;
553 for (
int i = 0;
i <=
pps->chroma_qp_offset_list_len_minus1;
i++) {
554 vkpps->cb_qp_offset_list[
i] =
pps->cb_qp_offset_list[
i];
555 vkpps->cr_qp_offset_list[
i] =
pps->cr_qp_offset_list[
i];
560 StdVideoH265VideoParameterSet *vkvps,
561 StdVideoH265ProfileTierLevel *
ptl,
562 StdVideoH265DecPicBufMgr *dpbm,
563 StdVideoH265HrdParameters *sls_hdr,
566 for (
int i = 0;
i <
vps->vps_num_hrd_parameters;
i++) {
569 sls_hdr[
i] = (StdVideoH265HrdParameters) {
570 .flags = (StdVideoH265HrdFlags) {
571 .nal_hrd_parameters_present_flag =
src->nal_hrd_parameters_present_flag,
572 .vcl_hrd_parameters_present_flag =
src->vcl_hrd_parameters_present_flag,
573 .sub_pic_hrd_params_present_flag =
src->sub_pic_hrd_params_present_flag,
574 .sub_pic_cpb_params_in_pic_timing_sei_flag =
src->sub_pic_cpb_params_in_pic_timing_sei_flag,
575 .fixed_pic_rate_general_flag =
src->flags.fixed_pic_rate_general_flag,
576 .fixed_pic_rate_within_cvs_flag =
src->flags.fixed_pic_rate_within_cvs_flag,
577 .low_delay_hrd_flag =
src->flags.low_delay_hrd_flag,
579 .tick_divisor_minus2 =
src->tick_divisor_minus2,
580 .du_cpb_removal_delay_increment_length_minus1 =
src->du_cpb_removal_delay_increment_length_minus1,
581 .dpb_output_delay_du_length_minus1 =
src->dpb_output_delay_du_length_minus1,
582 .bit_rate_scale =
src->bit_rate_scale,
583 .cpb_size_scale =
src->cpb_size_scale,
584 .cpb_size_du_scale =
src->cpb_size_du_scale,
585 .initial_cpb_removal_delay_length_minus1 =
src->initial_cpb_removal_delay_length_minus1,
586 .au_cpb_removal_delay_length_minus1 =
src->au_cpb_removal_delay_length_minus1,
587 .dpb_output_delay_length_minus1 =
src->dpb_output_delay_length_minus1,
589 .pSubLayerHrdParametersNal = sls[
i].
nal_hdr,
590 .pSubLayerHrdParametersVcl = sls[
i].
vcl_hdr,
593 memcpy(sls_hdr[
i].cpb_cnt_minus1,
src->cpb_cnt_minus1,
594 STD_VIDEO_H265_SUBLAYERS_LIST_SIZE*
sizeof(*sls_hdr[
i].cpb_cnt_minus1));
595 memcpy(sls_hdr[
i].elemental_duration_in_tc_minus1,
src->elemental_duration_in_tc_minus1,
596 STD_VIDEO_H265_SUBLAYERS_LIST_SIZE*
sizeof(*sls_hdr[
i].elemental_duration_in_tc_minus1));
602 *
ptl = (StdVideoH265ProfileTierLevel) {
603 .flags = (StdVideoH265ProfileTierLevelFlags) {
605 .general_progressive_source_flag =
vps->ptl.general_ptl.progressive_source_flag,
606 .general_interlaced_source_flag =
vps->ptl.general_ptl.interlaced_source_flag,
607 .general_non_packed_constraint_flag =
vps->ptl.general_ptl.non_packed_constraint_flag,
608 .general_frame_only_constraint_flag =
vps->ptl.general_ptl.frame_only_constraint_flag,
610 .general_profile_idc =
vps->ptl.general_ptl.profile_idc,
614 for (
int i = 0;
i <
vps->vps_max_sub_layers;
i++) {
615 dpbm->max_latency_increase_plus1[
i] =
vps->vps_max_latency_increase[
i] + 1;
616 dpbm->max_dec_pic_buffering_minus1[
i] =
vps->vps_max_dec_pic_buffering[
i] - 1;
617 dpbm->max_num_reorder_pics[
i] =
vps->vps_num_reorder_pics[
i];
620 *vkvps = (StdVideoH265VideoParameterSet) {
621 .flags = (StdVideoH265VpsFlags) {
622 .vps_temporal_id_nesting_flag =
vps->vps_temporal_id_nesting_flag,
623 .vps_sub_layer_ordering_info_present_flag =
vps->vps_sub_layer_ordering_info_present_flag,
624 .vps_timing_info_present_flag =
vps->vps_timing_info_present_flag,
625 .vps_poc_proportional_to_timing_flag =
vps->vps_poc_proportional_to_timing_flag,
627 .vps_video_parameter_set_id =
vps->vps_id,
628 .vps_max_sub_layers_minus1 =
vps->vps_max_sub_layers - 1,
631 .vps_num_units_in_tick =
vps->vps_num_units_in_tick,
632 .vps_time_scale =
vps->vps_time_scale,
633 .vps_num_ticks_poc_diff_one_minus1 =
vps->vps_num_ticks_poc_diff_one - 1,
635 .pDecPicBufMgr = dpbm,
636 .pHrdParameters = sls_hdr,
637 .pProfileTierLevel =
ptl,
648 VkVideoDecodeH265SessionParametersAddInfoKHR h265_params_info = {
649 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_SESSION_PARAMETERS_ADD_INFO_KHR,
654 VkVideoDecodeH265SessionParametersCreateInfoKHR h265_params = {
655 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_SESSION_PARAMETERS_CREATE_INFO_KHR,
656 .pParametersAddInfo = &h265_params_info,
658 VkVideoSessionParametersCreateInfoKHR session_params_create = {
659 .sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR,
660 .pNext = &h265_params,
661 .videoSession =
ctx->common.session,
662 .videoSessionParametersTemplate = VK_NULL_HANDLE,
670 if (
h->ps.vps_list[
i])
671 vps_list_idx[nb_vps++] =
i;
679 h265_params_info.pStdSPSs = hdr->
sps;
680 h265_params_info.pStdPPSs = hdr->
pps;
681 h265_params_info.pStdVPSs = hdr->
vps;
685 if (
h->ps.sps_list[
i]) {
686 const HEVCSPS *sps_l =
h->ps.sps_list[
i];
687 int idx = h265_params_info.stdSPSCount++;
697 if (
h->ps.pps_list[
i]) {
698 const HEVCPPS *pps_l =
h->ps.pps_list[
i];
700 int idx = h265_params_info.stdPPSCount++;
707 for (
int i = 0;
i < nb_vps;
i++) {
708 const HEVCVPS *vps_l =
h->ps.vps_list[vps_list_idx[
i]];
711 h265_params_info.stdVPSCount++;
714 h265_params.maxStdSPSCount = h265_params_info.stdSPSCount;
715 h265_params.maxStdPPSCount = h265_params_info.stdPPSCount;
716 h265_params.maxStdVPSCount = h265_params_info.stdVPSCount;
723 h265_params_info.stdSPSCount, h265_params_info.stdPPSCount,
724 h265_params_info.stdVPSCount);
750 hp->
h265pic = (StdVideoDecodeH265PictureInfo) {
751 .flags = (StdVideoDecodeH265PictureInfoFlags) {
754 .IsReference =
h->nal_unit_type < 16 ?
h->nal_unit_type & 1 : 1,
755 .short_term_ref_pic_set_sps_flag =
h->sh.short_term_ref_pic_set_sps_flag,
757 .sps_video_parameter_set_id =
sps->vps_id,
758 .pps_seq_parameter_set_id =
pps->sps_id,
759 .pps_pic_parameter_set_id =
pps->pps_id,
760 .NumDeltaPocsOfRefRpsIdx =
h->sh.short_term_rps ?
h->sh.short_term_rps->rps_idx_num_delta_pocs : 0,
761 .PicOrderCntVal =
h->poc,
762 .NumBitsForSTRefPicSetInSlice = !
h->sh.short_term_ref_pic_set_sps_flag ?
763 h->sh.short_term_ref_pic_set_size : 0,
792 memset(hp->
h265pic.RefPicSetStCurrBefore, 0xff, 8);
798 hp->
h265pic.RefPicSetStCurrBefore[
i] = j;
803 memset(hp->
h265pic.RefPicSetStCurrAfter, 0xff, 8);
809 hp->
h265pic.RefPicSetStCurrAfter[
i] = j;
814 memset(hp->
h265pic.RefPicSetLtCurr, 0xff, 8);
815 for (
int i = 0;
i <
h->rps[
LT_CURR].nb_refs;
i++) {
827 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PICTURE_INFO_KHR,
828 .pStdPictureInfo = &hp->
h265pic,
829 .sliceSegmentCount = 0,
833 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_INFO_KHR,
836 .pSetupReferenceSlot = &vp->
ref_slot,
837 .referenceSlotCount = nb_refs,
839 .dstPictureResource = (VkVideoPictureResourceInfoKHR) {
840 .sType = VK_STRUCTURE_TYPE_VIDEO_PICTURE_RESOURCE_INFO_KHR,
841 .codedOffset = (VkOffset2D){ 0, 0 },
842 .codedExtent = (VkExtent2D){ pic->
f->
width, pic->
f->
height },
887 unsigned int pps_id =
h->sh.pps_id;
888 if (pps_id < HEVC_MAX_PPS_COUNT && h->ps.pps_list[pps_id] !=
NULL)
889 pps =
h->ps.pps_list[pps_id];
894 "Encountered frame without a valid active PPS reference.\n");
902 hp->
h265pic.sps_video_parameter_set_id =
sps->vps_id;
903 hp->
h265pic.pps_seq_parameter_set_id =
pps->sps_id;
904 hp->
h265pic.pps_pic_parameter_set_id =
pps->pps_id;
929 .
p.
name =
"hevc_vulkan",