]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
tsfix: add check and correction for wrong DVBSUB dts/pts
authorJaroslav Kysela <perex@perex.cz>
Tue, 4 Aug 2015 07:39:20 +0000 (09:39 +0200)
committerJaroslav Kysela <perex@perex.cz>
Tue, 4 Aug 2015 07:39:20 +0000 (09:39 +0200)
src/plumbing/tsfix.c

index 66b8e5d2725aff980edf0fdeaf5ca171235b48a6..622ea1b7b8d6c90413b72b4fffa02de2acb28042 100644 (file)
@@ -49,6 +49,8 @@ typedef struct tfstream {
 
   int tfs_seen;
 
+  struct tfstream *tfs_parent;
+
 } tfstream_t;
 
 
@@ -429,7 +431,7 @@ tsfix_input_packet(tsfix_t *tf, streaming_message_t *sm)
       (tfs->tfs_video && pkt->pkt_frametype == PKT_I_FRAME))) {
     threshold = 22500;
     LIST_FOREACH(tfs2, &tf->tf_streams, tfs_link)
-      if (tfs != tfs2 && tfs2->tfs_audio && tfs2->tfs_video && !tfs2->tfs_seen) {
+      if (tfs != tfs2 && (tfs2->tfs_audio || tfs2->tfs_video) && !tfs2->tfs_seen) {
         threshold = 90000;
         break;
       }
@@ -453,6 +455,22 @@ tsfix_input_packet(tsfix_t *tf, streaming_message_t *sm)
       } else {
         tfs->tfs_local_ref = tf->tf_tsref;
       }
+    } else if (tfs->tfs_type == SCT_DVBSUB) {
+      diff = tsfix_ts_diff(tf->tf_tsref, pkt->pkt_dts);
+      if (diff > 2 * 90000) {
+        LIST_FOREACH(tfs2, &tf->tf_streams, tfs_link) {
+          if(tfs2->tfs_audio && tfs2->tfs_local_ref != PTS_UNSET) {
+            tvhwarn("parser", "The timediff for DVBSUB is big (%"PRId64"), using audio dts", diff);
+            tfs->tfs_parent = tfs2;
+            break;
+          }
+        }
+        if (tfs2 == NULL) {
+          pkt_ref_dec(pkt);
+          return;
+        }
+        tfs->tfs_local_ref = tfs2->tfs_local_ref;
+      }
     } else if (tfs->tfs_type == SCT_TELETEXT) {
       diff = tsfix_ts_diff(tf->tf_tsref, pkt->pkt_dts);
       if (diff > 2 * 90000) {
@@ -488,6 +506,9 @@ tsfix_input_packet(tsfix_t *tf, streaming_message_t *sm)
                tfs->tfs_last_dts_in, pdur, pkt->pkt_dts);
   }
 
+  if (tfs->tfs_parent)
+    pkt->pkt_dts = pkt->pkt_pts = tfs->tfs_parent->tfs_last_dts_in;
+
   tfs->tfs_last_dts_in = pkt->pkt_dts;
 
   compute_pts(tf, tfs, pkt);