Commit c09abba1 authored by Michael Niedermayer's avatar Michael Niedermayer

ffmpeg: avoid multiple redundant av_gettime() calls, rather reuse the value in...

ffmpeg: avoid multiple redundant av_gettime() calls, rather reuse the value in a iteration of the main loop.
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent f3afc9d7
...@@ -1378,7 +1378,7 @@ static void do_video_stats(AVFormatContext *os, OutputStream *ost, ...@@ -1378,7 +1378,7 @@ static void do_video_stats(AVFormatContext *os, OutputStream *ost,
static void print_report(OutputFile *output_files, static void print_report(OutputFile *output_files,
OutputStream *ost_table, int nb_ostreams, 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]; char buf[1024];
OutputStream *ost; OutputStream *ost;
...@@ -1393,9 +1393,6 @@ static void print_report(OutputFile *output_files, ...@@ -1393,9 +1393,6 @@ static void print_report(OutputFile *output_files,
int hours, mins, secs, us; int hours, mins, secs, us;
if (!is_last_report) { if (!is_last_report) {
int64_t cur_time;
/* display the report every 0.5 seconds */
cur_time = av_gettime();
if (last_time == -1) { if (last_time == -1) {
last_time = cur_time; last_time = cur_time;
return; return;
...@@ -1424,7 +1421,7 @@ static void print_report(OutputFile *output_files, ...@@ -1424,7 +1421,7 @@ static void print_report(OutputFile *output_files,
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "q=%2.1f ", q); snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "q=%2.1f ", q);
} }
if (!vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) { 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; frame_number = ost->frame_number;
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "frame=%5d fps=%3d q=%3.1f ", 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, ...@@ -2441,6 +2438,7 @@ static int transcode(OutputFile *output_files, int nb_output_files,
AVPacket pkt; AVPacket pkt;
int64_t ipts_min; int64_t ipts_min;
double opts_min; double opts_min;
int64_t cur_time= av_gettime();
ipts_min= INT64_MAX; ipts_min= INT64_MAX;
opts_min= 1e100; opts_min= 1e100;
...@@ -2650,7 +2648,7 @@ static int transcode(OutputFile *output_files, int nb_output_files, ...@@ -2650,7 +2648,7 @@ static int transcode(OutputFile *output_files, int nb_output_files,
av_free_packet(&pkt); av_free_packet(&pkt);
/* dump report by using the output first video and audio streams */ /* 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 */ /* 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, ...@@ -2671,7 +2669,7 @@ static int transcode(OutputFile *output_files, int nb_output_files,
} }
/* dump report by using the first video and audio streams */ /* 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 */ /* close each encoder */
for (i = 0; i < nb_output_streams; i++) { for (i = 0; i < nb_output_streams; i++) {
......
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