Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
timeshift: little optimization
  • Loading branch information
perexg committed Jan 4, 2016
1 parent fdf8dcb commit b3870dd
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/timeshift.c
Expand Up @@ -270,16 +270,14 @@ timeshift_packet_flush ( timeshift_t *ts, int64_t time )
}

static void
timeshift_packet( timeshift_t *ts, th_pkt_t *pkt )
timeshift_packet( timeshift_t *ts, streaming_message_t *sm )
{
streaming_message_t *sm;
th_pkt_t *pkt = sm->sm_data;
int64_t time;

if (pkt->pkt_componentindex >= TIMESHIFT_BACKLOG_MAX)
return;

sm = streaming_msg_create_pkt(pkt);

time = ts_rescale(pkt->pkt_pts, 1000000);
if (time > ts->last_time) {
ts->last_time = time;
Expand All @@ -306,7 +304,7 @@ static void timeshift_input
{
int type = sm->sm_type;
timeshift_t *ts = opaque;
th_pkt_t *pkt = sm->sm_data, *pkt2;
th_pkt_t *pkt, *pkt2;

/* Control */
if (type == SMT_SKIP) {
Expand All @@ -322,11 +320,12 @@ static void timeshift_input

/* Change PTS/DTS offsets */
else if (ts->packet_mode && ts->start_pts && type == SMT_PACKET) {
pkt = sm->sm_data;
pkt2 = pkt_copy_shallow(pkt);
pkt_ref_dec(pkt);
sm->sm_data = pkt = pkt2;
pkt->pkt_pts += ts->start_pts;
pkt->pkt_dts += ts->start_pts;
sm->sm_data = pkt2;
pkt2->pkt_pts += ts->start_pts;
pkt2->pkt_dts += ts->start_pts;
}

/* Check for exit */
Expand All @@ -341,8 +340,7 @@ static void timeshift_input
if (ts->packet_mode) {
sm->sm_time = ts->last_wr_time;
if (type == SMT_PACKET) {
timeshift_packet(ts, pkt);
streaming_msg_free(sm);
timeshift_packet(ts, sm);
goto _exit;
}
} else {
Expand Down

0 comments on commit b3870dd

Please sign in to comment.