[FFmpeg-cvslog] libavformat/utils: only run delta_dts_min calculation code when its value is used.
Michael Niedermayer
git at videolan.org
Wed Sep 7 00:43:38 CEST 2011
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Wed Sep 7 00:23:18 2011 +0200| [9243454e310248d872182b41cb18c099ad870228] | committer: Michael Niedermayer
libavformat/utils: only run delta_dts_min calculation code when its value is used.
This should improve speed.
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9243454e310248d872182b41cb18c099ad870228
---
libavformat/utils.c | 36 ++++++++++++++++++++----------------
1 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/libavformat/utils.c b/libavformat/utils.c
index f261308..d7d78bf 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;
More information about the ffmpeg-cvslog
mailing list