From: Edward Hervey Date: Mon, 2 Jun 2014 09:07:01 +0000 (+0200) Subject: mpegtspacketizer: Handle early PTS conversion X-Git-Tag: 1.3.3~151 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a822517ca94c132104faf484d11aaeaaecf9769a;p=platform%2Fupstream%2Fgst-plugins-bad.git mpegtspacketizer: Handle early PTS conversion When handling the PTS/DTS conversion in new groups, there's a possibility that the PTS might be smaller than the first PCR value observed, due to re-ordering. When using the current group, only apply the wraparound correction when we are certain it is one (i.e. differs by more than a second) and not when it's just a small difference (like out-of-order PTS). https://bugzilla.gnome.org/show_bug.cgi?id=731088 --- diff --git a/gst/mpegtsdemux/mpegtspacketizer.c b/gst/mpegtsdemux/mpegtspacketizer.c index 53a528001..b8a976add 100644 --- a/gst/mpegtsdemux/mpegtspacketizer.c +++ b/gst/mpegtsdemux/mpegtspacketizer.c @@ -2151,8 +2151,16 @@ mpegts_packetizer_pts_to_ts (MpegTSPacketizer2 * packetizer, GST_TIME_ARGS (PCRTIME_TO_GSTTIME (group->pcr_offset))); refpcr = group->first_pcr; refpcroffset = group->pcr_offset; - if (pts < PCRTIME_TO_GSTTIME (refpcr)) - refpcr -= PCR_MAX_VALUE; + if (pts < PCRTIME_TO_GSTTIME (refpcr)) { + /* Only apply wrapover if we're certain it is, and avoid + * returning bogus values if it's a PTS/DTS which is *just* + * before the start of the current group + */ + if (ABSDIFF (pts, PCRTIME_TO_GSTTIME (refpcr)) > GST_SECOND) + refpcr -= PCR_MAX_VALUE; + else + refpcr = G_MAXINT64; + } } else { GList *tmp; /* Otherwise, find a suitable group */