pesparse: Be a bit more permissive with PTS/DTS parsing

According to the specifications a PTS_DTS_flags value of 0x01 is forbidden.
... but there are some rare files out there that do that.

Instead of erroring out, let's warn, carry on parsing accordingly.

If the packet is really corrupted there are enough checks afterward to
detect that.
This commit is contained in:
Edward Hervey 2012-05-26 14:08:41 +02:00
parent 6ea05840a4
commit b6732a27d3

View file

@ -137,8 +137,9 @@ mpegts_parse_pes_header (const guint8 * data, gsize length, PESHeader * res,
/* PTS/DTS */ /* PTS/DTS */
/* PTS_DTS_flags == 0x01 is invalid */ /* PTS_DTS_flags == 0x01 is invalid */
if (G_UNLIKELY ((flags >> 6) == 0x01)) if (G_UNLIKELY ((flags >> 6) == 0x01)) {
goto bad_PTS_DTS_flags; GST_WARNING ("Invalid PTS_DTS_flag (0x01 is forbidden)");
}
if ((flags & 0x80) == 0x80) { if ((flags & 0x80) == 0x80) {
/* PTS */ /* PTS */
@ -150,6 +151,8 @@ mpegts_parse_pes_header (const guint8 * data, gsize length, PESHeader * res,
GST_LOG ("PTS %" G_GUINT64_FORMAT " %" GST_TIME_FORMAT, GST_LOG ("PTS %" G_GUINT64_FORMAT " %" GST_TIME_FORMAT,
res->PTS, GST_TIME_ARGS (MPEGTIME_TO_GSTTIME (res->PTS))); res->PTS, GST_TIME_ARGS (MPEGTIME_TO_GSTTIME (res->PTS)));
}
if ((flags & 0x40) == 0x40) { if ((flags & 0x40) == 0x40) {
/* DTS */ /* DTS */
if (G_UNLIKELY (length < 5)) if (G_UNLIKELY (length < 5))
@ -161,7 +164,6 @@ mpegts_parse_pes_header (const guint8 * data, gsize length, PESHeader * res,
GST_LOG ("DTS %" G_GUINT64_FORMAT " %" GST_TIME_FORMAT, GST_LOG ("DTS %" G_GUINT64_FORMAT " %" GST_TIME_FORMAT,
res->DTS, GST_TIME_ARGS (MPEGTIME_TO_GSTTIME (res->DTS))); res->DTS, GST_TIME_ARGS (MPEGTIME_TO_GSTTIME (res->DTS)));
} }
}
if (flags & 0x20) { if (flags & 0x20) {
/* ESCR */ /* ESCR */
@ -380,10 +382,6 @@ bad_marker_1:
val8); val8);
return PES_PARSING_BAD; return PES_PARSING_BAD;
bad_PTS_DTS_flags:
GST_WARNING ("Invalid '0x01' PTS_DTS_flags");
return PES_PARSING_BAD;
bad_PTS_value: bad_PTS_value:
GST_WARNING ("bad PTS value"); GST_WARNING ("bad PTS value");
return PES_PARSING_BAD; return PES_PARSING_BAD;