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
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 */