7 #ifndef PACKAGER_MEDIA_CODECS_H265_PARSER_H_
8 #define PACKAGER_MEDIA_CODECS_H265_PARSER_H_
14 #include <packager/macros/classes.h>
15 #include <packager/media/codecs/h26x_bit_reader.h>
22 enum H265SliceType { kBSlice = 0, kPSlice = 1, kISlice = 2 };
24 const int kMaxRefPicSetCount = 16;
30 bool ExtractResolutionFromSps(
const H265Sps& sps,
31 uint32_t* coded_width,
32 uint32_t* coded_height,
33 uint32_t* pixel_width,
34 uint32_t* pixel_height);
37 int delta_poc_s0[kMaxRefPicSetCount];
38 int delta_poc_s1[kMaxRefPicSetCount];
39 bool used_by_curr_pic_s0[kMaxRefPicSetCount];
40 bool used_by_curr_pic_s1[kMaxRefPicSetCount];
42 int num_negative_pics;
43 int num_positive_pics;
48 enum { kExtendedSar = 255 };
50 bool aspect_ratio_info_present_flag =
false;
51 int aspect_ratio_idc = 0;
54 int transfer_characteristics = 0;
55 int color_primaries = 0;
56 int matrix_coefficients = 0;
58 bool vui_timing_info_present_flag =
false;
59 long vui_num_units_in_tick = 0;
60 long vui_time_scale = 0;
62 bool bitstream_restriction_flag =
false;
63 int min_spatial_segmentation_idc = 0;
75 int pic_parameter_set_id = 0;
76 int seq_parameter_set_id = 0;
78 bool dependent_slice_segments_enabled_flag =
false;
79 bool output_flag_present_flag =
false;
80 int num_extra_slice_header_bits = 0;
81 bool sign_data_hiding_enabled_flag =
false;
82 bool cabac_init_present_flag =
false;
84 int num_ref_idx_l0_default_active_minus1 = 0;
85 int num_ref_idx_l1_default_active_minus1 = 0;
86 int init_qp_minus26 = 0;
87 bool constrained_intra_pred_flag =
false;
88 bool transform_skip_enabled_flag =
false;
90 bool cu_qp_delta_enabled_flag = 0;
91 int diff_cu_qp_delta_depth = 0;
95 bool slice_chroma_qp_offsets_present_flag =
false;
96 bool weighted_pred_flag =
false;
97 bool weighted_bipred_flag =
false;
98 bool transquant_bypass_enabled_flag =
false;
99 bool tiles_enabled_flag =
false;
100 bool entropy_coding_sync_enabled_flag =
false;
102 int num_tile_columns_minus1 = 0;
103 int num_tile_rows_minus1 = 0;
104 bool uniform_spacing_flag =
true;
105 std::vector<int> column_width_minus1;
106 std::vector<int> row_height_minus1;
107 bool loop_filter_across_tiles_enabled_flag =
true;
109 bool loop_filter_across_slices_enabled_flag =
false;
110 bool deblocking_filter_control_present_flag =
false;
111 bool deblocking_filter_override_enabled_flag =
false;
112 bool deblocking_filter_disabled_flag =
false;
113 int beta_offset_div2 = 0;
114 int tc_offset_div2 = 0;
116 bool scaling_list_data_present_flag =
false;
119 bool lists_modification_present_flag =
false;
120 int log2_parallel_merge_level_minus2 = 0;
121 bool slice_segment_header_extension_present_flag =
false;
124 bool chroma_qp_offset_list_enabled_flag =
false;
133 int GetPicSizeInCtbsY()
const;
134 int GetChromaArrayType()
const;
139 int video_parameter_set_id = 0;
140 int max_sub_layers_minus1 = 0;
141 bool temporal_id_nesting_flag =
false;
146 int general_profile_tier_level_data[12] = {};
148 int seq_parameter_set_id = 0;
150 int chroma_format_idc = 0;
151 bool separate_colour_plane_flag =
false;
152 int pic_width_in_luma_samples = 0;
153 int pic_height_in_luma_samples = 0;
155 bool conformance_window_flag =
false;
156 int conf_win_left_offset = 0;
157 int conf_win_right_offset = 0;
158 int conf_win_top_offset = 0;
159 int conf_win_bottom_offset = 0;
161 int bit_depth_luma_minus8 = 0;
162 int bit_depth_chroma_minus8 = 0;
163 int log2_max_pic_order_cnt_lsb_minus4 = 0;
165 bool sub_layer_ordering_info_present_flag =
false;
166 int max_dec_pic_buffering_minus1[8];
167 int max_num_reorder_pics[8];
168 int max_latency_increase_plus1[8];
170 int log2_min_luma_coding_block_size_minus3 = 0;
171 int log2_diff_max_min_luma_coding_block_size = 0;
172 int log2_min_luma_transform_block_size_minus2 = 0;
173 int log2_diff_max_min_luma_transform_block_size = 0;
174 int max_transform_hierarchy_depth_inter = 0;
175 int max_transform_hierarchy_depth_intra = 0;
177 bool scaling_list_enabled_flag =
false;
178 bool scaling_list_data_present_flag =
false;
181 bool amp_enabled_flag =
false;
182 bool sample_adaptive_offset_enabled_flag =
false;
183 bool pcm_enabled_flag =
false;
184 int pcm_sample_bit_depth_luma_minus1 = 0;
185 int pcm_sample_bit_depth_chroma_minus1 = 0;
186 int log2_min_pcm_luma_coding_block_size_minus3 = 0;
187 int log2_diff_max_min_pcm_luma_coding_block_size = 0;
188 bool pcm_loop_filter_disabled_flag =
false;
190 int num_short_term_ref_pic_sets = 0;
191 std::vector<H265ReferencePictureSet> st_ref_pic_sets;
193 bool long_term_ref_pic_present_flag =
false;
194 int num_long_term_ref_pics = 0;
195 std::vector<int> lt_ref_pic_poc_lsb;
196 std::vector<bool> used_by_curr_pic_lt_flag;
198 bool temporal_mvp_enabled_flag =
false;
199 bool strong_intra_smoothing_enabled_flag =
false;
201 bool vui_parameters_present =
false;
211 bool ref_pic_list_modification_flag_l0 =
false;
212 std::vector<int> list_entry_l0;
214 bool ref_pic_list_modification_flag_l1 =
false;
215 std::vector<int> list_entry_l1;
223 bool delta_poc_msb_present_flag;
224 int delta_poc_msb_cycle_lt;
228 int used_by_curr_pic_lt = 0;
237 size_t header_bit_size = 0;
239 bool first_slice_segment_in_pic_flag =
false;
240 bool no_output_of_prior_pics_flag =
false;
241 int pic_parameter_set_id = 0;
243 bool dependent_slice_segment_flag =
false;
244 int segment_address = 0;
246 bool pic_output_flag =
true;
247 int colour_plane_id = 0;
248 int slice_pic_order_cnt_lsb = 0;
250 bool short_term_ref_pic_set_sps_flag =
false;
252 int short_term_ref_pic_set_idx = 0;
254 int num_long_term_sps = 0;
255 int num_long_term_pics = 0;
256 std::vector<LongTermPicsInfo> long_term_pics_info;
258 bool slice_temporal_mvp_enabled_flag =
false;
259 bool slice_sao_luma_flag =
false;
260 bool slice_sao_chroma_flag =
false;
262 bool num_ref_idx_active_override_flag =
false;
263 int num_ref_idx_l0_active_minus1 = 0;
264 int num_ref_idx_l1_active_minus1 = 0;
268 bool mvd_l1_zero_flag =
false;
269 bool cabac_init_flag =
false;
270 bool collocated_from_l0 =
true;
271 int collocated_ref_idx = 0;
273 int five_minus_max_num_merge_cand = 0;
274 int slice_qp_delta = 0;
275 int slice_cb_qp_offset = 0;
276 int slice_cr_qp_offset = 0;
278 bool cu_chroma_qp_offset_enabled_flag =
false;
279 bool deblocking_filter_override_flag =
false;
280 bool slice_deblocking_filter_disabled_flag =
false;
281 int slice_beta_offset_div2 = 0;
282 int slice_tc_offset_div2 = 0;
283 bool slice_loop_filter_across_slices_enabled_flag =
false;
285 int num_entry_point_offsets = 0;
286 int offset_len_minus1 = 0;
287 std::vector<int> entry_point_offset_minus1;
323 Result ParseVuiParameters(
int max_num_sub_layers_minus1,
327 Result ParseReferencePictureSet(
328 int num_short_term_ref_pic_sets,
330 const std::vector<H265ReferencePictureSet>& ref_pic_sets,
334 Result SkipReferencePictureListModification(
337 int num_pic_total_curr,
340 Result SkipPredictionWeightTablePart(
int num_ref_idx_minus1,
341 int chroma_array_type,
344 Result SkipPredictionWeightTable(
bool is_b_slice,
349 Result ReadProfileTierLevel(
bool profile_present,
350 int max_num_sub_layers_minus1,
356 Result SkipHrdParameters(
int max_num_sub_layers_minus1,
H26xBitReader* br);
358 Result SkipSubLayerHrdParameters(
int cpb_cnt_minus1,
359 bool sub_pic_hdr_params_present_flag,
364 typedef std::map<int, std::unique_ptr<H265Sps>> SpsById;
365 typedef std::map<int, std::unique_ptr<H265Pps>> PpsById;
367 SpsById active_spses_;
368 PpsById active_ppses_;
All the methods that are virtual are virtual for mocking.