Commit a8e3815d authored by Michael Niedermayer's avatar Michael Niedermayer

lavf: factorize timestamp shift in update_initial_timestamps()

Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent cddbafb5
...@@ -940,24 +940,26 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index, ...@@ -940,24 +940,26 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index,
{ {
AVStream *st= s->streams[stream_index]; AVStream *st= s->streams[stream_index];
AVPacketList *pktl= s->parse_queue ? s->parse_queue : s->packet_buffer; AVPacketList *pktl= s->parse_queue ? s->parse_queue : s->packet_buffer;
int64_t shift;
if(st->first_dts != AV_NOPTS_VALUE || dts == AV_NOPTS_VALUE || st->cur_dts == AV_NOPTS_VALUE || is_relative(dts)) if(st->first_dts != AV_NOPTS_VALUE || dts == AV_NOPTS_VALUE || st->cur_dts == AV_NOPTS_VALUE || is_relative(dts))
return; return;
st->first_dts= dts - (st->cur_dts - RELATIVE_TS_BASE); st->first_dts= dts - (st->cur_dts - RELATIVE_TS_BASE);
st->cur_dts= dts; st->cur_dts= dts;
shift = st->first_dts - RELATIVE_TS_BASE;
if (is_relative(pts)) if (is_relative(pts))
pts += st->first_dts - RELATIVE_TS_BASE; pts += shift;
for(; pktl; pktl= get_next_pkt(s, st, pktl)){ for(; pktl; pktl= get_next_pkt(s, st, pktl)){
if(pktl->pkt.stream_index != stream_index) if(pktl->pkt.stream_index != stream_index)
continue; continue;
if(is_relative(pktl->pkt.pts)) if(is_relative(pktl->pkt.pts))
pktl->pkt.pts += st->first_dts - RELATIVE_TS_BASE; pktl->pkt.pts += shift;
if(is_relative(pktl->pkt.dts)) if(is_relative(pktl->pkt.dts))
pktl->pkt.dts += st->first_dts - RELATIVE_TS_BASE; pktl->pkt.dts += shift;
if(st->start_time == AV_NOPTS_VALUE && pktl->pkt.pts != AV_NOPTS_VALUE) if(st->start_time == AV_NOPTS_VALUE && pktl->pkt.pts != AV_NOPTS_VALUE)
st->start_time= pktl->pkt.pts; st->start_time= pktl->pkt.pts;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment