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
This commit is contained in:
Edward Hervey 2014-06-02 11:07:01 +02:00 committed by Edward Hervey
parent c60f4ecd11
commit a822517ca9

View file

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