From c09abba1d9e0c30c8720199af3e17bf69ed0ed78 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 8 Oct 2011 17:32:06 +0200 Subject: [PATCH] ffmpeg: avoid multiple redundant av_gettime() calls, rather reuse the value in a iteration of the main loop. Signed-off-by: Michael Niedermayer --- ffmpeg.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 96503c01f0..a3c1dd79d7 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -1378,7 +1378,7 @@ static void do_video_stats(AVFormatContext *os, OutputStream *ost, static void print_report(OutputFile *output_files, OutputStream *ost_table, int nb_ostreams, - int is_last_report, int64_t timer_start) + int is_last_report, int64_t timer_start, int64_t cur_time) { char buf[1024]; OutputStream *ost; @@ -1393,9 +1393,6 @@ static void print_report(OutputFile *output_files, int hours, mins, secs, us; if (!is_last_report) { - int64_t cur_time; - /* display the report every 0.5 seconds */ - cur_time = av_gettime(); if (last_time == -1) { last_time = cur_time; return; @@ -1424,7 +1421,7 @@ static void print_report(OutputFile *output_files, snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "q=%2.1f ", q); } if (!vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) { - float t = (av_gettime()-timer_start) / 1000000.0; + float t = (cur_time-timer_start) / 1000000.0; frame_number = ost->frame_number; snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "frame=%5d fps=%3d q=%3.1f ", @@ -2441,6 +2438,7 @@ static int transcode(OutputFile *output_files, int nb_output_files, AVPacket pkt; int64_t ipts_min; double opts_min; + int64_t cur_time= av_gettime(); ipts_min= INT64_MAX; opts_min= 1e100; @@ -2650,7 +2648,7 @@ static int transcode(OutputFile *output_files, int nb_output_files, av_free_packet(&pkt); /* dump report by using the output first video and audio streams */ - print_report(output_files, output_streams, nb_output_streams, 0, timer_start); + print_report(output_files, output_streams, nb_output_streams, 0, timer_start, cur_time); } /* at the end of stream, we must flush the decoder buffers */ @@ -2671,7 +2669,7 @@ static int transcode(OutputFile *output_files, int nb_output_files, } /* dump report by using the first video and audio streams */ - print_report(output_files, output_streams, nb_output_streams, 1, timer_start); + print_report(output_files, output_streams, nb_output_streams, 1, timer_start, av_gettime()); /* close each encoder */ for (i = 0; i < nb_output_streams; i++) {