diff options
author | Rodger Combs <rodger.combs@gmail.com> | 2016-03-06 20:43:37 -0600 |
---|---|---|
committer | Rodger Combs <rodger.combs@gmail.com> | 2016-04-02 13:31:26 -0500 |
commit | 5b4f44f66ae3c42b7497929b6ef5f67e8b1ff0ad (patch) | |
tree | a7f8b59c299c5ce895595fbea35447c16036f079 | |
parent | 44a9395b5acf332823b9ac0ebd0e966b190b02f5 (diff) | |
download | ffmpeg-5b4f44f66ae3c42b7497929b6ef5f67e8b1ff0ad.tar.gz |
lavf/segment: slight refactor to seg_write_packet
This reduces some code duplication, and ensures that cur_entry.last_duration is
always set.
-rw-r--r-- | libavformat/segment.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/libavformat/segment.c b/libavformat/segment.c index 4c1e1156af..d6473f4675 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -860,11 +860,13 @@ static int seg_write_packet(AVFormatContext *s, AVPacket *pkt) seg->cur_entry.index = seg->segment_idx + seg->segment_idx_wrap * seg->segment_idx_wrap_nb; seg->cur_entry.start_time = (double)pkt->pts * av_q2d(st->time_base); seg->cur_entry.start_pts = av_rescale_q(pkt->pts, st->time_base, AV_TIME_BASE_Q); - seg->cur_entry.end_time = seg->cur_entry.start_time + - pkt->pts != AV_NOPTS_VALUE ? (double)(pkt->pts + pkt->duration) * av_q2d(st->time_base) : 0; - } else if (pkt->pts != AV_NOPTS_VALUE && pkt->stream_index == seg->reference_stream_index) { - seg->cur_entry.end_time = - FFMAX(seg->cur_entry.end_time, (double)(pkt->pts + pkt->duration) * av_q2d(st->time_base)); + seg->cur_entry.end_time = seg->cur_entry.start_time; + } + + if (pkt->stream_index == seg->reference_stream_index) { + if (pkt->pts != AV_NOPTS_VALUE) + seg->cur_entry.end_time = + FFMAX(seg->cur_entry.end_time, (double)(pkt->pts + pkt->duration) * av_q2d(st->time_base)); seg->cur_entry.last_duration = pkt->duration; } |