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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3234>
This commit is contained in:
Nicolas Dufresne 2023-03-15 15:55:02 -04:00 committed by GStreamer Marge Bot
parent 0780e31581
commit 9deb3d6aa4

View file

@ -1417,9 +1417,8 @@ gst_h264_parse_handle_frame (GstBaseParse * parse,
} }
break; break;
case GST_H264_PARSER_NO_NAL: case GST_H264_PARSER_NO_NAL:
/* Start code may have up to 4 bytes */ /* we don't have enough bytes to make any decisions yet */
*skipsize = size - 4; goto more;
goto skip;
break; break;
default: default:
/* should not really occur either */ /* 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) ", GST_DEBUG_OBJECT (h264parse, "complete nal (offset, size): (%u, %u) ",
nalu.offset, nalu.size); nalu.offset, nalu.size);
break; 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: case GST_H264_PARSER_NO_NAL_END:
/* In NAL alignment, assume the NAL is complete */ /* In NAL alignment, assume the NAL is complete */
if (h264parse->in_align == GST_H264_PARSE_ALIGN_NAL || 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, GST_ELEMENT_ERROR (h264parse, STREAM, FORMAT,
("Error parsing H.264 stream"), ("Invalid H.264 stream")); ("Error parsing H.264 stream"), ("Invalid H.264 stream"));
goto invalid_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: case GST_H264_PARSER_BROKEN_DATA:
GST_WARNING_OBJECT (h264parse, "input stream is corrupt; " GST_WARNING_OBJECT (h264parse, "input stream is corrupt; "
"it contains a NAL unit of length %u", nalu.size); "it contains a NAL unit of length %u", nalu.size);