mpegtspacketizer: avoid timestamp overflows
authorThiago Santos <ts.santos@osg.sisa.samsung.com>
Tue, 29 Jul 2014 05:11:54 +0000 (02:11 -0300)
committerThiago Santos <thiagoss@osg.samsung.com>
Fri, 1 Aug 2014 13:42:27 +0000 (10:42 -0300)
Cause timing to break in the pipeline that can lead to a stall

https://bugzilla.gnome.org/show_bug.cgi?id=733837

gst/mpegtsdemux/mpegtspacketizer.c

index 7889c7e..60cb9a2 100644 (file)
@@ -2178,8 +2178,13 @@ mpegts_packetizer_pts_to_ts (MpegTSPacketizer2 * packetizer,
      */
     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 {
+      GstClockTime tmp = pcrtable->base_time + pcrtable->skew;
+      if (tmp + res > pcrtable->base_pcrtime)
+        res += tmp - pcrtable->base_pcrtime;
+      else
+        res = GST_CLOCK_TIME_NONE;
+    }
   } else if (packetizer->calculate_offset && pcrtable->groups) {
     gint64 refpcr = G_MAXINT64, refpcroffset;
     PCROffsetGroup *group = pcrtable->current->group;