]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
tsfix: remove if (1) condition
authorJaroslav Kysela <perex@perex.cz>
Thu, 23 Oct 2014 19:29:27 +0000 (21:29 +0200)
committerJaroslav Kysela <perex@perex.cz>
Thu, 23 Oct 2014 19:30:23 +0000 (21:30 +0200)
src/plumbing/tsfix.c

index 832817e95619fb97ad6781c944744a569142ed0c..b1b1afde63199529e4b3eabdd705290efedd2a24 100644 (file)
@@ -152,72 +152,67 @@ normalize_ts(tsfix_t *tf, tfstream_t *tfs, th_pkt_t *pkt)
 {
   int64_t dts, d;
 
-  int checkts = SCT_ISAUDIO(tfs->tfs_type) || SCT_ISVIDEO(tfs->tfs_type);
+  if(tf->tf_tsref == PTS_UNSET) {
+    pkt_ref_dec(pkt);
+    return;
+  }
+
+  pkt->pkt_dts &= PTS_MASK;
+  pkt->pkt_pts &= PTS_MASK;
 
-  if (1 /* all streams */) {
-    if(tf->tf_tsref == PTS_UNSET) {
+  /* Subtract the transport wide start offset */
+  dts = pkt->pkt_dts - tf->tf_tsref;
+
+  if(tfs->tfs_last_dts_norm == PTS_UNSET) {
+    if(dts < 0) {
+      /* Early packet with negative time stamp, drop those */
       pkt_ref_dec(pkt);
       return;
     }
+  } else {
+    d = dts + tfs->tfs_dts_epoch - tfs->tfs_last_dts_norm;
 
-    pkt->pkt_dts &= PTS_MASK;
-    pkt->pkt_pts &= PTS_MASK;
-
-    /* Subtract the transport wide start offset */
-    dts = pkt->pkt_dts - tf->tf_tsref;
-
-    if(tfs->tfs_last_dts_norm == PTS_UNSET) {
-      if(dts < 0) {
-        /* Early packet with negative time stamp, drop those */
-        pkt_ref_dec(pkt);
-        return;
-      }
-    } else if (checkts) {
-      d = dts + tfs->tfs_dts_epoch - tfs->tfs_last_dts_norm;
-
-      if(d < 0 || d > 90000) {
+    if(d < 0 || d > 90000) {
 
-        if(d < -PTS_MASK || d > -PTS_MASK + 180000) {
+      if(d < -PTS_MASK || d > -PTS_MASK + 180000) {
 
-         tfs->tfs_bad_dts++;
+       tfs->tfs_bad_dts++;
 
-         if(tfs->tfs_bad_dts < 5) {
-           tvhlog(LOG_ERR, "parser",
-                  "transport stream %s, DTS discontinuity. "
-                  "DTS = %" PRId64 ", last = %" PRId64,
-                  streaming_component_type2txt(tfs->tfs_type),
-                  dts, tfs->tfs_last_dts_norm);
-         }
-        } else {
-         /* DTS wrapped, increase upper bits */
-         tfs->tfs_dts_epoch += PTS_MASK + 1;
-         tfs->tfs_bad_dts = 0;
-        }
+       if(tfs->tfs_bad_dts < 5) {
+         tvhlog(LOG_ERR, "parser",
+                "transport stream %s, DTS discontinuity. "
+                "DTS = %" PRId64 ", last = %" PRId64,
+                streaming_component_type2txt(tfs->tfs_type),
+                dts, tfs->tfs_last_dts_norm);
+       }
       } else {
-        tfs->tfs_bad_dts = 0;
+       /* DTS wrapped, increase upper bits */
+       tfs->tfs_dts_epoch += PTS_MASK + 1;
+       tfs->tfs_bad_dts = 0;
       }
+    } else {
+      tfs->tfs_bad_dts = 0;
     }
+  }
 
-    dts += tfs->tfs_dts_epoch;
-    tfs->tfs_last_dts_norm = dts;
-
-    if(pkt->pkt_pts != PTS_UNSET) {
-      /* Compute delta between PTS and DTS (and watch out for 33 bit wrap) */
-      int64_t ptsoff = (pkt->pkt_pts - pkt->pkt_dts) & PTS_MASK;
+  dts += tfs->tfs_dts_epoch;
+  tfs->tfs_last_dts_norm = dts;
 
-      pkt->pkt_pts = dts + ptsoff;
-    }
+  if(pkt->pkt_pts != PTS_UNSET) {
+    /* Compute delta between PTS and DTS (and watch out for 33 bit wrap) */
+    d = (pkt->pkt_pts - pkt->pkt_dts) & PTS_MASK;
+    pkt->pkt_pts = dts + d;
+  }
 
-    pkt->pkt_dts = dts;
+  pkt->pkt_dts = dts;
 
-    tsfixprintf("TSFIX: %-12s %d %10"PRId64" %10"PRId64" %10d %zd\n",
+  tsfixprintf("TSFIX: %-12s %d %10"PRId64" %10"PRId64" %10d %zd\n",
              streaming_component_type2txt(tfs->tfs_type),
              pkt->pkt_frametype,
              pkt->pkt_dts,
              pkt->pkt_pts,
              pkt->pkt_duration,
              pktbuf_len(pkt->pkt_payload));
-  }
 
   streaming_message_t *sm = streaming_msg_create_pkt(pkt);
   streaming_target_deliver2(tf->tf_output, sm);