summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNicolas Dufresne <nicolas.dufresne@collabora.com>2020-05-07 14:05:16 -0400
committerNicolas Dufresne <nicolas.dufresne@collabora.com>2020-05-07 14:17:28 -0400
commitfac627ba1b53371c90e7969e3de3e33d791c4780 (patch)
tree8daf50199d8300df9f401af336f9554d0d867a13 /tests
parent90ca8850dee926e99773a61ce19ad6678119c54f (diff)
downloadgstreamer-plugins-bad-fac627ba1b53371c90e7969e3de3e33d791c4780.tar.gz
test: h265parse: Test parsing buffer the ends with half a NAL header
This test cover the case where we are parsing, but our current buffers ends with half the NAL header (which is 2 bytes in HEVC). Previously we would throw an error message on the bus. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1251>
Diffstat (limited to 'tests')
-rw-r--r--tests/check/elements/h265parse.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/check/elements/h265parse.c b/tests/check/elements/h265parse.c
index f32c7327d..6609544cf 100644
--- a/tests/check/elements/h265parse.c
+++ b/tests/check/elements/h265parse.c
@@ -996,6 +996,40 @@ GST_START_TEST (test_parse_skip_to_4bytes_sc)
GST_END_TEST;
+GST_START_TEST (test_parse_sc_with_half_header)
+{
+ GstHarness *h;
+ GstBuffer *buf1, *buf2;
+ GstMapInfo map;
+
+ h = gst_harness_new ("h265parse");
+
+ gst_harness_set_caps_str (h, "video/x-h265, stream-format=byte-stream",
+ "video/x-h265, stream-format=byte-stream, alignment=nal");
+
+ buf1 = composite_buffer (100, 0, 4, h265_vps, sizeof (h265_vps),
+ h265_sps, sizeof (h265_sps), h265_pps, sizeof (h265_pps), h265_idr, 5);
+ buf2 = wrap_buffer (h265_idr + 5, sizeof (h265_idr) - 5, 100, 0);
+
+ fail_unless_equals_int (gst_harness_push (h, buf1), GST_FLOW_OK);
+ fail_unless_equals_int (gst_harness_buffers_in_queue (h), 0);
+
+ fail_unless_equals_int (gst_harness_push (h, buf2), GST_FLOW_OK);
+ /* The parser will deliver VPS, SPS, PPS as it now have complete cpas */
+ fail_unless_equals_int (gst_harness_buffers_in_queue (h), 3);
+
+ buf1 = gst_harness_pull (h);
+ gst_buffer_map (buf1, &map, GST_MAP_READ);
+ fail_unless_equals_int (gst_buffer_get_size (buf1), sizeof (h265_vps));
+ gst_buffer_unmap (buf1, &map);
+ gst_buffer_unref (buf1);
+
+ gst_harness_teardown (h);
+}
+
+GST_END_TEST;
+
+
/* nal->au has latency, but EOS should force the last AU out */
GST_START_TEST (test_drain)
@@ -1049,6 +1083,7 @@ h265parse_harnessed_suite (void)
tcase_add_test (tc_chain, test_sliced_au_au);
tcase_add_test (tc_chain, test_parse_skip_to_4bytes_sc);
+ tcase_add_test (tc_chain, test_parse_sc_with_half_header);
tcase_add_test (tc_chain, test_drain);