summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorEdward Hervey <edward.hervey@collabora.co.uk>2012-05-26 14:08:41 +0200
committerAndre Moreira Magalhaes (andrunko) <andre.magalhaes@collabora.co.uk>2012-05-28 14:36:01 -0300
commit957804deca76bf48977b13e721a2cbc618a808f2 (patch)
tree14a8eb535bbb1af91933cce981e27de0bccdeef4 /gst
parentc780312e73e8bdf70cd307fe71e398a299bf2af9 (diff)
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.
Diffstat (limited to 'gst')
-rw-r--r--gst/mpegtsdemux/pesparse.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/gst/mpegtsdemux/pesparse.c b/gst/mpegtsdemux/pesparse.c
index e5100688d..ce3ff41a9 100644
--- a/gst/mpegtsdemux/pesparse.c
+++ b/gst/mpegtsdemux/pesparse.c
@@ -137,8 +137,9 @@ mpegts_parse_pes_header (const guint8 * data, gsize length, PESHeader * res,
/* PTS/DTS */
/* PTS_DTS_flags == 0x01 is invalid */
- if (G_UNLIKELY ((flags >> 6) == 0x01))
- goto bad_PTS_DTS_flags;
+ if (G_UNLIKELY ((flags >> 6) == 0x01)) {
+ GST_WARNING ("Invalid PTS_DTS_flag (0x01 is forbidden)");
+ }
if ((flags & 0x80) == 0x80) {
/* PTS */
@@ -150,17 +151,18 @@ mpegts_parse_pes_header (const guint8 * data, gsize length, PESHeader * res,
GST_LOG ("PTS %" G_GUINT64_FORMAT " %" GST_TIME_FORMAT,
res->PTS, GST_TIME_ARGS (MPEGTIME_TO_GSTTIME (res->PTS)));
- if ((flags & 0x40) == 0x40) {
- /* DTS */
- if (G_UNLIKELY (length < 5))
- goto need_more_data;
+ }
- READ_TS (data, res->DTS, bad_DTS_value);
- length -= 5;
+ if ((flags & 0x40) == 0x40) {
+ /* DTS */
+ if (G_UNLIKELY (length < 5))
+ goto need_more_data;
- GST_LOG ("DTS %" G_GUINT64_FORMAT " %" GST_TIME_FORMAT,
- res->DTS, GST_TIME_ARGS (MPEGTIME_TO_GSTTIME (res->DTS)));
- }
+ READ_TS (data, res->DTS, bad_DTS_value);
+ length -= 5;
+
+ GST_LOG ("DTS %" G_GUINT64_FORMAT " %" GST_TIME_FORMAT,
+ res->DTS, GST_TIME_ARGS (MPEGTIME_TO_GSTTIME (res->DTS)));
}
if (flags & 0x20) {
@@ -380,10 +382,6 @@ bad_marker_1:
val8);
return PES_PARSING_BAD;
-bad_PTS_DTS_flags:
- GST_WARNING ("Invalid '0x01' PTS_DTS_flags");
- return PES_PARSING_BAD;
-
bad_PTS_value:
GST_WARNING ("bad PTS value");
return PES_PARSING_BAD;