1 /* 2 * This file is part of FFmpeg. 3 * 4 * FFmpeg is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation; either 7 * version 2.1 of the License, or (at your option) any later version. 8 * 9 * FFmpeg is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public 15 * License along with FFmpeg; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 */ 18 19 #ifndef AVCODEC_CBS_H265_H 20 #define AVCODEC_CBS_H265_H 21 22 #include <stddef.h> 23 #include <stdint.h> 24 25 #include "cbs_h2645.h" 26 #include "hevc.h" 27 28 enum { 29 // This limit is arbitrary - it is sufficient for one message of each 30 // type plus some repeats, and will therefore easily cover all sane 31 // streams. However, it is possible to make technically-valid streams 32 // for which it will fail (for example, by including a large number of 33 // user-data-unregistered messages). 34 H265_MAX_SEI_PAYLOADS = 64, 35 }; 36 37 typedef struct H265RawNALUnitHeader { 38 uint8_t nal_unit_type; 39 uint8_t nuh_layer_id; 40 uint8_t nuh_temporal_id_plus1; 41 } H265RawNALUnitHeader; 42 43 typedef struct H265RawProfileTierLevel { 44 uint8_t general_profile_space; 45 uint8_t general_tier_flag; 46 uint8_t general_profile_idc; 47 48 uint8_t general_profile_compatibility_flag[32]; 49 50 uint8_t general_progressive_source_flag; 51 uint8_t general_interlaced_source_flag; 52 uint8_t general_non_packed_constraint_flag; 53 uint8_t general_frame_only_constraint_flag; 54 55 uint8_t general_max_12bit_constraint_flag; 56 uint8_t general_max_10bit_constraint_flag; 57 uint8_t general_max_8bit_constraint_flag; 58 uint8_t general_max_422chroma_constraint_flag; 59 uint8_t general_max_420chroma_constraint_flag; 60 uint8_t general_max_monochrome_constraint_flag; 61 uint8_t general_intra_constraint_flag; 62 uint8_t general_one_picture_only_constraint_flag; 63 uint8_t general_lower_bit_rate_constraint_flag; 64 uint8_t general_max_14bit_constraint_flag; 65 66 uint8_t general_inbld_flag; 67 68 uint8_t general_level_idc; 69 70 uint8_t sub_layer_profile_present_flag[HEVC_MAX_SUB_LAYERS]; 71 uint8_t sub_layer_level_present_flag[HEVC_MAX_SUB_LAYERS]; 72 73 uint8_t sub_layer_profile_space[HEVC_MAX_SUB_LAYERS]; 74 uint8_t sub_layer_tier_flag[HEVC_MAX_SUB_LAYERS]; 75 uint8_t sub_layer_profile_idc[HEVC_MAX_SUB_LAYERS]; 76 77 uint8_t sub_layer_profile_compatibility_flag[HEVC_MAX_SUB_LAYERS][32]; 78 79 uint8_t sub_layer_progressive_source_flag[HEVC_MAX_SUB_LAYERS]; 80 uint8_t sub_layer_interlaced_source_flag[HEVC_MAX_SUB_LAYERS]; 81 uint8_t sub_layer_non_packed_constraint_flag[HEVC_MAX_SUB_LAYERS]; 82 uint8_t sub_layer_frame_only_constraint_flag[HEVC_MAX_SUB_LAYERS]; 83 84 uint8_t sub_layer_max_12bit_constraint_flag[HEVC_MAX_SUB_LAYERS]; 85 uint8_t sub_layer_max_10bit_constraint_flag[HEVC_MAX_SUB_LAYERS]; 86 uint8_t sub_layer_max_8bit_constraint_flag[HEVC_MAX_SUB_LAYERS]; 87 uint8_t sub_layer_max_422chroma_constraint_flag[HEVC_MAX_SUB_LAYERS]; 88 uint8_t sub_layer_max_420chroma_constraint_flag[HEVC_MAX_SUB_LAYERS]; 89 uint8_t sub_layer_max_monochrome_constraint_flag[HEVC_MAX_SUB_LAYERS]; 90 uint8_t sub_layer_intra_constraint_flag[HEVC_MAX_SUB_LAYERS]; 91 uint8_t sub_layer_one_picture_only_constraint_flag[HEVC_MAX_SUB_LAYERS]; 92 uint8_t sub_layer_lower_bit_rate_constraint_flag[HEVC_MAX_SUB_LAYERS]; 93 uint8_t sub_layer_max_14bit_constraint_flag[HEVC_MAX_SUB_LAYERS]; 94 95 uint8_t sub_layer_inbld_flag[HEVC_MAX_SUB_LAYERS]; 96 97 uint8_t sub_layer_level_idc[HEVC_MAX_SUB_LAYERS]; 98 } H265RawProfileTierLevel; 99 100 typedef struct H265RawSubLayerHRDParameters { 101 uint32_t bit_rate_value_minus1[HEVC_MAX_CPB_CNT]; 102 uint32_t cpb_size_value_minus1[HEVC_MAX_CPB_CNT]; 103 uint32_t cpb_size_du_value_minus1[HEVC_MAX_CPB_CNT]; 104 uint32_t bit_rate_du_value_minus1[HEVC_MAX_CPB_CNT]; 105 uint8_t cbr_flag[HEVC_MAX_CPB_CNT]; 106 } H265RawSubLayerHRDParameters; 107 108 typedef struct H265RawHRDParameters { 109 uint8_t nal_hrd_parameters_present_flag; 110 uint8_t vcl_hrd_parameters_present_flag; 111 112 uint8_t sub_pic_hrd_params_present_flag; 113 uint8_t tick_divisor_minus2; 114 uint8_t du_cpb_removal_delay_increment_length_minus1; 115 uint8_t sub_pic_cpb_params_in_pic_timing_sei_flag; 116 uint8_t dpb_output_delay_du_length_minus1; 117 118 uint8_t bit_rate_scale; 119 uint8_t cpb_size_scale; 120 uint8_t cpb_size_du_scale; 121 122 uint8_t initial_cpb_removal_delay_length_minus1; 123 uint8_t au_cpb_removal_delay_length_minus1; 124 uint8_t dpb_output_delay_length_minus1; 125 126 uint8_t fixed_pic_rate_general_flag[HEVC_MAX_SUB_LAYERS]; 127 uint8_t fixed_pic_rate_within_cvs_flag[HEVC_MAX_SUB_LAYERS]; 128 uint16_t elemental_duration_in_tc_minus1[HEVC_MAX_SUB_LAYERS]; 129 uint8_t low_delay_hrd_flag[HEVC_MAX_SUB_LAYERS]; 130 uint8_t cpb_cnt_minus1[HEVC_MAX_SUB_LAYERS]; 131 H265RawSubLayerHRDParameters nal_sub_layer_hrd_parameters[HEVC_MAX_SUB_LAYERS]; 132 H265RawSubLayerHRDParameters vcl_sub_layer_hrd_parameters[HEVC_MAX_SUB_LAYERS]; 133 } H265RawHRDParameters; 134 135 typedef struct H265RawVUI { 136 uint8_t aspect_ratio_info_present_flag; 137 uint8_t aspect_ratio_idc; 138 uint16_t sar_width; 139 uint16_t sar_height; 140 141 uint8_t overscan_info_present_flag; 142 uint8_t overscan_appropriate_flag; 143 144 uint8_t video_signal_type_present_flag; 145 uint8_t video_format; 146 uint8_t video_full_range_flag; 147 uint8_t colour_description_present_flag; 148 uint8_t colour_primaries; 149 uint8_t transfer_characteristics; 150 uint8_t matrix_coefficients; 151 152 uint8_t chroma_loc_info_present_flag; 153 uint8_t chroma_sample_loc_type_top_field; 154 uint8_t chroma_sample_loc_type_bottom_field; 155 156 uint8_t neutral_chroma_indication_flag; 157 uint8_t field_seq_flag; 158 uint8_t frame_field_info_present_flag; 159 160 uint8_t default_display_window_flag; 161 uint16_t def_disp_win_left_offset; 162 uint16_t def_disp_win_right_offset; 163 uint16_t def_disp_win_top_offset; 164 uint16_t def_disp_win_bottom_offset; 165 166 uint8_t vui_timing_info_present_flag; 167 uint32_t vui_num_units_in_tick; 168 uint32_t vui_time_scale; 169 uint8_t vui_poc_proportional_to_timing_flag; 170 uint32_t vui_num_ticks_poc_diff_one_minus1; 171 uint8_t vui_hrd_parameters_present_flag; 172 H265RawHRDParameters hrd_parameters; 173 174 uint8_t bitstream_restriction_flag; 175 uint8_t tiles_fixed_structure_flag; 176 uint8_t motion_vectors_over_pic_boundaries_flag; 177 uint8_t restricted_ref_pic_lists_flag; 178 uint16_t min_spatial_segmentation_idc; 179 uint8_t max_bytes_per_pic_denom; 180 uint8_t max_bits_per_min_cu_denom; 181 uint8_t log2_max_mv_length_horizontal; 182 uint8_t log2_max_mv_length_vertical; 183 } H265RawVUI; 184 185 typedef struct H265RawExtensionData { 186 uint8_t *data; 187 size_t bit_length; 188 AVBufferRef *data_ref; 189 } H265RawExtensionData; 190 191 typedef struct H265RawVPS { 192 H265RawNALUnitHeader nal_unit_header; 193 194 uint8_t vps_video_parameter_set_id; 195 196 uint8_t vps_base_layer_internal_flag; 197 uint8_t vps_base_layer_available_flag; 198 uint8_t vps_max_layers_minus1; 199 uint8_t vps_max_sub_layers_minus1; 200 uint8_t vps_temporal_id_nesting_flag; 201 202 H265RawProfileTierLevel profile_tier_level; 203 204 uint8_t vps_sub_layer_ordering_info_present_flag; 205 uint8_t vps_max_dec_pic_buffering_minus1[HEVC_MAX_SUB_LAYERS]; 206 uint8_t vps_max_num_reorder_pics[HEVC_MAX_SUB_LAYERS]; 207 uint32_t vps_max_latency_increase_plus1[HEVC_MAX_SUB_LAYERS]; 208 209 uint8_t vps_max_layer_id; 210 uint16_t vps_num_layer_sets_minus1; 211 uint8_t layer_id_included_flag[HEVC_MAX_LAYER_SETS][HEVC_MAX_LAYERS]; 212 213 uint8_t vps_timing_info_present_flag; 214 uint32_t vps_num_units_in_tick; 215 uint32_t vps_time_scale; 216 uint8_t vps_poc_proportional_to_timing_flag; 217 uint32_t vps_num_ticks_poc_diff_one_minus1; 218 uint16_t vps_num_hrd_parameters; 219 uint16_t hrd_layer_set_idx[HEVC_MAX_LAYER_SETS]; 220 uint8_t cprms_present_flag[HEVC_MAX_LAYER_SETS]; 221 H265RawHRDParameters hrd_parameters[HEVC_MAX_LAYER_SETS]; 222 223 uint8_t vps_extension_flag; 224 H265RawExtensionData extension_data; 225 } H265RawVPS; 226 227 typedef struct H265RawSTRefPicSet { 228 uint8_t inter_ref_pic_set_prediction_flag; 229 230 uint8_t delta_idx_minus1; 231 uint8_t delta_rps_sign; 232 uint16_t abs_delta_rps_minus1; 233 234 uint8_t used_by_curr_pic_flag[HEVC_MAX_REFS]; 235 uint8_t use_delta_flag[HEVC_MAX_REFS]; 236 237 uint8_t num_negative_pics; 238 uint8_t num_positive_pics; 239 uint16_t delta_poc_s0_minus1[HEVC_MAX_REFS]; 240 uint8_t used_by_curr_pic_s0_flag[HEVC_MAX_REFS]; 241 uint16_t delta_poc_s1_minus1[HEVC_MAX_REFS]; 242 uint8_t used_by_curr_pic_s1_flag[HEVC_MAX_REFS]; 243 } H265RawSTRefPicSet; 244 245 typedef struct H265RawScalingList { 246 uint8_t scaling_list_pred_mode_flag[4][6]; 247 uint8_t scaling_list_pred_matrix_id_delta[4][6]; 248 int16_t scaling_list_dc_coef_minus8[4][6]; 249 int8_t scaling_list_delta_coeff[4][6][64]; 250 } H265RawScalingList; 251 252 typedef struct H265RawSPS { 253 H265RawNALUnitHeader nal_unit_header; 254 255 uint8_t sps_video_parameter_set_id; 256 257 uint8_t sps_max_sub_layers_minus1; 258 uint8_t sps_temporal_id_nesting_flag; 259 260 H265RawProfileTierLevel profile_tier_level; 261 262 uint8_t sps_seq_parameter_set_id; 263 264 uint8_t chroma_format_idc; 265 uint8_t separate_colour_plane_flag; 266 267 uint16_t pic_width_in_luma_samples; 268 uint16_t pic_height_in_luma_samples; 269 270 uint8_t conformance_window_flag; 271 uint16_t conf_win_left_offset; 272 uint16_t conf_win_right_offset; 273 uint16_t conf_win_top_offset; 274 uint16_t conf_win_bottom_offset; 275 276 uint8_t bit_depth_luma_minus8; 277 uint8_t bit_depth_chroma_minus8; 278 279 uint8_t log2_max_pic_order_cnt_lsb_minus4; 280 281 uint8_t sps_sub_layer_ordering_info_present_flag; 282 uint8_t sps_max_dec_pic_buffering_minus1[HEVC_MAX_SUB_LAYERS]; 283 uint8_t sps_max_num_reorder_pics[HEVC_MAX_SUB_LAYERS]; 284 uint32_t sps_max_latency_increase_plus1[HEVC_MAX_SUB_LAYERS]; 285 286 uint8_t log2_min_luma_coding_block_size_minus3; 287 uint8_t log2_diff_max_min_luma_coding_block_size; 288 uint8_t log2_min_luma_transform_block_size_minus2; 289 uint8_t log2_diff_max_min_luma_transform_block_size; 290 uint8_t max_transform_hierarchy_depth_inter; 291 uint8_t max_transform_hierarchy_depth_intra; 292 293 uint8_t scaling_list_enabled_flag; 294 uint8_t sps_scaling_list_data_present_flag; 295 H265RawScalingList scaling_list; 296 297 uint8_t amp_enabled_flag; 298 uint8_t sample_adaptive_offset_enabled_flag; 299 300 uint8_t pcm_enabled_flag; 301 uint8_t pcm_sample_bit_depth_luma_minus1; 302 uint8_t pcm_sample_bit_depth_chroma_minus1; 303 uint8_t log2_min_pcm_luma_coding_block_size_minus3; 304 uint8_t log2_diff_max_min_pcm_luma_coding_block_size; 305 uint8_t pcm_loop_filter_disabled_flag; 306 307 uint8_t num_short_term_ref_pic_sets; 308 H265RawSTRefPicSet st_ref_pic_set[HEVC_MAX_SHORT_TERM_REF_PIC_SETS]; 309 310 uint8_t long_term_ref_pics_present_flag; 311 uint8_t num_long_term_ref_pics_sps; 312 uint16_t lt_ref_pic_poc_lsb_sps[HEVC_MAX_LONG_TERM_REF_PICS]; 313 uint8_t used_by_curr_pic_lt_sps_flag[HEVC_MAX_LONG_TERM_REF_PICS]; 314 315 uint8_t sps_temporal_mvp_enabled_flag; 316 uint8_t strong_intra_smoothing_enabled_flag; 317 318 uint8_t vui_parameters_present_flag; 319 H265RawVUI vui; 320 321 uint8_t sps_extension_present_flag; 322 uint8_t sps_range_extension_flag; 323 uint8_t sps_multilayer_extension_flag; 324 uint8_t sps_3d_extension_flag; 325 uint8_t sps_scc_extension_flag; 326 uint8_t sps_extension_4bits; 327 328 H265RawExtensionData extension_data; 329 330 // Range extension. 331 uint8_t transform_skip_rotation_enabled_flag; 332 uint8_t transform_skip_context_enabled_flag; 333 uint8_t implicit_rdpcm_enabled_flag; 334 uint8_t explicit_rdpcm_enabled_flag; 335 uint8_t extended_precision_processing_flag; 336 uint8_t intra_smoothing_disabled_flag; 337 uint8_t high_precision_offsets_enabled_flag; 338 uint8_t persistent_rice_adaptation_enabled_flag; 339 uint8_t cabac_bypass_alignment_enabled_flag; 340 341 // Screen content coding extension. 342 uint8_t sps_curr_pic_ref_enabled_flag; 343 uint8_t palette_mode_enabled_flag; 344 uint8_t palette_max_size; 345 uint8_t delta_palette_max_predictor_size; 346 uint8_t sps_palette_predictor_initializer_present_flag; 347 uint8_t sps_num_palette_predictor_initializer_minus1; 348 uint16_t sps_palette_predictor_initializers[3][128]; 349 350 uint8_t motion_vector_resolution_control_idc; 351 uint8_t intra_boundary_filtering_disable_flag; 352 } H265RawSPS; 353 354 typedef struct H265RawPPS { 355 H265RawNALUnitHeader nal_unit_header; 356 357 uint8_t pps_pic_parameter_set_id; 358 uint8_t pps_seq_parameter_set_id; 359 360 uint8_t dependent_slice_segments_enabled_flag; 361 uint8_t output_flag_present_flag; 362 uint8_t num_extra_slice_header_bits; 363 uint8_t sign_data_hiding_enabled_flag; 364 uint8_t cabac_init_present_flag; 365 366 uint8_t num_ref_idx_l0_default_active_minus1; 367 uint8_t num_ref_idx_l1_default_active_minus1; 368 369 int8_t init_qp_minus26; 370 371 uint8_t constrained_intra_pred_flag; 372 uint8_t transform_skip_enabled_flag; 373 uint8_t cu_qp_delta_enabled_flag; 374 uint8_t diff_cu_qp_delta_depth; 375 376 int8_t pps_cb_qp_offset; 377 int8_t pps_cr_qp_offset; 378 uint8_t pps_slice_chroma_qp_offsets_present_flag; 379 380 uint8_t weighted_pred_flag; 381 uint8_t weighted_bipred_flag; 382 383 uint8_t transquant_bypass_enabled_flag; 384 uint8_t tiles_enabled_flag; 385 uint8_t entropy_coding_sync_enabled_flag; 386 387 uint8_t num_tile_columns_minus1; 388 uint8_t num_tile_rows_minus1; 389 uint8_t uniform_spacing_flag; 390 uint16_t column_width_minus1[HEVC_MAX_TILE_COLUMNS]; 391 uint16_t row_height_minus1[HEVC_MAX_TILE_ROWS]; 392 uint8_t loop_filter_across_tiles_enabled_flag; 393 394 uint8_t pps_loop_filter_across_slices_enabled_flag; 395 uint8_t deblocking_filter_control_present_flag; 396 uint8_t deblocking_filter_override_enabled_flag; 397 uint8_t pps_deblocking_filter_disabled_flag; 398 int8_t pps_beta_offset_div2; 399 int8_t pps_tc_offset_div2; 400 401 uint8_t pps_scaling_list_data_present_flag; 402 H265RawScalingList scaling_list; 403 404 uint8_t lists_modification_present_flag; 405 uint8_t log2_parallel_merge_level_minus2; 406 407 uint8_t slice_segment_header_extension_present_flag; 408 409 uint8_t pps_extension_present_flag; 410 uint8_t pps_range_extension_flag; 411 uint8_t pps_multilayer_extension_flag; 412 uint8_t pps_3d_extension_flag; 413 uint8_t pps_scc_extension_flag; 414 uint8_t pps_extension_4bits; 415 416 H265RawExtensionData extension_data; 417 418 // Range extension. 419 uint8_t log2_max_transform_skip_block_size_minus2; 420 uint8_t cross_component_prediction_enabled_flag; 421 uint8_t chroma_qp_offset_list_enabled_flag; 422 uint8_t diff_cu_chroma_qp_offset_depth; 423 uint8_t chroma_qp_offset_list_len_minus1; 424 int8_t cb_qp_offset_list[6]; 425 int8_t cr_qp_offset_list[6]; 426 uint8_t log2_sao_offset_scale_luma; 427 uint8_t log2_sao_offset_scale_chroma; 428 429 // Screen content coding extension. 430 uint8_t pps_curr_pic_ref_enabled_flag; 431 uint8_t residual_adaptive_colour_transform_enabled_flag; 432 uint8_t pps_slice_act_qp_offsets_present_flag; 433 int8_t pps_act_y_qp_offset_plus5; 434 int8_t pps_act_cb_qp_offset_plus5; 435 int8_t pps_act_cr_qp_offset_plus3; 436 437 uint8_t pps_palette_predictor_initializer_present_flag; 438 uint8_t pps_num_palette_predictor_initializer; 439 uint8_t monochrome_palette_flag; 440 uint8_t luma_bit_depth_entry_minus8; 441 uint8_t chroma_bit_depth_entry_minus8; 442 uint16_t pps_palette_predictor_initializers[3][128]; 443 } H265RawPPS; 444 445 typedef struct H265RawAUD { 446 H265RawNALUnitHeader nal_unit_header; 447 448 uint8_t pic_type; 449 } H265RawAUD; 450 451 typedef struct H265RawSliceHeader { 452 H265RawNALUnitHeader nal_unit_header; 453 454 uint8_t first_slice_segment_in_pic_flag; 455 uint8_t no_output_of_prior_pics_flag; 456 uint8_t slice_pic_parameter_set_id; 457 458 uint8_t dependent_slice_segment_flag; 459 uint16_t slice_segment_address; 460 461 uint8_t slice_reserved_flag[8]; 462 uint8_t slice_type; 463 464 uint8_t pic_output_flag; 465 uint8_t colour_plane_id; 466 467 uint16_t slice_pic_order_cnt_lsb; 468 469 uint8_t short_term_ref_pic_set_sps_flag; 470 H265RawSTRefPicSet short_term_ref_pic_set; 471 uint8_t short_term_ref_pic_set_idx; 472 473 uint8_t num_long_term_sps; 474 uint8_t num_long_term_pics; 475 uint8_t lt_idx_sps[HEVC_MAX_REFS]; 476 uint8_t poc_lsb_lt[HEVC_MAX_REFS]; 477 uint8_t used_by_curr_pic_lt_flag[HEVC_MAX_REFS]; 478 uint8_t delta_poc_msb_present_flag[HEVC_MAX_REFS]; 479 uint32_t delta_poc_msb_cycle_lt[HEVC_MAX_REFS]; 480 481 uint8_t slice_temporal_mvp_enabled_flag; 482 483 uint8_t slice_sao_luma_flag; 484 uint8_t slice_sao_chroma_flag; 485 486 uint8_t num_ref_idx_active_override_flag; 487 uint8_t num_ref_idx_l0_active_minus1; 488 uint8_t num_ref_idx_l1_active_minus1; 489 490 uint8_t ref_pic_list_modification_flag_l0; 491 uint8_t list_entry_l0[HEVC_MAX_REFS]; 492 uint8_t ref_pic_list_modification_flag_l1; 493 uint8_t list_entry_l1[HEVC_MAX_REFS]; 494 495 uint8_t mvd_l1_zero_flag; 496 uint8_t cabac_init_flag; 497 uint8_t collocated_from_l0_flag; 498 uint8_t collocated_ref_idx; 499 500 uint8_t luma_log2_weight_denom; 501 int8_t delta_chroma_log2_weight_denom; 502 uint8_t luma_weight_l0_flag[HEVC_MAX_REFS]; 503 uint8_t chroma_weight_l0_flag[HEVC_MAX_REFS]; 504 int8_t delta_luma_weight_l0[HEVC_MAX_REFS]; 505 int16_t luma_offset_l0[HEVC_MAX_REFS]; 506 int8_t delta_chroma_weight_l0[HEVC_MAX_REFS][2]; 507 int16_t chroma_offset_l0[HEVC_MAX_REFS][2]; 508 uint8_t luma_weight_l1_flag[HEVC_MAX_REFS]; 509 uint8_t chroma_weight_l1_flag[HEVC_MAX_REFS]; 510 int8_t delta_luma_weight_l1[HEVC_MAX_REFS]; 511 int16_t luma_offset_l1[HEVC_MAX_REFS]; 512 int8_t delta_chroma_weight_l1[HEVC_MAX_REFS][2]; 513 int16_t chroma_offset_l1[HEVC_MAX_REFS][2]; 514 515 uint8_t five_minus_max_num_merge_cand; 516 uint8_t use_integer_mv_flag; 517 518 int8_t slice_qp_delta; 519 int8_t slice_cb_qp_offset; 520 int8_t slice_cr_qp_offset; 521 int8_t slice_act_y_qp_offset; 522 int8_t slice_act_cb_qp_offset; 523 int8_t slice_act_cr_qp_offset; 524 uint8_t cu_chroma_qp_offset_enabled_flag; 525 526 uint8_t deblocking_filter_override_flag; 527 uint8_t slice_deblocking_filter_disabled_flag; 528 int8_t slice_beta_offset_div2; 529 int8_t slice_tc_offset_div2; 530 uint8_t slice_loop_filter_across_slices_enabled_flag; 531 532 uint16_t num_entry_point_offsets; 533 uint8_t offset_len_minus1; 534 uint32_t entry_point_offset_minus1[HEVC_MAX_ENTRY_POINT_OFFSETS]; 535 536 uint16_t slice_segment_header_extension_length; 537 uint8_t slice_segment_header_extension_data_byte[256]; 538 } H265RawSliceHeader; 539 540 541 typedef struct H265RawSlice { 542 H265RawSliceHeader header; 543 544 uint8_t *data; 545 size_t data_size; 546 int data_bit_start; 547 AVBufferRef *data_ref; 548 } H265RawSlice; 549 550 551 typedef struct H265RawSEIBufferingPeriod { 552 uint8_t bp_seq_parameter_set_id; 553 uint8_t irap_cpb_params_present_flag; 554 uint32_t cpb_delay_offset; 555 uint32_t dpb_delay_offset; 556 uint8_t concatenation_flag; 557 uint32_t au_cpb_removal_delay_delta_minus1; 558 559 uint32_t nal_initial_cpb_removal_delay[HEVC_MAX_CPB_CNT]; 560 uint32_t nal_initial_cpb_removal_offset[HEVC_MAX_CPB_CNT]; 561 uint32_t nal_initial_alt_cpb_removal_delay[HEVC_MAX_CPB_CNT]; 562 uint32_t nal_initial_alt_cpb_removal_offset[HEVC_MAX_CPB_CNT]; 563 564 uint32_t vcl_initial_cpb_removal_delay[HEVC_MAX_CPB_CNT]; 565 uint32_t vcl_initial_cpb_removal_offset[HEVC_MAX_CPB_CNT]; 566 uint32_t vcl_initial_alt_cpb_removal_delay[HEVC_MAX_CPB_CNT]; 567 uint32_t vcl_initial_alt_cpb_removal_offset[HEVC_MAX_CPB_CNT]; 568 569 uint8_t use_alt_cpb_params_flag; 570 } H265RawSEIBufferingPeriod; 571 572 typedef struct H265RawSEIPicTiming { 573 uint8_t pic_struct; 574 uint8_t source_scan_type; 575 uint8_t duplicate_flag; 576 577 uint32_t au_cpb_removal_delay_minus1; 578 uint32_t pic_dpb_output_delay; 579 uint32_t pic_dpb_output_du_delay; 580 581 uint16_t num_decoding_units_minus1; 582 uint8_t du_common_cpb_removal_delay_flag; 583 uint32_t du_common_cpb_removal_delay_increment_minus1; 584 uint16_t num_nalus_in_du_minus1[HEVC_MAX_SLICE_SEGMENTS]; 585 uint32_t du_cpb_removal_delay_increment_minus1[HEVC_MAX_SLICE_SEGMENTS]; 586 } H265RawSEIPicTiming; 587 588 typedef struct H265RawSEIPanScanRect { 589 uint32_t pan_scan_rect_id; 590 uint8_t pan_scan_rect_cancel_flag; 591 uint8_t pan_scan_cnt_minus1; 592 int32_t pan_scan_rect_left_offset[3]; 593 int32_t pan_scan_rect_right_offset[3]; 594 int32_t pan_scan_rect_top_offset[3]; 595 int32_t pan_scan_rect_bottom_offset[3]; 596 uint16_t pan_scan_rect_persistence_flag; 597 } H265RawSEIPanScanRect; 598 599 typedef struct H265RawSEIUserDataRegistered { 600 uint8_t itu_t_t35_country_code; 601 uint8_t itu_t_t35_country_code_extension_byte; 602 uint8_t *data; 603 size_t data_length; 604 AVBufferRef *data_ref; 605 } H265RawSEIUserDataRegistered; 606 607 typedef struct H265RawSEIUserDataUnregistered { 608 uint8_t uuid_iso_iec_11578[16]; 609 uint8_t *data; 610 size_t data_length; 611 AVBufferRef *data_ref; 612 } H265RawSEIUserDataUnregistered; 613 614 typedef struct H265RawSEIRecoveryPoint { 615 int16_t recovery_poc_cnt; 616 uint8_t exact_match_flag; 617 uint8_t broken_link_flag; 618 } H265RawSEIRecoveryPoint; 619 620 typedef struct H265RawSEIDisplayOrientation { 621 uint8_t display_orientation_cancel_flag; 622 uint8_t hor_flip; 623 uint8_t ver_flip; 624 uint16_t anticlockwise_rotation; 625 uint16_t display_orientation_repetition_period; 626 uint8_t display_orientation_persistence_flag; 627 } H265RawSEIDisplayOrientation; 628 629 typedef struct H265RawSEIActiveParameterSets { 630 uint8_t active_video_parameter_set_id; 631 uint8_t self_contained_cvs_flag; 632 uint8_t no_parameter_set_update_flag; 633 uint8_t num_sps_ids_minus1; 634 uint8_t active_seq_parameter_set_id[HEVC_MAX_SPS_COUNT]; 635 uint8_t layer_sps_idx[HEVC_MAX_LAYERS]; 636 } H265RawSEIActiveParameterSets; 637 638 typedef struct H265RawSEIDecodedPictureHash { 639 uint8_t hash_type; 640 uint8_t picture_md5[3][16]; 641 uint16_t picture_crc[3]; 642 uint32_t picture_checksum[3]; 643 } H265RawSEIDecodedPictureHash; 644 645 typedef struct H265RawSEITimeCode { 646 uint8_t num_clock_ts; 647 uint8_t clock_timestamp_flag[3]; 648 uint8_t units_field_based_flag[3]; 649 uint8_t counting_type[3]; 650 uint8_t full_timestamp_flag[3]; 651 uint8_t discontinuity_flag[3]; 652 uint8_t cnt_dropped_flag[3]; 653 uint16_t n_frames[3]; 654 uint8_t seconds_value[3]; 655 uint8_t minutes_value[3]; 656 uint8_t hours_value[3]; 657 uint8_t seconds_flag[3]; 658 uint8_t minutes_flag[3]; 659 uint8_t hours_flag[3]; 660 uint8_t time_offset_length[3]; 661 int32_t time_offset_value[3]; 662 } H265RawSEITimeCode; 663 664 typedef struct H265RawSEIMasteringDisplayColourVolume { 665 uint16_t display_primaries_x[3]; 666 uint16_t display_primaries_y[3]; 667 uint16_t white_point_x; 668 uint16_t white_point_y; 669 uint32_t max_display_mastering_luminance; 670 uint32_t min_display_mastering_luminance; 671 } H265RawSEIMasteringDisplayColourVolume; 672 673 typedef struct H265RawSEIContentLightLevelInfo { 674 uint16_t max_content_light_level; 675 uint16_t max_pic_average_light_level; 676 } H265RawSEIContentLightLevelInfo; 677 678 typedef struct H265RawSEIAlternativeTransferCharacteristics { 679 uint8_t preferred_transfer_characteristics; 680 } H265RawSEIAlternativeTransferCharacteristics; 681 682 typedef struct H265RawSEIAlphaChannelInfo { 683 uint8_t alpha_channel_cancel_flag; 684 uint8_t alpha_channel_use_idc; 685 uint8_t alpha_channel_bit_depth_minus8; 686 uint16_t alpha_transparent_value; 687 uint16_t alpha_opaque_value; 688 uint8_t alpha_channel_incr_flag; 689 uint8_t alpha_channel_clip_flag; 690 uint8_t alpha_channel_clip_type_flag; 691 } H265RawSEIAlphaChannelInfo; 692 693 typedef struct H265RawSEIPayload { 694 uint32_t payload_type; 695 uint32_t payload_size; 696 union { 697 H265RawSEIBufferingPeriod buffering_period; 698 H265RawSEIPicTiming pic_timing; 699 H265RawSEIPanScanRect pan_scan_rect; 700 H265RawSEIUserDataRegistered user_data_registered; 701 H265RawSEIUserDataUnregistered user_data_unregistered; 702 H265RawSEIRecoveryPoint recovery_point; 703 H265RawSEIDisplayOrientation display_orientation; 704 H265RawSEIActiveParameterSets active_parameter_sets; 705 H265RawSEIDecodedPictureHash decoded_picture_hash; 706 H265RawSEITimeCode time_code; 707 H265RawSEIMasteringDisplayColourVolume mastering_display; 708 H265RawSEIContentLightLevelInfo content_light_level; 709 H265RawSEIAlternativeTransferCharacteristics 710 alternative_transfer_characteristics; 711 H265RawSEIAlphaChannelInfo alpha_channel_info; 712 struct { 713 uint8_t *data; 714 size_t data_length; 715 AVBufferRef *data_ref; 716 } other; 717 } payload; 718 H265RawExtensionData extension_data; 719 } H265RawSEIPayload; 720 721 typedef struct H265RawSEI { 722 H265RawNALUnitHeader nal_unit_header; 723 724 H265RawSEIPayload payload[H265_MAX_SEI_PAYLOADS]; 725 uint8_t payload_count; 726 } H265RawSEI; 727 728 typedef struct CodedBitstreamH265Context { 729 // Reader/writer context in common with the H.264 implementation. 730 CodedBitstreamH2645Context common; 731 732 // All currently available parameter sets. These are updated when 733 // any parameter set NAL unit is read/written with this context. 734 AVBufferRef *vps_ref[HEVC_MAX_VPS_COUNT]; 735 AVBufferRef *sps_ref[HEVC_MAX_SPS_COUNT]; 736 AVBufferRef *pps_ref[HEVC_MAX_PPS_COUNT]; 737 H265RawVPS *vps[HEVC_MAX_VPS_COUNT]; 738 H265RawSPS *sps[HEVC_MAX_SPS_COUNT]; 739 H265RawPPS *pps[HEVC_MAX_PPS_COUNT]; 740 741 // The currently active parameter sets. These are updated when any 742 // NAL unit refers to the relevant parameter set. These pointers 743 // must also be present in the arrays above. 744 const H265RawVPS *active_vps; 745 const H265RawSPS *active_sps; 746 const H265RawPPS *active_pps; 747 } CodedBitstreamH265Context; 748 749 750 #endif /* AVCODEC_CBS_H265_H */ 751