tests: h264parse: fix failures due to insertion of au delimiter

Since insertion of aud landed, we need to change some testcases
accroding to the change.

Note that counting frames are changed in parser.c,
due to generated frames, AUD.

https://bugzilla.gnome.org/show_bug.cgi?id=736213
This commit is contained in:
Hyunjun Ko 2017-03-08 17:11:17 +09:00 committed by Sebastian Dröge
parent a997a99fdd
commit 08219f3665
3 changed files with 69 additions and 13 deletions

View file

@ -65,6 +65,12 @@ GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
/* some data */
/* AUD */
static guint8 h264_aud[] = {
0x00, 0x00, 0x00, 0x01, 0x09, 0xf0
};
/* SPS */
static guint8 h264_sps[] = {
0x00, 0x00, 0x00, 0x01, 0x67, 0x4d, 0x40, 0x15,
@ -129,14 +135,25 @@ verify_buffer (buffer_verify_data_s * vdata, GstBuffer * buffer)
/* check separate header NALs */
gint i = vdata->buffer_counter;
guint ofs;
gboolean aud;
/* SEI with start code prefix with 2 0-bytes */
ofs = i == 1;
ofs = i == 2;
aud = i == 0;
fail_unless (i <= 3);
if (aud) {
fail_unless (gst_buffer_get_size (buffer) == sizeof (h264_aud));
fail_unless (gst_buffer_memcmp (buffer, 0, h264_aud,
gst_buffer_get_size (buffer)) == 0);
vdata->discard++;
} else {
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;
@ -152,6 +169,16 @@ verify_buffer (buffer_verify_data_s * vdata, GstBuffer * buffer)
gst_buffer_unmap (buffer, &map);
return TRUE;
} else if (GST_READ_UINT32_BE (map.data) == 0x01) {
gboolean aud = FALSE;
aud = vdata->buffer_counter % 2;
if (aud) {
fail_unless (gst_buffer_get_size (buffer) == sizeof (h264_aud));
fail_unless (gst_buffer_memcmp (buffer, 0, h264_aud,
gst_buffer_get_size (buffer)) == 0);
gst_buffer_unmap (buffer, &map);
return TRUE;
}
/* this is not avc, use default tests from parser.c */
gst_buffer_unmap (buffer, &map);
return FALSE;
@ -204,9 +231,12 @@ verify_buffer_bs_au (buffer_verify_data_s * vdata, GstBuffer * buffer)
if (vdata->buffer_counter == 0) {
guint8 *data = map.data;
/* SPS, SEI, PPS */
/* AUD, SPS, SEI, PPS */
fail_unless (map.size == vdata->data_to_verify_size +
ctx_headers[0].size + ctx_headers[1].size + ctx_headers[2].size);
sizeof (h264_aud) + ctx_headers[0].size +
ctx_headers[1].size + ctx_headers[2].size);
fail_unless (memcmp (data, h264_aud, sizeof (h264_aud)) == 0);
data += sizeof (h264_aud);
fail_unless (memcmp (data, ctx_headers[0].data, ctx_headers[0].size) == 0);
data += ctx_headers[0].size;
fail_unless (memcmp (data, ctx_headers[1].data, ctx_headers[1].size) == 0);
@ -219,8 +249,11 @@ verify_buffer_bs_au (buffer_verify_data_s * vdata, GstBuffer * buffer)
vdata->data_to_verify_size) == 0);
} else {
/* IDR frame */
fail_unless (map.size == vdata->data_to_verify_size);
fail_unless (memcmp (map.data, vdata->data_to_verify, map.size) == 0);
guint aud_size = sizeof (h264_aud);
fail_unless (map.size == vdata->data_to_verify_size + aud_size);
fail_unless (memcmp (map.data, h264_aud, aud_size) == 0);
fail_unless (memcmp (map.data + aud_size, vdata->data_to_verify,
map.size - aud_size) == 0);
}
gst_buffer_unmap (buffer, &map);
@ -344,6 +377,10 @@ verify_buffer_packetized (buffer_verify_data_s * vdata, GstBuffer * buffer)
gint size;
if (vdata->buffer_counter == 0) {
data = h264_aud;
size = sizeof (h264_aud);
vdata->discard++;
} else if (vdata->buffer_counter == 1) {
data = h264_sps;
size = sizeof (h264_sps);
} else {
@ -354,9 +391,19 @@ verify_buffer_packetized (buffer_verify_data_s * vdata, GstBuffer * buffer)
fail_unless (map.size == size);
fail_unless (memcmp (map.data + 4, data + 4, size - 4) == 0);
} else {
fail_unless (map.size == vdata->data_to_verify_size);
fail_unless (memcmp (map.data + 4,
vdata->data_to_verify + 4, map.size - 4) == 0);
guint8 *data;
gint size;
gboolean aud = vdata->buffer_counter % 2;
if (aud) {
data = h264_aud;
size = sizeof (h264_aud);
} else {
data = (gpointer) vdata->data_to_verify;
size = map.size;
}
fail_unless (map.size == size);
fail_unless (memcmp (map.data + 4, data + 4, size - 4) == 0);
}
gst_buffer_unmap (buffer, &map);
@ -443,6 +490,7 @@ main (int argc, char **argv)
ctx_headers[2].data = h264_pps;
ctx_headers[2].size = sizeof (h264_pps);
ctx_verify_buffer = verify_buffer;
ctx_frame_generated = TRUE;
/* discard initial sps/pps buffers */
ctx_discard = 3;
/* no timing info to parse */
@ -461,6 +509,7 @@ main (int argc, char **argv)
ctx_sink_template = &sinktemplate_bs_au;
ctx_verify_buffer = verify_buffer_bs_au;
ctx_discard = 0;
ctx_frame_generated = FALSE;
s = h264parse_suite ();
nf += gst_check_run_suite (s, ctx_suite, __FILE__ "_to_bs_au.c");
@ -497,6 +546,7 @@ main (int argc, char **argv)
ctx_sink_template = &sinktemplate_bs_nal;
/* and ignore inserted codec-data NALs */
ctx_discard = 2;
ctx_frame_generated = TRUE;
/* no more config headers */
ctx_headers[0].data = NULL;
ctx_headers[1].data = NULL;

View file

@ -38,6 +38,7 @@ datablob ctx_headers[MAX_HEADERS] = { {NULL, 0}, };
VerifyBuffer ctx_verify_buffer = NULL;
ElementSetup ctx_setup = NULL;
gboolean ctx_frame_generated = FALSE;
gboolean ctx_no_metadata = FALSE;
@ -235,6 +236,7 @@ gst_parser_test_run (GstParserTest * test, GstCaps ** out_caps)
GstCaps *src_caps;
guint i, j, k;
guint frames = 0, size = 0;
guint added_frame = 0;
element = setup_element (test->factory, test->factory_setup,
test->sink_template, NULL, test->src_template, test->src_caps);
@ -245,6 +247,9 @@ gst_parser_test_run (GstParserTest * test, GstCaps ** out_caps)
fail_unless_equals_int (gst_pad_push (srcpad, buffer), GST_FLOW_OK);
}
if (ctx_frame_generated)
added_frame = test->series[0].fpb;
for (j = 0; j < 3; j++) {
for (i = 0; i < test->series[j].num; i++) {
/* sanity enforcing */
@ -262,7 +267,7 @@ gst_parser_test_run (GstParserTest * test, GstCaps ** out_caps)
else if (j == 1)
vdata.offset_skip_amount += test->series[j].size * test->series[j].fpb;
if (j != 1) {
frames += test->series[j].fpb;
frames += test->series[j].fpb + added_frame;
size += test->series[j].size * test->series[j].fpb;
}
}

View file

@ -64,6 +64,7 @@ extern gboolean ctx_no_metadata;
extern VerifyBuffer ctx_verify_buffer;
extern ElementSetup ctx_setup;
extern gboolean ctx_frame_generated;
/* no refs taken/kept, all up to caller */
typedef struct