flvdemux: fix discontinuity threshold check when timestamps go backwards
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Sat, 3 Dec 2011 17:30:10 +0000 (17:30 +0000)
committerVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Sat, 3 Dec 2011 17:30:10 +0000 (17:30 +0000)
Since unsigned types are used, a negative value would show as very, very
positive.
Fixes A/V sync on some... less than well made files where timestamps go
backwards.

gst/flv/gstflvdemux.c

index 598f760..00a68e4 100644 (file)
@@ -766,11 +766,11 @@ static void
 gst_flv_demux_update_resync (GstFlvDemux * demux, guint32 pts, gboolean discont,
     guint32 * last, GstClockTime * offset)
 {
-  if (!discont && ABS (pts - *last) >= RESYNC_THRESHOLD) {
+  gint32 dpts = pts - *last;
+  if (!discont && ABS (dpts) >= RESYNC_THRESHOLD) {
     /* Theoretically, we should use substract the duration of the last buffer,
        but this demuxer sends no durations on buffers, not sure if it cannot
        know, or just does not care to calculate. */
-    gint32 dpts = pts - *last;
     *offset -= dpts * GST_MSECOND;
     GST_WARNING_OBJECT (demux,
         "Large pts gap (%" G_GINT32_FORMAT " ms), assuming resync, offset now %"