7 #ifndef PACKAGER_MEDIA_CODECS_AV1_PARSER_H_ 8 #define PACKAGER_MEDIA_CODECS_AV1_PARSER_H_ 25 size_t start_offset_in_bytes;
40 virtual bool Parse(
const uint8_t* data,
42 std::vector<Tile>* tiles);
53 struct ObuExtensionHeader {
60 bool obu_has_size_field =
false;
61 ObuExtensionHeader extension_header;
66 bool mono_chrome =
false;
68 int color_primaries = 0;
69 int transfer_chracteristics = 0;
70 int matrix_coefficients = 0;
71 bool color_range =
false;
72 bool subsampling_x =
false;
73 bool subsampling_y =
false;
74 int chroma_sampling_position = 0;
75 bool separate_uv_delta_q =
false;
79 bool equal_picture_interval =
false;
82 struct DecoderModelInfo {
83 int buffer_delay_length_minus_1 = 0;
84 int buffer_removal_time_length_minus_1 = 0;
85 int frame_presentation_time_length_minus_1 = 0;
88 struct SequenceHeaderObu {
90 bool reduced_still_picture_header =
false;
92 TimingInfo timing_info;
93 bool decoder_model_info_present_flag =
false;
94 DecoderModelInfo decoder_model_info;
96 int operating_points_cnt_minus_1 = 0;
97 static constexpr
int kMaxOperatingPointsCount = 1 << 5;
98 int operating_point_idc[kMaxOperatingPointsCount] = {};
99 bool decoder_model_present_for_this_op[kMaxOperatingPointsCount] = {};
101 int frame_width_bits_minus_1 = 0;
102 int frame_height_bits_minus_1 = 0;
103 int max_frame_width_minus_1 = 0;
104 int max_frame_height_minus_1 = 0;
106 bool frame_id_numbers_present_flag =
false;
107 int delta_frame_id_length_minus_2 = 0;
108 int additional_frame_id_length_minus_1 = 0;
110 bool use_128x128_superblock =
false;
112 bool enable_warped_motion =
false;
113 bool enable_order_hint =
false;
114 bool enable_ref_frame_mvs =
false;
115 int order_hint_bits = 0;
117 int seq_force_screen_content_tools = 0;
118 int seq_force_integer_mv = 0;
120 bool enable_superres =
false;
121 bool enable_cdef =
false;
122 bool enable_restoration =
false;
123 ColorConfig color_config;
124 bool film_grain_params_present =
false;
130 int tile_cols_log2 = 0;
131 int tile_rows_log2 = 0;
132 int tile_size_bytes = 0;
135 struct QuantizationParams {
144 static constexpr
int kMaxSegments = 8;
145 static constexpr
int kSegLvlMax = 8;
146 struct SegmentationParams {
147 bool segmentation_enabled =
false;
148 bool feature_enabled[kMaxSegments][kSegLvlMax] = {};
149 int feature_data[kMaxSegments][kSegLvlMax] = {};
152 static constexpr
int kRefsPerFrame = 7;
153 struct FrameHeaderObu {
154 bool seen_frame_header =
false;
156 bool show_existing_frame =
false;
157 int frame_to_show_map_idx = 0;
160 int refresh_frame_flags = 0;
162 int ref_frame_idx[kRefsPerFrame] = {};
167 int frame_height = 0;
168 int upscaled_width = 0;
169 int render_width = 0;
170 int render_height = 0;
176 QuantizationParams quantization_params;
177 SegmentationParams segmentation_params;
180 struct ReferenceFrame {
185 int frame_height = 0;
186 int upscaled_width = 0;
187 int render_width = 0;
188 int render_height = 0;
194 bool subsampling_x =
false;
195 bool subsampling_y =
false;
198 bool ParseOpenBitstreamUnit(
BitReader* reader, std::vector<Tile>* tiles);
199 bool ParseObuHeader(
BitReader* reader, ObuHeader* obu_header);
200 bool ParseObuExtensionHeader(
BitReader* reader,
201 ObuExtensionHeader* obu_extension_header);
202 bool ParseTrailingBits(
size_t nb_bits,
BitReader* reader);
206 bool ParseSequenceHeaderObu(
BitReader* reader);
207 bool ParseColorConfig(
BitReader* reader);
209 bool ParseDecoderModelInfo(
BitReader* reader);
210 bool SkipOperatingParametersInfo(
BitReader* reader);
213 bool ParseFrameHeaderObu(
const ObuHeader& obu_header,
BitReader* reader);
214 bool ParseUncompressedHeader(
const ObuHeader& obu_header,
BitReader* reader);
215 int GetRelativeDist(
int a,
int b);
216 bool ParseFrameSize(
bool frame_size_override_flag,
BitReader* reader);
218 bool ParseFrameSizeWithRefs(
bool frame_size_override_flag,
BitReader* reader);
219 bool ParseSuperresParams(
BitReader* reader);
220 void ComputeImageSize();
221 bool SkipInterpolationFilter(
BitReader* reader);
222 bool ParseLoopFilterParams(
bool coded_lossless,
226 bool ParseQuantizationParams(
BitReader* reader);
227 bool ReadDeltaQ(
BitReader* reader,
int* delta_q);
228 bool ParseSegmentationParams(
int primary_ref_frame,
BitReader* reader);
229 bool SkipDeltaQParams(
BitReader* reader,
bool* delta_q_present);
230 bool SkipDeltaLfParams(
bool delta_q_present,
233 bool ParseCdefParams(
bool coded_lossless,
236 bool ParseLrParams(
bool all_lossless,
bool allow_intrabc,
BitReader* reader);
237 bool SkipTxMode(
bool coded_lossless,
BitReader* reader);
238 bool SkipSkipModeParams(
bool frame_is_intra,
239 bool reference_select,
241 bool ParseFrameReferenceMode(
bool frame_is_intra,
243 bool* reference_select);
244 bool SkipGlobalMotionParams(
bool frame_is_intra,
245 bool allow_high_precision_mv,
247 bool SkipGlobalParam(
int type,
250 bool allow_high_precision_mv,
252 bool SkipDecodeSignedSubexpWithRef(
int low,
int high,
BitReader* reader);
253 bool SkipDecodeUnsignedSubexpWithRef(
int mx,
BitReader* reader);
254 bool SkipDecodeSubexp(
int num_syms,
BitReader* reader);
255 bool SkipFilmGrainParams(
bool show_frame,
258 bool SkipTemporalPointInfo(
BitReader* reader);
261 bool ParseFrameObu(
const ObuHeader& obu_header,
264 std::vector<Tile>* tiles);
267 bool ParseTileGroupObu(
size_t size,
269 std::vector<Tile>* tiles);
270 bool SegFeatureActiveIdx(
int idx,
int feature);
275 void DecodeFrameWrapup();
276 bool SetFrameRefs(
int last_frame_idx,
int gold_frame_idx);
277 int GetQIndex(
bool ignore_delta_q,
int segment_id);
279 SequenceHeaderObu sequence_header_;
280 FrameHeaderObu frame_header_;
281 static constexpr
int kNumRefFrames = 8;
282 ReferenceFrame reference_frames_[kNumRefFrames];
288 #endif // PACKAGER_MEDIA_CODECS_AV1_PARSER_H_
All the methods that are virtual are virtual for mocking.