| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * HEVC parameter set parsing | ||
| 3 | * | ||
| 4 | * This file is part of FFmpeg. | ||
| 5 | * | ||
| 6 | * FFmpeg is free software; you can redistribute it and/or | ||
| 7 | * modify it under the terms of the GNU Lesser General Public | ||
| 8 | * License as published by the Free Software Foundation; either | ||
| 9 | * version 2.1 of the License, or (at your option) any later version. | ||
| 10 | * | ||
| 11 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 14 | * Lesser General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU Lesser General Public | ||
| 17 | * License along with FFmpeg; if not, write to the Free Software | ||
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | */ | ||
| 20 | |||
| 21 | #ifndef AVCODEC_HEVC_PS_H | ||
| 22 | #define AVCODEC_HEVC_PS_H | ||
| 23 | |||
| 24 | #include <stdint.h> | ||
| 25 | |||
| 26 | #include "libavutil/pixfmt.h" | ||
| 27 | #include "libavutil/rational.h" | ||
| 28 | |||
| 29 | #include "libavcodec/avcodec.h" | ||
| 30 | #include "libavcodec/get_bits.h" | ||
| 31 | #include "libavcodec/h2645_vui.h" | ||
| 32 | |||
| 33 | #include "hevc.h" | ||
| 34 | |||
| 35 | #define HEVC_VPS_MAX_LAYERS 2 | ||
| 36 | |||
| 37 | typedef struct HEVCSublayerHdrParams { | ||
| 38 | uint32_t bit_rate_value_minus1[HEVC_MAX_CPB_CNT]; | ||
| 39 | uint32_t cpb_size_value_minus1[HEVC_MAX_CPB_CNT]; | ||
| 40 | uint32_t cpb_size_du_value_minus1[HEVC_MAX_CPB_CNT]; | ||
| 41 | uint32_t bit_rate_du_value_minus1[HEVC_MAX_CPB_CNT]; | ||
| 42 | uint32_t cbr_flag; | ||
| 43 | } HEVCSublayerHdrParams; | ||
| 44 | |||
| 45 | // flags in bitmask form | ||
| 46 | typedef struct HEVCHdrFlagParams { | ||
| 47 | uint8_t fixed_pic_rate_general_flag; | ||
| 48 | uint8_t fixed_pic_rate_within_cvs_flag; | ||
| 49 | uint8_t low_delay_hrd_flag; | ||
| 50 | } HEVCHdrFlagParams; | ||
| 51 | |||
| 52 | typedef struct HEVCHdrParams { | ||
| 53 | HEVCHdrFlagParams flags; | ||
| 54 | uint8_t nal_hrd_parameters_present_flag; | ||
| 55 | uint8_t vcl_hrd_parameters_present_flag; | ||
| 56 | uint8_t sub_pic_hrd_params_present_flag; | ||
| 57 | uint8_t sub_pic_cpb_params_in_pic_timing_sei_flag; | ||
| 58 | |||
| 59 | uint8_t tick_divisor_minus2; | ||
| 60 | uint8_t du_cpb_removal_delay_increment_length_minus1; | ||
| 61 | uint8_t dpb_output_delay_du_length_minus1; | ||
| 62 | uint8_t bit_rate_scale; | ||
| 63 | uint8_t cpb_size_scale; | ||
| 64 | uint8_t cpb_size_du_scale; | ||
| 65 | uint8_t initial_cpb_removal_delay_length_minus1; | ||
| 66 | uint8_t au_cpb_removal_delay_length_minus1; | ||
| 67 | uint8_t dpb_output_delay_length_minus1; | ||
| 68 | uint8_t cpb_cnt_minus1[HEVC_MAX_SUB_LAYERS]; | ||
| 69 | uint16_t elemental_duration_in_tc_minus1[HEVC_MAX_SUB_LAYERS]; | ||
| 70 | |||
| 71 | HEVCSublayerHdrParams nal_params[HEVC_MAX_SUB_LAYERS]; | ||
| 72 | HEVCSublayerHdrParams vcl_params[HEVC_MAX_SUB_LAYERS]; | ||
| 73 | } HEVCHdrParams; | ||
| 74 | |||
| 75 | typedef struct ShortTermRPS { | ||
| 76 | int32_t delta_poc[32]; | ||
| 77 | uint32_t used; | ||
| 78 | |||
| 79 | uint8_t delta_idx; | ||
| 80 | uint8_t num_negative_pics; | ||
| 81 | uint8_t num_delta_pocs; | ||
| 82 | uint8_t rps_idx_num_delta_pocs; | ||
| 83 | |||
| 84 | uint16_t abs_delta_rps; | ||
| 85 | unsigned delta_rps_sign:1; | ||
| 86 | |||
| 87 | unsigned rps_predict:1; | ||
| 88 | unsigned use_delta:1; | ||
| 89 | } ShortTermRPS; | ||
| 90 | |||
| 91 | typedef struct HEVCWindow { | ||
| 92 | unsigned int left_offset; | ||
| 93 | unsigned int right_offset; | ||
| 94 | unsigned int top_offset; | ||
| 95 | unsigned int bottom_offset; | ||
| 96 | } HEVCWindow; | ||
| 97 | |||
| 98 | typedef struct VUI { | ||
| 99 | H2645VUI common; | ||
| 100 | |||
| 101 | int neutra_chroma_indication_flag; | ||
| 102 | |||
| 103 | int field_seq_flag; | ||
| 104 | int frame_field_info_present_flag; | ||
| 105 | |||
| 106 | int default_display_window_flag; | ||
| 107 | HEVCWindow def_disp_win; | ||
| 108 | |||
| 109 | int vui_timing_info_present_flag; | ||
| 110 | uint32_t vui_num_units_in_tick; | ||
| 111 | uint32_t vui_time_scale; | ||
| 112 | int vui_poc_proportional_to_timing_flag; | ||
| 113 | int vui_num_ticks_poc_diff_one_minus1; | ||
| 114 | int vui_hrd_parameters_present_flag; | ||
| 115 | |||
| 116 | int bitstream_restriction_flag; | ||
| 117 | int tiles_fixed_structure_flag; | ||
| 118 | int motion_vectors_over_pic_boundaries_flag; | ||
| 119 | int restricted_ref_pic_lists_flag; | ||
| 120 | int min_spatial_segmentation_idc; | ||
| 121 | int max_bytes_per_pic_denom; | ||
| 122 | int max_bits_per_min_cu_denom; | ||
| 123 | int log2_max_mv_length_horizontal; | ||
| 124 | int log2_max_mv_length_vertical; | ||
| 125 | } VUI; | ||
| 126 | |||
| 127 | typedef struct PTLCommon { | ||
| 128 | uint8_t profile_space; | ||
| 129 | uint8_t tier_flag; | ||
| 130 | uint8_t profile_idc; | ||
| 131 | uint8_t profile_compatibility_flag[32]; | ||
| 132 | uint8_t progressive_source_flag; | ||
| 133 | uint8_t interlaced_source_flag; | ||
| 134 | uint8_t non_packed_constraint_flag; | ||
| 135 | uint8_t frame_only_constraint_flag; | ||
| 136 | uint8_t max_12bit_constraint_flag; | ||
| 137 | uint8_t max_10bit_constraint_flag; | ||
| 138 | uint8_t max_8bit_constraint_flag; | ||
| 139 | uint8_t max_422chroma_constraint_flag; | ||
| 140 | uint8_t max_420chroma_constraint_flag; | ||
| 141 | uint8_t max_monochrome_constraint_flag; | ||
| 142 | uint8_t intra_constraint_flag; | ||
| 143 | uint8_t one_picture_only_constraint_flag; | ||
| 144 | uint8_t lower_bit_rate_constraint_flag; | ||
| 145 | uint8_t max_14bit_constraint_flag; | ||
| 146 | uint8_t inbld_flag; | ||
| 147 | uint8_t level_idc; | ||
| 148 | } PTLCommon; | ||
| 149 | |||
| 150 | typedef struct PTL { | ||
| 151 | PTLCommon general_ptl; | ||
| 152 | PTLCommon sub_layer_ptl[HEVC_MAX_SUB_LAYERS]; | ||
| 153 | |||
| 154 | uint8_t sub_layer_profile_present_flag[HEVC_MAX_SUB_LAYERS]; | ||
| 155 | uint8_t sub_layer_level_present_flag[HEVC_MAX_SUB_LAYERS]; | ||
| 156 | } PTL; | ||
| 157 | |||
| 158 | typedef struct RepFormat { | ||
| 159 | uint16_t pic_width_in_luma_samples; | ||
| 160 | uint16_t pic_height_in_luma_samples; | ||
| 161 | uint8_t chroma_format_idc; | ||
| 162 | uint8_t separate_colour_plane_flag; | ||
| 163 | uint8_t bit_depth_luma; ///< bit_depth_vps_luma_minus8 + 8 | ||
| 164 | uint8_t bit_depth_chroma; ///< bit_depth_vps_chroma_minus8 + 8 | ||
| 165 | uint16_t conf_win_left_offset; | ||
| 166 | uint16_t conf_win_right_offset; | ||
| 167 | uint16_t conf_win_top_offset; | ||
| 168 | uint16_t conf_win_bottom_offset; | ||
| 169 | } RepFormat; | ||
| 170 | |||
| 171 | typedef struct HEVCVPS { | ||
| 172 | unsigned int vps_id; | ||
| 173 | |||
| 174 | uint8_t vps_temporal_id_nesting_flag; | ||
| 175 | int vps_max_layers; | ||
| 176 | int vps_max_sub_layers; ///< vps_max_temporal_layers_minus1 + 1 | ||
| 177 | |||
| 178 | PTL ptl; | ||
| 179 | int vps_sub_layer_ordering_info_present_flag; | ||
| 180 | unsigned int vps_max_dec_pic_buffering[HEVC_MAX_SUB_LAYERS]; | ||
| 181 | unsigned int vps_num_reorder_pics[HEVC_MAX_SUB_LAYERS]; | ||
| 182 | unsigned int vps_max_latency_increase[HEVC_MAX_SUB_LAYERS]; | ||
| 183 | int vps_max_layer_id; | ||
| 184 | int vps_num_layer_sets; ///< vps_num_layer_sets_minus1 + 1 | ||
| 185 | uint8_t vps_timing_info_present_flag; | ||
| 186 | uint32_t vps_num_units_in_tick; | ||
| 187 | uint32_t vps_time_scale; | ||
| 188 | uint8_t vps_poc_proportional_to_timing_flag; | ||
| 189 | int vps_num_ticks_poc_diff_one; ///< vps_num_ticks_poc_diff_one_minus1 + 1 | ||
| 190 | int vps_num_hrd_parameters; | ||
| 191 | |||
| 192 | HEVCHdrParams *hdr; | ||
| 193 | |||
| 194 | /* VPS extension */ | ||
| 195 | |||
| 196 | /* Number of layers this VPS was parsed for, between 1 and | ||
| 197 | * min(HEVC_VPS_MAX_LAYERS, vps_max_layers). | ||
| 198 | * | ||
| 199 | * Note that vps_max_layers contains the layer count declared in the | ||
| 200 | * bitstream, while nb_layers contains the number of layers exported to | ||
| 201 | * users of this API (which may be smaller as we only support a subset of | ||
| 202 | * multilayer extensions). | ||
| 203 | * | ||
| 204 | * Arrays below documented as [layer_idx] have nb_layers valid entries. | ||
| 205 | */ | ||
| 206 | int nb_layers; | ||
| 207 | |||
| 208 | uint16_t scalability_mask_flag; | ||
| 209 | |||
| 210 | // LayerIdxInVps[nuh_layer_id], i.e. a mapping of nuh_layer_id to VPS layer | ||
| 211 | // indices. Valid values are between 0 and HEVC_VPS_MAX_LAYERS. Entries for | ||
| 212 | // unmapped values of nuh_layer_id are set to -1. | ||
| 213 | int8_t layer_idx[HEVC_MAX_NUH_LAYER_ID + 1]; | ||
| 214 | |||
| 215 | uint8_t layer_id_in_nuh[HEVC_VPS_MAX_LAYERS]; | ||
| 216 | |||
| 217 | uint8_t default_ref_layers_active; | ||
| 218 | uint8_t max_one_active_ref_layer; | ||
| 219 | uint8_t poc_lsb_aligned; | ||
| 220 | // bitmask of poc_lsb_not_present[layer_idx] | ||
| 221 | uint8_t poc_lsb_not_present; | ||
| 222 | |||
| 223 | struct { | ||
| 224 | unsigned max_dec_pic_buffering; // max_vps_dec_pic_buffering_minus1 + 1 | ||
| 225 | unsigned max_num_reorder_pics; // max_vps_num_reorder_pics | ||
| 226 | unsigned max_latency_increase; // max_vps_latency_increase_plus1 - 1 | ||
| 227 | } dpb_size; | ||
| 228 | |||
| 229 | // ViewId[layer_idx] | ||
| 230 | uint16_t view_id[HEVC_VPS_MAX_LAYERS]; | ||
| 231 | |||
| 232 | // NumOutputLayerSets | ||
| 233 | uint8_t num_output_layer_sets; | ||
| 234 | // Bitmasks specifying output layer sets. i-th bit set means layer with VPS | ||
| 235 | // index i is present in the layer set. | ||
| 236 | uint64_t ols[HEVC_VPS_MAX_LAYERS]; | ||
| 237 | |||
| 238 | // NumDirectRefLayers[layer_idx] | ||
| 239 | uint8_t num_direct_ref_layers[HEVC_VPS_MAX_LAYERS]; | ||
| 240 | uint8_t num_add_layer_sets; | ||
| 241 | |||
| 242 | RepFormat rep_format; | ||
| 243 | |||
| 244 | uint8_t *data; | ||
| 245 | int data_size; | ||
| 246 | } HEVCVPS; | ||
| 247 | |||
| 248 | typedef struct ScalingList { | ||
| 249 | /* This is a little wasteful, since sizeID 0 only needs 8 coeffs, | ||
| 250 | * and size ID 3 only has 2 arrays, not 6. */ | ||
| 251 | uint8_t sl[4][6][64]; | ||
| 252 | uint8_t sl_dc[2][6]; | ||
| 253 | } ScalingList; | ||
| 254 | |||
| 255 | typedef struct HEVCSPS { | ||
| 256 | unsigned vps_id; | ||
| 257 | int chroma_format_idc; | ||
| 258 | |||
| 259 | HEVCWindow output_window; | ||
| 260 | |||
| 261 | HEVCWindow pic_conf_win; | ||
| 262 | |||
| 263 | HEVCHdrParams hdr; | ||
| 264 | |||
| 265 | int bit_depth; | ||
| 266 | int bit_depth_chroma; | ||
| 267 | int pixel_shift; | ||
| 268 | enum AVPixelFormat pix_fmt; | ||
| 269 | |||
| 270 | unsigned int log2_max_poc_lsb; | ||
| 271 | |||
| 272 | int max_sub_layers; | ||
| 273 | struct { | ||
| 274 | int max_dec_pic_buffering; | ||
| 275 | int num_reorder_pics; | ||
| 276 | int max_latency_increase; | ||
| 277 | } temporal_layer[HEVC_MAX_SUB_LAYERS]; | ||
| 278 | |||
| 279 | int vui_present; | ||
| 280 | VUI vui; | ||
| 281 | PTL ptl; | ||
| 282 | |||
| 283 | ScalingList scaling_list; | ||
| 284 | |||
| 285 | unsigned int nb_st_rps; | ||
| 286 | ShortTermRPS st_rps[HEVC_MAX_SHORT_TERM_REF_PIC_SETS]; | ||
| 287 | |||
| 288 | uint16_t lt_ref_pic_poc_lsb_sps[HEVC_MAX_LONG_TERM_REF_PICS]; | ||
| 289 | uint32_t used_by_curr_pic_lt; | ||
| 290 | uint8_t num_long_term_ref_pics_sps; | ||
| 291 | |||
| 292 | struct { | ||
| 293 | uint8_t bit_depth; | ||
| 294 | uint8_t bit_depth_chroma; | ||
| 295 | unsigned int log2_min_pcm_cb_size; | ||
| 296 | unsigned int log2_max_pcm_cb_size; | ||
| 297 | } pcm; | ||
| 298 | |||
| 299 | unsigned int log2_min_cb_size; | ||
| 300 | unsigned int log2_diff_max_min_coding_block_size; | ||
| 301 | unsigned int log2_min_tb_size; | ||
| 302 | unsigned int log2_max_trafo_size; | ||
| 303 | unsigned int log2_ctb_size; | ||
| 304 | unsigned int log2_min_pu_size; | ||
| 305 | unsigned int log2_diff_max_min_transform_block_size; | ||
| 306 | |||
| 307 | int max_transform_hierarchy_depth_inter; | ||
| 308 | int max_transform_hierarchy_depth_intra; | ||
| 309 | |||
| 310 | uint8_t separate_colour_plane; | ||
| 311 | uint8_t conformance_window; | ||
| 312 | uint8_t pcm_enabled; | ||
| 313 | uint8_t pcm_loop_filter_disabled; | ||
| 314 | uint8_t sublayer_ordering_info; | ||
| 315 | uint8_t temporal_id_nesting; | ||
| 316 | uint8_t extension_present; | ||
| 317 | uint8_t scaling_list_enabled; | ||
| 318 | uint8_t amp_enabled; | ||
| 319 | uint8_t sao_enabled; | ||
| 320 | uint8_t long_term_ref_pics_present; | ||
| 321 | uint8_t temporal_mvp_enabled; | ||
| 322 | uint8_t strong_intra_smoothing_enabled; | ||
| 323 | uint8_t range_extension; | ||
| 324 | uint8_t transform_skip_rotation_enabled; | ||
| 325 | uint8_t transform_skip_context_enabled; | ||
| 326 | uint8_t implicit_rdpcm_enabled; | ||
| 327 | uint8_t explicit_rdpcm_enabled; | ||
| 328 | uint8_t extended_precision_processing; | ||
| 329 | uint8_t intra_smoothing_disabled; | ||
| 330 | uint8_t high_precision_offsets_enabled; | ||
| 331 | uint8_t persistent_rice_adaptation_enabled; | ||
| 332 | uint8_t cabac_bypass_alignment_enabled; | ||
| 333 | |||
| 334 | uint8_t multilayer_extension; | ||
| 335 | uint8_t sps_3d_extension; | ||
| 336 | |||
| 337 | uint8_t scc_extension; | ||
| 338 | uint8_t curr_pic_ref_enabled; | ||
| 339 | uint8_t palette_mode_enabled; | ||
| 340 | uint8_t palette_predictor_initializers_present; | ||
| 341 | uint8_t intra_boundary_filtering_disabled; | ||
| 342 | |||
| 343 | int palette_max_size; | ||
| 344 | int delta_palette_max_predictor_size; | ||
| 345 | int sps_num_palette_predictor_initializers; | ||
| 346 | int sps_palette_predictor_initializer[3][HEVC_MAX_PALETTE_PREDICTOR_SIZE]; | ||
| 347 | int motion_vector_resolution_control_idc; | ||
| 348 | |||
| 349 | /// coded frame dimension in various units | ||
| 350 | int width; | ||
| 351 | int height; | ||
| 352 | int ctb_width; | ||
| 353 | int ctb_height; | ||
| 354 | int ctb_size; | ||
| 355 | int min_cb_width; | ||
| 356 | int min_cb_height; | ||
| 357 | int min_tb_width; | ||
| 358 | int min_tb_height; | ||
| 359 | int min_pu_width; | ||
| 360 | int min_pu_height; | ||
| 361 | int tb_mask; | ||
| 362 | |||
| 363 | int hshift[3]; | ||
| 364 | int vshift[3]; | ||
| 365 | |||
| 366 | int qp_bd_offset; | ||
| 367 | |||
| 368 | uint8_t *data; | ||
| 369 | int data_size; | ||
| 370 | |||
| 371 | const HEVCVPS *vps; ///< RefStruct reference | ||
| 372 | } HEVCSPS; | ||
| 373 | |||
| 374 | typedef struct HEVCPPS { | ||
| 375 | unsigned int pps_id; | ||
| 376 | unsigned int sps_id; ///< seq_parameter_set_id | ||
| 377 | |||
| 378 | uint8_t sign_data_hiding_flag; | ||
| 379 | |||
| 380 | uint8_t cabac_init_present_flag; | ||
| 381 | |||
| 382 | int num_ref_idx_l0_default_active; ///< num_ref_idx_l0_default_active_minus1 + 1 | ||
| 383 | int num_ref_idx_l1_default_active; ///< num_ref_idx_l1_default_active_minus1 + 1 | ||
| 384 | int pic_init_qp_minus26; | ||
| 385 | |||
| 386 | uint8_t constrained_intra_pred_flag; | ||
| 387 | uint8_t transform_skip_enabled_flag; | ||
| 388 | |||
| 389 | uint8_t cu_qp_delta_enabled_flag; | ||
| 390 | int diff_cu_qp_delta_depth; | ||
| 391 | |||
| 392 | int cb_qp_offset; | ||
| 393 | int cr_qp_offset; | ||
| 394 | uint8_t pic_slice_level_chroma_qp_offsets_present_flag; | ||
| 395 | uint8_t weighted_pred_flag; | ||
| 396 | uint8_t weighted_bipred_flag; | ||
| 397 | uint8_t output_flag_present_flag; | ||
| 398 | uint8_t transquant_bypass_enable_flag; | ||
| 399 | |||
| 400 | uint8_t dependent_slice_segments_enabled_flag; | ||
| 401 | uint8_t tiles_enabled_flag; | ||
| 402 | uint8_t entropy_coding_sync_enabled_flag; | ||
| 403 | |||
| 404 | uint16_t num_tile_columns; ///< num_tile_columns_minus1 + 1 | ||
| 405 | uint16_t num_tile_rows; ///< num_tile_rows_minus1 + 1 | ||
| 406 | uint8_t uniform_spacing_flag; | ||
| 407 | uint8_t loop_filter_across_tiles_enabled_flag; | ||
| 408 | |||
| 409 | uint8_t seq_loop_filter_across_slices_enabled_flag; | ||
| 410 | |||
| 411 | uint8_t deblocking_filter_control_present_flag; | ||
| 412 | uint8_t deblocking_filter_override_enabled_flag; | ||
| 413 | uint8_t disable_dbf; | ||
| 414 | int beta_offset; ///< beta_offset_div2 * 2 | ||
| 415 | int tc_offset; ///< tc_offset_div2 * 2 | ||
| 416 | |||
| 417 | uint8_t scaling_list_data_present_flag; | ||
| 418 | ScalingList scaling_list; | ||
| 419 | |||
| 420 | uint8_t lists_modification_present_flag; | ||
| 421 | int log2_parallel_merge_level; ///< log2_parallel_merge_level_minus2 + 2 | ||
| 422 | int num_extra_slice_header_bits; | ||
| 423 | uint8_t slice_header_extension_present_flag; | ||
| 424 | uint8_t log2_max_transform_skip_block_size; | ||
| 425 | uint8_t pps_extension_present_flag; | ||
| 426 | uint8_t pps_range_extensions_flag; | ||
| 427 | uint8_t pps_multilayer_extension_flag; | ||
| 428 | uint8_t pps_3d_extension_flag; | ||
| 429 | uint8_t pps_scc_extension_flag; | ||
| 430 | uint8_t cross_component_prediction_enabled_flag; | ||
| 431 | uint8_t chroma_qp_offset_list_enabled_flag; | ||
| 432 | uint8_t diff_cu_chroma_qp_offset_depth; | ||
| 433 | uint8_t chroma_qp_offset_list_len_minus1; | ||
| 434 | int8_t cb_qp_offset_list[6]; | ||
| 435 | int8_t cr_qp_offset_list[6]; | ||
| 436 | uint8_t log2_sao_offset_scale_luma; | ||
| 437 | uint8_t log2_sao_offset_scale_chroma; | ||
| 438 | |||
| 439 | // Multilayer extension parameters | ||
| 440 | uint8_t poc_reset_info_present_flag; | ||
| 441 | uint8_t pps_infer_scaling_list_flag; | ||
| 442 | uint8_t pps_scaling_list_ref_layer_id; | ||
| 443 | uint8_t num_ref_loc_offsets; | ||
| 444 | uint8_t ref_loc_offset_layer_id[64]; | ||
| 445 | uint8_t scaled_ref_layer_offset_present_flag[64]; | ||
| 446 | int16_t scaled_ref_layer_left_offset[64]; | ||
| 447 | int16_t scaled_ref_layer_top_offset[64]; | ||
| 448 | int16_t scaled_ref_layer_right_offset[64]; | ||
| 449 | int16_t scaled_ref_layer_bottom_offset[64]; | ||
| 450 | uint8_t ref_region_offset_present_flag[64]; | ||
| 451 | int16_t ref_region_left_offset[64]; | ||
| 452 | int16_t ref_region_top_offset[64]; | ||
| 453 | int16_t ref_region_right_offset[64]; | ||
| 454 | int16_t ref_region_bottom_offset[64]; | ||
| 455 | uint8_t resample_phase_set_present_flag[64]; | ||
| 456 | uint8_t phase_hor_luma[64]; | ||
| 457 | uint8_t phase_ver_luma[64]; | ||
| 458 | int8_t phase_hor_chroma[64]; | ||
| 459 | int8_t phase_ver_chroma[64]; | ||
| 460 | uint8_t colour_mapping_enabled_flag; | ||
| 461 | uint8_t num_cm_ref_layers; | ||
| 462 | uint8_t cm_ref_layer_id[62]; | ||
| 463 | uint8_t cm_octant_depth; | ||
| 464 | uint8_t cm_y_part_num_log2; | ||
| 465 | uint8_t luma_bit_depth_cm_input; | ||
| 466 | uint8_t chroma_bit_depth_cm_input; | ||
| 467 | uint8_t luma_bit_depth_cm_output; | ||
| 468 | uint8_t chroma_bit_depth_cm_output; | ||
| 469 | uint8_t cm_res_quant_bits; | ||
| 470 | uint8_t cm_delta_flc_bits; | ||
| 471 | int8_t cm_adapt_threshold_u_delta; | ||
| 472 | int8_t cm_adapt_threshold_v_delta; | ||
| 473 | |||
| 474 | // 3D extension parameters | ||
| 475 | uint8_t pps_bit_depth_for_depth_layers_minus8; | ||
| 476 | |||
| 477 | // SCC extension parameters | ||
| 478 | uint8_t pps_curr_pic_ref_enabled_flag; | ||
| 479 | uint8_t residual_adaptive_colour_transform_enabled_flag; | ||
| 480 | uint8_t pps_slice_act_qp_offsets_present_flag; | ||
| 481 | int8_t pps_act_y_qp_offset; // _plus5 | ||
| 482 | int8_t pps_act_cb_qp_offset; // _plus5 | ||
| 483 | int8_t pps_act_cr_qp_offset; // _plus3 | ||
| 484 | uint8_t pps_palette_predictor_initializers_present_flag; | ||
| 485 | uint8_t pps_num_palette_predictor_initializers; | ||
| 486 | uint8_t monochrome_palette_flag; | ||
| 487 | uint8_t luma_bit_depth_entry; | ||
| 488 | uint8_t chroma_bit_depth_entry; | ||
| 489 | uint16_t pps_palette_predictor_initializer[3][HEVC_MAX_PALETTE_PREDICTOR_SIZE]; | ||
| 490 | |||
| 491 | // Inferred parameters | ||
| 492 | unsigned int *column_width; ///< ColumnWidth | ||
| 493 | unsigned int *row_height; ///< RowHeight | ||
| 494 | unsigned int *col_bd; ///< ColBd | ||
| 495 | unsigned int *row_bd; ///< RowBd | ||
| 496 | int *col_idxX; | ||
| 497 | |||
| 498 | int *ctb_addr_rs_to_ts; ///< CtbAddrRSToTS | ||
| 499 | int *ctb_addr_ts_to_rs; ///< CtbAddrTSToRS | ||
| 500 | int *tile_id; ///< TileId | ||
| 501 | int *tile_pos_rs; ///< TilePosRS | ||
| 502 | int *min_tb_addr_zs; ///< MinTbAddrZS | ||
| 503 | int *min_tb_addr_zs_tab;///< MinTbAddrZS | ||
| 504 | |||
| 505 | uint8_t *data; | ||
| 506 | int data_size; | ||
| 507 | |||
| 508 | const HEVCSPS *sps; ///< RefStruct reference | ||
| 509 | } HEVCPPS; | ||
| 510 | |||
| 511 | typedef struct HEVCParamSets { | ||
| 512 | const HEVCVPS *vps_list[HEVC_MAX_VPS_COUNT]; ///< RefStruct references | ||
| 513 | const HEVCSPS *sps_list[HEVC_MAX_SPS_COUNT]; ///< RefStruct references | ||
| 514 | const HEVCPPS *pps_list[HEVC_MAX_PPS_COUNT]; ///< RefStruct references | ||
| 515 | } HEVCParamSets; | ||
| 516 | |||
| 517 | /** | ||
| 518 | * Parse the SPS from the bitstream into the provided HEVCSPS struct. | ||
| 519 | * | ||
| 520 | * @param sps_id the SPS id will be written here | ||
| 521 | * @param apply_defdispwin if set 1, the default display window from the VUI | ||
| 522 | * will be applied to the video dimensions | ||
| 523 | * @param vps_list if non-NULL, this function will validate that the SPS refers | ||
| 524 | * to an existing VPS | ||
| 525 | */ | ||
| 526 | int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, | ||
| 527 | unsigned nuh_layer_id, int apply_defdispwin, | ||
| 528 | const HEVCVPS * const *vps_list, AVCodecContext *avctx); | ||
| 529 | |||
| 530 | int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx, | ||
| 531 | HEVCParamSets *ps); | ||
| 532 | int ff_hevc_decode_nal_sps(GetBitContext *gb, AVCodecContext *avctx, | ||
| 533 | HEVCParamSets *ps, unsigned nuh_layer_id, | ||
| 534 | int apply_defdispwin); | ||
| 535 | int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx, | ||
| 536 | HEVCParamSets *ps); | ||
| 537 | |||
| 538 | void ff_hevc_ps_uninit(HEVCParamSets *ps); | ||
| 539 | |||
| 540 | int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx, | ||
| 541 | ShortTermRPS *rps, const HEVCSPS *sps, int is_slice_header); | ||
| 542 | |||
| 543 | int ff_hevc_encode_nal_vps(HEVCVPS *vps, unsigned int id, | ||
| 544 | uint8_t *buf, int buf_size); | ||
| 545 | |||
| 546 | /** | ||
| 547 | * Compute POC of the current frame and return it. | ||
| 548 | */ | ||
| 549 | int ff_hevc_compute_poc2(unsigned log2_max_poc_lsb, int pocTid0, int poc_lsb, int nal_unit_type); | ||
| 550 | |||
| 551 | 32620 | static inline int ff_hevc_compute_poc(const HEVCSPS *sps, int pocTid0, int poc_lsb, int nal_unit_type) | |
| 552 | { | ||
| 553 | 32620 | return ff_hevc_compute_poc2(sps->log2_max_poc_lsb, pocTid0, poc_lsb, nal_unit_type); | |
| 554 | } | ||
| 555 | |||
| 556 | #endif /* AVCODEC_HEVC_PS_H */ | ||
| 557 |