---
 libavcodec/utils.c | 22 +++++++++++++++-------
 libavformat/dump.c | 22 ++++++++++++++--------
 2 files changed, 29 insertions(+), 15 deletions(-)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index c5fa50d..ac5fb87 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1846,6 +1846,7 @@ void avcodec_string(char *buf, int buf_size, 
AVCodecContext *enc, int encode)
     const AVCodec *p;
     char buf1[32];
     int bitrate;
+    int new_line = 0;
     AVRational display_aspect_ratio;
 
     if (enc->codec)
@@ -1878,35 +1879,42 @@ void avcodec_string(char *buf, int buf_size, 
AVCodecContext *enc, int encode)
         if (profile)
             snprintf(buf + strlen(buf), buf_size - strlen(buf),
                      " (%s)", profile);
+        snprintf(buf + strlen(buf), buf_size - strlen(buf), "\n      ");
         if (enc->pix_fmt != AV_PIX_FMT_NONE) {
             snprintf(buf + strlen(buf), buf_size - strlen(buf),
-                     ", %s",
+                     "%s",
                      av_get_pix_fmt_name(enc->pix_fmt));
         }
         if (enc->width) {
+            if (new_line)
+                snprintf(buf + strlen(buf), buf_size - strlen(buf), "\n      
");
+            else
+                av_strlcat(buf, ", ", buf_size);
+
             snprintf(buf + strlen(buf), buf_size - strlen(buf),
-                     ", %dx%d",
+                     "%dx%d",
                      enc->width, enc->height);
+            av_strlcat(buf, ", ", buf_size);
             if (enc->sample_aspect_ratio.num) {
                 av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
                           enc->width * enc->sample_aspect_ratio.num,
                           enc->height * enc->sample_aspect_ratio.den,
                           1024 * 1024);
                 snprintf(buf + strlen(buf), buf_size - strlen(buf),
-                         " [PAR %d:%d DAR %d:%d]",
+                         "[PAR %d:%d DAR %d:%d] ",
                          enc->sample_aspect_ratio.num, 
enc->sample_aspect_ratio.den,
                          display_aspect_ratio.num, display_aspect_ratio.den);
             }
             if (av_log_get_level() >= AV_LOG_DEBUG) {
                 int g = av_gcd(enc->time_base.num, enc->time_base.den);
                 snprintf(buf + strlen(buf), buf_size - strlen(buf),
-                         ", %d/%d",
+                         "%d/%d, ",
                          enc->time_base.num / g, enc->time_base.den / g);
             }
         }
         if (encode) {
             snprintf(buf + strlen(buf), buf_size - strlen(buf),
-                     ", q=%d-%d", enc->qmin, enc->qmax);
+                     "q=%d-%d", enc->qmin, enc->qmax);
         }
         break;
     case AVMEDIA_TYPE_AUDIO:
@@ -1920,7 +1928,7 @@ void avcodec_string(char *buf, int buf_size, 
AVCodecContext *enc, int encode)
             snprintf(buf + strlen(buf), buf_size - strlen(buf),
                      ", %d Hz", enc->sample_rate);
         }
-        av_strlcat(buf, ", ", buf_size);
+        snprintf(buf + strlen(buf), buf_size - strlen(buf), "\n      ");
         av_get_channel_layout_string(buf + strlen(buf), buf_size - 
strlen(buf), enc->channels, enc->channel_layout);
         if (enc->sample_fmt != AV_SAMPLE_FMT_NONE) {
             snprintf(buf + strlen(buf), buf_size - strlen(buf),
@@ -1951,7 +1959,7 @@ void avcodec_string(char *buf, int buf_size, 
AVCodecContext *enc, int encode)
     bitrate = get_bit_rate(enc);
     if (bitrate != 0) {
         snprintf(buf + strlen(buf), buf_size - strlen(buf),
-                 ", %d kb/s", bitrate / 1000);
+                 "%d kb/s", bitrate / 1000);
     }
 }
 
diff --git a/libavformat/dump.c b/libavformat/dump.c
index 58ed654..649678c 100644
--- a/libavformat/dump.c
+++ b/libavformat/dump.c
@@ -116,11 +116,11 @@ 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);
+        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);
+        av_log(NULL, AV_LOG_INFO, "%1.0f %s", d, postfix);
     else
-        av_log(NULL, AV_LOG_INFO, ", %1.0fk %s", d / 1000, postfix);
+        av_log(NULL, AV_LOG_INFO, "%1.0fk %s", d / 1000, postfix);
 }
 
 static void dump_metadata(void *ctx, AVDictionary *m, const char *indent)
@@ -357,11 +357,17 @@ static void dump_stream_format(AVFormatContext *ic, int i,
     }
 
     if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
-        if (st->avg_frame_rate.den && st->avg_frame_rate.num)
-            print_fps(av_q2d(st->avg_frame_rate), "fps");
-        if (st->time_base.den && st->time_base.num)
-            print_fps(1 / av_q2d(st->time_base), "tbn");
-        if (st->codec->time_base.den && st->codec->time_base.num)
+        int fps = st->avg_frame_rate.den && st->avg_frame_rate.num;
+        int tbn = st->time_base.den && st->time_base.num;
+        int tbc = st->codec->time_base.den && st->codec->time_base.num;
+
+        if (fps || tbn || tbc)
+            av_log(NULL, AV_LOG_INFO, "\n      ");
+        if (fps)
+            print_fps(av_q2d(st->avg_frame_rate), tbn || tbc ? "fps, " : 
"fps");
+        if (tbn)
+            print_fps(1 / av_q2d(st->time_base), tbc ? "tbn, " : "tbn");
+        if (tbc)
             print_fps(1 / av_q2d(st->codec->time_base), "tbc");
     }
 
-- 
1.9.3 (Apple Git-50)

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to