Commit 9243454e authored by Michael Niedermayer's avatar Michael Niedermayer

libavformat/utils: only run delta_dts_min calculation code when its value is used.

This should improve speed.
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent effbeff5
...@@ -3230,28 +3230,32 @@ int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pk ...@@ -3230,28 +3230,32 @@ int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pk
for(i=0; i < s->nb_streams; i++) { for(i=0; i < s->nb_streams; i++) {
if (s->streams[i]->last_in_packet_buffer) { if (s->streams[i]->last_in_packet_buffer) {
int64_t delta_dts =
av_rescale_q(s->streams[i]->last_in_packet_buffer->pkt.dts,
s->streams[i]->time_base,
AV_TIME_BASE_Q) -
av_rescale_q(s->packet_buffer->pkt.dts,
s->streams[s->packet_buffer->pkt.stream_index]->time_base,
AV_TIME_BASE_Q);
delta_dts_min = FFMIN(delta_dts_min, delta_dts);
++stream_count; ++stream_count;
} else { } else if(s->streams[i]->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
if(s->streams[i]->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) ++noninterleaved_count;
++noninterleaved_count;
} }
} }
if (s->nb_streams == stream_count) { if (s->nb_streams == stream_count) {
flush = 1; flush = 1;
} else if (!flush && } else if (!flush){
s->nb_streams == stream_count+noninterleaved_count && for(i=0; i < s->nb_streams; i++) {
delta_dts_min > 20*AV_TIME_BASE) { if (s->streams[i]->last_in_packet_buffer) {
av_log(s, AV_LOG_DEBUG, "flushing with %d noninterleaved\n", noninterleaved_count); int64_t delta_dts =
flush = 1; av_rescale_q(s->streams[i]->last_in_packet_buffer->pkt.dts,
s->streams[i]->time_base,
AV_TIME_BASE_Q) -
av_rescale_q(s->packet_buffer->pkt.dts,
s->streams[s->packet_buffer->pkt.stream_index]->time_base,
AV_TIME_BASE_Q);
delta_dts_min = FFMIN(delta_dts_min, delta_dts);
}
}
if(s->nb_streams == stream_count+noninterleaved_count &&
delta_dts_min > 20*AV_TIME_BASE) {
av_log(s, AV_LOG_DEBUG, "flushing with %d noninterleaved\n", noninterleaved_count);
flush = 1;
}
} }
if(stream_count && flush){ if(stream_count && flush){
pktl= s->packet_buffer; pktl= s->packet_buffer;
......
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