7 #ifndef PACKAGER_MEDIA_CODECS_H264_PARSER_H_
8 #define PACKAGER_MEDIA_CODECS_H264_PARSER_H_
15 #include <packager/macros/classes.h>
16 #include <packager/media/codecs/h26x_bit_reader.h>
17 #include <packager/media/codecs/nalu_reader.h>
26 bool ExtractResolutionFromSps(
const H264Sps& sps,
27 uint32_t* coded_width,
28 uint32_t* coded_height,
29 uint32_t* pixel_width,
30 uint32_t* pixel_height);
33 kH264ScalingList4x4Length = 16,
34 kH264ScalingList8x8Length = 64,
39 bool constraint_set0_flag;
40 bool constraint_set1_flag;
41 bool constraint_set2_flag;
42 bool constraint_set3_flag;
43 bool constraint_set4_flag;
44 bool constraint_set5_flag;
46 int seq_parameter_set_id;
48 int chroma_format_idc;
49 bool separate_colour_plane_flag;
50 int bit_depth_luma_minus8;
51 int bit_depth_chroma_minus8;
52 bool qpprime_y_zero_transform_bypass_flag;
54 bool seq_scaling_matrix_present_flag;
55 int scaling_list4x4[6][kH264ScalingList4x4Length];
56 int scaling_list8x8[6][kH264ScalingList8x8Length];
58 int log2_max_frame_num_minus4;
59 int pic_order_cnt_type;
60 int log2_max_pic_order_cnt_lsb_minus4;
61 bool delta_pic_order_always_zero_flag;
62 int offset_for_non_ref_pic;
63 int offset_for_top_to_bottom_field;
64 int num_ref_frames_in_pic_order_cnt_cycle;
65 int expected_delta_per_pic_order_cnt_cycle;
66 int offset_for_ref_frame[255];
67 int max_num_ref_frames;
68 bool gaps_in_frame_num_value_allowed_flag;
69 int pic_width_in_mbs_minus1;
70 int pic_height_in_map_units_minus1;
71 bool frame_mbs_only_flag;
72 bool mb_adaptive_frame_field_flag;
73 bool direct_8x8_inference_flag;
74 bool frame_cropping_flag;
75 int frame_crop_left_offset;
76 int frame_crop_right_offset;
77 int frame_crop_top_offset;
78 int frame_crop_bottom_offset;
80 bool vui_parameters_present_flag;
83 int transfer_characteristics;
85 int matrix_coefficients;
87 bool timing_info_present_flag;
88 long num_units_in_tick;
90 bool fixed_frame_rate_flag;
92 bool bitstream_restriction_flag;
93 int max_num_reorder_frames;
94 int max_dec_frame_buffering;
96 int chroma_array_type;
100 int pic_parameter_set_id;
101 int seq_parameter_set_id;
102 bool entropy_coding_mode_flag;
103 bool bottom_field_pic_order_in_frame_present_flag;
104 int num_slice_groups_minus1;
105 int num_ref_idx_l0_default_active_minus1;
106 int num_ref_idx_l1_default_active_minus1;
107 bool weighted_pred_flag;
108 int weighted_bipred_idc;
109 int pic_init_qp_minus26;
110 int pic_init_qs_minus26;
111 int chroma_qp_index_offset;
112 bool deblocking_filter_control_present_flag;
113 bool constrained_intra_pred_flag;
114 bool redundant_pic_cnt_present_flag;
115 bool transform_8x8_mode_flag;
117 bool pic_scaling_matrix_present_flag;
118 int scaling_list4x4[6][kH264ScalingList4x4Length];
119 int scaling_list8x8[6][kH264ScalingList8x8Length];
121 int second_chroma_qp_index_offset;
125 int modification_of_pic_nums_idc;
127 int abs_diff_pic_num_minus1;
128 int long_term_pic_num;
133 bool luma_weight_flag[32];
134 bool chroma_weight_flag[32];
137 int chroma_weight[32][2];
138 int chroma_offset[32][2];
142 int memory_mgmnt_control_operation;
143 int difference_of_pic_nums_minus1;
144 int long_term_pic_num;
145 int long_term_frame_idx;
146 int max_long_term_frame_idx_plus1;
152 kRefListModSize = kRefListSize
163 bool IsPSlice()
const;
164 bool IsBSlice()
const;
165 bool IsISlice()
const;
166 bool IsSPSlice()
const;
167 bool IsSISlice()
const;
172 const uint8_t* nalu_data;
181 size_t header_bit_size;
183 int first_mb_in_slice;
185 int pic_parameter_set_id;
189 bool bottom_field_flag;
191 int pic_order_cnt_lsb;
192 int delta_pic_order_cnt_bottom;
193 int delta_pic_order_cnt[2];
194 int redundant_pic_cnt;
195 bool direct_spatial_mv_pred_flag;
197 bool num_ref_idx_active_override_flag;
198 int num_ref_idx_l0_active_minus1;
199 int num_ref_idx_l1_active_minus1;
200 bool ref_pic_list_modification_flag_l0;
201 bool ref_pic_list_modification_flag_l1;
205 int luma_log2_weight_denom;
206 int chroma_log2_weight_denom;
211 bool no_output_of_prior_pics_flag;
212 bool long_term_reference_flag;
214 bool adaptive_ref_pic_marking_mode_flag;
219 bool sp_for_switch_flag;
221 int disable_deblocking_filter_idc;
222 int slice_alpha_c0_offset_div2;
223 int slice_beta_offset_div2;
227 int recovery_frame_cnt;
228 bool exact_match_flag;
229 bool broken_link_flag;
230 int changing_slice_group_idc;
235 kSEIRecoveryPoint = 6,
271 Result ParseSps(
const Nalu& nalu,
int* sps_id);
272 Result ParsePps(
const Nalu& nalu,
int* pps_id);
276 const H264Sps* GetSps(
int sps_id);
277 const H264Pps* GetPps(
int pps_id);
307 bool* hrd_parameters_present);
312 int num_ref_idx_active_minus1,
322 int num_ref_idx_active_minus1,
323 int chroma_array_type,
324 int luma_log2_weight_denom,
325 int chroma_log2_weight_denom,
332 typedef std::map<int, std::unique_ptr<H264Sps>> SpsById;
333 typedef std::map<int, std::unique_ptr<H264Pps>> PpsById;
334 SpsById active_SPSes_;
335 PpsById active_PPSes_;
All the methods that are virtual are virtual for mocking.