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