From 0780e31581a72f5913c68155edb4cf1dff8dfc24 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Thu, 20 Oct 2022 15:07:15 -0400 Subject: [PATCH] test: h265parser: Test for NAL missing header bytes H.265 NAL always have 2 bytes of headers. Unlike the H.264 parser, this parser will simply return that there is NO_NAL if some of these bytes are missing. This is then properly special cased by parsers and decoders. Add a test to ensure we don't break this in the future. Part-of: --- .../tests/check/libs/h265parser.c | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/subprojects/gst-plugins-bad/tests/check/libs/h265parser.c b/subprojects/gst-plugins-bad/tests/check/libs/h265parser.c index f7dd95e452..a565ba738d 100644 --- a/subprojects/gst-plugins-bad/tests/check/libs/h265parser.c +++ b/subprojects/gst-plugins-bad/tests/check/libs/h265parser.c @@ -1450,6 +1450,26 @@ GST_START_TEST (test_h265_decoder_config_record) GST_END_TEST; +GST_START_TEST (test_h265_parse_partial_nal) +{ + GstH265ParserResult res; + GstH265NalUnit nalu; + GstH265Parser *parser = gst_h265_parser_new (); + const guint8 *buf = slice_eos_slice_eob; + const guint buf_size = 5; + + res = gst_h265_parser_identify_nalu (parser, buf, 0, buf_size, &nalu); + + /* H.265 parser is a bit different then H.264 one, and will return + * NO_NAL if there is a start code but not enough bytes to hold the + * header. */ + assert_equals_int (res, GST_H265_PARSER_NO_NAL); + + gst_h265_parser_free (parser); +} + +GST_END_TEST; + static Suite * h265parser_suite (void) { @@ -1474,6 +1494,7 @@ h265parser_suite (void) tcase_add_test (tc_chain, test_h265_create_sei); tcase_add_test (tc_chain, test_h265_split_hevc); tcase_add_test (tc_chain, test_h265_decoder_config_record); + tcase_add_test (tc_chain, test_h265_parse_partial_nal); return s; }