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,
184 for (
int i = 0;
i < STD_VIDEO_H265_SCALING_LIST_4X4_NUM_LISTS;
i++) {
185 for (
int j = 0; j < STD_VIDEO_H265_SCALING_LIST_4X4_NUM_ELEMENTS; j++) {
187 vksl->ScalingList4x4[
i][j] = sl->
sl[0][
i][
pos];
191 for (
int i = 0;
i < STD_VIDEO_H265_SCALING_LIST_8X8_NUM_LISTS;
i++) {
192 for (
int j = 0; j < STD_VIDEO_H265_SCALING_LIST_8X8_NUM_ELEMENTS; j++) {
194 vksl->ScalingList8x8[
i][j] = sl->
sl[1][
i][
pos];
198 for (
int i = 0;
i < STD_VIDEO_H265_SCALING_LIST_16X16_NUM_LISTS;
i++) {
199 for (
int j = 0; j < STD_VIDEO_H265_SCALING_LIST_16X16_NUM_ELEMENTS; j++) {
201 vksl->ScalingList16x16[
i][j] = sl->
sl[2][
i][
pos];
205 for (
int i = 0;
i < STD_VIDEO_H265_SCALING_LIST_32X32_NUM_LISTS;
i++) {
206 for (
int j = 0; j < STD_VIDEO_H265_SCALING_LIST_32X32_NUM_ELEMENTS; j++) {
208 vksl->ScalingList32x32[
i][j] = sl->
sl[3][
i * 3][
pos];
212 memcpy(vksl->ScalingListDCCoef16x16, sl->
sl_dc[0],
213 STD_VIDEO_H265_SCALING_LIST_16X16_NUM_LISTS *
sizeof(*vksl->ScalingListDCCoef16x16));
215 for (
int i = 0;
i < STD_VIDEO_H265_SCALING_LIST_32X32_NUM_LISTS;
i++)
216 vksl->ScalingListDCCoef32x32[
i] = sl->
sl_dc[1][
i * 3];
220 StdVideoH265ScalingLists *vksps_scaling,
221 StdVideoH265HrdParameters *vksps_vui_header,
222 StdVideoH265SequenceParameterSetVui *vksps_vui,
223 StdVideoH265SequenceParameterSet *vksps,
224 StdVideoH265SubLayerHrdParameters *slhdrnal,
225 StdVideoH265SubLayerHrdParameters *slhdrvcl,
226 StdVideoH265ProfileTierLevel *
ptl,
227 StdVideoH265DecPicBufMgr *dpbm,
228 StdVideoH265PredictorPaletteEntries *pal,
229 StdVideoH265ShortTermRefPicSet *str,
230 StdVideoH265LongTermRefPicsSps *ltr)
234 *vksps_vui_header = (StdVideoH265HrdParameters) {
235 .flags = (StdVideoH265HrdFlags) {
236 .nal_hrd_parameters_present_flag =
sps->hdr.nal_hrd_parameters_present_flag,
237 .vcl_hrd_parameters_present_flag =
sps->hdr.vcl_hrd_parameters_present_flag,
238 .sub_pic_hrd_params_present_flag =
sps->hdr.sub_pic_hrd_params_present_flag,
239 .sub_pic_cpb_params_in_pic_timing_sei_flag =
sps->hdr.sub_pic_cpb_params_in_pic_timing_sei_flag,
240 .fixed_pic_rate_general_flag =
sps->hdr.flags.fixed_pic_rate_general_flag,
241 .fixed_pic_rate_within_cvs_flag =
sps->hdr.flags.fixed_pic_rate_within_cvs_flag,
242 .low_delay_hrd_flag =
sps->hdr.flags.low_delay_hrd_flag,
244 .tick_divisor_minus2 =
sps->hdr.tick_divisor_minus2,
245 .du_cpb_removal_delay_increment_length_minus1 =
sps->hdr.du_cpb_removal_delay_increment_length_minus1,
246 .dpb_output_delay_du_length_minus1 =
sps->hdr.dpb_output_delay_du_length_minus1,
247 .bit_rate_scale =
sps->hdr.bit_rate_scale,
248 .cpb_size_scale =
sps->hdr.cpb_size_scale,
249 .cpb_size_du_scale =
sps->hdr.cpb_size_du_scale,
250 .initial_cpb_removal_delay_length_minus1 =
sps->hdr.initial_cpb_removal_delay_length_minus1,
251 .au_cpb_removal_delay_length_minus1 =
sps->hdr.au_cpb_removal_delay_length_minus1,
252 .dpb_output_delay_length_minus1 =
sps->hdr.dpb_output_delay_length_minus1,
254 .pSubLayerHrdParametersNal = slhdrnal,
255 .pSubLayerHrdParametersVcl = slhdrvcl,
258 memcpy(vksps_vui_header->cpb_cnt_minus1,
sps->hdr.cpb_cnt_minus1,
259 STD_VIDEO_H265_SUBLAYERS_LIST_SIZE*
sizeof(*vksps_vui_header->cpb_cnt_minus1));
260 memcpy(vksps_vui_header->elemental_duration_in_tc_minus1,
sps->hdr.elemental_duration_in_tc_minus1,
261 STD_VIDEO_H265_SUBLAYERS_LIST_SIZE*
sizeof(*vksps_vui_header->elemental_duration_in_tc_minus1));
266 *vksps_vui = (StdVideoH265SequenceParameterSetVui) {
267 .flags = (StdVideoH265SpsVuiFlags) {
268 .aspect_ratio_info_present_flag =
sps->vui.common.aspect_ratio_info_present_flag,
269 .overscan_info_present_flag =
sps->vui.common.overscan_info_present_flag,
270 .overscan_appropriate_flag =
sps->vui.common.overscan_appropriate_flag,
271 .video_signal_type_present_flag =
sps->vui.common.video_signal_type_present_flag,
272 .video_full_range_flag =
sps->vui.common.video_full_range_flag,
273 .colour_description_present_flag =
sps->vui.common.colour_description_present_flag,
274 .chroma_loc_info_present_flag =
sps->vui.common.chroma_loc_info_present_flag,
275 .neutral_chroma_indication_flag =
sps->vui.neutra_chroma_indication_flag,
276 .field_seq_flag =
sps->vui.field_seq_flag,
277 .frame_field_info_present_flag =
sps->vui.frame_field_info_present_flag,
278 .default_display_window_flag =
sps->vui.default_display_window_flag,
279 .vui_timing_info_present_flag =
sps->vui.vui_timing_info_present_flag,
280 .vui_poc_proportional_to_timing_flag =
sps->vui.vui_poc_proportional_to_timing_flag,
281 .vui_hrd_parameters_present_flag =
sps->vui.vui_hrd_parameters_present_flag,
282 .bitstream_restriction_flag =
sps->vui.bitstream_restriction_flag,
283 .tiles_fixed_structure_flag =
sps->vui.tiles_fixed_structure_flag,
284 .motion_vectors_over_pic_boundaries_flag =
sps->vui.motion_vectors_over_pic_boundaries_flag,
285 .restricted_ref_pic_lists_flag =
sps->vui.restricted_ref_pic_lists_flag,
287 .aspect_ratio_idc =
sps->vui.common.aspect_ratio_idc,
288 .sar_width =
sps->vui.common.sar.num,
289 .sar_height =
sps->vui.common.sar.den,
290 .video_format =
sps->vui.common.video_format,
291 .colour_primaries =
sps->vui.common.colour_primaries,
292 .transfer_characteristics =
sps->vui.common.transfer_characteristics,
293 .matrix_coeffs =
sps->vui.common.matrix_coeffs,
294 .chroma_sample_loc_type_top_field =
sps->vui.common.chroma_sample_loc_type_top_field,
295 .chroma_sample_loc_type_bottom_field =
sps->vui.common.chroma_sample_loc_type_bottom_field,
298 .def_disp_win_left_offset =
sps->vui.def_disp_win.left_offset,
299 .def_disp_win_right_offset =
sps->vui.def_disp_win.right_offset,
300 .def_disp_win_top_offset =
sps->vui.def_disp_win.top_offset,
301 .def_disp_win_bottom_offset =
sps->vui.def_disp_win.bottom_offset,
302 .vui_num_units_in_tick =
sps->vui.vui_num_units_in_tick,
303 .vui_time_scale =
sps->vui.vui_time_scale,
304 .vui_num_ticks_poc_diff_one_minus1 =
sps->vui.vui_num_ticks_poc_diff_one_minus1,
305 .min_spatial_segmentation_idc =
sps->vui.min_spatial_segmentation_idc,
306 .max_bytes_per_pic_denom =
sps->vui.max_bytes_per_pic_denom,
307 .max_bits_per_min_cu_denom =
sps->vui.max_bits_per_min_cu_denom,
308 .log2_max_mv_length_horizontal =
sps->vui.log2_max_mv_length_horizontal,
309 .log2_max_mv_length_vertical =
sps->vui.log2_max_mv_length_vertical,
310 .pHrdParameters = vksps_vui_header,
313 *
ptl = (StdVideoH265ProfileTierLevel) {
314 .flags = (StdVideoH265ProfileTierLevelFlags) {
316 .general_progressive_source_flag =
sps->ptl.general_ptl.progressive_source_flag,
317 .general_interlaced_source_flag =
sps->ptl.general_ptl.interlaced_source_flag,
318 .general_non_packed_constraint_flag =
sps->ptl.general_ptl.non_packed_constraint_flag,
319 .general_frame_only_constraint_flag =
sps->ptl.general_ptl.frame_only_constraint_flag,
321 .general_profile_idc =
sps->ptl.general_ptl.profile_idc,
325 for (
int i = 0;
i <
sps->max_sub_layers;
i++) {
326 dpbm->max_latency_increase_plus1[
i] =
sps->temporal_layer[
i].max_latency_increase + 1;
327 dpbm->max_dec_pic_buffering_minus1[
i] =
sps->temporal_layer[
i].max_dec_pic_buffering - 1;
328 dpbm->max_num_reorder_pics[
i] =
sps->temporal_layer[
i].num_reorder_pics;
331 for (
int i = 0;
i < (
sps->chroma_format_idc ? 3 : 1);
i++)
332 for (
int j = 0; j <
sps->sps_num_palette_predictor_initializers; j++)
333 pal->PredictorPaletteEntries[
i][j] =
sps->sps_palette_predictor_initializer[
i][j];
335 for (
int i = 0;
i <
sps->nb_st_rps;
i++) {
338 str[
i] = (StdVideoH265ShortTermRefPicSet) {
339 .flags = (StdVideoH265ShortTermRefPicSetFlags) {
340 .inter_ref_pic_set_prediction_flag =
sps->st_rps[
i].rps_predict,
341 .delta_rps_sign =
sps->st_rps[
i].delta_rps_sign,
343 .delta_idx_minus1 =
sps->st_rps[
i].delta_idx - 1,
344 .use_delta_flag =
sps->st_rps[
i].use_delta,
345 .abs_delta_rps_minus1 =
sps->st_rps[
i].abs_delta_rps - 1,
346 .used_by_curr_pic_flag = 0x0,
347 .used_by_curr_pic_s0_flag = 0x0,
348 .used_by_curr_pic_s1_flag = 0x0,
352 .num_negative_pics =
sps->st_rps[
i].num_negative_pics,
353 .num_positive_pics =
sps->st_rps[
i].num_delta_pocs -
sps->st_rps[
i].num_negative_pics,
358 str[
i].used_by_curr_pic_flag = st_rps->
used;
360 str[
i].used_by_curr_pic_s1_flag = st_rps->
used >> str[
i].num_negative_pics;
362 for (
int j = 0; j < str[
i].num_negative_pics; j++)
363 str[
i].delta_poc_s0_minus1[j] = st_rps->
delta_poc[j] - (j ? st_rps->
delta_poc[j - 1] : 0) - 1;
365 for (
int j = 0; j < str[
i].num_positive_pics; j++)
370 *ltr = (StdVideoH265LongTermRefPicsSps) {
371 .used_by_curr_pic_lt_sps_flag =
sps->used_by_curr_pic_lt,
374 for (
int i = 0;
i <
sps->num_long_term_ref_pics_sps;
i++) {
375 ltr->lt_ref_pic_poc_lsb_sps[
i] =
sps->lt_ref_pic_poc_lsb_sps[
i];
378 *vksps = (StdVideoH265SequenceParameterSet) {
379 .flags = (StdVideoH265SpsFlags) {
380 .sps_temporal_id_nesting_flag =
sps->temporal_id_nesting,
381 .separate_colour_plane_flag =
sps->separate_colour_plane,
382 .conformance_window_flag =
sps->conformance_window,
383 .sps_sub_layer_ordering_info_present_flag =
sps->sublayer_ordering_info,
384 .scaling_list_enabled_flag =
sps->scaling_list_enabled,
385 .sps_scaling_list_data_present_flag =
sps->scaling_list_enabled,
386 .amp_enabled_flag =
sps->amp_enabled,
387 .sample_adaptive_offset_enabled_flag =
sps->sao_enabled,
388 .pcm_enabled_flag =
sps->pcm_enabled,
389 .pcm_loop_filter_disabled_flag =
sps->pcm_loop_filter_disabled,
390 .long_term_ref_pics_present_flag =
sps->long_term_ref_pics_present,
391 .sps_temporal_mvp_enabled_flag =
sps->temporal_mvp_enabled,
392 .strong_intra_smoothing_enabled_flag =
sps->strong_intra_smoothing_enabled,
393 .vui_parameters_present_flag =
sps->vui_present,
394 .sps_extension_present_flag =
sps->extension_present,
395 .sps_range_extension_flag =
sps->range_extension,
396 .transform_skip_rotation_enabled_flag =
sps->transform_skip_rotation_enabled,
397 .transform_skip_context_enabled_flag =
sps->transform_skip_context_enabled,
398 .implicit_rdpcm_enabled_flag =
sps->implicit_rdpcm_enabled,
399 .explicit_rdpcm_enabled_flag =
sps->explicit_rdpcm_enabled,
400 .extended_precision_processing_flag =
sps->extended_precision_processing,
401 .intra_smoothing_disabled_flag =
sps->intra_smoothing_disabled,
402 .high_precision_offsets_enabled_flag =
sps->high_precision_offsets_enabled,
403 .persistent_rice_adaptation_enabled_flag =
sps->persistent_rice_adaptation_enabled,
404 .cabac_bypass_alignment_enabled_flag =
sps->cabac_bypass_alignment_enabled,
405 .sps_scc_extension_flag =
sps->scc_extension,
406 .sps_curr_pic_ref_enabled_flag =
sps->curr_pic_ref_enabled,
407 .palette_mode_enabled_flag =
sps->palette_mode_enabled,
408 .sps_palette_predictor_initializers_present_flag =
sps->palette_predictor_initializers_present,
409 .intra_boundary_filtering_disabled_flag =
sps->intra_boundary_filtering_disabled,
411 .chroma_format_idc =
sps->chroma_format_idc,
412 .pic_width_in_luma_samples =
sps->width,
413 .pic_height_in_luma_samples =
sps->height,
414 .sps_video_parameter_set_id =
sps->vps_id,
415 .sps_max_sub_layers_minus1 =
sps->max_sub_layers - 1,
416 .sps_seq_parameter_set_id = sps_idx,
417 .bit_depth_luma_minus8 =
sps->bit_depth - 8,
418 .bit_depth_chroma_minus8 =
sps->bit_depth_chroma - 8,
419 .log2_max_pic_order_cnt_lsb_minus4 =
sps->log2_max_poc_lsb - 4,
420 .log2_min_luma_coding_block_size_minus3 =
sps->log2_min_cb_size - 3,
421 .log2_diff_max_min_luma_coding_block_size =
sps->log2_diff_max_min_coding_block_size,
422 .log2_min_luma_transform_block_size_minus2 =
sps->log2_min_tb_size - 2,
423 .log2_diff_max_min_luma_transform_block_size =
sps->log2_diff_max_min_transform_block_size,
424 .max_transform_hierarchy_depth_inter =
sps->max_transform_hierarchy_depth_inter,
425 .max_transform_hierarchy_depth_intra =
sps->max_transform_hierarchy_depth_intra,
426 .num_short_term_ref_pic_sets =
sps->nb_st_rps,
427 .num_long_term_ref_pics_sps =
sps->num_long_term_ref_pics_sps,
428 .pcm_sample_bit_depth_luma_minus1 =
sps->pcm.bit_depth - 1,
429 .pcm_sample_bit_depth_chroma_minus1 =
sps->pcm.bit_depth_chroma - 1,
430 .log2_min_pcm_luma_coding_block_size_minus3 =
sps->pcm.log2_min_pcm_cb_size - 3,
431 .log2_diff_max_min_pcm_luma_coding_block_size =
sps->pcm.log2_max_pcm_cb_size -
sps->pcm.log2_min_pcm_cb_size,
434 .palette_max_size =
sps->palette_max_size,
435 .delta_palette_max_predictor_size =
sps->delta_palette_max_predictor_size,
436 .motion_vector_resolution_control_idc =
sps->motion_vector_resolution_control_idc,
437 .sps_num_palette_predictor_initializers_minus1 =
sps->sps_num_palette_predictor_initializers - 1,
438 .conf_win_left_offset =
sps->pic_conf_win.left_offset,
439 .conf_win_right_offset =
sps->pic_conf_win.right_offset,
440 .conf_win_top_offset =
sps->pic_conf_win.top_offset,
441 .conf_win_bottom_offset =
sps->pic_conf_win.bottom_offset,
442 .pProfileTierLevel =
ptl,
443 .pDecPicBufMgr = dpbm,
444 .pScalingLists = vksps_scaling,
445 .pShortTermRefPicSet = str,
446 .pLongTermRefPicsSps = ltr,
447 .pSequenceParameterSetVui = vksps_vui,
448 .pPredictorPaletteEntries = pal,
453 StdVideoH265ScalingLists *vkpps_scaling,
454 StdVideoH265PictureParameterSet *vkpps,
455 StdVideoH265PredictorPaletteEntries *pal)
459 *vkpps = (StdVideoH265PictureParameterSet) {
460 .flags = (StdVideoH265PpsFlags) {
461 .dependent_slice_segments_enabled_flag =
pps->dependent_slice_segments_enabled_flag,
462 .output_flag_present_flag =
pps->output_flag_present_flag,
463 .sign_data_hiding_enabled_flag =
pps->sign_data_hiding_flag,
464 .cabac_init_present_flag =
pps->cabac_init_present_flag,
465 .constrained_intra_pred_flag =
pps->constrained_intra_pred_flag,
466 .transform_skip_enabled_flag =
pps->transform_skip_enabled_flag,
467 .cu_qp_delta_enabled_flag =
pps->cu_qp_delta_enabled_flag,
468 .pps_slice_chroma_qp_offsets_present_flag =
pps->pic_slice_level_chroma_qp_offsets_present_flag,
469 .weighted_pred_flag =
pps->weighted_pred_flag,
470 .weighted_bipred_flag =
pps->weighted_bipred_flag,
471 .transquant_bypass_enabled_flag =
pps->transquant_bypass_enable_flag,
472 .tiles_enabled_flag =
pps->tiles_enabled_flag,
473 .entropy_coding_sync_enabled_flag =
pps->entropy_coding_sync_enabled_flag,
474 .uniform_spacing_flag =
pps->uniform_spacing_flag,
475 .loop_filter_across_tiles_enabled_flag =
pps->loop_filter_across_tiles_enabled_flag,
476 .pps_loop_filter_across_slices_enabled_flag =
pps->seq_loop_filter_across_slices_enabled_flag,
477 .deblocking_filter_control_present_flag =
pps->deblocking_filter_control_present_flag,
478 .deblocking_filter_override_enabled_flag =
pps->deblocking_filter_override_enabled_flag,
479 .pps_deblocking_filter_disabled_flag =
pps->disable_dbf,
480 .pps_scaling_list_data_present_flag =
pps->scaling_list_data_present_flag,
481 .lists_modification_present_flag =
pps->lists_modification_present_flag,
482 .slice_segment_header_extension_present_flag =
pps->slice_header_extension_present_flag,
483 .pps_extension_present_flag =
pps->pps_extension_present_flag,
484 .cross_component_prediction_enabled_flag =
pps->cross_component_prediction_enabled_flag,
485 .chroma_qp_offset_list_enabled_flag =
pps->chroma_qp_offset_list_enabled_flag,
486 .pps_curr_pic_ref_enabled_flag =
pps->pps_curr_pic_ref_enabled_flag,
487 .residual_adaptive_colour_transform_enabled_flag =
pps->residual_adaptive_colour_transform_enabled_flag,
488 .pps_slice_act_qp_offsets_present_flag =
pps->pps_slice_act_qp_offsets_present_flag,
489 .pps_palette_predictor_initializers_present_flag =
pps->pps_palette_predictor_initializers_present_flag,
490 .monochrome_palette_flag =
pps->monochrome_palette_flag,
491 .pps_range_extension_flag =
pps->pps_range_extensions_flag,
493 .pps_pic_parameter_set_id =
pps->pps_id,
494 .pps_seq_parameter_set_id =
pps->sps_id,
495 .sps_video_parameter_set_id =
sps->vps_id,
496 .num_extra_slice_header_bits =
pps->num_extra_slice_header_bits,
497 .num_ref_idx_l0_default_active_minus1 =
pps->num_ref_idx_l0_default_active - 1,
498 .num_ref_idx_l1_default_active_minus1 =
pps->num_ref_idx_l1_default_active - 1,
499 .init_qp_minus26 =
pps->pic_init_qp_minus26,
500 .diff_cu_qp_delta_depth =
pps->diff_cu_qp_delta_depth,
501 .pps_cb_qp_offset =
pps->cb_qp_offset,
502 .pps_cr_qp_offset =
pps->cr_qp_offset,
503 .pps_beta_offset_div2 =
pps->beta_offset >> 1,
504 .pps_tc_offset_div2 =
pps->tc_offset >> 1,
505 .log2_parallel_merge_level_minus2 =
pps->log2_parallel_merge_level - 2,
506 .log2_max_transform_skip_block_size_minus2 =
pps->log2_max_transform_skip_block_size - 2,
507 .diff_cu_chroma_qp_offset_depth =
pps->diff_cu_chroma_qp_offset_depth,
508 .chroma_qp_offset_list_len_minus1 =
pps->chroma_qp_offset_list_len_minus1,
509 .log2_sao_offset_scale_luma =
pps->log2_sao_offset_scale_luma,
510 .log2_sao_offset_scale_chroma =
pps->log2_sao_offset_scale_chroma,
511 .pps_act_y_qp_offset_plus5 =
pps->pps_act_y_qp_offset + 5,
512 .pps_act_cb_qp_offset_plus5 =
pps->pps_act_cb_qp_offset + 5,
513 .pps_act_cr_qp_offset_plus3 =
pps->pps_act_cr_qp_offset + 3,
514 .pps_num_palette_predictor_initializers =
pps->pps_num_palette_predictor_initializers,
515 .luma_bit_depth_entry_minus8 =
pps->luma_bit_depth_entry - 8,
516 .chroma_bit_depth_entry_minus8 =
pps->chroma_bit_depth_entry - 8,
517 .num_tile_columns_minus1 =
pps->num_tile_columns - 1,
518 .num_tile_rows_minus1 =
pps->num_tile_rows - 1,
519 .pScalingLists = vkpps_scaling,
520 .pPredictorPaletteEntries = pal,
523 for (
int i = 0;
i < (
pps->monochrome_palette_flag ? 1 : 3);
i++) {
524 for (
int j = 0; j <
pps->pps_num_palette_predictor_initializers; j++)
525 pal->PredictorPaletteEntries[
i][j] =
pps->pps_palette_predictor_initializer[
i][j];
528 for (
int i = 0;
i <
pps->num_tile_columns - 1;
i++)
529 vkpps->column_width_minus1[
i] =
pps->column_width[
i] - 1;
531 for (
int i = 0;
i <
pps->num_tile_rows - 1;
i++)
532 vkpps->row_height_minus1[
i] =
pps->row_height[
i] - 1;
534 for (
int i = 0;
i <=
pps->chroma_qp_offset_list_len_minus1;
i++) {
535 vkpps->cb_qp_offset_list[
i] =
pps->cb_qp_offset_list[
i];
536 vkpps->cr_qp_offset_list[
i] =
pps->cr_qp_offset_list[
i];
541 StdVideoH265VideoParameterSet *vkvps,
542 StdVideoH265ProfileTierLevel *
ptl,
543 StdVideoH265DecPicBufMgr *dpbm,
544 StdVideoH265HrdParameters *sls_hdr,
547 for (
int i = 0;
i <
vps->vps_num_hrd_parameters;
i++) {
550 sls_hdr[
i] = (StdVideoH265HrdParameters) {
551 .flags = (StdVideoH265HrdFlags) {
552 .nal_hrd_parameters_present_flag =
src->nal_hrd_parameters_present_flag,
553 .vcl_hrd_parameters_present_flag =
src->vcl_hrd_parameters_present_flag,
554 .sub_pic_hrd_params_present_flag =
src->sub_pic_hrd_params_present_flag,
555 .sub_pic_cpb_params_in_pic_timing_sei_flag =
src->sub_pic_cpb_params_in_pic_timing_sei_flag,
556 .fixed_pic_rate_general_flag =
src->flags.fixed_pic_rate_general_flag,
557 .fixed_pic_rate_within_cvs_flag =
src->flags.fixed_pic_rate_within_cvs_flag,
558 .low_delay_hrd_flag =
src->flags.low_delay_hrd_flag,
560 .tick_divisor_minus2 =
src->tick_divisor_minus2,
561 .du_cpb_removal_delay_increment_length_minus1 =
src->du_cpb_removal_delay_increment_length_minus1,
562 .dpb_output_delay_du_length_minus1 =
src->dpb_output_delay_du_length_minus1,
563 .bit_rate_scale =
src->bit_rate_scale,
564 .cpb_size_scale =
src->cpb_size_scale,
565 .cpb_size_du_scale =
src->cpb_size_du_scale,
566 .initial_cpb_removal_delay_length_minus1 =
src->initial_cpb_removal_delay_length_minus1,
567 .au_cpb_removal_delay_length_minus1 =
src->au_cpb_removal_delay_length_minus1,
568 .dpb_output_delay_length_minus1 =
src->dpb_output_delay_length_minus1,
570 .pSubLayerHrdParametersNal = sls[
i].
nal_hdr,
571 .pSubLayerHrdParametersVcl = sls[
i].
vcl_hdr,
574 memcpy(sls_hdr[
i].cpb_cnt_minus1,
src->cpb_cnt_minus1,
575 STD_VIDEO_H265_SUBLAYERS_LIST_SIZE*
sizeof(*sls_hdr[
i].cpb_cnt_minus1));
576 memcpy(sls_hdr[
i].elemental_duration_in_tc_minus1,
src->elemental_duration_in_tc_minus1,
577 STD_VIDEO_H265_SUBLAYERS_LIST_SIZE*
sizeof(*sls_hdr[
i].elemental_duration_in_tc_minus1));
583 *
ptl = (StdVideoH265ProfileTierLevel) {
584 .flags = (StdVideoH265ProfileTierLevelFlags) {
586 .general_progressive_source_flag =
vps->ptl.general_ptl.progressive_source_flag,
587 .general_interlaced_source_flag =
vps->ptl.general_ptl.interlaced_source_flag,
588 .general_non_packed_constraint_flag =
vps->ptl.general_ptl.non_packed_constraint_flag,
589 .general_frame_only_constraint_flag =
vps->ptl.general_ptl.frame_only_constraint_flag,
595 for (
int i = 0;
i <
vps->vps_max_sub_layers;
i++) {
596 dpbm->max_latency_increase_plus1[
i] =
vps->vps_max_latency_increase[
i] + 1;
597 dpbm->max_dec_pic_buffering_minus1[
i] =
vps->vps_max_dec_pic_buffering[
i] - 1;
598 dpbm->max_num_reorder_pics[
i] =
vps->vps_num_reorder_pics[
i];
601 *vkvps = (StdVideoH265VideoParameterSet) {
602 .flags = (StdVideoH265VpsFlags) {
603 .vps_temporal_id_nesting_flag =
vps->vps_temporal_id_nesting_flag,
604 .vps_sub_layer_ordering_info_present_flag =
vps->vps_sub_layer_ordering_info_present_flag,
605 .vps_timing_info_present_flag =
vps->vps_timing_info_present_flag,
606 .vps_poc_proportional_to_timing_flag =
vps->vps_poc_proportional_to_timing_flag,
608 .vps_video_parameter_set_id =
vps->vps_id,
609 .vps_max_sub_layers_minus1 =
vps->vps_max_sub_layers - 1,
612 .vps_num_units_in_tick =
vps->vps_num_units_in_tick,
613 .vps_time_scale =
vps->vps_time_scale,
614 .vps_num_ticks_poc_diff_one_minus1 =
vps->vps_num_ticks_poc_diff_one - 1,
616 .pDecPicBufMgr = dpbm,
617 .pHrdParameters = sls_hdr,
618 .pProfileTierLevel =
ptl,
629 VkVideoDecodeH265SessionParametersAddInfoKHR h265_params_info = {
630 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_SESSION_PARAMETERS_ADD_INFO_KHR,
635 VkVideoDecodeH265SessionParametersCreateInfoKHR h265_params = {
636 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_SESSION_PARAMETERS_CREATE_INFO_KHR,
637 .pParametersAddInfo = &h265_params_info,
639 VkVideoSessionParametersCreateInfoKHR session_params_create = {
640 .sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR,
641 .pNext = &h265_params,
642 .videoSession =
ctx->common.session,
643 .videoSessionParametersTemplate = VK_NULL_HANDLE,
651 if (
h->ps.vps_list[
i])
652 vps_list_idx[nb_vps++] =
i;
660 h265_params_info.pStdSPSs = hdr->
sps;
661 h265_params_info.pStdPPSs = hdr->
pps;
662 h265_params_info.pStdVPSs = hdr->
vps;
666 if (
h->ps.sps_list[
i]) {
667 const HEVCSPS *sps_l =
h->ps.sps_list[
i];
668 int idx = h265_params_info.stdSPSCount++;
678 if (
h->ps.pps_list[
i]) {
679 const HEVCPPS *pps_l =
h->ps.pps_list[
i];
681 int idx = h265_params_info.stdPPSCount++;
688 for (
int i = 0;
i < nb_vps;
i++) {
689 const HEVCVPS *vps_l =
h->ps.vps_list[vps_list_idx[
i]];
692 h265_params_info.stdVPSCount++;
695 h265_params.maxStdSPSCount = h265_params_info.stdSPSCount;
696 h265_params.maxStdPPSCount = h265_params_info.stdPPSCount;
697 h265_params.maxStdVPSCount = h265_params_info.stdVPSCount;
704 h265_params_info.stdSPSCount, h265_params_info.stdPPSCount,
705 h265_params_info.stdVPSCount);
731 hp->
h265pic = (StdVideoDecodeH265PictureInfo) {
732 .flags = (StdVideoDecodeH265PictureInfoFlags) {
735 .IsReference =
h->nal_unit_type < 16 ?
h->nal_unit_type & 1 : 1,
736 .short_term_ref_pic_set_sps_flag =
h->sh.short_term_ref_pic_set_sps_flag,
738 .sps_video_parameter_set_id =
sps->vps_id,
739 .pps_seq_parameter_set_id =
pps->sps_id,
740 .pps_pic_parameter_set_id =
pps->pps_id,
741 .NumDeltaPocsOfRefRpsIdx =
h->sh.short_term_rps ?
h->sh.short_term_rps->rps_idx_num_delta_pocs : 0,
742 .PicOrderCntVal =
h->poc,
743 .NumBitsForSTRefPicSetInSlice = !
h->sh.short_term_ref_pic_set_sps_flag ?
744 h->sh.short_term_ref_pic_set_size : 0,
773 memset(hp->
h265pic.RefPicSetStCurrBefore, 0xff, 8);
779 hp->
h265pic.RefPicSetStCurrBefore[
i] = j;
784 memset(hp->
h265pic.RefPicSetStCurrAfter, 0xff, 8);
790 hp->
h265pic.RefPicSetStCurrAfter[
i] = j;
795 memset(hp->
h265pic.RefPicSetLtCurr, 0xff, 8);
796 for (
int i = 0;
i <
h->rps[
LT_CURR].nb_refs;
i++) {
808 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PICTURE_INFO_KHR,
809 .pStdPictureInfo = &hp->
h265pic,
810 .sliceSegmentCount = 0,
814 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_INFO_KHR,
817 .pSetupReferenceSlot = &vp->
ref_slot,
818 .referenceSlotCount = nb_refs,
820 .dstPictureResource = (VkVideoPictureResourceInfoKHR) {
821 .sType = VK_STRUCTURE_TYPE_VIDEO_PICTURE_RESOURCE_INFO_KHR,
822 .codedOffset = (VkOffset2D){ 0, 0 },
823 .codedExtent = (VkExtent2D){ pic->
f->
width, pic->
f->
height },
868 unsigned int pps_id =
h->sh.pps_id;
869 if (pps_id < HEVC_MAX_PPS_COUNT && h->ps.pps_list[pps_id] !=
NULL)
870 pps =
h->ps.pps_list[pps_id];
875 "Encountered frame without a valid active PPS reference.\n");
883 hp->
h265pic.sps_video_parameter_set_id =
sps->vps_id;
884 hp->
h265pic.pps_seq_parameter_set_id =
pps->sps_id;
885 hp->
h265pic.pps_pic_parameter_set_id =
pps->pps_id;
910 .
p.
name =
"hevc_vulkan",