tsfix: Fix the decision boundary for ts_diff, handle reference for text subtitles, too

This commit is contained in:
Jaroslav Kysela 2014-10-24 08:53:24 +02:00
parent 9c6b8c2975
commit c23eca2b0b

View file

@ -77,7 +77,7 @@ tsfix_ts_diff(int64_t ts1, int64_t ts2)
ts2 &= PTS_MASK;
r = abs(ts1 - ts2);
if (r > (PTS_MASK / 4)) {
if (r > (PTS_MASK / 2)) {
/* try to wrap the lowest value */
if (ts1 < ts2)
ts1 += PTS_MASK + 1;
@ -354,8 +354,13 @@ tsfix_input_packet(tsfix_t *tf, streaming_message_t *sm)
tf->tf_tsref != PTS_UNSET) {
int64_t diff = tsfix_ts_diff(tf->tf_tsref, pkt->pkt_dts);
if (diff > 2 * 90000) {
tfstream_t *tfs2;
tvhwarn("parser", "The timediff for TELETEXT is big (%"PRId64"), using current dts", diff);
tfs->tfs_local_ref = pkt->pkt_dts;
/* Text subtitles extracted from teletext have same timebase */
LIST_FOREACH(tfs2, &tf->tf_streams, tfs_link)
if(tfs2->tfs_type == SCT_TEXTSUB)
tfs2->tfs_local_ref = pkt->pkt_dts;
} else {
tfs->tfs_local_ref = tf->tf_tsref;
}