7 #ifndef MEDIA_FILTERS_H264_PARSER_H_
8 #define MEDIA_FILTERS_H264_PARSER_H_
15 #include "packager/media/filters/h26x_bit_reader.h"
16 #include "packager/media/filters/nalu_reader.h"
25 bool ExtractResolutionFromSps(
const H264Sps& sps,
26 uint32_t* coded_width,
27 uint32_t* coded_height,
28 uint32_t* pixel_width,
29 uint32_t* pixel_height);
32 kH264ScalingList4x4Length = 16,
33 kH264ScalingList8x8Length = 64,
40 bool constraint_set0_flag;
41 bool constraint_set1_flag;
42 bool constraint_set2_flag;
43 bool constraint_set3_flag;
44 bool constraint_set4_flag;
45 bool constraint_set5_flag;
47 int seq_parameter_set_id;
49 int chroma_format_idc;
50 bool separate_colour_plane_flag;
51 int bit_depth_luma_minus8;
52 int bit_depth_chroma_minus8;
53 bool qpprime_y_zero_transform_bypass_flag;
55 bool seq_scaling_matrix_present_flag;
56 int scaling_list4x4[6][kH264ScalingList4x4Length];
57 int scaling_list8x8[6][kH264ScalingList8x8Length];
59 int log2_max_frame_num_minus4;
60 int pic_order_cnt_type;
61 int log2_max_pic_order_cnt_lsb_minus4;
62 bool delta_pic_order_always_zero_flag;
63 int offset_for_non_ref_pic;
64 int offset_for_top_to_bottom_field;
65 int num_ref_frames_in_pic_order_cnt_cycle;
66 int expected_delta_per_pic_order_cnt_cycle;
67 int offset_for_ref_frame[255];
68 int max_num_ref_frames;
69 bool gaps_in_frame_num_value_allowed_flag;
70 int pic_width_in_mbs_minus1;
71 int pic_height_in_map_units_minus1;
72 bool frame_mbs_only_flag;
73 bool mb_adaptive_frame_field_flag;
74 bool direct_8x8_inference_flag;
75 bool frame_cropping_flag;
76 int frame_crop_left_offset;
77 int frame_crop_right_offset;
78 int frame_crop_top_offset;
79 int frame_crop_bottom_offset;
81 bool vui_parameters_present_flag;
84 bool bitstream_restriction_flag;
85 int max_num_reorder_frames;
86 int max_dec_frame_buffering;
88 int chroma_array_type;
94 int pic_parameter_set_id;
95 int seq_parameter_set_id;
96 bool entropy_coding_mode_flag;
97 bool bottom_field_pic_order_in_frame_present_flag;
98 int num_slice_groups_minus1;
99 int num_ref_idx_l0_default_active_minus1;
100 int num_ref_idx_l1_default_active_minus1;
101 bool weighted_pred_flag;
102 int weighted_bipred_idc;
103 int pic_init_qp_minus26;
104 int pic_init_qs_minus26;
105 int chroma_qp_index_offset;
106 bool deblocking_filter_control_present_flag;
107 bool constrained_intra_pred_flag;
108 bool redundant_pic_cnt_present_flag;
109 bool transform_8x8_mode_flag;
111 bool pic_scaling_matrix_present_flag;
112 int scaling_list4x4[6][kH264ScalingList4x4Length];
113 int scaling_list8x8[6][kH264ScalingList8x8Length];
115 int second_chroma_qp_index_offset;
119 int modification_of_pic_nums_idc;
121 int abs_diff_pic_num_minus1;
122 int long_term_pic_num;
127 bool luma_weight_flag;
128 bool chroma_weight_flag;
131 int chroma_weight[32][2];
132 int chroma_offset[32][2];
136 int memory_mgmnt_control_operation;
137 int difference_of_pic_nums_minus1;
138 int long_term_pic_num;
139 int long_term_frame_idx;
140 int max_long_term_frame_idx_plus1;
148 kRefListModSize = kRefListSize
159 bool IsPSlice()
const;
160 bool IsBSlice()
const;
161 bool IsISlice()
const;
162 bool IsSPSlice()
const;
163 bool IsSISlice()
const;
167 const uint8_t* nalu_data;
169 off_t header_bit_size;
171 int first_mb_in_slice;
173 int pic_parameter_set_id;
177 bool bottom_field_flag;
179 int pic_order_cnt_lsb;
180 int delta_pic_order_cnt_bottom;
181 int delta_pic_order_cnt[2];
182 int redundant_pic_cnt;
183 bool direct_spatial_mv_pred_flag;
185 bool num_ref_idx_active_override_flag;
186 int num_ref_idx_l0_active_minus1;
187 int num_ref_idx_l1_active_minus1;
188 bool ref_pic_list_modification_flag_l0;
189 bool ref_pic_list_modification_flag_l1;
193 int luma_log2_weight_denom;
194 int chroma_log2_weight_denom;
196 bool luma_weight_l0_flag;
197 bool chroma_weight_l0_flag;
200 bool luma_weight_l1_flag;
201 bool chroma_weight_l1_flag;
204 bool no_output_of_prior_pics_flag;
205 bool long_term_reference_flag;
207 bool adaptive_ref_pic_marking_mode_flag;
212 bool sp_for_switch_flag;
214 int disable_deblocking_filter_idc;
215 int slice_alpha_c0_offset_div2;
216 int slice_beta_offset_div2;
220 int recovery_frame_cnt;
221 bool exact_match_flag;
222 bool broken_link_flag;
223 int changing_slice_group_idc;
230 kSEIRecoveryPoint = 6,
266 Result ParseSps(
const Nalu& nalu,
int* sps_id);
267 Result ParsePps(
const Nalu& nalu,
int* pps_id);
271 const H264Sps* GetSps(
int sps_id);
272 const H264Pps* GetPps(
int pps_id);
302 bool* hrd_parameters_present);
307 int num_ref_idx_active_minus1,
317 int num_ref_idx_active_minus1,
318 int chroma_array_type,
319 int luma_log2_weight_denom,
320 int chroma_log2_weight_denom,
327 typedef std::map<int, H264Sps*> SpsById;
328 typedef std::map<int, H264Pps*> PpsById;
329 SpsById active_SPSes_;
330 PpsById active_PPSes_;
338 #endif // MEDIA_FILTERS_H264_PARSER_H_