h264parser lib: Always consume all SEI bits

If parsing an SEI errors out, it might not consume
all bits, leaving extra unparsed data in the reader
that the outer loop then tries to parse as a new
appended SEI.

Skip all the bits if any are left over to avoid
'finding' extra garbage SEI in the parsing.
This commit is contained in:
Jan Schmidt 2019-06-28 14:42:19 +10:00
parent a978bd2cab
commit 75ce024b1e

View file

@ -1177,10 +1177,10 @@ gst_h264_parser_parse_sei_message (GstH264NalParser * nalparser,
{
guint32 payloadSize;
guint8 payload_type_byte, payload_size_byte;
guint remaining, payload_size;
guint remaining, payload_size, next;
GstH264ParserResult res;
GST_DEBUG ("parsing \"Sei message\"");
GST_DEBUG ("parsing \"SEI message\"");
memset (sei, 0, sizeof (*sei));
@ -1198,6 +1198,7 @@ gst_h264_parser_parse_sei_message (GstH264NalParser * nalparser,
remaining = nal_reader_get_remaining (nr);
payload_size = payloadSize * 8 < remaining ? payloadSize * 8 : remaining;
next = nal_reader_get_pos (nr) + payload_size;
GST_DEBUG ("SEI message received: payloadType %u, payloadSize = %u bits",
sei->payloadType, payload_size);
@ -1255,6 +1256,15 @@ gst_h264_parser_parse_sei_message (GstH264NalParser * nalparser,
}
}
/* Always make sure all the advertised SEI bits
* were consumed during parsing */
if (next > nal_reader_get_pos (nr)) {
GST_LOG ("Skipping %u unused SEI bits", next - nal_reader_get_pos (nr));
if (!nal_reader_skip_long (nr, next - nal_reader_get_pos (nr)))
goto error;
}
return res;
error: