]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
warn if DTS is not linear
authorAndreas Öman <andreas@lonelycoder.com>
Tue, 27 Nov 2007 11:34:08 +0000 (11:34 +0000)
committerAndreas Öman <andreas@lonelycoder.com>
Tue, 27 Nov 2007 11:34:08 +0000 (11:34 +0000)
pes.c
tvhead.h

diff --git a/pes.c b/pes.c
index 74ff6b922fae37f642c006089b508b6dcb0d14f5..b981f608952f39f33cce2935dd85ab41fd4d5299 100644 (file)
--- a/pes.c
+++ b/pes.c
@@ -317,7 +317,7 @@ pes_compute_duration(th_transport_t *t, th_stream_t *st, th_pkt_t *pkt)
   th_pkt_t *next;
   th_muxer_t *tm;
   int delta;
-
+  int64_t d;
   delta = abs(pkt->pkt_dts - pkt->pkt_pts);
 
   if(delta > 250000) 
@@ -332,15 +332,33 @@ pes_compute_duration(th_transport_t *t, th_stream_t *st, th_pkt_t *pkt)
   if((next = TAILQ_NEXT(pkt, pkt_queue_link)) == NULL)
     return;
 
-  pkt->pkt_duration = next->pkt_dts - pkt->pkt_dts;
+  d = next->pkt_dts - pkt->pkt_dts;
 
   TAILQ_REMOVE(&st->st_durationq, pkt, pkt_queue_link);
 
-  if(pkt->pkt_duration < 1 || pkt->pkt_duration > 500000) {
+  if(d != st->st_last_duration) {
+
+    if(st->st_last_duration_frames > 30) {
+      syslog(LOG_INFO, "\"%s\" on \"%s\": \"%s\" "
+            "Non-linear timestamps detected. "
+            "DTS delta was %lld, but should be %lld for this stream",
+            t->tht_channel->ch_name,
+            t->tht_name,
+            htstvstreamtype2txt(st->st_type),
+            d, st->st_last_duration);
+    }
+    st->st_last_duration = d;
+    st->st_last_duration_frames = 0;
+  } else {
+    st->st_last_duration_frames++;
+  }
+
+  if(d < 1 || d > 500000) {
     pkt_deref(pkt);
     return;
   }
 
+  pkt->pkt_duration = d;
   pkt->pkt_stream = st;
 
   /* Alert all muxers tied to us that a new packet has arrived */
index ba13a2de827798ed10a777b7cb8475cb196931aa..573e694b0b3faea0d4f1fbafa6e648bf9eae531a 100644 (file)
--- a/tvhead.h
+++ b/tvhead.h
@@ -292,7 +292,9 @@ typedef struct th_stream {
   /* Temporary frame store for calculating duration */
 
   struct th_pkt_queue st_durationq;
-  int st_duration;
+
+  int64_t st_last_duration;
+  int st_last_duration_frames;
 
   /* Final frame store */