| 1 |
/* |
| 2 |
** Copyright (c) 2019-2021 The Khronos Group Inc. |
| 3 |
** |
| 4 |
** SPDX-License-Identifier: Apache-2.0 |
| 5 |
*/ |
| 6 |
|
| 7 |
#ifndef VULKAN_VIDEO_CODEC_H264STD_H_ |
| 8 |
#define VULKAN_VIDEO_CODEC_H264STD_H_ 1 |
| 9 |
|
| 10 |
#ifdef __cplusplus |
| 11 |
extern "C" { |
| 12 |
#endif |
| 13 |
|
| 14 |
#include "vk_video/vulkan_video_codecs_common.h" |
| 15 |
|
| 16 |
// Vulkan 0.9 provisional Vulkan video H.264 encode and decode std specification version number |
| 17 |
#define VK_STD_VULKAN_VIDEO_CODEC_H264_API_VERSION_0_9 VK_MAKE_VIDEO_STD_VERSION(0, 9, 0) // Patch version should always be set to 0 |
| 18 |
|
| 19 |
// Format must be in the form XX.XX where the first two digits are the major and the second two, the minor. |
| 20 |
#define VK_STD_VULKAN_VIDEO_CODEC_H264_SPEC_VERSION VK_STD_VULKAN_VIDEO_CODEC_H264_API_VERSION_0_9 |
| 21 |
#define VK_STD_VULKAN_VIDEO_CODEC_H264_EXTENSION_NAME "VK_STD_vulkan_video_codec_h264" |
| 22 |
|
| 23 |
// ************************************************* |
| 24 |
// Video H.264 common definitions: |
| 25 |
// ************************************************* |
| 26 |
|
| 27 |
typedef enum StdVideoH264ChromaFormatIdc { |
| 28 |
std_video_h264_chroma_format_idc_monochrome = 0, |
| 29 |
std_video_h264_chroma_format_idc_420 = 1, |
| 30 |
std_video_h264_chroma_format_idc_422 = 2, |
| 31 |
std_video_h264_chroma_format_idc_444 = 3, |
| 32 |
} StdVideoH264ChromaFormatIdc; |
| 33 |
|
| 34 |
typedef enum StdVideoH264ProfileIdc { |
| 35 |
std_video_h264_profile_idc_baseline = 66, /* Only constrained baseline is supported */ |
| 36 |
std_video_h264_profile_idc_main = 77, |
| 37 |
std_video_h264_profile_idc_high = 100, |
| 38 |
std_video_h264_profile_idc_high_444_predictive = 244, |
| 39 |
std_video_h264_profile_idc_invalid = 0x7FFFFFFF |
| 40 |
} StdVideoH264ProfileIdc; |
| 41 |
|
| 42 |
typedef enum StdVideoH264Level { |
| 43 |
std_video_h264_level_1_0 = 0, |
| 44 |
std_video_h264_level_1_1 = 1, |
| 45 |
std_video_h264_level_1_2 = 2, |
| 46 |
std_video_h264_level_1_3 = 3, |
| 47 |
std_video_h264_level_2_0 = 4, |
| 48 |
std_video_h264_level_2_1 = 5, |
| 49 |
std_video_h264_level_2_2 = 6, |
| 50 |
std_video_h264_level_3_0 = 7, |
| 51 |
std_video_h264_level_3_1 = 8, |
| 52 |
std_video_h264_level_3_2 = 9, |
| 53 |
std_video_h264_level_4_0 = 10, |
| 54 |
std_video_h264_level_4_1 = 11, |
| 55 |
std_video_h264_level_4_2 = 12, |
| 56 |
std_video_h264_level_5_0 = 13, |
| 57 |
std_video_h264_level_5_1 = 14, |
| 58 |
std_video_h264_level_5_2 = 15, |
| 59 |
std_video_h264_level_6_0 = 16, |
| 60 |
std_video_h264_level_6_1 = 17, |
| 61 |
std_video_h264_level_6_2 = 18, |
| 62 |
std_video_h264_level_invalid = 0x7FFFFFFF |
| 63 |
} StdVideoH264Level; |
| 64 |
|
| 65 |
typedef enum StdVideoH264PocType { |
| 66 |
std_video_h264_poc_type_0 = 0, |
| 67 |
std_video_h264_poc_type_1 = 1, |
| 68 |
std_video_h264_poc_type_2 = 2, |
| 69 |
std_video_h264_poc_type_invalid = 0x7FFFFFFF |
| 70 |
} StdVideoH264PocType; |
| 71 |
|
| 72 |
typedef enum StdVideoH264AspectRatioIdc { |
| 73 |
std_video_h264_aspect_ratio_idc_unspecified = 0, |
| 74 |
std_video_h264_aspect_ratio_idc_square = 1, |
| 75 |
std_video_h264_aspect_ratio_idc_12_11 = 2, |
| 76 |
std_video_h264_aspect_ratio_idc_10_11 = 3, |
| 77 |
std_video_h264_aspect_ratio_idc_16_11 = 4, |
| 78 |
std_video_h264_aspect_ratio_idc_40_33 = 5, |
| 79 |
std_video_h264_aspect_ratio_idc_24_11 = 6, |
| 80 |
std_video_h264_aspect_ratio_idc_20_11 = 7, |
| 81 |
std_video_h264_aspect_ratio_idc_32_11 = 8, |
| 82 |
std_video_h264_aspect_ratio_idc_80_33 = 9, |
| 83 |
std_video_h264_aspect_ratio_idc_18_11 = 10, |
| 84 |
std_video_h264_aspect_ratio_idc_15_11 = 11, |
| 85 |
std_video_h264_aspect_ratio_idc_64_33 = 12, |
| 86 |
std_video_h264_aspect_ratio_idc_160_99 = 13, |
| 87 |
std_video_h264_aspect_ratio_idc_4_3 = 14, |
| 88 |
std_video_h264_aspect_ratio_idc_3_2 = 15, |
| 89 |
std_video_h264_aspect_ratio_idc_2_1 = 16, |
| 90 |
std_video_h264_aspect_ratio_idc_extended_sar = 255, |
| 91 |
std_video_h264_aspect_ratio_idc_invalid = 0x7FFFFFFF |
| 92 |
} StdVideoH264AspectRatioIdc; |
| 93 |
|
| 94 |
typedef enum StdVideoH264WeightedBiPredIdc { |
| 95 |
std_video_h264_default_weighted_b_slices_prediction_idc = 0, |
| 96 |
std_video_h264_explicit_weighted_b_slices_prediction_idc = 1, |
| 97 |
std_video_h264_implicit_weighted_b_slices_prediction_idc = 2, |
| 98 |
std_video_h264_invalid_weighted_b_slices_prediction_idc = 0x7FFFFFFF |
| 99 |
} StdVideoH264WeightedBiPredIdc; |
| 100 |
|
| 101 |
typedef enum StdVideoH264ModificationOfPicNumsIdc { |
| 102 |
std_video_h264_modification_of_pic_nums_idc_short_term_subtract = 0, |
| 103 |
std_video_h264_modification_of_pic_nums_idc_short_term_add = 1, |
| 104 |
std_video_h264_modification_of_pic_nums_idc_long_term = 2, |
| 105 |
std_video_h264_modification_of_pic_nums_idc_end = 3, |
| 106 |
std_video_h264_modification_of_pic_nums_idc_invalid = 0x7FFFFFFF |
| 107 |
} StdVideoH264ModificationOfPicNumsIdc; |
| 108 |
|
| 109 |
typedef enum StdVideoH264MemMgmtControlOp { |
| 110 |
std_video_h264_mem_mgmt_control_op_end = 0, |
| 111 |
std_video_h264_mem_mgmt_control_op_unmark_short_term = 1, |
| 112 |
std_video_h264_mem_mgmt_control_op_unmark_long_term = 2, |
| 113 |
std_video_h264_mem_mgmt_control_op_mark_long_term = 3, |
| 114 |
std_video_h264_mem_mgmt_control_op_set_max_long_term_index = 4, |
| 115 |
std_video_h264_mem_mgmt_control_op_unmark_all = 5, |
| 116 |
std_video_h264_mem_mgmt_control_op_mark_current_as_long_term = 6, |
| 117 |
std_video_h264_mem_mgmt_control_op_invalid = 0x7FFFFFFF |
| 118 |
} StdVideoH264MemMgmtControlOp; |
| 119 |
|
| 120 |
typedef enum StdVideoH264CabacInitIdc { |
| 121 |
std_video_h264_cabac_init_idc_0 = 0, |
| 122 |
std_video_h264_cabac_init_idc_1 = 1, |
| 123 |
std_video_h264_cabac_init_idc_2 = 2, |
| 124 |
std_video_h264_cabac_init_idc_invalid = 0x7FFFFFFF |
| 125 |
} StdVideoH264CabacInitIdc; |
| 126 |
|
| 127 |
typedef enum StdVideoH264DisableDeblockingFilterIdc { |
| 128 |
std_video_h264_disable_deblocking_filter_idc_disabled = 0, |
| 129 |
std_video_h264_disable_deblocking_filter_idc_enabled = 1, |
| 130 |
std_video_h264_disable_deblocking_filter_idc_partial = 2, |
| 131 |
std_video_h264_disable_deblocking_filter_idc_invalid = 0x7FFFFFFF |
| 132 |
} StdVideoH264DisableDeblockingFilterIdc; |
| 133 |
|
| 134 |
typedef enum StdVideoH264PictureType { |
| 135 |
std_video_h264_picture_type_i = 0, |
| 136 |
std_video_h264_picture_type_p = 1, |
| 137 |
std_video_h264_picture_type_b = 2, |
| 138 |
std_video_h264_picture_type_invalid = 0x7FFFFFFF |
| 139 |
} StdVideoH264PictureType; |
| 140 |
|
| 141 |
typedef enum StdVideoH264SliceType { |
| 142 |
std_video_h264_slice_type_i = 0, |
| 143 |
std_video_h264_slice_type_p = 1, |
| 144 |
std_video_h264_slice_type_b = 2, |
| 145 |
std_video_h264_slice_type_invalid = 0x7FFFFFFF |
| 146 |
} StdVideoH264SliceType; |
| 147 |
|
| 148 |
typedef enum StdVideoH264NonVclNaluType { |
| 149 |
std_video_h264_non_vcl_nalu_type_sps = 0, |
| 150 |
std_video_h264_non_vcl_nalu_type_pps = 1, |
| 151 |
std_video_h264_non_vcl_nalu_type_aud = 2, |
| 152 |
std_video_h264_non_vcl_nalu_type_prefix = 3, |
| 153 |
std_video_h264_non_vcl_nalu_type_end_of_sequence = 4, |
| 154 |
std_video_h264_non_vcl_nalu_type_end_of_stream = 5, |
| 155 |
std_video_h264_non_vcl_nalu_type_precoded = 6, |
| 156 |
std_video_h264_non_vcl_nalu_type_invalid = 0x7FFFFFFF |
| 157 |
} StdVideoH264NonVclNaluType; |
| 158 |
|
| 159 |
typedef struct StdVideoH264SpsVuiFlags { |
| 160 |
uint32_t aspect_ratio_info_present_flag:1; |
| 161 |
uint32_t overscan_info_present_flag:1; |
| 162 |
uint32_t overscan_appropriate_flag:1; |
| 163 |
uint32_t video_signal_type_present_flag:1; |
| 164 |
uint32_t video_full_range_flag:1; |
| 165 |
uint32_t color_description_present_flag:1; |
| 166 |
uint32_t chroma_loc_info_present_flag:1; |
| 167 |
uint32_t timing_info_present_flag:1; |
| 168 |
uint32_t fixed_frame_rate_flag:1; |
| 169 |
uint32_t bitstream_restriction_flag:1; |
| 170 |
uint32_t nal_hrd_parameters_present_flag:1; |
| 171 |
uint32_t vcl_hrd_parameters_present_flag:1; |
| 172 |
} StdVideoH264SpsVuiFlags; |
| 173 |
|
| 174 |
typedef struct StdVideoH264HrdParameters { |
| 175 |
uint8_t cpb_cnt_minus1; |
| 176 |
uint8_t bit_rate_scale; |
| 177 |
uint8_t cpb_size_scale; |
| 178 |
uint32_t bit_rate_value_minus1[32]; |
| 179 |
uint32_t cpb_size_value_minus1[32]; |
| 180 |
uint8_t cbr_flag[32]; |
| 181 |
uint32_t initial_cpb_removal_delay_length_minus1; |
| 182 |
uint32_t cpb_removal_delay_length_minus1; |
| 183 |
uint32_t dpb_output_delay_length_minus1; |
| 184 |
uint32_t time_offset_length; |
| 185 |
} StdVideoH264HrdParameters; |
| 186 |
|
| 187 |
typedef struct StdVideoH264SequenceParameterSetVui { |
| 188 |
StdVideoH264AspectRatioIdc aspect_ratio_idc; |
| 189 |
uint16_t sar_width; |
| 190 |
uint16_t sar_height; |
| 191 |
uint8_t video_format; |
| 192 |
uint8_t color_primaries; |
| 193 |
uint8_t transfer_characteristics; |
| 194 |
uint8_t matrix_coefficients; |
| 195 |
uint32_t num_units_in_tick; |
| 196 |
uint32_t time_scale; |
| 197 |
StdVideoH264HrdParameters hrd_parameters; |
| 198 |
uint8_t num_reorder_frames; |
| 199 |
uint8_t max_dec_frame_buffering; |
| 200 |
StdVideoH264SpsVuiFlags flags; |
| 201 |
} StdVideoH264SequenceParameterSetVui; |
| 202 |
|
| 203 |
typedef struct StdVideoH264SpsFlags { |
| 204 |
uint32_t constraint_set0_flag:1; |
| 205 |
uint32_t constraint_set1_flag:1; |
| 206 |
uint32_t constraint_set2_flag:1; |
| 207 |
uint32_t constraint_set3_flag:1; |
| 208 |
uint32_t constraint_set4_flag:1; |
| 209 |
uint32_t constraint_set5_flag:1; |
| 210 |
uint32_t direct_8x8_inference_flag:1; |
| 211 |
uint32_t mb_adaptive_frame_field_flag:1; |
| 212 |
uint32_t frame_mbs_only_flag:1; |
| 213 |
uint32_t delta_pic_order_always_zero_flag:1; |
| 214 |
uint32_t residual_colour_transform_flag:1; |
| 215 |
uint32_t gaps_in_frame_num_value_allowed_flag:1; |
| 216 |
uint32_t first_picture_after_seek_flag:1; // where is this being documented? |
| 217 |
uint32_t qpprime_y_zero_transform_bypass_flag:1; |
| 218 |
uint32_t frame_cropping_flag:1; |
| 219 |
uint32_t scaling_matrix_present_flag:1; |
| 220 |
uint32_t vui_parameters_present_flag:1; |
| 221 |
} StdVideoH264SpsFlags; |
| 222 |
|
| 223 |
typedef struct StdVideoH264ScalingLists |
| 224 |
{ |
| 225 |
// scaling_list_present_mask has one bit for each |
| 226 |
// seq_scaling_list_present_flag[i] for SPS OR |
| 227 |
// pic_scaling_list_present_flag[i] for PPS, |
| 228 |
// bit 0 - 5 are for each entry of ScalingList4x4 |
| 229 |
// bit 6 - 7 are for each entry plus 6 for ScalingList8x8 |
| 230 |
uint8_t scaling_list_present_mask; |
| 231 |
// use_default_scaling_matrix_mask has one bit for each |
| 232 |
// UseDefaultScalingMatrix4x4Flag[ i ] and |
| 233 |
// UseDefaultScalingMatrix8x8Flag[ i - 6 ] for SPS OR PPS |
| 234 |
// bit 0 - 5 are for each entry of ScalingList4x4 |
| 235 |
// bit 6 - 7 are for each entry plus 6 for ScalingList8x8 |
| 236 |
uint8_t use_default_scaling_matrix_mask; |
| 237 |
uint8_t ScalingList4x4[6][16]; |
| 238 |
uint8_t ScalingList8x8[2][64]; |
| 239 |
} StdVideoH264ScalingLists; |
| 240 |
|
| 241 |
typedef struct StdVideoH264SequenceParameterSet |
| 242 |
{ |
| 243 |
StdVideoH264ProfileIdc profile_idc; |
| 244 |
StdVideoH264Level level_idc; |
| 245 |
uint8_t seq_parameter_set_id; |
| 246 |
StdVideoH264ChromaFormatIdc chroma_format_idc; |
| 247 |
uint8_t bit_depth_luma_minus8; |
| 248 |
uint8_t bit_depth_chroma_minus8; |
| 249 |
uint8_t log2_max_frame_num_minus4; |
| 250 |
StdVideoH264PocType pic_order_cnt_type; |
| 251 |
uint8_t log2_max_pic_order_cnt_lsb_minus4; |
| 252 |
int32_t offset_for_non_ref_pic; |
| 253 |
int32_t offset_for_top_to_bottom_field; |
| 254 |
uint8_t num_ref_frames_in_pic_order_cnt_cycle; |
| 255 |
uint8_t max_num_ref_frames; |
| 256 |
uint32_t pic_width_in_mbs_minus1; |
| 257 |
uint32_t pic_height_in_map_units_minus1; |
| 258 |
uint32_t frame_crop_left_offset; |
| 259 |
uint32_t frame_crop_right_offset; |
| 260 |
uint32_t frame_crop_top_offset; |
| 261 |
uint32_t frame_crop_bottom_offset; |
| 262 |
StdVideoH264SpsFlags flags; |
| 263 |
int32_t offset_for_ref_frame[255]; // The number of valid values are defined by the num_ref_frames_in_pic_order_cnt_cycle |
| 264 |
StdVideoH264ScalingLists* pScalingLists; // Must be a valid pointer if scaling_matrix_present_flag is set |
| 265 |
StdVideoH264SequenceParameterSetVui* pSequenceParameterSetVui; // Must be a valid pointer if StdVideoH264SpsFlags:vui_parameters_present_flag is set |
| 266 |
} StdVideoH264SequenceParameterSet; |
| 267 |
|
| 268 |
typedef struct StdVideoH264PpsFlags { |
| 269 |
uint32_t transform_8x8_mode_flag:1; |
| 270 |
uint32_t redundant_pic_cnt_present_flag:1; |
| 271 |
uint32_t constrained_intra_pred_flag:1; |
| 272 |
uint32_t deblocking_filter_control_present_flag:1; |
| 273 |
uint32_t weighted_bipred_idc_flag:1; |
| 274 |
uint32_t weighted_pred_flag:1; |
| 275 |
uint32_t pic_order_present_flag:1; |
| 276 |
uint32_t entropy_coding_mode_flag:1; |
| 277 |
uint32_t scaling_matrix_present_flag:1; |
| 278 |
} StdVideoH264PpsFlags; |
| 279 |
|
| 280 |
typedef struct StdVideoH264PictureParameterSet |
| 281 |
{ |
| 282 |
uint8_t seq_parameter_set_id; |
| 283 |
uint8_t pic_parameter_set_id; |
| 284 |
uint8_t num_ref_idx_l0_default_active_minus1; |
| 285 |
uint8_t num_ref_idx_l1_default_active_minus1; |
| 286 |
StdVideoH264WeightedBiPredIdc weighted_bipred_idc; |
| 287 |
int8_t pic_init_qp_minus26; |
| 288 |
int8_t pic_init_qs_minus26; |
| 289 |
int8_t chroma_qp_index_offset; |
| 290 |
int8_t second_chroma_qp_index_offset; |
| 291 |
StdVideoH264PpsFlags flags; |
| 292 |
StdVideoH264ScalingLists* pScalingLists; // Must be a valid pointer if StdVideoH264PpsFlags::scaling_matrix_present_flag is set. |
| 293 |
} StdVideoH264PictureParameterSet; |
| 294 |
|
| 295 |
#ifdef __cplusplus |
| 296 |
} |
| 297 |
#endif |
| 298 |
|
| 299 |
#endif // VULKAN_VIDEO_CODEC_H264STD_H_ |