46 .encode_op = VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR,
48 .extensionName = VK_STD_VULKAN_VIDEO_CODEC_H264_ENCODE_EXTENSION_NAME,
49 .specVersion = VK_STD_VULKAN_VIDEO_CODEC_H264_ENCODE_SPEC_VERSION,
55 0x03, 0xfd, 0xf2, 0x0a, 0x5d, 0x4c, 0x05, 0x48,
56 0x20, 0x98, 0xca, 0x6b, 0x0c, 0x95, 0x30, 0x1c,
75 VkVideoEncodeH264NaluSliceInfoKHR
vkslice;
101 VkVideoEncodeH264CapabilitiesKHR
caps;
118 VkVideoEncodeRateControlInfoKHR *rc_info,
119 VkVideoEncodeRateControlLayerInfoKHR *rc_layer)
125 hp->
vkrc_info = (VkVideoEncodeH264RateControlInfoKHR) {
126 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_RATE_CONTROL_INFO_KHR,
127 .flags = VK_VIDEO_ENCODE_H264_RATE_CONTROL_REFERENCE_PATTERN_FLAT_BIT_KHR |
128 VK_VIDEO_ENCODE_H264_RATE_CONTROL_REGULAR_GOP_BIT_KHR,
129 .idrPeriod =
ctx->base.gop_size,
130 .gopFrameCount =
ctx->base.gop_size,
131 .consecutiveBFrameCount =
FFMAX(
ctx->base.b_per_p - 1, 0),
132 .temporalLayerCount = 0,
136 if (rc_info->rateControlMode > VK_VIDEO_ENCODE_RATE_CONTROL_MODE_DISABLED_BIT_KHR) {
141 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_RATE_CONTROL_LAYER_INFO_KHR,
143 .useMinQp = avctx->
qmin > 0,
144 .minQp.qpI = avctx->
qmin > 0 ? avctx->
qmin : 0,
145 .minQp.qpP = avctx->
qmin > 0 ? avctx->
qmin : 0,
146 .minQp.qpB = avctx->
qmin > 0 ? avctx->
qmin : 0,
148 .useMaxQp = avctx->
qmax > 0,
149 .maxQp.qpI = avctx->
qmax > 0 ? avctx->
qmax : 0,
150 .maxQp.qpP = avctx->
qmax > 0 ? avctx->
qmax : 0,
151 .maxQp.qpB = avctx->
qmax > 0 ? avctx->
qmax : 0,
153 .useMaxFrameSize = 0,
221 .exact_match_flag = 1,
222 .broken_link_flag =
ctx->base.b_per_p > 0,
230 size_t sei_a53cc_len;
253 hp->
slice_wt = (StdVideoEncodeH264WeightTable) {
254 .flags = (StdVideoEncodeH264WeightTableFlags) {
255 .luma_weight_l0_flag = 0,
256 .chroma_weight_l0_flag = 0,
257 .luma_weight_l1_flag = 0,
258 .chroma_weight_l1_flag = 0,
260 .luma_log2_weight_denom = 0,
261 .chroma_log2_weight_denom = 0,
262 .luma_weight_l0 = { 0 },
263 .luma_offset_l0 = { 0 },
264 .chroma_weight_l0 = { { 0 } },
265 .chroma_offset_l0 = { { 0 } },
266 .luma_weight_l1 = { 0 },
267 .luma_offset_l1 = { 0 },
268 .chroma_weight_l1 = { { 0 } },
269 .chroma_offset_l1 = { { 0 } },
272 hp->
slice_hdr = (StdVideoEncodeH264SliceHeader) {
273 .flags = (StdVideoEncodeH264SliceHeaderFlags) {
274 .direct_spatial_mv_pred_flag = 1,
276 .num_ref_idx_active_override_flag =
280 .first_mb_in_slice = 1,
282 .slice_alpha_c0_offset_div2 = 0,
283 .slice_beta_offset_div2 = 0,
287 .disable_deblocking_filter_idc = 0,
288 .pWeightTable =
NULL,
291 hp->
vkslice = (VkVideoEncodeH264NaluSliceInfoKHR) {
292 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_NALU_SLICE_INFO_KHR,
300 if (enc->
common.
opts.
rc_mode != VK_VIDEO_ENCODE_RATE_CONTROL_MODE_DISABLED_BIT_KHR)
329 for (j = n; j > 0; j--) {
334 rpl0[j] = rpl0[j - 1];
336 rpl0[j] = prev->
dpb[
i];
339 for (j = n; j > 0; j--) {
350 rpl0[j] = rpl0[j - 1];
352 rpl0[j] = prev->
dpb[
i];
354 for (j = n; j > 0; j--) {
365 rpl1[j] = rpl1[j - 1];
367 rpl1[j] = prev->
dpb[
i];
374 for (
i = 0;
i < n;
i++) {
375 if (rpl0[
i] != rpl1[
i])
386 for (
i = 0;
i < n;
i++) {
389 hn->frame_num,
hn->pic_order_cnt);
396 for (
i = 0;
i < n;
i++) {
399 hn->frame_num,
hn->pic_order_cnt);
409 VkVideoEncodeInfoKHR *encode_info)
419 .flags = (StdVideoEncodeH264ReferenceListsInfoFlags) {
420 .ref_pic_list_modification_flag_l0 = 0,
421 .ref_pic_list_modification_flag_l1 = 0,
425 .num_ref_idx_l0_active_minus1 = pic->
nb_refs[0] - 1,
426 .num_ref_idx_l1_active_minus1 = pic->
nb_refs[1] - 1,
430 .pRefList0ModOperations =
NULL,
431 .refList0ModOpCount = 0,
432 .pRefList1ModOperations =
NULL,
433 .refList1ModOpCount = 0,
434 .pRefPicMarkingOperations =
NULL,
435 .refPicMarkingOpCount = 0,
438 for (
i = 0;
i < STD_VIDEO_H264_MAX_NUM_LIST_REF;
i++)
443 VkVideoReferenceSlotInfoKHR *slot_info;
444 slot_info = (VkVideoReferenceSlotInfoKHR *)&encode_info->pReferenceSlots[
i];
450 VkVideoReferenceSlotInfoKHR *slot_info;
451 slot_info = (VkVideoReferenceSlotInfoKHR *)&encode_info->pReferenceSlots[pic->
nb_refs[0] +
i];
459 int discard = 0, keep = 0;
465 if (prev->
dpb[
i] == pic->
dpb[j])
469 discard_list[discard] = prev->
dpb[
i];
478 hp->
h264pic_info.flags.adaptive_ref_pic_marking_mode_flag = 0;
480 hp->
h264pic_info.flags.adaptive_ref_pic_marking_mode_flag = 1;
481 for (
i = 0;
i < discard;
i++) {
484 hp->
mmco[
i] = (StdVideoEncodeH264RefPicMarkingEntry) {
485 .memory_management_control_operation = 1,
489 hp->
mmco[
i] = (StdVideoEncodeH264RefPicMarkingEntry) {
490 .memory_management_control_operation = 0,
513 hp->
ref_list_info.flags.ref_pic_list_modification_flag_l0 = need_rplm;
520 hp->
mods[0][
i] = (StdVideoEncodeH264RefListModEntry) {
521 .modification_of_pic_nums_idc = 0,
522 .abs_diff_pic_num_minus1 = pic_num - href->
frame_num - 1,
525 hp->
mods[0][
i] = (StdVideoEncodeH264RefListModEntry) {
526 .modification_of_pic_nums_idc = 1,
527 .abs_diff_pic_num_minus1 = href->
frame_num - pic_num - 1,
536 int need_rplm_l0 = 0, need_rplm_l1 = 0;
556 hp->
ref_list_info.flags.ref_pic_list_modification_flag_l0 = need_rplm_l0;
563 hp->
mods[0][j] = (StdVideoEncodeH264RefListModEntry) {
564 .modification_of_pic_nums_idc = 0,
565 .abs_diff_pic_num_minus1 = pic_num - href->
frame_num - 1,
568 hp->
mods[0][j] = (StdVideoEncodeH264RefListModEntry) {
569 .modification_of_pic_nums_idc = 1,
570 .abs_diff_pic_num_minus1 = href->
frame_num - pic_num - 1,
580 hp->
ref_list_info.flags.ref_pic_list_modification_flag_l1 = need_rplm_l1;
587 hp->
mods[1][j] = (StdVideoEncodeH264RefListModEntry) {
588 .modification_of_pic_nums_idc = 0,
589 .abs_diff_pic_num_minus1 = pic_num - href->
frame_num - 1,
592 hp->
mods[1][j] = (StdVideoEncodeH264RefListModEntry) {
593 .modification_of_pic_nums_idc = 1,
594 .abs_diff_pic_num_minus1 = href->
frame_num - pic_num - 1,
607 VkVideoEncodeInfoKHR *encode_info)
612 VkVideoReferenceSlotInfoKHR *ref_slot;
619 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_PICTURE_INFO_KHR,
621 .pNaluSliceEntries =
NULL,
622 .naluSliceEntryCount = 0,
627 .flags = (StdVideoEncodeH264PictureInfoFlags) {
630 .no_output_of_prior_pics_flag = 0,
631 .long_term_reference_flag = 0,
632 .adaptive_ref_pic_marking_mode_flag = 0,
635 .seq_parameter_set_id = 0,
636 .pic_parameter_set_id = 0,
641 STD_VIDEO_H264_PICTURE_TYPE_IDR,
651 .flags = (StdVideoEncodeH264ReferenceInfoFlags) {
652 .used_for_long_term_reference = 0,
658 .long_term_pic_num = 0,
659 .long_term_frame_idx = 0,
663 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_DPB_SLOT_INFO_KHR,
669 ref_slot = (VkVideoReferenceSlotInfoKHR *)encode_info->pSetupReferenceSlot;
680 VkVideoProfileInfoKHR *
profile,
void *pnext)
687 VkVideoEncodeH264CapabilitiesKHR h264_caps = {
688 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_CAPABILITIES_KHR,
690 VkVideoEncodeCapabilitiesKHR enc_caps = {
691 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_CAPABILITIES_KHR,
694 VkVideoCapabilitiesKHR caps = {
695 .sType = VK_STRUCTURE_TYPE_VIDEO_CAPABILITIES_KHR,
701 static const int known_profiles[] = {
713 if (
desc->comp[0].depth == 8)
716 enc->
profile = (VkVideoEncodeH264ProfileInfoKHR) {
717 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_PROFILE_INFO_KHR,
732 for (
int i = 0;
i < nb_profiles;
i++) {
734 ret = vk->GetPhysicalDeviceVideoCapabilitiesKHR(
s->hwctx->phys_dev,
737 if (
ret == VK_SUCCESS) {
740 last_supported = known_profiles[
i];
752 avctx->
profile = last_supported;
772 "must have initial buffer size (%d) <= "
773 "buffer size (%"PRId64
").\n",
782 if (enc->
common.
opts.
rc_mode == VK_VIDEO_ENCODE_RATE_CONTROL_MODE_DISABLED_BIT_KHR) {
803 "%d / %d / %d for IDR- / P- / B-frames.\n",
838 !!(enc->
caps.stdSyntaxFlags & VK_VIDEO_ENCODE_H264_STD_SCALING_MATRIX_PRESENT_FLAG_SET_BIT_KHR);
840 !!(enc->
caps.stdSyntaxFlags & VK_VIDEO_ENCODE_H264_STD_SCALING_MATRIX_PRESENT_FLAG_SET_BIT_KHR);
842 !!(enc->
caps.stdSyntaxFlags & VK_VIDEO_ENCODE_H264_STD_TRANSFORM_8X8_MODE_FLAG_SET_BIT_KHR);
848 StdVideoH264SequenceParameterSet
vksps;
853 StdVideoH264PictureParameterSet
vkpps;
866 StdVideoH264ScalingLists *vksps_scaling = &vk_units->
vksps_scaling;
868 StdVideoH264SequenceParameterSetVui *vksps_vui = &vk_units->
vksps_vui;
869 StdVideoH264SequenceParameterSet *vksps = &vk_units->
vksps;
872 StdVideoH264ScalingLists *vkpps_scaling = &vk_units->
vkpps_scaling;
873 StdVideoH264PictureParameterSet *vkpps = &vk_units->
vkpps;
875 *vksps_scaling = (StdVideoH264ScalingLists) {
876 .scaling_list_present_mask = 0x0,
877 .use_default_scaling_matrix_mask = 1,
880 *vksps_vui_header = (StdVideoH264HrdParameters) {
895 vksps_vui_header->cbr_flag[
i] = hrd->
cbr_flag[
i];
898 *vksps_vui = (StdVideoH264SequenceParameterSetVui) {
899 .flags = (StdVideoH264SpsVuiFlags) {
900 .aspect_ratio_info_present_flag =
sps->vui.aspect_ratio_info_present_flag,
901 .overscan_info_present_flag =
sps->vui.overscan_info_present_flag,
902 .overscan_appropriate_flag =
sps->vui.overscan_appropriate_flag,
903 .video_signal_type_present_flag =
sps->vui.video_signal_type_present_flag,
904 .video_full_range_flag =
sps->vui.video_full_range_flag,
905 .color_description_present_flag =
sps->vui.colour_description_present_flag,
906 .chroma_loc_info_present_flag =
sps->vui.chroma_loc_info_present_flag,
907 .timing_info_present_flag =
sps->vui.timing_info_present_flag,
908 .fixed_frame_rate_flag =
sps->vui.fixed_frame_rate_flag,
909 .bitstream_restriction_flag =
sps->vui.bitstream_restriction_flag,
910 .nal_hrd_parameters_present_flag =
sps->vui.nal_hrd_parameters_present_flag,
911 .vcl_hrd_parameters_present_flag =
sps->vui.vcl_hrd_parameters_present_flag,
913 .aspect_ratio_idc =
sps->vui.aspect_ratio_idc,
914 .sar_width =
sps->vui.sar_width,
915 .sar_height =
sps->vui.sar_height,
916 .video_format =
sps->vui.video_format,
917 .colour_primaries =
sps->vui.colour_primaries,
918 .transfer_characteristics =
sps->vui.transfer_characteristics,
919 .matrix_coefficients =
sps->vui.matrix_coefficients,
920 .num_units_in_tick =
sps->vui.num_units_in_tick,
921 .time_scale =
sps->vui.time_scale,
922 .max_num_reorder_frames =
sps->vui.max_num_reorder_frames,
923 .max_dec_frame_buffering =
sps->vui.max_dec_frame_buffering,
924 .chroma_sample_loc_type_top_field =
sps->vui.chroma_sample_loc_type_top_field,
925 .chroma_sample_loc_type_bottom_field =
sps->vui.chroma_sample_loc_type_bottom_field,
927 .pHrdParameters = vksps_vui_header,
930 *vksps = (StdVideoH264SequenceParameterSet) {
931 .flags = (StdVideoH264SpsFlags) {
932 .constraint_set0_flag =
sps->constraint_set0_flag,
933 .constraint_set1_flag =
sps->constraint_set1_flag,
934 .constraint_set2_flag =
sps->constraint_set2_flag,
935 .constraint_set3_flag =
sps->constraint_set3_flag,
936 .constraint_set4_flag =
sps->constraint_set4_flag,
937 .constraint_set5_flag =
sps->constraint_set5_flag,
938 .direct_8x8_inference_flag =
sps->direct_8x8_inference_flag,
939 .mb_adaptive_frame_field_flag =
sps->mb_adaptive_frame_field_flag,
940 .frame_mbs_only_flag =
sps->frame_mbs_only_flag,
941 .delta_pic_order_always_zero_flag =
sps->delta_pic_order_always_zero_flag,
942 .separate_colour_plane_flag =
sps->separate_colour_plane_flag,
943 .gaps_in_frame_num_value_allowed_flag =
sps->gaps_in_frame_num_allowed_flag,
944 .qpprime_y_zero_transform_bypass_flag =
sps->qpprime_y_zero_transform_bypass_flag,
945 .frame_cropping_flag =
sps->frame_cropping_flag,
946 .seq_scaling_matrix_present_flag =
sps->seq_scaling_matrix_present_flag,
947 .vui_parameters_present_flag =
sps->vui_parameters_present_flag,
951 .chroma_format_idc =
sps->chroma_format_idc,
952 .seq_parameter_set_id =
sps->seq_parameter_set_id,
953 .bit_depth_luma_minus8 =
sps->bit_depth_luma_minus8,
954 .bit_depth_chroma_minus8 =
sps->bit_depth_chroma_minus8,
955 .log2_max_frame_num_minus4 =
sps->log2_max_frame_num_minus4,
956 .pic_order_cnt_type =
sps->pic_order_cnt_type,
957 .offset_for_non_ref_pic =
sps->offset_for_non_ref_pic,
958 .offset_for_top_to_bottom_field =
sps->offset_for_top_to_bottom_field,
959 .log2_max_pic_order_cnt_lsb_minus4 =
sps->log2_max_pic_order_cnt_lsb_minus4,
960 .num_ref_frames_in_pic_order_cnt_cycle =
sps->num_ref_frames_in_pic_order_cnt_cycle,
961 .max_num_ref_frames =
sps->max_num_ref_frames,
963 .pic_width_in_mbs_minus1 =
sps->pic_width_in_mbs_minus1,
964 .pic_height_in_map_units_minus1 =
sps->pic_height_in_map_units_minus1,
965 .frame_crop_left_offset =
sps->frame_crop_left_offset,
966 .frame_crop_right_offset =
sps->frame_crop_right_offset,
967 .frame_crop_top_offset =
sps->frame_crop_top_offset,
968 .frame_crop_bottom_offset =
sps->frame_crop_bottom_offset,
970 .pOffsetForRefFrame =
sps->offset_for_ref_frame,
971 .pScalingLists = vksps_scaling,
972 .pSequenceParameterSetVui = vksps_vui,
975 *vkpps_scaling = (StdVideoH264ScalingLists) {
976 .scaling_list_present_mask = 0x0,
977 .use_default_scaling_matrix_mask = 1,
980 *vkpps = (StdVideoH264PictureParameterSet) {
981 .flags = (StdVideoH264PpsFlags) {
982 .transform_8x8_mode_flag =
pps->transform_8x8_mode_flag,
983 .redundant_pic_cnt_present_flag =
pps->redundant_pic_cnt_present_flag,
984 .constrained_intra_pred_flag =
pps->constrained_intra_pred_flag,
985 .deblocking_filter_control_present_flag =
pps->deblocking_filter_control_present_flag,
986 .weighted_pred_flag =
pps->weighted_pred_flag,
987 .bottom_field_pic_order_in_frame_present_flag =
pps->bottom_field_pic_order_in_frame_present_flag,
988 .entropy_coding_mode_flag =
pps->entropy_coding_mode_flag,
989 .pic_scaling_matrix_present_flag =
pps->pic_scaling_matrix_present_flag,
991 .seq_parameter_set_id =
pps->seq_parameter_set_id,
992 .pic_parameter_set_id =
pps->pic_parameter_set_id,
993 .num_ref_idx_l0_default_active_minus1 =
pps->num_ref_idx_l0_default_active_minus1,
994 .num_ref_idx_l1_default_active_minus1 =
pps->num_ref_idx_l1_default_active_minus1,
995 .weighted_bipred_idc =
pps->weighted_bipred_idc,
996 .pic_init_qp_minus26 =
pps->pic_init_qp_minus26,
997 .pic_init_qs_minus26 =
pps->pic_init_qs_minus26,
998 .chroma_qp_index_offset =
pps->chroma_qp_index_offset,
999 .second_chroma_qp_index_offset =
pps->second_chroma_qp_index_offset,
1000 .pScalingLists = vkpps_scaling,
1016 VkVideoEncodeH264SessionParametersAddInfoKHR h264_params_info;
1017 VkVideoEncodeH264SessionParametersCreateInfoKHR h264_params;
1028 if (
ctx->session_params)
1029 vk->DestroyVideoSessionParametersKHR(
s->hwctx->act_dev,
1030 ctx->session_params,
1033 h264_params_info = (VkVideoEncodeH264SessionParametersAddInfoKHR) {
1034 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_SESSION_PARAMETERS_ADD_INFO_KHR,
1035 .pStdSPSs = &vk_units.
vksps,
1037 .pStdPPSs = &vk_units.
vkpps,
1040 h264_params = (VkVideoEncodeH264SessionParametersCreateInfoKHR) {
1041 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_SESSION_PARAMETERS_CREATE_INFO_KHR,
1042 .maxStdSPSCount = 1,
1043 .maxStdPPSCount = 1,
1044 .pParametersAddInfo = &h264_params_info,
1052 int sps_override,
int pps_override)
1097 VkVideoEncodeH264SessionParametersGetInfoKHR h264_params_info;
1098 VkVideoEncodeSessionParametersGetInfoKHR params_info;
1099 VkVideoEncodeH264SessionParametersFeedbackInfoKHR h264_params_feedback;
1100 VkVideoEncodeSessionParametersFeedbackInfoKHR params_feedback;
1103 size_t data_size = 0;
1118 h264_params_info = (VkVideoEncodeH264SessionParametersGetInfoKHR) {
1119 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_SESSION_PARAMETERS_GET_INFO_KHR,
1125 params_info = (VkVideoEncodeSessionParametersGetInfoKHR) {
1126 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_SESSION_PARAMETERS_GET_INFO_KHR,
1127 .pNext = &h264_params_info,
1128 .videoSessionParameters =
ctx->session_params,
1131 h264_params_feedback = (VkVideoEncodeH264SessionParametersFeedbackInfoKHR) {
1132 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_SESSION_PARAMETERS_FEEDBACK_INFO_KHR,
1134 params_feedback = (VkVideoEncodeSessionParametersFeedbackInfoKHR) {
1135 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_SESSION_PARAMETERS_FEEDBACK_INFO_KHR,
1136 .pNext = &h264_params_feedback,
1139 ret = vk->GetEncodedVideoSessionParametersKHR(
s->hwctx->act_dev, ¶ms_info,
1142 if (
ret == VK_INCOMPLETE ||
1143 (
ret == VK_SUCCESS) && (data_size > 0)) {
1152 ret = vk->GetEncodedVideoSessionParametersKHR(
s->hwctx->act_dev, ¶ms_info,
1155 if (
ret != VK_SUCCESS) {
1161 params_feedback.hasOverrides,
1162 h264_params_feedback.hasStdSPSOverrides,
1163 h264_params_feedback.hasStdPPSOverrides);
1165 params_feedback.hasOverrides = 1;
1166 h264_params_feedback.hasStdPPSOverrides = 1;
1169 if (!params_feedback.hasOverrides)
1174 h264_params_feedback.hasStdSPSOverrides,
1175 h264_params_feedback.hasStdPPSOverrides);
1197 "type = %d.\n",
header->nal_unit_type);
1203 uint8_t *
data,
size_t *data_len,
1214 if (*data_len < au->data_size) {
1228 uint8_t *
data,
size_t *data_len)
1257 uint8_t *
data,
size_t *data_len)
1323 uint8_t *
data,
size_t *data_len)
1351 .filler_header_size = 6,
1362 int err, ref_l0, ref_l1;
1372 enc->
caps = (VkVideoEncodeH264CapabilitiesKHR) {
1373 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_CAPABILITIES_KHR,
1376 enc->
quality_props = (VkVideoEncodeH264QualityLevelPropertiesKHR) {
1377 .sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_QUALITY_LEVEL_PROPERTIES_KHR,
1389 !!(enc->
caps.stdSyntaxFlags & VK_VIDEO_ENCODE_H264_STD_SEPARATE_COLOR_PLANE_FLAG_SET_BIT_KHR));
1391 !!(enc->
caps.stdSyntaxFlags & VK_VIDEO_ENCODE_H264_STD_QPPRIME_Y_ZERO_TRANSFORM_BYPASS_FLAG_SET_BIT_KHR));
1393 !!(enc->
caps.stdSyntaxFlags & VK_VIDEO_ENCODE_H264_STD_SCALING_MATRIX_PRESENT_FLAG_SET_BIT_KHR));
1395 !!(enc->
caps.stdSyntaxFlags & VK_VIDEO_ENCODE_H264_STD_CHROMA_QP_INDEX_OFFSET_BIT_KHR));
1397 !!(enc->
caps.stdSyntaxFlags & VK_VIDEO_ENCODE_H264_STD_SECOND_CHROMA_QP_INDEX_OFFSET_BIT_KHR));
1399 !!(enc->
caps.stdSyntaxFlags & VK_VIDEO_ENCODE_H264_STD_PIC_INIT_QP_MINUS26_BIT_KHR));
1401 enc->
caps.stdSyntaxFlags & VK_VIDEO_ENCODE_H264_STD_WEIGHTED_PRED_FLAG_SET_BIT_KHR ?
1403 enc->
caps.stdSyntaxFlags & VK_VIDEO_ENCODE_H264_STD_WEIGHTED_BIPRED_IDC_EXPLICIT_BIT_KHR ?
1404 " bipred_explicit" :
"",
1405 enc->
caps.stdSyntaxFlags & VK_VIDEO_ENCODE_H264_STD_WEIGHTED_BIPRED_IDC_IMPLICIT_BIT_KHR ?
1406 " bipred_implicit" :
"");
1408 !!(enc->
caps.stdSyntaxFlags & VK_VIDEO_ENCODE_H264_STD_TRANSFORM_8X8_MODE_FLAG_SET_BIT_KHR));
1410 !!(enc->
caps.stdSyntaxFlags & VK_VIDEO_ENCODE_H264_STD_DIRECT_SPATIAL_MV_PRED_FLAG_UNSET_BIT_KHR));
1412 enc->
caps.stdSyntaxFlags & VK_VIDEO_ENCODE_H264_STD_ENTROPY_CODING_MODE_FLAG_UNSET_BIT_KHR ?
1414 enc->
caps.stdSyntaxFlags & VK_VIDEO_ENCODE_H264_STD_ENTROPY_CODING_MODE_FLAG_SET_BIT_KHR ?
1417 !!(enc->
caps.stdSyntaxFlags & VK_VIDEO_ENCODE_H264_STD_DIRECT_8X8_INFERENCE_FLAG_UNSET_BIT_KHR));
1419 !!(enc->
caps.stdSyntaxFlags & VK_VIDEO_ENCODE_H264_STD_CONSTRAINED_INTRA_PRED_FLAG_SET_BIT_KHR));
1421 enc->
caps.stdSyntaxFlags & VK_VIDEO_ENCODE_H264_STD_DEBLOCKING_FILTER_DISABLED_BIT_KHR ?
1422 " filter_disabling" :
"",
1423 enc->
caps.stdSyntaxFlags & VK_VIDEO_ENCODE_H264_STD_DEBLOCKING_FILTER_ENABLED_BIT_KHR ?
1424 " filter_enabling" :
"",
1425 enc->
caps.stdSyntaxFlags & VK_VIDEO_ENCODE_H264_STD_DEBLOCKING_FILTER_PARTIAL_BIT_KHR ?
1426 " filter_partial" :
"");
1430 !!(enc->
caps.flags & VK_VIDEO_ENCODE_H264_CAPABILITY_HRD_COMPLIANCE_BIT_KHR));
1432 !!(enc->
caps.flags & VK_VIDEO_ENCODE_H264_CAPABILITY_PREDICTION_WEIGHT_TABLE_GENERATED_BIT_KHR));
1434 !!(enc->
caps.flags & VK_VIDEO_ENCODE_H264_CAPABILITY_ROW_UNALIGNED_SLICE_BIT_KHR));
1436 !!(enc->
caps.flags & VK_VIDEO_ENCODE_H264_CAPABILITY_DIFFERENT_SLICE_TYPE_BIT_KHR));
1438 !!(enc->
caps.flags & VK_VIDEO_ENCODE_H264_CAPABILITY_B_FRAME_IN_L0_LIST_BIT_KHR));
1440 !!(enc->
caps.flags & VK_VIDEO_ENCODE_H264_CAPABILITY_B_FRAME_IN_L1_LIST_BIT_KHR));
1442 !!(enc->
caps.flags & VK_VIDEO_ENCODE_H264_CAPABILITY_PER_PICTURE_TYPE_MIN_MAX_QP_BIT_KHR));
1444 !!(enc->
caps.flags & VK_VIDEO_ENCODE_H264_CAPABILITY_PER_SLICE_CONSTANT_QP_BIT_KHR));
1446 !!(enc->
caps.flags & VK_VIDEO_ENCODE_H264_CAPABILITY_GENERATE_PREFIX_NALU_BIT_KHR));
1450 enc->
caps.maxLevelIdc);
1452 enc->
caps.maxSliceCount);
1454 enc->
caps.maxPPictureL0ReferenceCount,
1455 enc->
caps.maxBPictureL0ReferenceCount);
1457 enc->
caps.maxL1ReferenceCount);
1459 enc->
caps.maxTemporalLayerCount);
1461 enc->
caps.expectDyadicTemporalLayerPattern);
1465 enc->
caps.prefersGopRemainingFrames);
1467 enc->
caps.requiresGopRemainingFrames);
1474 if (!enc->
caps.maxPPictureL0ReferenceCount &&
1475 !enc->
caps.maxBPictureL0ReferenceCount &&
1476 !enc->
caps.maxL1ReferenceCount) {
1479 ref_l0 = ref_l1 = 0;
1480 }
else if (!enc->
caps.maxPPictureL0ReferenceCount) {
1483 ref_l0 = enc->
caps.maxBPictureL0ReferenceCount;
1484 ref_l1 = enc->
caps.maxL1ReferenceCount;
1485 }
else if (!enc->
caps.maxBPictureL0ReferenceCount &&
1486 !enc->
caps.maxL1ReferenceCount) {
1489 ref_l0 = enc->
caps.maxPPictureL0ReferenceCount;
1493 ref_l0 =
FFMIN(enc->
caps.maxPPictureL0ReferenceCount,
1494 enc->
caps.maxBPictureL0ReferenceCount);
1495 ref_l1 = enc->
caps.maxL1ReferenceCount;
1515 "%s / Vulkan video %i.%i.%i / %s %i.%i.%i / %s",
1518 s->driver_props.driverName,
1519 CODEC_VER(
s->props.properties.driverVersion),
1520 s->props.properties.deviceName);
1528 "%s / Vulkan video %i.%i.%i / %s %i.%i.%i / %s",
1531 s->driver_props.driverName,
1532 CODEC_VER(
s->props.properties.driverVersion),
1533 s->props.properties.deviceName);
1565 #define OFFSET(x) offsetof(VulkanEncodeH264Context, x)
1566 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
1571 {
"profile",
"Set profile (profile_idc and constraint_set*_flag)",
1575 #define PROFILE(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
1576 { .i64 = value }, 0, 0, FLAGS, .unit = "profile"
1583 {
"level",
"Set level (level_idc)",
1587 #define LEVEL(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
1588 { .i64 = value }, 0, 0, FLAGS, .unit = "level"
1590 {
LEVEL(
"1.1", 11) },
1591 {
LEVEL(
"1.2", 12) },
1592 {
LEVEL(
"1.3", 13) },
1594 {
LEVEL(
"2.1", 21) },
1595 {
LEVEL(
"2.2", 22) },
1597 {
LEVEL(
"3.1", 31) },
1598 {
LEVEL(
"3.2", 32) },
1600 {
LEVEL(
"4.1", 41) },
1601 {
LEVEL(
"4.2", 42) },
1603 {
LEVEL(
"5.1", 51) },
1604 {
LEVEL(
"5.2", 52) },
1606 {
LEVEL(
"6.1", 61) },
1607 {
LEVEL(
"6.2", 62) },
1628 {
"i_qfactor",
"1" },
1629 {
"i_qoffset",
"0" },
1630 {
"b_qfactor",
"1" },
1631 {
"b_qoffset",
"0" },
1645 .
p.
name =
"h264_vulkan",
1666 .p.wrapper_name =
"vulkan",