Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
tsfix: add check and correction for wrong DVBSUB dts/pts
  • Loading branch information
perexg committed Aug 4, 2015
1 parent af270b6 commit f632da3
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/plumbing/tsfix.c
Expand Up @@ -49,6 +49,8 @@ typedef struct tfstream {

int tfs_seen;

struct tfstream *tfs_parent;

} tfstream_t;


Expand Down Expand Up @@ -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;
}
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down

5 comments on commit f632da3

@ksooo
Copy link
Contributor

@ksooo ksooo commented on f632da3 Aug 4, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this fix any timeshifting issues? I remember that you touched this code last time to fix timeshifting?

@tarvip
Copy link

@tarvip tarvip commented on f632da3 Oct 17, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That commit broke subtitles, subtitles are shown, but looks like a complete mess, some subtitles get skipped others are shown for a very short time, also some stay for few minutes.
Also following messages are in syslog:
Oct 17 11:28:32 localhost tvheadend[5281]: parser: The timediff for DVBSUB is big (452265), using audio dts
Oct 17 11:28:32 localhost tvheadend[5281]: parser: The timediff for DVBSUB is big (452265), using audio dts
Oct 17 11:28:32 localhost tvheadend[5281]: parser: The timediff for DVBSUB is big (452265), using audio dts
Oct 17 11:35:06 localhost tvheadend[5281]: parser: The timediff for DVBSUB is big (416010), using audio dts
Oct 17 11:49:59 localhost tvheadend[6085]: parser: The timediff for DVBSUB is big (405465), using audio dts
Oct 17 11:49:59 localhost tvheadend[6085]: parser: The timediff for DVBSUB is big (405465), using audio dts
Oct 17 11:49:59 localhost tvheadend[6085]: parser: The timediff for DVBSUB is big (405465), using audio dts

After reverting that commit, everything is back to normal.

@perexg
Copy link
Contributor Author

@perexg perexg commented on f632da3 Oct 17, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tarvip : Could you try to change added 'if (diff > 2 * 90000) {' to 'if (diff > 10 * 90000) {' ?

@perexg
Copy link
Contributor Author

@perexg perexg commented on f632da3 Oct 17, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tarvip : Forgot my request, please. It will resolve your issue but not other... I need to look into this more deeply.

@perexg
Copy link
Contributor Author

@perexg perexg commented on f632da3 Oct 17, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tarvip : Fixed in 091c10d . It was just thinko. The time must be compared against actual audio time, not the reference (start) time .

Please sign in to comment.