test: Correct the test suite name of the h264 and h265 bitwriter.
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-bad / tests / check / libs / h264bitwriter.c
1 /* GStreamer
2  *  Copyright (C) 2020 Intel Corporation
3  *     Author: He Junyan <junyan.he@intel.com>
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 the0
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/gsth264bitwriter.h>
23
24 /* *INDENT-OFF* */
25 static const GstH264SPS sps = {
26   .id = 0,
27   .profile_idc = 100,
28   .constraint_set0_flag = 0,
29   .constraint_set1_flag = 0,
30   .constraint_set2_flag = 0,
31   .constraint_set3_flag = 0,
32   .constraint_set4_flag = 0,
33   .constraint_set5_flag = 0,
34   .level_idc = 31,
35
36   .chroma_format_idc = 1,
37   .bit_depth_luma_minus8 = 0,
38   .bit_depth_chroma_minus8 = 0,
39
40   .scaling_matrix_present_flag = 1,
41   .scaling_lists_4x4[0] = { 17, 32, 31, 30, 23, 15, 33, 39, 39, 35, 35, 14, 28, 32, 27, 27 },
42
43   .log2_max_frame_num_minus4 = 2,
44   .pic_order_cnt_type = 0,
45   .log2_max_pic_order_cnt_lsb_minus4 = 3,
46
47   .num_ref_frames = 8,
48   .gaps_in_frame_num_value_allowed_flag = 0,
49   .pic_width_in_mbs_minus1 = 49,
50   .pic_height_in_map_units_minus1 = 37,
51   .frame_mbs_only_flag = 1,
52   .mb_adaptive_frame_field_flag = 0,
53   .direct_8x8_inference_flag = 1,
54   .frame_cropping_flag = 1,
55   .frame_crop_left_offset = 8,
56   .frame_crop_right_offset = 8,
57   .frame_crop_top_offset = 16,
58   .frame_crop_bottom_offset = 8,
59
60   .vui_parameters_present_flag = 1,
61   .vui_parameters = {
62     .aspect_ratio_info_present_flag = 1,
63     .aspect_ratio_idc = 255,
64     .sar_width = 1,
65     .sar_height = 1,
66     .overscan_info_present_flag = 0,
67     .overscan_appropriate_flag = 0,
68     .chroma_loc_info_present_flag = 0,
69     .timing_info_present_flag = 1,
70     .num_units_in_tick = 1,
71     .time_scale = 60,
72     .fixed_frame_rate_flag = 1,
73
74     .nal_hrd_parameters_present_flag = 1,
75     .nal_hrd_parameters = {
76       .cpb_cnt_minus1 = 0,
77       .bit_rate_scale = 4,
78       .cpb_size_scale = 2,
79       .bit_rate_value_minus1[0] = 1999,
80       .cpb_size_value_minus1[0] = 63999,
81       .cbr_flag[0] = 1,
82       .initial_cpb_removal_delay_length_minus1 = 23,
83       .cpb_removal_delay_length_minus1 = 23,
84       .dpb_output_delay_length_minus1 = 23,
85       .time_offset_length = 24,
86     },
87
88     .vcl_hrd_parameters_present_flag = 0,
89     .low_delay_hrd_flag = 0,
90     .pic_struct_present_flag = 1,
91     .bitstream_restriction_flag = 1,
92     .motion_vectors_over_pic_boundaries_flag = 1,
93     .max_bytes_per_pic_denom = 2,
94     .max_bits_per_mb_denom = 1,
95     .log2_max_mv_length_horizontal = 13,
96     .log2_max_mv_length_vertical = 11,
97     .num_reorder_frames = 3,
98     .max_dec_frame_buffering = 8,
99   },
100 };
101
102 static const GstH264PPS pps = {
103   .id = 2,
104   .entropy_coding_mode_flag = 1,
105   .pic_order_present_flag = 0,
106   .num_slice_groups_minus1 = 0,
107
108   .num_ref_idx_l0_active_minus1 = 4,
109   .num_ref_idx_l1_active_minus1 = 2,
110
111   .weighted_pred_flag = 0,
112   .weighted_bipred_idc = 0,
113   .pic_init_qp_minus26 = 2,
114   .pic_init_qs_minus26 = 0,
115   .chroma_qp_index_offset = 1,
116   .deblocking_filter_control_present_flag = 1,
117   .constrained_intra_pred_flag = 0,
118   .redundant_pic_cnt_present_flag = 0,
119   .transform_8x8_mode_flag = 0,
120
121   .pic_scaling_matrix_present_flag = 0,
122   .second_chroma_qp_index_offset = 0,
123
124   .sequence = (GstH264SPS *) &sps,
125 };
126
127 static const GstH264SliceHdr slice_hdr = {
128   .first_mb_in_slice = 0,
129   .type = 1,
130   .frame_num = 10,
131
132   .field_pic_flag = 0,
133   .bottom_field_flag = 0,
134   .idr_pic_id = 0,
135
136   .pic_order_cnt_lsb = 4,
137   .delta_pic_order_cnt_bottom = 0,
138
139   .direct_spatial_mv_pred_flag = 1,
140
141   .num_ref_idx_active_override_flag = 1,
142   .num_ref_idx_l0_active_minus1 = 2,
143   .num_ref_idx_l1_active_minus1 = 2,
144
145   .ref_pic_list_modification_flag_l0 = 0,
146   .ref_pic_list_modification_flag_l1 = 0,
147
148   .dec_ref_pic_marking.no_output_of_prior_pics_flag = 0,
149   .dec_ref_pic_marking.long_term_reference_flag = 0,
150   .dec_ref_pic_marking.adaptive_ref_pic_marking_mode_flag = 0,
151
152   .cabac_init_idc = 1,
153   .slice_qp_delta = 8,
154
155   .disable_deblocking_filter_idc = 0,
156   .slice_alpha_c0_offset_div2 = 2,
157   .slice_beta_offset_div2 = 2,
158
159   .pps = (GstH264PPS *) &pps,
160 };
161 /* *INDENT-ON* */
162
163 GST_START_TEST (test_h264_bitwriter_sps_pps_slice_hdr)
164 {
165   GstH264ParserResult res;
166   gboolean ret;
167   GstH264NalUnit nalu;
168   GstH264NalParser *const parser = gst_h264_nal_parser_new ();
169   GstH264SPS sps_parsed;
170   GstH264PPS pps_parsed;
171   GstH264SliceHdr slice_parsed;
172   guint8 header_data[128] = { 0, };
173   guint8 header_nal[128] = { 0, };
174   guint size, trail_bits;
175   guint nal_size;
176   guint i;
177
178   size = sizeof (header_data);
179   ret = gst_h264_bit_writer_sps (&sps, TRUE, header_data, &size);
180   fail_if (ret != GST_H264_BIT_WRITER_OK);
181
182   nal_size = sizeof (header_nal);
183   ret = gst_h264_bit_writer_convert_to_nal (4, FALSE, TRUE, FALSE,
184       header_data, size * 8, header_nal, &nal_size);
185   fail_if (ret != GST_H264_BIT_WRITER_OK);
186   fail_if (nal_size < size);
187
188   /* Parse it again */
189   res = gst_h264_parser_identify_nalu (parser, header_nal, 0,
190       sizeof (header_nal), &nalu);
191   assert_equals_int (res, GST_H264_PARSER_NO_NAL_END);
192
193   res = gst_h264_parser_parse_sps (parser, &nalu, &sps_parsed);
194   assert_equals_int (res, GST_H264_PARSER_OK);
195
196   /* We can not do simply memcmp, the parser may set some default
197      value for the fields which are not used for writing. */
198 #define CHECK_FIELD(FIELD)  fail_if(sps_parsed.FIELD != sps.FIELD)
199   CHECK_FIELD (id);
200   CHECK_FIELD (profile_idc);
201   CHECK_FIELD (constraint_set0_flag);
202   CHECK_FIELD (constraint_set1_flag);
203   CHECK_FIELD (constraint_set2_flag);
204   CHECK_FIELD (constraint_set3_flag);
205   CHECK_FIELD (constraint_set4_flag);
206   CHECK_FIELD (constraint_set5_flag);
207   CHECK_FIELD (level_idc);
208
209   CHECK_FIELD (chroma_format_idc);
210   CHECK_FIELD (bit_depth_luma_minus8);
211   CHECK_FIELD (bit_depth_chroma_minus8);
212
213   CHECK_FIELD (scaling_matrix_present_flag);
214   for (i = 0; i < 16; i++)
215     CHECK_FIELD (scaling_lists_4x4[0][i]);
216
217   CHECK_FIELD (log2_max_frame_num_minus4);
218   CHECK_FIELD (pic_order_cnt_type);
219   CHECK_FIELD (log2_max_pic_order_cnt_lsb_minus4);
220
221   CHECK_FIELD (num_ref_frames);
222   CHECK_FIELD (gaps_in_frame_num_value_allowed_flag);
223   CHECK_FIELD (pic_width_in_mbs_minus1);
224   CHECK_FIELD (pic_height_in_map_units_minus1);
225   CHECK_FIELD (frame_mbs_only_flag);
226   CHECK_FIELD (mb_adaptive_frame_field_flag);
227   CHECK_FIELD (direct_8x8_inference_flag);
228   CHECK_FIELD (frame_cropping_flag);
229   CHECK_FIELD (frame_crop_left_offset);
230   CHECK_FIELD (frame_crop_right_offset);
231   CHECK_FIELD (frame_crop_top_offset);
232   CHECK_FIELD (frame_crop_bottom_offset);
233
234   CHECK_FIELD (vui_parameters_present_flag);
235   CHECK_FIELD (vui_parameters.aspect_ratio_info_present_flag);
236   CHECK_FIELD (vui_parameters.aspect_ratio_idc);
237   CHECK_FIELD (vui_parameters.sar_width);
238   CHECK_FIELD (vui_parameters.sar_height);
239   CHECK_FIELD (vui_parameters.overscan_info_present_flag);
240   CHECK_FIELD (vui_parameters.overscan_appropriate_flag);
241   CHECK_FIELD (vui_parameters.chroma_loc_info_present_flag);
242   CHECK_FIELD (vui_parameters.timing_info_present_flag);
243   CHECK_FIELD (vui_parameters.num_units_in_tick);
244   CHECK_FIELD (vui_parameters.time_scale);
245   CHECK_FIELD (vui_parameters.fixed_frame_rate_flag);
246
247   CHECK_FIELD (vui_parameters.nal_hrd_parameters_present_flag);
248   CHECK_FIELD (vui_parameters.nal_hrd_parameters.cpb_cnt_minus1);
249   CHECK_FIELD (vui_parameters.nal_hrd_parameters.bit_rate_scale);
250   CHECK_FIELD (vui_parameters.nal_hrd_parameters.cpb_size_scale);
251   CHECK_FIELD (vui_parameters.nal_hrd_parameters.bit_rate_value_minus1[0]);
252   CHECK_FIELD (vui_parameters.nal_hrd_parameters.cpb_size_value_minus1[0]);
253   CHECK_FIELD (vui_parameters.nal_hrd_parameters.cbr_flag[0]);
254   CHECK_FIELD (vui_parameters.
255       nal_hrd_parameters.initial_cpb_removal_delay_length_minus1);
256   CHECK_FIELD (vui_parameters.
257       nal_hrd_parameters.cpb_removal_delay_length_minus1);
258   CHECK_FIELD (vui_parameters.
259       nal_hrd_parameters.dpb_output_delay_length_minus1);
260   CHECK_FIELD (vui_parameters.nal_hrd_parameters.time_offset_length);
261
262   CHECK_FIELD (vui_parameters.vcl_hrd_parameters_present_flag);
263   CHECK_FIELD (vui_parameters.low_delay_hrd_flag);
264   CHECK_FIELD (vui_parameters.pic_struct_present_flag);
265   CHECK_FIELD (vui_parameters.bitstream_restriction_flag);
266   CHECK_FIELD (vui_parameters.motion_vectors_over_pic_boundaries_flag);
267   CHECK_FIELD (vui_parameters.max_bytes_per_pic_denom);
268   CHECK_FIELD (vui_parameters.max_bits_per_mb_denom);
269   CHECK_FIELD (vui_parameters.log2_max_mv_length_horizontal);
270   CHECK_FIELD (vui_parameters.log2_max_mv_length_vertical);
271   CHECK_FIELD (vui_parameters.num_reorder_frames);
272   CHECK_FIELD (vui_parameters.max_dec_frame_buffering);
273 #undef CHECK_FIELD
274
275   memset (header_data, 0, sizeof (header_data));
276   memset (header_nal, 0, sizeof (header_nal));
277
278   size = sizeof (header_data);
279   ret = gst_h264_bit_writer_pps (&pps, TRUE, header_data, &size);
280   fail_if (ret != GST_H264_BIT_WRITER_OK);
281
282   nal_size = sizeof (header_nal);
283   ret = gst_h264_bit_writer_convert_to_nal (4, FALSE, TRUE, FALSE,
284       header_data, size * 8, header_nal, &nal_size);
285   fail_if (ret != GST_H264_BIT_WRITER_OK);
286   fail_if (nal_size < size);
287
288   /* Parse it again */
289   res = gst_h264_parser_identify_nalu (parser, header_nal, 0,
290       sizeof (header_nal), &nalu);
291   assert_equals_int (res, GST_H264_PARSER_NO_NAL_END);
292
293   res = gst_h264_parser_parse_pps (parser, &nalu, &pps_parsed);
294   assert_equals_int (res, GST_H264_PARSER_OK);
295
296 #define CHECK_FIELD(FIELD)  fail_if(pps_parsed.FIELD != pps.FIELD)
297   CHECK_FIELD (id);
298   CHECK_FIELD (entropy_coding_mode_flag);
299   CHECK_FIELD (pic_order_present_flag);
300   CHECK_FIELD (num_slice_groups_minus1);
301
302   CHECK_FIELD (num_ref_idx_l0_active_minus1);
303   CHECK_FIELD (num_ref_idx_l1_active_minus1);
304
305   CHECK_FIELD (weighted_pred_flag);
306   CHECK_FIELD (weighted_bipred_idc);
307   CHECK_FIELD (pic_init_qp_minus26);
308   CHECK_FIELD (pic_init_qs_minus26);
309   CHECK_FIELD (chroma_qp_index_offset);
310   CHECK_FIELD (deblocking_filter_control_present_flag);
311   CHECK_FIELD (constrained_intra_pred_flag);
312   CHECK_FIELD (redundant_pic_cnt_present_flag);
313   CHECK_FIELD (transform_8x8_mode_flag);
314
315   CHECK_FIELD (pic_scaling_matrix_present_flag);
316   CHECK_FIELD (second_chroma_qp_index_offset);
317 #undef CHECK_FIELD
318
319   memset (header_data, 0, sizeof (header_data));
320   memset (header_nal, 0, sizeof (header_nal));
321
322   size = sizeof (header_data);
323   trail_bits = 0;
324   ret = gst_h264_bit_writer_slice_hdr (&slice_hdr, TRUE, GST_H264_NAL_SLICE,
325       FALSE, header_data, &size, &trail_bits);
326   fail_if (ret != GST_H264_BIT_WRITER_OK);
327
328   nal_size = sizeof (header_nal);
329   ret = gst_h264_bit_writer_convert_to_nal (4, FALSE, TRUE, TRUE,
330       header_data, size * 8 + trail_bits, header_nal, &nal_size);
331   fail_if (ret != GST_H264_BIT_WRITER_OK);
332   fail_if (nal_size < size);
333
334   /* Parse it again */
335   res = gst_h264_parser_identify_nalu (parser, header_nal, 0,
336       sizeof (header_nal), &nalu);
337   assert_equals_int (res, GST_H264_PARSER_NO_NAL_END);
338
339   res = gst_h264_parser_parse_slice_hdr (parser, &nalu, &slice_parsed,
340       TRUE, TRUE);
341   assert_equals_int (res, GST_H264_PARSER_OK);
342
343 #define CHECK_FIELD(FIELD)  fail_if(slice_parsed.FIELD != slice_hdr.FIELD)
344   CHECK_FIELD (first_mb_in_slice);
345   CHECK_FIELD (type);
346   CHECK_FIELD (frame_num);
347   CHECK_FIELD (field_pic_flag);
348   CHECK_FIELD (bottom_field_flag);
349   CHECK_FIELD (idr_pic_id);
350   CHECK_FIELD (pic_order_cnt_lsb);
351   CHECK_FIELD (delta_pic_order_cnt_bottom);
352   CHECK_FIELD (direct_spatial_mv_pred_flag);
353   CHECK_FIELD (num_ref_idx_active_override_flag);
354   CHECK_FIELD (num_ref_idx_l0_active_minus1);
355   CHECK_FIELD (num_ref_idx_l1_active_minus1);
356   CHECK_FIELD (ref_pic_list_modification_flag_l0);
357   CHECK_FIELD (ref_pic_list_modification_flag_l1);
358   CHECK_FIELD (dec_ref_pic_marking.no_output_of_prior_pics_flag);
359   CHECK_FIELD (dec_ref_pic_marking.long_term_reference_flag);
360   CHECK_FIELD (dec_ref_pic_marking.adaptive_ref_pic_marking_mode_flag);
361   CHECK_FIELD (cabac_init_idc);
362   CHECK_FIELD (slice_qp_delta);
363   CHECK_FIELD (disable_deblocking_filter_idc);
364   CHECK_FIELD (slice_alpha_c0_offset_div2);
365   CHECK_FIELD (slice_beta_offset_div2);
366 #undef CHECK_FIELD
367
368   gst_h264_nal_parser_free (parser);
369 }
370
371 GST_END_TEST;
372
373 static const guint8 nalu_sps[] = {
374   0x00, 0x00, 0x00, 0x01, 0x27, 0x64, 0x00, 0x32, 0xac, 0x2c, 0xa2,
375   0x40, 0x78, 0x02, 0x27, 0xe5, 0xc0, 0x50, 0x80, 0x80, 0x80, 0xa0,
376   0x00, 0x00, 0x03, 0x00, 0x20, 0x00, 0x00, 0x07, 0x9d, 0x08, 0x00,
377   0x7a, 0x10, 0x00, 0x07, 0xa1, 0x23, 0x7b, 0xdf, 0x07, 0x68, 0x70,
378   0xc2, 0x89, 0x80,
379 };
380
381 GST_START_TEST (test_h264_bitwriter_sei)
382 {
383   GstH264ParserResult res;
384   GstH264NalUnit nalu;
385   GstH264SEIMessage sei_msg = { 0, };
386   gboolean ret;
387   GstH264SPS sps_parsed;
388   GstH264HRDParams *hrd_param = &sps_parsed.vui_parameters.nal_hrd_parameters;
389   GstH264NalParser *const parser = gst_h264_nal_parser_new ();
390   GstH264PicTiming *pic_timing = &sei_msg.payload.pic_timing;
391   GstH264BufferingPeriod *buf_per = &sei_msg.payload.buffering_period;
392   GstH264PicTiming *pic_timing_parsed;
393   GstH264BufferingPeriod *buf_per_parsed;
394   GArray *msg_array;
395   GArray *sei_parsed = NULL;
396   GstH264SEIMessage *sei_msg_parsed;
397   guint size;
398   guint size_nal;
399   guint8 sei_data[128] = { 0, };
400   guint8 sei_nal[128] = { 0, };
401
402   res = gst_h264_parser_identify_nalu (parser, nalu_sps, 0, sizeof (nalu_sps),
403       &nalu);
404   assert_equals_int (res, GST_H264_PARSER_NO_NAL_END);
405   assert_equals_int (nalu.type, GST_H264_NAL_SPS);
406   assert_equals_int (nalu.size, 43);
407   res = gst_h264_parser_parse_sps (parser, &nalu, &sps_parsed);
408   assert_equals_int (res, GST_H264_PARSER_OK);
409
410   msg_array = g_array_new (FALSE, FALSE, sizeof (GstH264SEIMessage));
411
412   sei_msg.payloadType = GST_H264_SEI_PIC_TIMING;
413   pic_timing->CpbDpbDelaysPresentFlag =
414       sps_parsed.vui_parameters.nal_hrd_parameters_present_flag;
415   pic_timing->cpb_removal_delay_length_minus1 =
416       hrd_param->cpb_removal_delay_length_minus1;
417   pic_timing->dpb_output_delay_length_minus1 =
418       hrd_param->dpb_output_delay_length_minus1;
419   pic_timing->cpb_removal_delay = 1020;
420   pic_timing->dpb_output_delay = 80;
421   pic_timing->pic_struct_present_flag = 1;
422   pic_timing->pic_struct = 2;
423
424   pic_timing->clock_timestamp_flag[0] = 1;
425   pic_timing->clock_timestamp_flag[1] = 0;
426   pic_timing->clock_timestamp_flag[2] = 0;
427
428   pic_timing->clock_timestamp[0].ct_type = GST_H264_CT_TYPE_INTERLACED;
429   pic_timing->clock_timestamp[0].nuit_field_based_flag = 1;
430   pic_timing->clock_timestamp[0].counting_type = 0;
431   pic_timing->clock_timestamp[0].discontinuity_flag = 0;
432   pic_timing->clock_timestamp[0].cnt_dropped_flag = 0;
433   pic_timing->clock_timestamp[0].n_frames = 1;
434   pic_timing->clock_timestamp[0].seconds_flag = 1;
435   pic_timing->clock_timestamp[0].seconds_value = 32;
436   pic_timing->clock_timestamp[0].minutes_flag = 1;
437   pic_timing->clock_timestamp[0].minutes_value = 52;
438   pic_timing->clock_timestamp[0].hours_flag = 1;
439   pic_timing->clock_timestamp[0].hours_value = 8;
440   pic_timing->clock_timestamp[0].full_timestamp_flag = 1;
441   pic_timing->clock_timestamp[0].time_offset = 80;
442
443   pic_timing->time_offset_length = 24;
444
445   g_array_append_val (msg_array, sei_msg);
446
447   memset (&sei_msg, 0, sizeof (sei_msg));
448
449   sei_msg.payloadType = GST_H264_SEI_BUF_PERIOD;
450
451   buf_per->sps = &sps_parsed;
452   buf_per->nal_initial_cpb_removal_delay[0] = 90021;
453   buf_per->nal_initial_cpb_removal_delay_offset[0] = 90021;
454
455   g_array_append_val (msg_array, sei_msg);
456
457   size = sizeof (sei_data);
458   ret = gst_h264_bit_writer_sei (msg_array, TRUE, sei_data, &size);
459   fail_if (ret != GST_H264_BIT_WRITER_OK);
460
461   size_nal = sizeof (sei_nal);
462   ret = gst_h264_bit_writer_convert_to_nal (4, FALSE, TRUE, FALSE,
463       sei_data, size * 8, sei_nal, &size_nal);
464   fail_if (ret != GST_H264_BIT_WRITER_OK);
465
466   /* Parse it again. */
467   res = gst_h264_parser_identify_nalu (parser, sei_nal, 0,
468       sizeof (sei_nal), &nalu);
469   assert_equals_int (res, GST_H264_PARSER_NO_NAL_END);
470
471   res = gst_h264_parser_parse_sei (parser, &nalu, &sei_parsed);
472   assert_equals_int (res, GST_H264_PARSER_OK);
473   assert_equals_int (sei_parsed->len, 2);
474
475   sei_msg_parsed = &g_array_index (sei_parsed, GstH264SEIMessage, 0);
476   assert_equals_int (sei_msg_parsed->payloadType, GST_H264_SEI_PIC_TIMING);
477   pic_timing_parsed = &sei_msg_parsed->payload.pic_timing;
478   pic_timing =
479       &((g_array_index (msg_array, GstH264SEIMessage, 0)).payload.pic_timing);
480
481 #define CHECK_FIELD(FIELD)  fail_if(pic_timing_parsed->FIELD != pic_timing->FIELD)
482   CHECK_FIELD (CpbDpbDelaysPresentFlag);
483   CHECK_FIELD (cpb_removal_delay_length_minus1);
484   CHECK_FIELD (dpb_output_delay_length_minus1);
485   CHECK_FIELD (cpb_removal_delay);
486   CHECK_FIELD (dpb_output_delay);
487   CHECK_FIELD (pic_struct_present_flag);
488   CHECK_FIELD (pic_struct);
489   CHECK_FIELD (clock_timestamp_flag[0]);
490   CHECK_FIELD (clock_timestamp_flag[1]);
491   CHECK_FIELD (clock_timestamp_flag[2]);
492   CHECK_FIELD (clock_timestamp[0].ct_type);
493   CHECK_FIELD (clock_timestamp[0].nuit_field_based_flag);
494   CHECK_FIELD (clock_timestamp[0].counting_type);
495   CHECK_FIELD (clock_timestamp[0].discontinuity_flag);
496   CHECK_FIELD (clock_timestamp[0].cnt_dropped_flag);
497   CHECK_FIELD (clock_timestamp[0].n_frames);
498   CHECK_FIELD (clock_timestamp[0].seconds_flag);
499   CHECK_FIELD (clock_timestamp[0].seconds_value);
500   CHECK_FIELD (clock_timestamp[0].minutes_flag);
501   CHECK_FIELD (clock_timestamp[0].minutes_value);
502   CHECK_FIELD (clock_timestamp[0].hours_flag);
503   CHECK_FIELD (clock_timestamp[0].hours_value);
504   CHECK_FIELD (clock_timestamp[0].full_timestamp_flag);
505   CHECK_FIELD (clock_timestamp[0].time_offset);
506 #undef CHECK_FIELD
507
508   sei_msg_parsed = &g_array_index (sei_parsed, GstH264SEIMessage, 1);
509   assert_equals_int (sei_msg_parsed->payloadType, GST_H264_SEI_BUF_PERIOD);
510   buf_per_parsed = &sei_msg_parsed->payload.buffering_period;
511   buf_per = &((g_array_index (msg_array, GstH264SEIMessage,
512               1)).payload.buffering_period);
513
514   fail_if (buf_per_parsed->nal_initial_cpb_removal_delay[0] !=
515       buf_per->nal_initial_cpb_removal_delay[0]);
516   fail_if (buf_per_parsed->nal_initial_cpb_removal_delay_offset[0] !=
517       buf_per->nal_initial_cpb_removal_delay_offset[0]);
518
519   g_array_unref (sei_parsed);
520   g_array_unref (msg_array);
521   gst_h264_nal_parser_free (parser);
522 }
523
524 GST_END_TEST;
525
526 static Suite *
527 h264bitwriter_suite (void)
528 {
529   Suite *s = suite_create ("H264 bitwriter library");
530
531   TCase *tc_chain = tcase_create ("general");
532
533   suite_add_tcase (s, tc_chain);
534   tcase_add_test (tc_chain, test_h264_bitwriter_sps_pps_slice_hdr);
535   tcase_add_test (tc_chain, test_h264_bitwriter_sei);
536
537   return s;
538 }
539
540 GST_CHECK_MAIN (h264bitwriter);