From: Jaroslav Kysela Date: Sat, 4 Nov 2017 16:53:26 +0000 (+0100) Subject: tsfix: take in account negative pcr for the video stream, issue #4701 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a5ecd97a941b0fbb8942d554ee15eef4573b2251;p=thirdparty%2Ftvheadend.git tsfix: take in account negative pcr for the video stream, issue #4701 --- diff --git a/src/plumbing/tsfix.c b/src/plumbing/tsfix.c index aa83b54b6..776389175 100644 --- a/src/plumbing/tsfix.c +++ b/src/plumbing/tsfix.c @@ -571,13 +571,17 @@ tsfix_input_packet(tsfix_t *tf, streaming_message_t *sm) break; } tf->tf_tsref = pkt->pkt_dts & PTS_MASK; + if (pts_is_greater_or_equal(pkt->pkt_pcr, pkt->pkt_dts) > 0) + tf->tf_tsref = pkt->pkt_pcr & PTS_MASK; diff = diff2 = tsfix_backlog_diff(tf); if (diff > threshold) { if (diff > 160000) diff = 160000; tf->tf_tsref = (tf->tf_tsref - diff) % PTS_MASK; - tvhtrace(LS_TSFIX, "reference clock set to %"PRId64" (backlog %"PRId64")", tf->tf_tsref, diff2); + tvhtrace(LS_TSFIX, "reference clock set to %"PRId64" (dts %"PRId64" pcr %"PRId64" backlog %"PRId64")", tf->tf_tsref, pkt->pkt_dts, pkt->pkt_pcr, diff2); tsfix_backlog(tf); + } else { + tvhtrace(LS_TSFIX, "reference clock set to %"PRId64" (dts %"PRId64" pcr %"PRId64" backlog %"PRId64")", tf->tf_tsref, pkt->pkt_dts, pkt->pkt_pcr, diff2); } } else if (txfix_need_to_update_ref(tf, tfs, pkt)) { r = tsfix_update_ref(tf, tfs, pkt);