tests: h264parse: check SEI buffering_period() message is output.
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>
Wed, 25 Jun 2014 16:47:55 +0000 (18:47 +0200)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Tue, 1 Jul 2014 14:26:48 +0000 (16:26 +0200)
If an SEI NAL unit with a buffering_period() message is inserted
between an SPS and PPS NAL unit, check that the output buffer still
contain it. i.e. make sure that this SEI message is not dropped.

https://bugzilla.gnome.org/show_bug.cgi?id=732156

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
tests/check/elements/h264parse.c

index 895f74c..16ae5e8 100644 (file)
@@ -71,6 +71,11 @@ static guint8 h264_pps[] = {
   0x00, 0x00, 0x00, 0x01, 0x68, 0xeb, 0xec, 0xb2
 };
 
+/* SEI buffering_period() message */
+static guint8 h264_sei_buffering_period[] = {
+  0x00, 0x00, 0x00, 0x01, 0x06, 0x00, 0x01, 0xc0
+};
+
 /* combines to this codec-data */
 static guint8 h264_avc_codec_data[] = {
   0x01, 0x4d, 0x40, 0x15, 0xff, 0xe1, 0x00, 0x17,
@@ -116,10 +121,14 @@ verify_buffer (buffer_verify_data_s * vdata, GstBuffer * buffer)
   if (vdata->discard) {
     /* check separate header NALs */
     gint i = vdata->buffer_counter;
+    guint ofs;
 
-    fail_unless (i <= 1);
-    fail_unless (gst_buffer_get_size (buffer) == ctx_headers[i].size);
-    fail_unless (gst_buffer_memcmp (buffer, 0, ctx_headers[i].data,
+    /* SEI with start code prefix with 2 0-bytes */
+    ofs = i == 1;
+
+    fail_unless (i <= 2);
+    fail_unless (gst_buffer_get_size (buffer) == ctx_headers[i].size - ofs);
+    fail_unless (gst_buffer_memcmp (buffer, 0, ctx_headers[i].data + ofs,
             gst_buffer_get_size (buffer)) == 0);
   } else {
     GstMapInfo map;
@@ -145,7 +154,7 @@ verify_buffer (buffer_verify_data_s * vdata, GstBuffer * buffer)
       guint8 *data = map.data;
 
       fail_unless (map.size == vdata->data_to_verify_size +
-          ctx_headers[0].size + ctx_headers[1].size);
+          ctx_headers[0].size + ctx_headers[1].size + ctx_headers[2].size);
       fail_unless (GST_READ_UINT32_BE (data) == ctx_headers[0].size - 4);
       fail_unless (memcmp (data + 4, ctx_headers[0].data + 4,
               ctx_headers[0].size - 4) == 0);
@@ -154,6 +163,10 @@ verify_buffer (buffer_verify_data_s * vdata, GstBuffer * buffer)
       fail_unless (memcmp (data + 4, ctx_headers[1].data + 4,
               ctx_headers[1].size - 4) == 0);
       data += ctx_headers[1].size;
+      fail_unless (GST_READ_UINT32_BE (data) == ctx_headers[2].size - 4);
+      fail_unless (memcmp (data + 4, ctx_headers[2].data + 4,
+              ctx_headers[2].size - 4) == 0);
+      data += ctx_headers[2].size;
       fail_unless (GST_READ_UINT32_BE (data) == vdata->data_to_verify_size - 4);
       fail_unless (memcmp (data + 4, vdata->data_to_verify + 4,
               vdata->data_to_verify_size - 4) == 0);
@@ -380,11 +393,13 @@ main (int argc, char **argv)
   ctx_src_template = &srctemplate;
   ctx_headers[0].data = h264_sps;
   ctx_headers[0].size = sizeof (h264_sps);
-  ctx_headers[1].data = h264_pps;
-  ctx_headers[1].size = sizeof (h264_pps);
+  ctx_headers[1].data = h264_sei_buffering_period;
+  ctx_headers[1].size = sizeof (h264_sei_buffering_period);
+  ctx_headers[2].data = h264_pps;
+  ctx_headers[2].size = sizeof (h264_pps);
   ctx_verify_buffer = verify_buffer;
   /* discard initial sps/pps buffers */
-  ctx_discard = 2;
+  ctx_discard = 3;
   /* no timing info to parse */
   ctx_no_metadata = TRUE;
   ctx_codec_data = FALSE;
@@ -436,8 +451,10 @@ main (int argc, char **argv)
   /* no more config headers */
   ctx_headers[0].data = NULL;
   ctx_headers[1].data = NULL;
+  ctx_headers[2].data = NULL;
   ctx_headers[0].size = 0;
   ctx_headers[1].size = 0;
+  ctx_headers[2].size = 0;
   /* and need adapter buffer check */
   ctx_verify_buffer = verify_buffer_packetized;