From be7a9e29df36875bf7b755f07e22b236fb0fa511 Mon Sep 17 00:00:00 2001 From: He Junyan Date: Sat, 23 Jan 2021 19:26:59 +0800 Subject: [PATCH] test: Add more test cases for the av1parse obu aligned output. Part-of: --- tests/check/elements/av1parse.c | 113 ++++++++++++++++++++++++++++++++++++++++ tests/check/elements/av1parse.h | 5 ++ 2 files changed, 118 insertions(+) diff --git a/tests/check/elements/av1parse.c b/tests/check/elements/av1parse.c index 511d9d5..e36149a 100644 --- a/tests/check/elements/av1parse.c +++ b/tests/check/elements/av1parse.c @@ -244,6 +244,117 @@ GST_START_TEST (test_annexb_to_frame) GST_END_TEST; +GST_START_TEST (test_annexb_to_obu) +{ + GstHarness *h; + GstBuffer *in_buf, *out_buf = NULL; + GstMapInfo map; + GstFlowReturn ret; + gint i = 0; + guint offset; + guint output_buf_num; + + h = gst_harness_new_parse ("av1parse"); + fail_unless (h != NULL); + + gst_harness_set_sink_caps_str (h, "video/x-av1,parsed=(boolean)true," + "alignment=(string)obu"); + gst_harness_set_src_caps_str (h, "video/x-av1,alignment=(string)tu," + "stream-format=(string)annexb"); + + gst_harness_play (h); + + output_buf_num = 0; + offset = 0; + for (i = 0; i < G_N_ELEMENTS (stream_annexb_av1_tu_len); i++) { + in_buf = gst_buffer_new_and_alloc (stream_annexb_av1_tu_len[i]); + gst_buffer_map (in_buf, &map, GST_MAP_WRITE); + memcpy (map.data, stream_annexb_av1 + offset, stream_annexb_av1_tu_len[i]); + gst_buffer_unmap (in_buf, &map); + offset += stream_annexb_av1_tu_len[i]; + + ret = gst_harness_push (h, in_buf); + fail_unless (ret == GST_FLOW_OK, "GstFlowReturn was %s", + gst_flow_get_name (ret)); + + gst_clear_buffer (&out_buf); + while ((out_buf = gst_harness_try_pull (h)) != NULL) { + if (output_buf_num == 0) + check_caps_event (h); + + fail_unless (gst_buffer_get_size (out_buf) == + stream_av1_obu_size[output_buf_num]); + + gst_clear_buffer (&out_buf); + output_buf_num++; + } + } + + fail_unless (output_buf_num == G_N_ELEMENTS (stream_av1_obu_size)); + + gst_harness_teardown (h); +} + +GST_END_TEST; + +GST_START_TEST (test_byte_to_obu) +{ + GstHarness *h; + GstBuffer *in_buf, *out_buf = NULL; + GstMapInfo map; + GstFlowReturn ret; + gint i = 0; + guint offset; + guint len; + guint output_buf_num; + + h = gst_harness_new_parse ("av1parse"); + fail_unless (h != NULL); + + gst_harness_set_sink_caps_str (h, "video/x-av1,parsed=(boolean)true," + "alignment=(string)obu,stream-format=(string)obu-stream"); + gst_harness_set_src_caps_str (h, "video/x-av1"); + + gst_harness_play (h); + + output_buf_num = 0; + offset = 0; + len = stream_no_annexb_av1_len / 5; + for (i = 0; i < 5; i++) { + if (i == 4) + len = stream_no_annexb_av1_len - offset; + + in_buf = gst_buffer_new_and_alloc (len); + gst_buffer_map (in_buf, &map, GST_MAP_WRITE); + memcpy (map.data, stream_no_annexb_av1 + offset, len); + gst_buffer_unmap (in_buf, &map); + offset += len; + + ret = gst_harness_push (h, in_buf); + fail_unless (ret == GST_FLOW_OK, "GstFlowReturn was %s", + gst_flow_get_name (ret)); + + gst_clear_buffer (&out_buf); + while ((out_buf = gst_harness_try_pull (h)) != NULL) { + if (output_buf_num == 0) + check_caps_event (h); + + fail_unless (gst_buffer_get_size (out_buf) == + stream_av1_obu_size[output_buf_num]); + + gst_clear_buffer (&out_buf); + output_buf_num++; + } + } + + fail_unless (output_buf_num == G_N_ELEMENTS (stream_av1_obu_size)); + + gst_harness_teardown (h); + +} + +GST_END_TEST; + static Suite * av1parse_suite (void) { @@ -258,6 +369,8 @@ av1parse_suite (void) tcase_add_test (tc_chain, test_byte_to_frame); tcase_add_test (tc_chain, test_byte_to_annexb); tcase_add_test (tc_chain, test_annexb_to_frame); + tcase_add_test (tc_chain, test_annexb_to_obu); + tcase_add_test (tc_chain, test_byte_to_obu); return s; } diff --git a/tests/check/elements/av1parse.h b/tests/check/elements/av1parse.h index 6f36b52..90230c6 100644 --- a/tests/check/elements/av1parse.h +++ b/tests/check/elements/av1parse.h @@ -1792,3 +1792,8 @@ static guint32 stream_no_annexb_av1_len = 10519; static gsize stream_av1_frame_size[] = { 5454, 1331, 29, 24, 1473, 543, 5, 555, 5, 897, 82, 5, 91, 25 }; + +static gsize stream_av1_obu_size[] = { + 2, 13, 5439, 2, 13, 1316, 2, 27, 24, 1473, 543, 2, + 3, 2, 553, 2, 3, 2, 895, 82, 2, 3, 2, 89, 2, 23 +}; -- 2.7.4