summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorEdward Hervey <bilboed@bilboed.com>2014-06-02 11:07:01 +0200
committerEdward Hervey <edward@collabora.com>2014-06-10 13:29:28 +0200
commita822517ca94c132104faf484d11aaeaaecf9769a (patch)
tree58b32064bf3145f3790afe014e693e817f32cdb0 /gst
parentc60f4ecd117202f22719ede718d379f08fde7ef1 (diff)
downloadgstreamer-plugins-bad-a822517ca94c132104faf484d11aaeaaecf9769a.tar.gz
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
Diffstat (limited to 'gst')
-rw-r--r--gst/mpegtsdemux/mpegtspacketizer.c12
1 files changed, 10 insertions, 2 deletions
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 */