57 VkVideoReferenceSlotInfoKHR *ref_slot,
58 VkVideoPictureResourceInfoKHR *
ref,
59 VkVideoDecodeH264DpbSlotInfoKHR *vkh264_ref,
60 StdVideoDecodeH264ReferenceInfo *h264_ref,
62 int is_field,
int picture_structure,
75 *h264_ref = (StdVideoDecodeH264ReferenceInfo) {
78 .flags = (StdVideoDecodeH264ReferenceInfoFlags) {
79 .top_field_flag = is_field ? !!(picture_structure &
PICT_TOP_FIELD) : 0,
93 *vkh264_ref = (VkVideoDecodeH264DpbSlotInfoKHR) {
94 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_DPB_SLOT_INFO_KHR,
95 .pStdReferenceInfo = h264_ref,
98 *
ref = (VkVideoPictureResourceInfoKHR) {
99 .sType = VK_STRUCTURE_TYPE_VIDEO_PICTURE_RESOURCE_INFO_KHR,
100 .codedOffset = (VkOffset2D){ 0, 0 },
101 .codedExtent = (VkExtent2D){ pic->
f->
width, pic->
f->
height },
102 .baseArrayLayer =
ctx->common.layered_dpb ? dpb_slot_index : 0,
103 .imageViewBinding = vkpic->
view.
ref,
106 *ref_slot = (VkVideoReferenceSlotInfoKHR) {
107 .sType = VK_STRUCTURE_TYPE_VIDEO_REFERENCE_SLOT_INFO_KHR,
109 .slotIndex = dpb_slot_index,
110 .pPictureResource =
ref,
146 StdVideoH264ScalingLists *vksps_scaling,
147 StdVideoH264HrdParameters *vksps_vui_header,
148 StdVideoH264SequenceParameterSetVui *vksps_vui,
149 StdVideoH264SequenceParameterSet *vksps)
151 *vksps_scaling = (StdVideoH264ScalingLists) {
152 .scaling_list_present_mask =
sps->scaling_matrix_present_mask,
153 .use_default_scaling_matrix_mask = 0,
156 for (
int i = 0;
i < STD_VIDEO_H264_SCALING_LIST_4X4_NUM_LISTS;
i++)
157 for (
int j = 0; j < STD_VIDEO_H264_SCALING_LIST_4X4_NUM_ELEMENTS; j++)
160 for (
int i = 0;
i < STD_VIDEO_H264_SCALING_LIST_8X8_NUM_LISTS;
i++)
161 for (
int j = 0; j < STD_VIDEO_H264_SCALING_LIST_8X8_NUM_ELEMENTS; j++)
162 vksps_scaling->ScalingList8x8[
i][j] =
165 *vksps_vui_header = (StdVideoH264HrdParameters) {
166 .cpb_cnt_minus1 =
sps->cpb_cnt - 1,
167 .bit_rate_scale =
sps->bit_rate_scale,
168 .initial_cpb_removal_delay_length_minus1 =
sps->initial_cpb_removal_delay_length - 1,
169 .cpb_removal_delay_length_minus1 =
sps->cpb_removal_delay_length - 1,
170 .dpb_output_delay_length_minus1 =
sps->dpb_output_delay_length - 1,
171 .time_offset_length =
sps->time_offset_length,
174 for (
int i = 0;
i <
sps->cpb_cnt;
i++) {
175 vksps_vui_header->bit_rate_value_minus1[
i] =
sps->bit_rate_value[
i] - 1;
176 vksps_vui_header->cpb_size_value_minus1[
i] =
sps->cpb_size_value[
i] - 1;
177 vksps_vui_header->cbr_flag[
i] = (
sps->cpr_flag >>
i) & 0x1;
180 *vksps_vui = (StdVideoH264SequenceParameterSetVui) {
181 .aspect_ratio_idc =
sps->vui.aspect_ratio_idc,
182 .sar_width =
sps->vui.sar.num,
183 .sar_height =
sps->vui.sar.den,
184 .video_format =
sps->vui.video_format,
185 .colour_primaries =
sps->vui.colour_primaries,
186 .transfer_characteristics =
sps->vui.transfer_characteristics,
187 .matrix_coefficients =
sps->vui.matrix_coeffs,
188 .num_units_in_tick =
sps->num_units_in_tick,
189 .time_scale =
sps->time_scale,
190 .pHrdParameters = vksps_vui_header,
191 .max_num_reorder_frames =
sps->num_reorder_frames,
192 .max_dec_frame_buffering =
sps->max_dec_frame_buffering,
193 .flags = (StdVideoH264SpsVuiFlags) {
194 .aspect_ratio_info_present_flag =
sps->vui.aspect_ratio_info_present_flag,
195 .overscan_info_present_flag =
sps->vui.overscan_info_present_flag,
196 .overscan_appropriate_flag =
sps->vui.overscan_appropriate_flag,
197 .video_signal_type_present_flag =
sps->vui.video_signal_type_present_flag,
198 .video_full_range_flag =
sps->vui.video_full_range_flag,
199 .color_description_present_flag =
sps->vui.colour_description_present_flag,
200 .chroma_loc_info_present_flag =
sps->vui.chroma_loc_info_present_flag,
201 .timing_info_present_flag =
sps->timing_info_present_flag,
202 .fixed_frame_rate_flag =
sps->fixed_frame_rate_flag,
203 .bitstream_restriction_flag =
sps->bitstream_restriction_flag,
204 .nal_hrd_parameters_present_flag =
sps->nal_hrd_parameters_present_flag,
205 .vcl_hrd_parameters_present_flag =
sps->vcl_hrd_parameters_present_flag,
209 *vksps = (StdVideoH264SequenceParameterSet) {
210 .profile_idc =
sps->profile_idc,
212 .seq_parameter_set_id =
sps->sps_id,
213 .chroma_format_idc =
sps->chroma_format_idc,
214 .bit_depth_luma_minus8 =
sps->bit_depth_luma - 8,
215 .bit_depth_chroma_minus8 =
sps->bit_depth_chroma - 8,
216 .log2_max_frame_num_minus4 =
sps->log2_max_frame_num - 4,
217 .pic_order_cnt_type =
sps->poc_type,
218 .log2_max_pic_order_cnt_lsb_minus4 =
sps->poc_type ? 0 :
sps->log2_max_poc_lsb - 4,
219 .offset_for_non_ref_pic =
sps->offset_for_non_ref_pic,
220 .offset_for_top_to_bottom_field =
sps->offset_for_top_to_bottom_field,
221 .num_ref_frames_in_pic_order_cnt_cycle =
sps->poc_cycle_length,
222 .max_num_ref_frames =
sps->ref_frame_count,
223 .pic_width_in_mbs_minus1 =
sps->mb_width - 1,
224 .pic_height_in_map_units_minus1 = (
sps->mb_height/(2 -
sps->frame_mbs_only_flag)) - 1,
225 .frame_crop_left_offset =
sps->crop_left,
226 .frame_crop_right_offset =
sps->crop_right,
227 .frame_crop_top_offset =
sps->crop_top,
228 .frame_crop_bottom_offset =
sps->crop_bottom,
229 .flags = (StdVideoH264SpsFlags) {
230 .constraint_set0_flag = (
sps->constraint_set_flags >> 0) & 0x1,
231 .constraint_set1_flag = (
sps->constraint_set_flags >> 1) & 0x1,
232 .constraint_set2_flag = (
sps->constraint_set_flags >> 2) & 0x1,
233 .constraint_set3_flag = (
sps->constraint_set_flags >> 3) & 0x1,
234 .constraint_set4_flag = (
sps->constraint_set_flags >> 4) & 0x1,
235 .constraint_set5_flag = (
sps->constraint_set_flags >> 5) & 0x1,
236 .direct_8x8_inference_flag =
sps->direct_8x8_inference_flag,
237 .mb_adaptive_frame_field_flag =
sps->mb_aff,
238 .frame_mbs_only_flag =
sps->frame_mbs_only_flag,
239 .delta_pic_order_always_zero_flag =
sps->delta_pic_order_always_zero_flag,
240 .separate_colour_plane_flag =
sps->residual_color_transform_flag,
241 .gaps_in_frame_num_value_allowed_flag =
sps->gaps_in_frame_num_allowed_flag,
242 .qpprime_y_zero_transform_bypass_flag =
sps->transform_bypass,
243 .frame_cropping_flag =
sps->crop,
244 .seq_scaling_matrix_present_flag =
sps->scaling_matrix_present,
245 .vui_parameters_present_flag =
sps->vui_parameters_present_flag,
247 .pOffsetForRefFrame =
sps->offset_for_ref_frame,
248 .pScalingLists = vksps_scaling,
249 .pSequenceParameterSetVui = vksps_vui,
254 StdVideoH264ScalingLists *vkpps_scaling,
255 StdVideoH264PictureParameterSet *vkpps)
257 *vkpps_scaling = (StdVideoH264ScalingLists) {
258 .scaling_list_present_mask =
pps->pic_scaling_matrix_present_mask,
259 .use_default_scaling_matrix_mask = 0,
262 for (
int i = 0;
i < STD_VIDEO_H264_SCALING_LIST_4X4_NUM_LISTS;
i++)
263 for (
int j = 0; j < STD_VIDEO_H264_SCALING_LIST_4X4_NUM_ELEMENTS; j++)
266 for (
int i = 0;
i < STD_VIDEO_H264_SCALING_LIST_8X8_NUM_LISTS;
i++)
267 for (
int j = 0; j < STD_VIDEO_H264_SCALING_LIST_8X8_NUM_ELEMENTS; j++)
268 vkpps_scaling->ScalingList8x8[
i][j] =
271 *vkpps = (StdVideoH264PictureParameterSet) {
272 .seq_parameter_set_id =
pps->sps_id,
273 .pic_parameter_set_id =
pps->pps_id,
274 .num_ref_idx_l0_default_active_minus1 =
pps->ref_count[0] - 1,
275 .num_ref_idx_l1_default_active_minus1 =
pps->ref_count[1] - 1,
276 .weighted_bipred_idc =
pps->weighted_bipred_idc,
277 .pic_init_qp_minus26 =
pps->init_qp - 26,
278 .pic_init_qs_minus26 =
pps->init_qs - 26,
279 .chroma_qp_index_offset =
pps->chroma_qp_index_offset[0],
280 .second_chroma_qp_index_offset =
pps->chroma_qp_index_offset[1],
281 .flags = (StdVideoH264PpsFlags) {
282 .transform_8x8_mode_flag =
pps->transform_8x8_mode,
283 .redundant_pic_cnt_present_flag =
pps->redundant_pic_cnt_present,
284 .constrained_intra_pred_flag =
pps->constrained_intra_pred,
285 .deblocking_filter_control_present_flag =
pps->deblocking_filter_parameters_present,
286 .weighted_pred_flag =
pps->weighted_pred,
287 .bottom_field_pic_order_in_frame_present_flag =
pps->pic_order_present,
288 .entropy_coding_mode_flag =
pps->cabac,
289 .pic_scaling_matrix_present_flag =
pps->pic_scaling_matrix_present_flag,
291 .pScalingLists = vkpps_scaling,
378 int dpb_slot_index = 0;
388 if (pic == &
h->DPB[slot]) {
389 dpb_slot_index = slot;
396 h->DPB[dpb_slot_index].field_picture,
397 h->DPB[dpb_slot_index].reference,
403 for (
int i = 0;
i <
h->short_ref_count;
i++) {
406 if (
h->short_ref[
i] == &
h->DPB[slot]) {
407 dpb_slot_index = slot;
414 h->DPB[dpb_slot_index].field_picture,
415 h->DPB[dpb_slot_index].reference,
423 i < h->short_ref_count +
h->long_ref_count;
r++) {
428 for (
unsigned slot = 0; slot < 16; slot++) {
429 if (
h->long_ref[
r] == &
h->DPB[slot]) {
430 dpb_slot_index = slot;
437 h->DPB[dpb_slot_index].field_picture,
438 h->DPB[dpb_slot_index].reference,
445 hp->
h264pic = (StdVideoDecodeH264PictureInfo) {
446 .seq_parameter_set_id = pic->
pps->
sps_id,
447 .pic_parameter_set_id = pic->
pps->
pps_id,
452 .flags = (StdVideoDecodeH264PictureInfoFlags) {
455 .IdrPicFlag =
h->picture_idr,
456 .bottom_field_flag =
h->picture_structure !=
PICT_FRAME &&
458 .is_reference =
h->nal_ref_idc != 0,
464 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_PICTURE_INFO_KHR,
465 .pStdPictureInfo = &hp->
h264pic,
469 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_INFO_KHR,
472 .pSetupReferenceSlot = &vp->
ref_slot,
473 .referenceSlotCount =
h->short_ref_count +
h->long_ref_count,
475 .dstPictureResource = (VkVideoPictureResourceInfoKHR) {
476 .sType = VK_STRUCTURE_TYPE_VIDEO_PICTURE_RESOURCE_INFO_KHR,
477 .codedOffset = (VkOffset2D){ 0, 0 },
478 .codedExtent = (VkExtent2D){ pic->
f->
width, pic->
f->
height },
480 .imageViewBinding = vp->
view.
out,