Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Indents for bug #2178 fix
  • Loading branch information
johsmi authored and perexg committed Aug 1, 2014
1 parent 92b1a08 commit 04649b3
Showing 1 changed file with 43 additions and 43 deletions.
86 changes: 43 additions & 43 deletions src/plumbing/tsfix.c
Expand Up @@ -99,7 +99,7 @@ tsfix_add_stream(tsfix_t *tf, int index, streaming_component_type_t type)
tfs->tfs_index = index;
tfs->tfs_last_dts_norm = PTS_UNSET;
tfs->tfs_last_dts_in = PTS_UNSET;
tfs->tfs_dts_epoch = 0;
tfs->tfs_dts_epoch = 0;

LIST_INSERT_HEAD(&tf->tf_streams, tfs, tfs_link);
}
Expand Down Expand Up @@ -150,62 +150,62 @@ normalize_ts(tsfix_t *tf, tfstream_t *tfs, th_pkt_t *pkt)
int checkts = SCT_ISAUDIO(tfs->tfs_type) || SCT_ISVIDEO(tfs->tfs_type);

if (checkts) {
if(tf->tf_tsref == PTS_UNSET) {
pkt_ref_dec(pkt);
return;
}

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 */
if(tf->tf_tsref == PTS_UNSET) {
pkt_ref_dec(pkt);
return;
}
} else {
d = dts + tfs->tfs_dts_epoch - tfs->tfs_last_dts_norm;

if(d < 0 || d > 90000) {
pkt->pkt_dts &= PTS_MASK;
pkt->pkt_pts &= PTS_MASK;

if(d < -PTS_MASK || d > -PTS_MASK + 180000) {
/* Subtract the transport wide start offset */
dts = pkt->pkt_dts - tf->tf_tsref;

tfs->tfs_bad_dts++;
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;

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);
}
if(d < 0 || d > 90000) {

if(d < -PTS_MASK || d > -PTS_MASK + 180000) {

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;
}
} else {
/* DTS wrapped, increase upper bits */
tfs->tfs_dts_epoch += PTS_MASK + 1;
tfs->tfs_bad_dts = 0;
tfs->tfs_bad_dts = 0;
}
} else {
tfs->tfs_bad_dts = 0;
}
}

dts += tfs->tfs_dts_epoch;
tfs->tfs_last_dts_norm = dts;
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;
pkt->pkt_pts = dts + ptsoff;
}
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;

pkt->pkt_pts = dts + ptsoff;
}

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,
Expand Down

0 comments on commit 04649b3

Please sign in to comment.