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
...@@ -3228,6 +3228,17 @@ int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pk ...@@ -3228,6 +3228,17 @@ int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pk
ff_interleave_add_packet(s, pkt, ff_interleave_compare_dts); ff_interleave_add_packet(s, pkt, ff_interleave_compare_dts);
} }
for(i=0; i < s->nb_streams; i++) {
if (s->streams[i]->last_in_packet_buffer) {
++stream_count;
} else if(s->streams[i]->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
++noninterleaved_count;
}
}
if (s->nb_streams == stream_count) {
flush = 1;
} else if (!flush){
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 = int64_t delta_dts =
...@@ -3238,21 +3249,14 @@ int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pk ...@@ -3238,21 +3249,14 @@ int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pk
s->streams[s->packet_buffer->pkt.stream_index]->time_base, s->streams[s->packet_buffer->pkt.stream_index]->time_base,
AV_TIME_BASE_Q); AV_TIME_BASE_Q);
delta_dts_min = FFMIN(delta_dts_min, delta_dts); delta_dts_min = FFMIN(delta_dts_min, delta_dts);
++stream_count;
} else {
if(s->streams[i]->codec->codec_type == AVMEDIA_TYPE_SUBTITLE)
++noninterleaved_count;
} }
} }
if(s->nb_streams == stream_count+noninterleaved_count &&
if (s->nb_streams == stream_count) {
flush = 1;
} else if (!flush &&
s->nb_streams == stream_count+noninterleaved_count &&
delta_dts_min > 20*AV_TIME_BASE) { delta_dts_min > 20*AV_TIME_BASE) {
av_log(s, AV_LOG_DEBUG, "flushing with %d noninterleaved\n", noninterleaved_count); av_log(s, AV_LOG_DEBUG, "flushing with %d noninterleaved\n", noninterleaved_count);
flush = 1; flush = 1;
} }
}
if(stream_count && flush){ if(stream_count && flush){
pktl= s->packet_buffer; pktl= s->packet_buffer;
*out= pktl->pkt; *out= pktl->pkt;
......
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