From 97b3382c80ba3f9ef2479e7b0bb2a6944e26c765 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Fri, 13 Jun 2014 11:46:19 +0200 Subject: mpegtspacketizer: live: handle pcr/dts discrepancies some more When wrapover/reset occur, we end up with a small window of time where the PTS/DTS will still be using the previous/next time-range. In order not to return bogus values, return GST_CLOCK_TIME_NONE if the PTS/DTS value to convert differs by more than 15s against the last seen PCR https://bugzilla.gnome.org/show_bug.cgi?id=674536 --- gst/mpegtsdemux/mpegtspacketizer.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'gst') diff --git a/gst/mpegtsdemux/mpegtspacketizer.c b/gst/mpegtsdemux/mpegtspacketizer.c index d39edefcc..b504739df 100644 --- a/gst/mpegtsdemux/mpegtspacketizer.c +++ b/gst/mpegtsdemux/mpegtspacketizer.c @@ -2135,12 +2135,24 @@ mpegts_packetizer_pts_to_ts (MpegTSPacketizer2 * packetizer, /* Use clock skew if present */ if (packetizer->calculate_skew && GST_CLOCK_TIME_IS_VALID (pcrtable->base_time)) { - GST_DEBUG ("pts %" G_GUINT64_FORMAT " base_pcrtime:%" G_GUINT64_FORMAT - " base_time:%" GST_TIME_FORMAT, pts, pcrtable->base_pcrtime, - GST_TIME_ARGS (pcrtable->base_time)); - res = - pts + pcrtable->pcroffset - pcrtable->base_pcrtime + - pcrtable->base_time + pcrtable->skew; + GST_DEBUG ("pts %" GST_TIME_FORMAT " base_pcrtime:%" GST_TIME_FORMAT + " base_time:%" GST_TIME_FORMAT " pcroffset:%" GST_TIME_FORMAT, + GST_TIME_ARGS (pts), + GST_TIME_ARGS (pcrtable->base_pcrtime), + GST_TIME_ARGS (pcrtable->base_time), + GST_TIME_ARGS (pcrtable->pcroffset)); + res = pts + pcrtable->pcroffset; + + /* Don't return anything if we differ too much against last seen PCR */ + /* FIXME : Ideally we want to figure out whether we have a wraparound or + * a reset so we can provide actual values. + * That being said, this will only happen for the small interval of time + * where PTS/DTS are wrapping just before we see the first reset/wrap PCR + */ + if (G_UNLIKELY (ABSDIFF (res, pcrtable->last_pcrtime) > 15 * GST_SECOND)) + res = GST_CLOCK_TIME_NONE; + else + res += pcrtable->base_time + pcrtable->skew - pcrtable->base_pcrtime; } else if (packetizer->calculate_offset && pcrtable->groups) { gint64 refpcr = G_MAXINT64, refpcroffset; PCROffsetGroup *group = pcrtable->current->group; -- cgit v1.2.1