1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

lavf/segment: slight refactor to seg_write_packet

This reduces some code duplication, and ensures that cur_entry.last_duration is
always set.
This commit is contained in:
Rodger Combs 2016-03-06 20:43:37 -06:00
parent 44a9395b5a
commit 5b4f44f66a

View File

@ -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.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_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.start_pts = av_rescale_q(pkt->pts, st->time_base, AV_TIME_BASE_Q);
seg->cur_entry.end_time = seg->cur_entry.start_time + 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 = if (pkt->stream_index == seg->reference_stream_index) {
FFMAX(seg->cur_entry.end_time, (double)(pkt->pts + pkt->duration) * av_q2d(st->time_base)); 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; seg->cur_entry.last_duration = pkt->duration;
} }