diff options
author | Aurélien Zanelli <aurelien.zanelli@parrot.com> | 2015-01-20 16:20:10 +0100 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2016-04-06 14:22:17 +0100 |
commit | 891dbc9c9d9a3a2ceb3e1404276d0120a67357b5 (patch) | |
tree | 793718e413eed7b0a5280c4225c0937e3fd8663b | |
parent | 3074fdf5ae174688a24b55888dabaff298b057af (diff) | |
download | gstreamer-plugins-bad-891dbc9c9d9a3a2ceb3e1404276d0120a67357b5.tar.gz |
mpegtspacketizer: handle early PTS conversion when a group has been found
In some cases, the PTS might be smaller than the first observed PCR
value which causes element to apply wraparound leading to bogus
timestamp. To solve this, we only apply it if the PTS-PCR difference is
greater that 1 second to be sure that it's a real wraparound.
Moreover, using unsigned 32 bits values to handle wrapover could end up
with bogus value, so it use pts value to handle it.
Also, convert pcr time to gst time before comparing it to pts.
Since refpcr is expressed in PCR time base while pts is expressed in GStreamer
time.
https://bugzilla.gnome.org/show_bug.cgi?id=743259
-rw-r--r-- | gst/mpegtsdemux/mpegtspacketizer.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/gst/mpegtsdemux/mpegtspacketizer.c b/gst/mpegtsdemux/mpegtspacketizer.c index 1cdb9e993..2a303ab46 100644 --- a/gst/mpegtsdemux/mpegtspacketizer.c +++ b/gst/mpegtsdemux/mpegtspacketizer.c @@ -2285,8 +2285,12 @@ mpegts_packetizer_pts_to_ts (MpegTSPacketizer2 * packetizer, GST_DEBUG ("Using group !"); refpcr = group->first_pcr; refpcroffset = group->pcr_offset; - if (pts < refpcr) - refpcr -= PCR_MAX_VALUE; + if (pts < PCRTIME_TO_GSTTIME (refpcr)) { + if (PCRTIME_TO_GSTTIME (refpcr) - pts > GST_SECOND) + pts += PCR_GST_MAX_VALUE; + else + refpcr = G_MAXINT64; + } } } if (refpcr != G_MAXINT64) |