7 #ifndef MEDIA_CODECS_H264_PARSER_H_
8 #define MEDIA_CODECS_H264_PARSER_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,
41 bool constraint_set0_flag;
42 bool constraint_set1_flag;
43 bool constraint_set2_flag;
44 bool constraint_set3_flag;
45 bool constraint_set4_flag;
46 bool constraint_set5_flag;
48 int seq_parameter_set_id;
50 int chroma_format_idc;
51 bool separate_colour_plane_flag;
52 int bit_depth_luma_minus8;
53 int bit_depth_chroma_minus8;
54 bool qpprime_y_zero_transform_bypass_flag;
56 bool seq_scaling_matrix_present_flag;
57 int scaling_list4x4[6][kH264ScalingList4x4Length];
58 int scaling_list8x8[6][kH264ScalingList8x8Length];
60 int log2_max_frame_num_minus4;
61 int pic_order_cnt_type;
62 int log2_max_pic_order_cnt_lsb_minus4;
63 bool delta_pic_order_always_zero_flag;
64 int offset_for_non_ref_pic;
65 int offset_for_top_to_bottom_field;
66 int num_ref_frames_in_pic_order_cnt_cycle;
67 int expected_delta_per_pic_order_cnt_cycle;
68 int offset_for_ref_frame[255];
69 int max_num_ref_frames;
70 bool gaps_in_frame_num_value_allowed_flag;
71 int pic_width_in_mbs_minus1;
72 int pic_height_in_map_units_minus1;
73 bool frame_mbs_only_flag;
74 bool mb_adaptive_frame_field_flag;
75 bool direct_8x8_inference_flag;
76 bool frame_cropping_flag;
77 int frame_crop_left_offset;
78 int frame_crop_right_offset;
79 int frame_crop_top_offset;
80 int frame_crop_bottom_offset;
82 bool vui_parameters_present_flag;
85 bool bitstream_restriction_flag;
86 int max_num_reorder_frames;
87 int max_dec_frame_buffering;
89 int chroma_array_type;
95 int pic_parameter_set_id;
96 int seq_parameter_set_id;
97 bool entropy_coding_mode_flag;
98 bool bottom_field_pic_order_in_frame_present_flag;
99 int num_slice_groups_minus1;
100 int num_ref_idx_l0_default_active_minus1;
101 int num_ref_idx_l1_default_active_minus1;
102 bool weighted_pred_flag;
103 int weighted_bipred_idc;
104 int pic_init_qp_minus26;
105 int pic_init_qs_minus26;
106 int chroma_qp_index_offset;
107 bool deblocking_filter_control_present_flag;
108 bool constrained_intra_pred_flag;
109 bool redundant_pic_cnt_present_flag;
110 bool transform_8x8_mode_flag;
112 bool pic_scaling_matrix_present_flag;
113 int scaling_list4x4[6][kH264ScalingList4x4Length];
114 int scaling_list8x8[6][kH264ScalingList8x8Length];
116 int second_chroma_qp_index_offset;
120 int modification_of_pic_nums_idc;
122 int abs_diff_pic_num_minus1;
123 int long_term_pic_num;
128 bool luma_weight_flag;
129 bool chroma_weight_flag;
132 int chroma_weight[32][2];
133 int chroma_offset[32][2];
137 int memory_mgmnt_control_operation;
138 int difference_of_pic_nums_minus1;
139 int long_term_pic_num;
140 int long_term_frame_idx;
141 int max_long_term_frame_idx_plus1;
149 kRefListModSize = kRefListSize
160 bool IsPSlice()
const;
161 bool IsBSlice()
const;
162 bool IsISlice()
const;
163 bool IsSPSlice()
const;
164 bool IsSISlice()
const;
169 const uint8_t* nalu_data;
178 off_t header_bit_size;
180 int first_mb_in_slice;
182 int pic_parameter_set_id;
186 bool bottom_field_flag;
188 int pic_order_cnt_lsb;
189 int delta_pic_order_cnt_bottom;
190 int delta_pic_order_cnt[2];
191 int redundant_pic_cnt;
192 bool direct_spatial_mv_pred_flag;
194 bool num_ref_idx_active_override_flag;
195 int num_ref_idx_l0_active_minus1;
196 int num_ref_idx_l1_active_minus1;
197 bool ref_pic_list_modification_flag_l0;
198 bool ref_pic_list_modification_flag_l1;
202 int luma_log2_weight_denom;
203 int chroma_log2_weight_denom;
205 bool luma_weight_l0_flag;
206 bool chroma_weight_l0_flag;
209 bool luma_weight_l1_flag;
210 bool chroma_weight_l1_flag;
213 bool no_output_of_prior_pics_flag;
214 bool long_term_reference_flag;
216 bool adaptive_ref_pic_marking_mode_flag;
221 bool sp_for_switch_flag;
223 int disable_deblocking_filter_idc;
224 int slice_alpha_c0_offset_div2;
225 int slice_beta_offset_div2;
229 int recovery_frame_cnt;
230 bool exact_match_flag;
231 bool broken_link_flag;
232 int changing_slice_group_idc;
239 kSEIRecoveryPoint = 6,
275 Result ParseSps(
const Nalu& nalu,
int* sps_id);
276 Result ParsePps(
const Nalu& nalu,
int* pps_id);
280 const H264Sps* GetSps(
int sps_id);
281 const H264Pps* GetPps(
int pps_id);
311 bool* hrd_parameters_present);
316 int num_ref_idx_active_minus1,
326 int num_ref_idx_active_minus1,
327 int chroma_array_type,
328 int luma_log2_weight_denom,
329 int chroma_log2_weight_denom,
336 typedef std::map<int, std::unique_ptr<H264Sps>> SpsById;
337 typedef std::map<int, std::unique_ptr<H264Pps>> PpsById;
338 SpsById active_SPSes_;
339 PpsById active_PPSes_;
347 #endif // MEDIA_CODECS_H264_PARSER_H_