1 /* Gstreamer
2 * Copyright (C) 2018 Georg Ottinger
3 * Author: Georg Ottinger <g.ottinger@gmx.at>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21 #include <gst/check/gstcheck.h>
22 #include <gst/codecparsers/gstav1parser.h>
23
24 static const guint8 aom_testdata_av1_1_b8_01_size_16x16[] = {
25 0x12, 0x00, 0x0a, 0x0a, 0x00, 0x00, 0x00, 0x01, 0x9f, 0xfb, 0xff, 0xf3,
26 0x00, 0x80, 0x32, 0xa6, 0x01, 0x10, 0x00, 0x87, 0x80, 0x00, 0x03, 0x00,
27 0x00, 0x00, 0x40, 0x00, 0x9e, 0x86, 0x5b, 0xb2, 0x22, 0xb5, 0x58, 0x4d,
28 0x68, 0xe6, 0x37, 0x54, 0x42, 0x7b, 0x84, 0xce, 0xdf, 0x9f, 0xec, 0xab,
29 0x07, 0x4d, 0xf6, 0xe1, 0x5e, 0x9e, 0x27, 0xbf, 0x93, 0x2f, 0x47, 0x0d,
30 0x7b, 0x7c, 0x45, 0x8d, 0xcf, 0x26, 0xf7, 0x6c, 0x06, 0xd7, 0x8c, 0x2e,
31 0xf5, 0x2c, 0xb0, 0x8a, 0x31, 0xac, 0x69, 0xf5, 0xcd, 0xd8, 0x71, 0x5d,
32 0xaf, 0xf8, 0x96, 0x43, 0x8c, 0x9c, 0x23, 0x6f, 0xab, 0xd0, 0x35, 0x43,
33 0xdf, 0x81, 0x12, 0xe3, 0x7d, 0xec, 0x22, 0xb0, 0x30, 0x54, 0x32, 0x9f,
34 0x90, 0xc0, 0x5d, 0x64, 0x9b, 0x0f, 0x75, 0x31, 0x84, 0x3a, 0x57, 0xd7,
35 0x5f, 0x03, 0x6e, 0x7f, 0x43, 0x17, 0x6d, 0x08, 0xc3, 0x81, 0x8a, 0xae,
36 0x73, 0x1c, 0xa8, 0xa7, 0xe4, 0x9c, 0xa9, 0x5b, 0x3f, 0xd1, 0xeb, 0x75,
37 0x3a, 0x7f, 0x22, 0x77, 0x38, 0x64, 0x1c, 0x77, 0xdb, 0xcd, 0xef, 0xb7,
38 0x08, 0x45, 0x8e, 0x7f, 0xea, 0xa3, 0xd0, 0x81, 0xc9, 0xc1, 0xbc, 0x93,
39 0x9b, 0x41, 0xb1, 0xa1, 0x42, 0x17, 0x98, 0x3f, 0x1e, 0x95, 0xdf, 0x68,
40 0x7c, 0xb7, 0x98, 0x12, 0x00, 0x32, 0x4b, 0x30, 0x03, 0xc3, 0x00, 0xa7,
41 0x2e, 0x46, 0x8a, 0x00, 0x00, 0x03, 0x00, 0x00, 0x50, 0xc0, 0x20, 0x00,
42 0xf0, 0xb1, 0x2f, 0x43, 0xf3, 0xbb, 0xe6, 0x5c, 0xbe, 0xe6, 0x53, 0xbc,
43 0xaa, 0x61, 0x7c, 0x7e, 0x0a, 0x04, 0x1b, 0xa2, 0x87, 0x81, 0xe8, 0xa6,
44 0x85, 0xfe, 0xc2, 0x71, 0xb9, 0xf8, 0xc0, 0x78, 0x9f, 0x52, 0x4f, 0xa7,
45 0x8f, 0x55, 0x96, 0x79, 0x90, 0xaa, 0x2b, 0x6d, 0x0a, 0xa7, 0x05, 0x2a,
46 0xf8, 0xfc, 0xc9, 0x7d, 0x9d, 0x4a, 0x61, 0x16, 0xb1, 0x65
47 };
48
49 /* testdata taken from aom testdata deecoded and reencoded with annexb */
50 static const guint8 aom_testdata_av1_1_b8_01_size_16x16_reencoded_annexb[] = {
51 0x8b, 0x02, 0x89, 0x02, 0x01, 0x10, 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 0x6e, 0xf3, 0x32, 0x3c, 0x55, 0x9f,
82 0x97, 0x9e, 0x1e, 0x1a, 0x51, 0x1d, 0xf4, 0x15, 0x16, 0xa0, 0xea, 0xec,
83 0x64, 0xd3, 0xff, 0xd9, 0x7a, 0xb7, 0x91, 0x10, 0x4b, 0xfd, 0x7a, 0x49,
84 0x62, 0xae, 0x46, 0xa8, 0x4b, 0x53, 0x15, 0xba, 0x27, 0x6d, 0x5b, 0x72,
85 0x5f, 0x7e, 0x63, 0xc6, 0x70, 0x79, 0x84, 0xe4, 0x2e, 0x3e, 0xfd, 0xdf,
86 0xeb, 0xf1, 0x2a, 0xe5, 0xc7, 0x68, 0x8e, 0x65, 0xfe, 0x0d, 0x1e, 0xea,
87 0xce, 0x0f, 0x83, 0x47, 0xfc, 0x11, 0x18, 0x0f, 0x2d, 0x29, 0x8e, 0xff,
88 0xbc, 0x5e, 0x7b, 0x45, 0x2e, 0x51, 0xd1, 0xa8, 0xdb, 0xd7, 0xbe, 0x1a,
89 0xf2, 0x59, 0xa3, 0x0b, 0x96, 0x5a, 0xc1, 0x81, 0x0e, 0xc9, 0xe9, 0x3d,
90 0x1c, 0x75, 0x41, 0xbe, 0x46, 0xba, 0xb1, 0x55, 0x95, 0xe1, 0x1a, 0x89,
91 0xce, 0x4f, 0xf4, 0x78, 0x9b, 0x71, 0x49, 0xe8, 0xf7, 0x58, 0x5b, 0xca,
92 0xde, 0xc3, 0x8f, 0x41, 0x80, 0xdd, 0xcc, 0xf8, 0xb6, 0x50, 0x24, 0x0d,
93 0x53, 0xa1, 0xcf, 0x5a, 0xc8, 0xc4, 0x81, 0x83, 0x2c, 0x2f, 0xfc, 0x37,
94 0x82, 0x67, 0xb6, 0x8a, 0xdc, 0xe0
95 };
96
97 /* hand crafted test case for metadata */
98 static const guint8 metadata_obu[] = {
99 0x2a, 0x05, 0x01, 0x12, 0x34, 0x56, 0x78
100 };
101
102 /* hand crafted test case for tile list */
103 static const guint8 tile_list_obu[] = {
104 0x42, 0x0a, 0x01, 0x01, 0x00, 0x01, 0x11, 0x22, 0x33, 0x00, 0x01, 0xa5
105 };
106
GST_START_TEST(test_av1_parse_aom_testdata_av1_1_b8_01_size_16x16)107 GST_START_TEST (test_av1_parse_aom_testdata_av1_1_b8_01_size_16x16)
108 {
109 GstAV1Parser *parser;
110 GstAV1SequenceHeaderOBU seq_header;
111 GstAV1FrameOBU frame;
112 GstAV1OBU obu;
113 GstAV1ParserResult ret;
114 guint32 consumed = 0;
115 const guint8 *data_ptr = aom_testdata_av1_1_b8_01_size_16x16;
116 guint data_sz = sizeof (aom_testdata_av1_1_b8_01_size_16x16);
117
118 parser = gst_av1_parser_new ();
119 gst_av1_parser_reset (parser, FALSE);
120 ret = gst_av1_parser_identify_one_obu (parser, data_ptr, data_sz,
121 &obu, &consumed);
122 assert_equals_int (ret, GST_AV1_PARSER_OK);
123 data_ptr += consumed;
124 data_sz -= consumed;
125
126 /* 1st OBU should be OBU_TEMPORAL_DELIMITER */
127 assert_equals_int (obu.obu_type, GST_AV1_OBU_TEMPORAL_DELIMITER);
128 assert_equals_int (obu.header.obu_extention_flag, 0);
129 assert_equals_int (obu.header.obu_has_size_field, 1);
130 assert_equals_int (obu.obu_size, 0);
131 ret = gst_av1_parser_parse_temporal_delimiter_obu (parser, &obu);
132 assert_equals_int (ret, GST_AV1_PARSER_OK);
133
134 /* 2nd OBU should be OBU_SEQUENCE_HEADER */
135 ret = gst_av1_parser_identify_one_obu (parser, data_ptr, data_sz,
136 &obu, &consumed);
137 assert_equals_int (ret, GST_AV1_PARSER_OK);
138 data_ptr += consumed;
139 data_sz -= consumed;
140
141 assert_equals_int (obu.obu_type, GST_AV1_OBU_SEQUENCE_HEADER);
142 assert_equals_int (obu.header.obu_extention_flag, 0);
143 assert_equals_int (obu.header.obu_has_size_field, 1);
144 assert_equals_int (obu.obu_size, 10);
145
146 ret = gst_av1_parser_parse_sequence_header_obu (parser, &obu, &seq_header);
147 assert_equals_int (ret, GST_AV1_PARSER_OK);
148
149 assert_equals_int (seq_header.seq_profile, GST_AV1_PROFILE_0);
150 assert_equals_int (seq_header.still_picture, 0);
151 assert_equals_int (seq_header.reduced_still_picture_header, 0);
152 assert_equals_int (seq_header.timing_info_present_flag, 0);
153 assert_equals_int (seq_header.initial_display_delay_present_flag, 0);
154 assert_equals_int (seq_header.operating_points_cnt_minus_1, 0);
155 assert_equals_int (seq_header.operating_points[0].idc, 0);
156 assert_equals_int (seq_header.operating_points[0].seq_level_idx, 0);
157 assert_equals_int (seq_header.frame_width_bits_minus_1, 3);
158 assert_equals_int (seq_header.frame_height_bits_minus_1, 3);
159 assert_equals_int (seq_header.max_frame_width_minus_1, 15);
160 assert_equals_int (seq_header.max_frame_height_minus_1, 15);
161 assert_equals_int (seq_header.frame_id_numbers_present_flag, 0);
162 assert_equals_int (seq_header.use_128x128_superblock, 1);
163 assert_equals_int (seq_header.enable_filter_intra, 1);
164 assert_equals_int (seq_header.enable_intra_edge_filter, 1);
165 assert_equals_int (seq_header.enable_interintra_compound, 1);
166 assert_equals_int (seq_header.enable_masked_compound, 1);
167 assert_equals_int (seq_header.enable_warped_motion, 1);
168 assert_equals_int (seq_header.enable_dual_filter, 1);
169 assert_equals_int (seq_header.enable_order_hint, 1);
170 assert_equals_int (seq_header.enable_jnt_comp, 1);
171 assert_equals_int (seq_header.enable_ref_frame_mvs, 1);
172 assert_equals_int (seq_header.seq_choose_screen_content_tools, 1);
173 assert_equals_int (seq_header.seq_choose_integer_mv, 1);
174 assert_equals_int (seq_header.order_hint_bits_minus_1, 6);
175 assert_equals_int (seq_header.enable_superres, 0);
176 assert_equals_int (seq_header.enable_cdef, 1);
177 assert_equals_int (seq_header.enable_restoration, 1);
178 assert_equals_int (seq_header.color_config.high_bitdepth, 0);
179 assert_equals_int (seq_header.color_config.mono_chrome, 0);
180 assert_equals_int (seq_header.color_config.color_description_present_flag, 0);
181 assert_equals_int (seq_header.color_config.chroma_sample_position,
182 GST_AV1_CSP_UNKNOWN);
183 assert_equals_int (seq_header.color_config.separate_uv_delta_q, 0);
184 assert_equals_int (seq_header.film_grain_params_present, 0);
185
186 /* 3rd OBU should be GST_AV1_OBU_FRAME */
187 ret = gst_av1_parser_identify_one_obu (parser, data_ptr, data_sz,
188 &obu, &consumed);
189 assert_equals_int (ret, GST_AV1_PARSER_OK);
190 data_ptr += consumed;
191 data_sz -= consumed;
192
193 assert_equals_int (obu.obu_type, GST_AV1_OBU_FRAME);
194 assert_equals_int (obu.header.obu_extention_flag, 0);
195 assert_equals_int (obu.header.obu_has_size_field, 1);
196 assert_equals_int (obu.obu_size, 166);
197
198 ret = gst_av1_parser_parse_frame_obu (parser, &obu, &frame);
199 assert_equals_int (ret, GST_AV1_PARSER_OK);
200
201 assert_equals_int (frame.frame_header.show_existing_frame, 0);
202 assert_equals_int (frame.frame_header.frame_type, GST_AV1_KEY_FRAME);
203 assert_equals_int (frame.frame_header.show_frame, 1);
204 assert_equals_int (frame.frame_header.disable_cdf_update, 0);
205 assert_equals_int (frame.frame_header.allow_screen_content_tools, 0);
206 assert_equals_int (frame.frame_header.frame_size_override_flag, 0);
207 assert_equals_int (frame.frame_header.order_hint, 0);
208 assert_equals_int (frame.frame_header.render_and_frame_size_different, 0);
209 assert_equals_int (frame.frame_header.disable_frame_end_update_cdf, 0);
210 assert_equals_int (frame.frame_header.tile_info.uniform_tile_spacing_flag, 1);
211 assert_equals_int (frame.frame_header.quantization_params.base_q_idx, 15);
212 assert_equals_int (frame.frame_header.quantization_params.delta_q_y_dc, 0);
213 assert_equals_int (frame.frame_header.quantization_params.delta_q_u_dc, 0);
214 assert_equals_int (frame.frame_header.quantization_params.delta_q_u_ac, 0);
215 assert_equals_int (frame.frame_header.quantization_params.using_qmatrix, 0);
216 assert_equals_int (frame.frame_header.quantization_params.delta_q_present, 0);
217 assert_equals_int (frame.frame_header.loop_filter_params.loop_filter_level[0],
218 0);
219 assert_equals_int (frame.frame_header.loop_filter_params.loop_filter_level[1],
220 0);
221 assert_equals_int (frame.frame_header.loop_filter_params.
222 loop_filter_sharpness, 0);
223 assert_equals_int (frame.frame_header.loop_filter_params.
224 loop_filter_delta_enabled, 1);
225 assert_equals_int (frame.frame_header.loop_filter_params.
226 loop_filter_delta_update, 1);
227 assert_equals_int (frame.frame_header.
228 loop_filter_params.loop_filter_ref_deltas[0], 1);
229 assert_equals_int (frame.frame_header.
230 loop_filter_params.loop_filter_ref_deltas[1], 0);
231 assert_equals_int (frame.frame_header.
232 loop_filter_params.loop_filter_ref_deltas[2], 0);
233 assert_equals_int (frame.frame_header.
234 loop_filter_params.loop_filter_ref_deltas[3], 0);
235 assert_equals_int (frame.frame_header.
236 loop_filter_params.loop_filter_ref_deltas[4], -1);
237 assert_equals_int (frame.frame_header.
238 loop_filter_params.loop_filter_ref_deltas[5], 0);
239 assert_equals_int (frame.frame_header.
240 loop_filter_params.loop_filter_ref_deltas[6], -1);
241 assert_equals_int (frame.frame_header.
242 loop_filter_params.loop_filter_ref_deltas[7], -1);
243 assert_equals_int (frame.frame_header.loop_filter_params.
244 loop_filter_mode_deltas[0], 0);
245 assert_equals_int (frame.frame_header.loop_filter_params.
246 loop_filter_mode_deltas[1], 0);
247 assert_equals_int (frame.frame_header.cdef_params.cdef_damping, 3);
248 assert_equals_int (frame.frame_header.cdef_params.cdef_bits, 0);
249 assert_equals_int (frame.frame_header.cdef_params.cdef_y_pri_strength[0], 0);
250 assert_equals_int (frame.frame_header.cdef_params.cdef_y_sec_strength[0], 0);
251 assert_equals_int (frame.frame_header.cdef_params.cdef_uv_pri_strength[0], 0);
252 assert_equals_int (frame.frame_header.cdef_params.cdef_uv_sec_strength[0], 1);
253 assert_equals_int (frame.frame_header.loop_restoration_params.
254 frame_restoration_type[0], GST_AV1_FRAME_RESTORE_NONE);
255 assert_equals_int (frame.frame_header.loop_restoration_params.
256 frame_restoration_type[1], GST_AV1_FRAME_RESTORE_NONE);
257 assert_equals_int (frame.frame_header.loop_restoration_params.
258 frame_restoration_type[2], GST_AV1_FRAME_RESTORE_NONE);
259 assert_equals_int (frame.frame_header.tx_mode_select, 0);
260 assert_equals_int (frame.frame_header.reduced_tx_set, 0);
261
262 /* 4th OBU should be OBU_TEMPORAL_DELIMITER */
263 ret = gst_av1_parser_identify_one_obu (parser, data_ptr, data_sz,
264 &obu, &consumed);
265 assert_equals_int (ret, GST_AV1_PARSER_OK);
266 data_ptr += consumed;
267 data_sz -= consumed;
268
269 assert_equals_int (obu.obu_type, GST_AV1_OBU_TEMPORAL_DELIMITER);
270 assert_equals_int (obu.header.obu_extention_flag, 0);
271 assert_equals_int (obu.header.obu_has_size_field, 1);
272 assert_equals_int (obu.obu_size, 0);
273
274 ret = gst_av1_parser_parse_temporal_delimiter_obu (parser, &obu);
275 assert_equals_int (ret, GST_AV1_PARSER_OK);
276
277 /* 5th OBU should be GST_AV1_OBU_FRAME */
278 ret = gst_av1_parser_identify_one_obu (parser, data_ptr, data_sz,
279 &obu, &consumed);
280 assert_equals_int (ret, GST_AV1_PARSER_OK);
281 data_ptr += consumed;
282 data_sz -= consumed;
283
284 assert_equals_int (obu.obu_type, GST_AV1_OBU_FRAME);
285 assert_equals_int (obu.header.obu_extention_flag, 0);
286 assert_equals_int (obu.header.obu_has_size_field, 1);
287 assert_equals_int (obu.obu_size, 75);
288
289 ret = gst_av1_parser_parse_frame_obu (parser, &obu, &frame);
290 assert_equals_int (ret, GST_AV1_PARSER_OK);
291
292 assert_equals_int (frame.frame_header.show_existing_frame, 0);
293 assert_equals_int (frame.frame_header.frame_type, GST_AV1_INTER_FRAME);
294 assert_equals_int (frame.frame_header.show_frame, 1);
295 assert_equals_int (frame.frame_header.error_resilient_mode, 0);
296 assert_equals_int (frame.frame_header.disable_cdf_update, 0);
297 assert_equals_int (frame.frame_header.allow_screen_content_tools, 0);
298 assert_equals_int (frame.frame_header.frame_size_override_flag, 0);
299 assert_equals_int (frame.frame_header.order_hint, 1);
300 assert_equals_int (frame.frame_header.primary_ref_frame, 7);
301 assert_equals_int (frame.frame_header.refresh_frame_flags, 12);
302 assert_equals_int (frame.frame_header.frame_refs_short_signaling, 0);
303 assert_equals_int (frame.frame_header.ref_frame_idx[0], 0);
304 assert_equals_int (frame.frame_header.ref_frame_idx[1], 1);
305 assert_equals_int (frame.frame_header.ref_frame_idx[2], 2);
306 assert_equals_int (frame.frame_header.ref_frame_idx[3], 3);
307 assert_equals_int (frame.frame_header.ref_frame_idx[4], 4);
308 assert_equals_int (frame.frame_header.ref_frame_idx[5], 5);
309 assert_equals_int (frame.frame_header.ref_frame_idx[6], 6);
310 assert_equals_int (frame.frame_header.allow_high_precision_mv, 1);
311 assert_equals_int (frame.frame_header.is_filter_switchable, 0);
312 assert_equals_int (frame.frame_header.interpolation_filter,
313 GST_AV1_INTERPOLATION_FILTER_EIGHTTAP);
314 assert_equals_int (frame.frame_header.is_motion_mode_switchable, 1);
315 assert_equals_int (frame.frame_header.use_ref_frame_mvs, 1);
316 assert_equals_int (frame.frame_header.disable_frame_end_update_cdf, 0);
317 assert_equals_int (frame.frame_header.quantization_params.base_q_idx, 20);
318 assert_equals_int (frame.frame_header.quantization_params.delta_q_y_dc, 0);
319 assert_equals_int (frame.frame_header.quantization_params.delta_q_u_dc, 0);
320 assert_equals_int (frame.frame_header.quantization_params.delta_q_u_ac, 0);
321 assert_equals_int (frame.frame_header.quantization_params.using_qmatrix, 0);
322 assert_equals_int (frame.frame_header.segmentation_params.
323 segmentation_enabled, 0);
324 assert_equals_int (frame.frame_header.quantization_params.delta_q_present, 0);
325 assert_equals_int (frame.frame_header.loop_filter_params.loop_filter_level[0],
326 0);
327 assert_equals_int (frame.frame_header.loop_filter_params.loop_filter_level[1],
328 0);
329 assert_equals_int (frame.frame_header.loop_filter_params.
330 loop_filter_sharpness, 0);
331 assert_equals_int (frame.frame_header.loop_filter_params.
332 loop_filter_delta_enabled, 1);
333 assert_equals_int (frame.frame_header.loop_filter_params.
334 loop_filter_delta_update, 1);
335 assert_equals_int (frame.frame_header.
336 loop_filter_params.loop_filter_ref_deltas[0], 1);
337 assert_equals_int (frame.frame_header.
338 loop_filter_params.loop_filter_ref_deltas[1], 0);
339 assert_equals_int (frame.frame_header.
340 loop_filter_params.loop_filter_ref_deltas[2], 0);
341 assert_equals_int (frame.frame_header.
342 loop_filter_params.loop_filter_ref_deltas[3], 0);
343 assert_equals_int (frame.frame_header.
344 loop_filter_params.loop_filter_ref_deltas[4], -1);
345 assert_equals_int (frame.frame_header.
346 loop_filter_params.loop_filter_ref_deltas[5], 0);
347 assert_equals_int (frame.frame_header.
348 loop_filter_params.loop_filter_ref_deltas[6], -1);
349 assert_equals_int (frame.frame_header.
350 loop_filter_params.loop_filter_ref_deltas[7], -1);
351 assert_equals_int (frame.frame_header.loop_filter_params.
352 loop_filter_mode_deltas[0], 0);
353 assert_equals_int (frame.frame_header.loop_filter_params.
354 loop_filter_mode_deltas[1], 0);
355 assert_equals_int (frame.frame_header.cdef_params.cdef_damping, 3);
356 assert_equals_int (frame.frame_header.cdef_params.cdef_bits, 0);
357 assert_equals_int (frame.frame_header.cdef_params.cdef_y_pri_strength[0], 1);
358 assert_equals_int (frame.frame_header.cdef_params.cdef_y_sec_strength[0], 1);
359 assert_equals_int (frame.frame_header.cdef_params.cdef_uv_pri_strength[0], 0);
360 assert_equals_int (frame.frame_header.cdef_params.cdef_uv_sec_strength[0], 4);
361 assert_equals_int (frame.frame_header.loop_restoration_params.
362 frame_restoration_type[0], GST_AV1_FRAME_RESTORE_NONE);
363 assert_equals_int (frame.frame_header.loop_restoration_params.
364 frame_restoration_type[1], GST_AV1_FRAME_RESTORE_NONE);
365 assert_equals_int (frame.frame_header.loop_restoration_params.
366 frame_restoration_type[2], GST_AV1_FRAME_RESTORE_NONE);
367 assert_equals_int (frame.frame_header.tx_mode_select, 0);
368 assert_equals_int (frame.frame_header.reference_select, 0);
369 assert_equals_int (frame.frame_header.allow_warped_motion, 1);
370 assert_equals_int (frame.frame_header.reduced_tx_set, 0);
371 assert_equals_int (frame.frame_header.global_motion_params.is_global[1], 0);
372 assert_equals_int (frame.frame_header.global_motion_params.is_global[2], 0);
373 assert_equals_int (frame.frame_header.global_motion_params.is_global[3], 0);
374 assert_equals_int (frame.frame_header.global_motion_params.is_global[4], 0);
375 assert_equals_int (frame.frame_header.global_motion_params.is_global[5], 0);
376 assert_equals_int (frame.frame_header.global_motion_params.is_global[6], 0);
377
378 gst_av1_parser_free (parser);
379 }
380
381 GST_END_TEST;
382
GST_START_TEST(test_av1_parse_aom_testdata_av1_1_b8_01_size_16x16_reencoded_annexb)383 GST_START_TEST
384 (test_av1_parse_aom_testdata_av1_1_b8_01_size_16x16_reencoded_annexb) {
385 GstAV1Parser *parser;
386 GstAV1OBU obu;
387 GstAV1SequenceHeaderOBU seq_header;
388 GstAV1FrameOBU frame;
389 gsize size;
390 guint32 consumed = 0;
391 const guint8 *data;
392 GstAV1ParserResult ret;
393
394 parser = gst_av1_parser_new ();
395
396 data = aom_testdata_av1_1_b8_01_size_16x16_reencoded_annexb;
397 size = sizeof (aom_testdata_av1_1_b8_01_size_16x16_reencoded_annexb);
398
399 gst_av1_parser_reset (parser, TRUE);
400
401 /* 1st OBU should be OBU_TEMPORAL_DELIMITER */
402 ret = gst_av1_parser_identify_one_obu (parser, data, size, &obu, &consumed);
403 assert_equals_int (ret, GST_AV1_PARSER_OK);
404 data += consumed;
405 size -= consumed;
406
407 assert_equals_int (obu.header.obu_type, GST_AV1_OBU_TEMPORAL_DELIMITER);
408 assert_equals_int (obu.header.obu_extention_flag, 0);
409 assert_equals_int (obu.header.obu_has_size_field, 0);
410 assert_equals_int (obu.obu_size, 0);
411
412 gst_av1_parser_parse_temporal_delimiter_obu (parser, &obu);
413
414 /* 2nd OBU should be OBU_SEQUENCE_HEADER */
415 ret = gst_av1_parser_identify_one_obu (parser, data, size, &obu, &consumed);
416 assert_equals_int (ret, GST_AV1_PARSER_OK);
417 data += consumed;
418 size -= consumed;
419
420 assert_equals_int (obu.header.obu_type, GST_AV1_OBU_SEQUENCE_HEADER);
421 assert_equals_int (obu.header.obu_extention_flag, 0);
422 assert_equals_int (obu.header.obu_has_size_field, 0);
423 assert_equals_int (obu.obu_size, 10);
424
425 gst_av1_parser_parse_sequence_header_obu (parser, &obu, &seq_header);
426 assert_equals_int (seq_header.seq_profile, GST_AV1_PROFILE_0);
427 assert_equals_int (seq_header.frame_width_bits_minus_1, 3);
428 assert_equals_int (seq_header.frame_height_bits_minus_1, 3);
429 assert_equals_int (seq_header.max_frame_width_minus_1, 15);
430 assert_equals_int (seq_header.max_frame_height_minus_1, 15);
431
432 /* 3rd OBU should be GST_AV1_OBU_FRAME */
433 ret = gst_av1_parser_identify_one_obu (parser, data, size, &obu, &consumed);
434 assert_equals_int (ret, GST_AV1_PARSER_OK);
435 data += consumed;
436 size -= consumed;
437
438 assert_equals_int (obu.header.obu_type, GST_AV1_OBU_FRAME);
439 assert_equals_int (obu.header.obu_extention_flag, 0);
440 assert_equals_int (obu.header.obu_has_size_field, 0);
441 assert_equals_int (obu.obu_size, 248);
442
443 gst_av1_parser_parse_frame_obu (parser, &obu, &frame);
444 assert_equals_int (frame.frame_header.show_existing_frame, 0);
445 assert_equals_int (frame.frame_header.frame_type, GST_AV1_KEY_FRAME);
446 assert_equals_int (frame.frame_header.show_frame, 1);
447 assert_equals_int (frame.frame_header.quantization_params.base_q_idx, 0);
448
449 assert_equals_int (frame.tile_group.num_tiles, 1);
450
451 /* 4th OBU should be OBU_TEMPORAL_DELIMITER */
452 ret = gst_av1_parser_identify_one_obu (parser, data, size, &obu, &consumed);
453 assert_equals_int (ret, GST_AV1_PARSER_OK);
454 data += consumed;
455 size -= consumed;
456
457 assert_equals_int (obu.header.obu_type, GST_AV1_OBU_TEMPORAL_DELIMITER);
458 assert_equals_int (obu.header.obu_extention_flag, 0);
459 assert_equals_int (obu.header.obu_has_size_field, 0);
460 assert_equals_int (obu.obu_size, 0);
461
462 gst_av1_parser_parse_temporal_delimiter_obu (parser, &obu);
463
464 /* 5th OBU should be GST_AV1_OBU_FRAME */
465 ret = gst_av1_parser_identify_one_obu (parser, data, size, &obu, &consumed);
466 assert_equals_int (ret, GST_AV1_PARSER_OK);
467 data += consumed;
468 size -= consumed;
469
470 assert_equals_int (obu.header.obu_type, GST_AV1_OBU_FRAME);
471 assert_equals_int (obu.header.obu_extention_flag, 0);
472 assert_equals_int (obu.header.obu_has_size_field, 0);
473 assert_equals_int (obu.obu_size, 244);
474
475 gst_av1_parser_parse_frame_obu (parser, &obu, &frame);
476 assert_equals_int (frame.frame_header.show_existing_frame, 0);
477 assert_equals_int (frame.frame_header.frame_type, GST_AV1_INTER_FRAME);
478 assert_equals_int (frame.frame_header.show_frame, 1);
479 assert_equals_int (frame.frame_header.quantization_params.base_q_idx, 0);
480
481 assert_equals_int (frame.tile_group.num_tiles, 1);
482
483 gst_av1_parser_free (parser);
484 }
485
486 GST_END_TEST;
487
GST_START_TEST(test_metadata_obu)488 GST_START_TEST (test_metadata_obu)
489 {
490 GstAV1Parser *parser;
491 GstAV1OBU obu;
492 GstAV1MetadataOBU metadata;
493 guint32 consumed = 0;
494 gsize size;
495 const guint8 *data;
496 GstAV1ParserResult ret;
497
498 parser = gst_av1_parser_new ();
499
500 data = metadata_obu;
501 size = sizeof (metadata_obu);
502
503 gst_av1_parser_reset (parser, FALSE);
504
505 ret = gst_av1_parser_identify_one_obu (parser, data, size, &obu, &consumed);
506 assert_equals_int (ret, GST_AV1_PARSER_OK);
507 data += consumed;
508 size -= consumed;
509
510 assert_equals_int (obu.header.obu_type, GST_AV1_OBU_METADATA);
511 assert_equals_int (obu.header.obu_extention_flag, 0);
512 assert_equals_int (obu.header.obu_has_size_field, 1);
513 assert_equals_int (obu.obu_size, 5);
514
515 gst_av1_parser_parse_metadata_obu (parser, &obu, &metadata);
516
517 assert_equals_int (metadata.metadata_type, GST_AV1_METADATA_TYPE_HDR_CLL);
518 assert_equals_int (metadata.hdr_cll.max_cll, 0x1234);
519 assert_equals_int (metadata.hdr_cll.max_fall, 0x5678);
520
521 gst_av1_parser_free (parser);
522 }
523
524 GST_END_TEST;
525
GST_START_TEST(test_tile_list_obu)526 GST_START_TEST (test_tile_list_obu)
527 {
528 GstAV1Parser *parser;
529 GstAV1OBU obu;
530 GstAV1TileListOBU tile_list;
531 guint32 consumed = 0;
532 gsize size;
533 const guint8 *data;
534 GstAV1ParserResult ret;
535
536 parser = gst_av1_parser_new ();
537
538 data = tile_list_obu;
539 size = sizeof (tile_list_obu);
540
541 gst_av1_parser_reset (parser, FALSE);
542
543 ret = gst_av1_parser_identify_one_obu (parser, data, size, &obu, &consumed);
544 assert_equals_int (ret, GST_AV1_PARSER_OK);
545 data += consumed;
546 size -= consumed;
547
548 assert_equals_int (obu.header.obu_type, GST_AV1_OBU_TILE_LIST);
549 assert_equals_int (obu.header.obu_extention_flag, 0);
550 assert_equals_int (obu.header.obu_has_size_field, 1);
551 assert_equals_int (obu.obu_size, 10);
552
553 gst_av1_parser_parse_tile_list_obu (parser, &obu, &tile_list);
554
555 assert_equals_int (tile_list.output_frame_width_in_tiles_minus_1, 1);
556 assert_equals_int (tile_list.output_frame_height_in_tiles_minus_1, 1);
557 assert_equals_int (tile_list.tile_count_minus_1, 1);
558
559 assert_equals_int (tile_list.entry[0].anchor_frame_idx, 0x11);
560 assert_equals_int (tile_list.entry[0].anchor_tile_row, 0x22);
561 assert_equals_int (tile_list.entry[0].anchor_tile_col, 0x33);
562 assert_equals_int (tile_list.entry[0].tile_data_size_minus_1, 0x01);
563 assert_equals_int (tile_list.entry[0].coded_tile_data[0], 0xa5);
564
565 gst_av1_parser_free (parser);
566 }
567
568 GST_END_TEST;
569
570 static Suite *
av1parsers_suite(void)571 av1parsers_suite (void)
572 {
573 Suite *s = suite_create ("AV1 Parser library");
574
575 TCase *tc_chain = tcase_create ("general");
576
577 suite_add_tcase (s, tc_chain);
578 tcase_add_test (tc_chain, test_av1_parse_aom_testdata_av1_1_b8_01_size_16x16);
579 tcase_add_test (tc_chain,
580 test_av1_parse_aom_testdata_av1_1_b8_01_size_16x16_reencoded_annexb);
581 tcase_add_test (tc_chain, test_metadata_obu);
582 tcase_add_test (tc_chain, test_tile_list_obu);
583
584 return s;
585 }
586
587 GST_CHECK_MAIN (av1parsers);
588