diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-09-07 00:23:18 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-09-07 00:23:18 +0200 |
commit | 9243454e310248d872182b41cb18c099ad870228 (patch) | |
tree | b34f05d696bbc48f044b53c27c3ea1b333908b21 | |
parent | effbeff5035dc4050c0229e10ba4fae996c280e5 (diff) | |
download | ffmpeg-9243454e310248d872182b41cb18c099ad870228.tar.gz |
libavformat/utils: only run delta_dts_min calculation code when its value is used.
This should improve speed.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavformat/utils.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index f2613087de..d7d78bf5a3 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3230,28 +3230,32 @@ int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pk for(i=0; i < s->nb_streams; i++) { 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; - } else { - if(s->streams[i]->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) - ++noninterleaved_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 && - 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; + } else if (!flush){ + for(i=0; i < s->nb_streams; i++) { + 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); + } + } + 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){ pktl= s->packet_buffer; |