From a5ecd97a941b0fbb8942d554ee15eef4573b2251 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Sat, 4 Nov 2017 17:53:26 +0100 Subject: [PATCH] tsfix: take in account negative pcr for the video stream, issue #4701 --- src/plumbing/tsfix.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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); -- 2.47.3