Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
DVR: improve dts/pts validation
  • Loading branch information
perexg committed Oct 31, 2015
1 parent b50466a commit 953fa60
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/dvr/dvr_rec.c
Expand Up @@ -1169,6 +1169,21 @@ dvr_thread_backlog_free(struct streaming_message_queue *backlog)
}
}

/**
*
*/
static inline int
dts_pts_valid(th_pkt_t *pkt, int64_t dts_offset)
{
if (pkt->pkt_dts == PTS_UNSET ||
pkt->pkt_pts == PTS_UNSET ||
dts_offset == PTS_UNSET ||
pkt->pkt_dts < dts_offset ||
pkt->pkt_pts < dts_offset)
return 0;
return 1;
}

/**
*
*/
Expand Down Expand Up @@ -1270,7 +1285,7 @@ dvr_thread(void *aux)
dts_offset = pkt2->pkt_dts;
}
pkt3 = (th_pkt_t *)sm2->sm_data;
if (dts_offset != PTS_UNSET && pkt->pkt_dts >= dts_offset) {
if (dts_pts_valid(pkt3, dts_offset)) {
pkt3 = pkt_copy_shallow(pkt3);
pkt3->pkt_dts -= dts_offset;
if (pkt3->pkt_pts != PTS_UNSET)
Expand All @@ -1285,8 +1300,7 @@ dvr_thread(void *aux)
}
if (dts_offset == PTS_UNSET && pkt->pkt_dts != PTS_UNSET)
dts_offset = pkt->pkt_dts;
if (pkt->pkt_dts != PTS_UNSET && dts_offset != PTS_UNSET &&
pkt->pkt_dts >= dts_offset) {
if (dts_pts_valid(pkt, dts_offset)) {
pkt3 = pkt_copy_shallow(pkt);
pkt3->pkt_dts -= dts_offset;
if (pkt3->pkt_pts != PTS_UNSET)
Expand Down

0 comments on commit 953fa60

Please sign in to comment.