From c132938d52cf8a60bb676f54812a77d2e131eca4 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 21 Feb 2009 23:00:07 +0000 Subject: [PATCH] Waste less space for printing timebases. Originally committed as revision 17505 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavformat/utils.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 177a69deed..63c77cfe59 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2755,6 +2755,13 @@ void av_program_add_stream_index(AVFormatContext *ac, int progid, unsigned int i } } +static void print_fps(double d, const char *postfix){ + uint64_t v= lrintf(d*100); + if (v% 100 ) av_log(NULL, AV_LOG_INFO, ", %3.2f %s", d, postfix); + else if(v%(100*1000)) av_log(NULL, AV_LOG_INFO, ", %1.0f %s", d, postfix); + else av_log(NULL, AV_LOG_INFO, ", %1.0fk %s", d/1000, postfix); +} + /* "user interface" functions */ static void dump_stream_format(AVFormatContext *ic, int i, int index, int is_output) { @@ -2785,11 +2792,11 @@ static void dump_stream_format(AVFormatContext *ic, int i, int index, int is_out } if(st->codec->codec_type == CODEC_TYPE_VIDEO){ if(st->r_frame_rate.den && st->r_frame_rate.num) - av_log(NULL, AV_LOG_INFO, ", %5.2f tb(r)", av_q2d(st->r_frame_rate)); + print_fps(av_q2d(st->r_frame_rate), "tbr"); if(st->time_base.den && st->time_base.num) - av_log(NULL, AV_LOG_INFO, ", %5.2f tb(m)", 1/av_q2d(st->time_base)); + print_fps(1/av_q2d(st->time_base), "tbn"); if(st->codec->time_base.den && st->codec->time_base.num) - av_log(NULL, AV_LOG_INFO, ", %5.2f tb(c)", 1/av_q2d(st->codec->time_base)); + print_fps(1/av_q2d(st->codec->time_base), "tbc"); } av_log(NULL, AV_LOG_INFO, "\n"); }