From 9deb3d6aa4b2052f620d0929d69f65f518944123 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Wed, 15 Mar 2023 15:55:02 -0400 Subject: [PATCH] h264parse: Stop considering NO_NAL as an error The NO_NAL return value simply means that the buffer did not contain enough data to identity a NAL. This should lead to waiting for more data not considering the stream as invalid. Part-of: --- .../gst/videoparsers/gsth264parse.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/subprojects/gst-plugins-bad/gst/videoparsers/gsth264parse.c b/subprojects/gst-plugins-bad/gst/videoparsers/gsth264parse.c index 0f27f48f02..bdb2c5ccdd 100644 --- a/subprojects/gst-plugins-bad/gst/videoparsers/gsth264parse.c +++ b/subprojects/gst-plugins-bad/gst/videoparsers/gsth264parse.c @@ -1417,9 +1417,8 @@ gst_h264_parse_handle_frame (GstBaseParse * parse, } break; case GST_H264_PARSER_NO_NAL: - /* Start code may have up to 4 bytes */ - *skipsize = size - 4; - goto skip; + /* we don't have enough bytes to make any decisions yet */ + goto more; break; default: /* should not really occur either */ @@ -1443,6 +1442,13 @@ gst_h264_parse_handle_frame (GstBaseParse * parse, GST_DEBUG_OBJECT (h264parse, "complete nal (offset, size): (%u, %u) ", nalu.offset, nalu.size); break; + case GST_H264_PARSER_NO_NAL: + /* In NAL alignment, assume the NAL is broken */ + if (h264parse->in_align == GST_H264_PARSE_ALIGN_NAL || + h264parse->in_align == GST_H264_PARSE_ALIGN_AU) { + goto broken; + } + goto more; case GST_H264_PARSER_NO_NAL_END: /* In NAL alignment, assume the NAL is complete */ if (h264parse->in_align == GST_H264_PARSE_ALIGN_NAL || @@ -1476,10 +1482,6 @@ gst_h264_parse_handle_frame (GstBaseParse * parse, GST_ELEMENT_ERROR (h264parse, STREAM, FORMAT, ("Error parsing H.264 stream"), ("Invalid H.264 stream")); goto invalid_stream; - case GST_H264_PARSER_NO_NAL: - GST_ELEMENT_ERROR (h264parse, STREAM, FORMAT, - ("Error parsing H.264 stream"), ("No H.264 NAL unit found")); - goto invalid_stream; case GST_H264_PARSER_BROKEN_DATA: GST_WARNING_OBJECT (h264parse, "input stream is corrupt; " "it contains a NAL unit of length %u", nalu.size);