7 #ifndef PACKAGER_MEDIA_CODECS_H264_PARSER_H_
8 #define PACKAGER_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,
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 bool bitstream_restriction_flag;
86 int max_num_reorder_frames;
87 int max_dec_frame_buffering;
89 int chroma_array_type;
93 int pic_parameter_set_id;
94 int seq_parameter_set_id;
95 bool entropy_coding_mode_flag;
96 bool bottom_field_pic_order_in_frame_present_flag;
97 int num_slice_groups_minus1;
98 int num_ref_idx_l0_default_active_minus1;
99 int num_ref_idx_l1_default_active_minus1;
100 bool weighted_pred_flag;
101 int weighted_bipred_idc;
102 int pic_init_qp_minus26;
103 int pic_init_qs_minus26;
104 int chroma_qp_index_offset;
105 bool deblocking_filter_control_present_flag;
106 bool constrained_intra_pred_flag;
107 bool redundant_pic_cnt_present_flag;
108 bool transform_8x8_mode_flag;
110 bool pic_scaling_matrix_present_flag;
111 int scaling_list4x4[6][kH264ScalingList4x4Length];
112 int scaling_list8x8[6][kH264ScalingList8x8Length];
114 int second_chroma_qp_index_offset;
118 int modification_of_pic_nums_idc;
120 int abs_diff_pic_num_minus1;
121 int long_term_pic_num;
126 bool luma_weight_flag[32];
127 bool chroma_weight_flag[32];
130 int chroma_weight[32][2];
131 int chroma_offset[32][2];
135 int memory_mgmnt_control_operation;
136 int difference_of_pic_nums_minus1;
137 int long_term_pic_num;
138 int long_term_frame_idx;
139 int max_long_term_frame_idx_plus1;
145 kRefListModSize = kRefListSize
156 bool IsPSlice()
const;
157 bool IsBSlice()
const;
158 bool IsISlice()
const;
159 bool IsSPSlice()
const;
160 bool IsSISlice()
const;
165 const uint8_t* nalu_data;
174 size_t header_bit_size;
176 int first_mb_in_slice;
178 int pic_parameter_set_id;
182 bool bottom_field_flag;
184 int pic_order_cnt_lsb;
185 int delta_pic_order_cnt_bottom;
186 int delta_pic_order_cnt[2];
187 int redundant_pic_cnt;
188 bool direct_spatial_mv_pred_flag;
190 bool num_ref_idx_active_override_flag;
191 int num_ref_idx_l0_active_minus1;
192 int num_ref_idx_l1_active_minus1;
193 bool ref_pic_list_modification_flag_l0;
194 bool ref_pic_list_modification_flag_l1;
198 int luma_log2_weight_denom;
199 int chroma_log2_weight_denom;
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;
228 kSEIRecoveryPoint = 6,
264 Result ParseSps(
const Nalu& nalu,
int* sps_id);
265 Result ParsePps(
const Nalu& nalu,
int* pps_id);
269 const H264Sps* GetSps(
int sps_id);
270 const H264Pps* GetPps(
int pps_id);
300 bool* hrd_parameters_present);
305 int num_ref_idx_active_minus1,
315 int num_ref_idx_active_minus1,
316 int chroma_array_type,
317 int luma_log2_weight_denom,
318 int chroma_log2_weight_denom,
325 typedef std::map<int, std::unique_ptr<H264Sps>> SpsById;
326 typedef std::map<int, std::unique_ptr<H264Pps>> PpsById;
327 SpsById active_SPSes_;
328 PpsById active_PPSes_;
All the methods that are virtual are virtual for mocking.