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>
This commit is contained in:
Nicolas Dufresne 2020-05-07 14:05:16 -04:00
parent 90ca8850de
commit fac627ba1b

View file

@ -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);