[FFmpeg-cvslog] lavf: Rewrite metadata printing from dump_metadata().

Michael Niedermayer git at videolan.org
Fri Feb 10 06:30:26 CET 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Fri Feb 10 02:39:14 2012 +0100| [789d6b73cf8120fc411a8862c4ffb7e533607245] | committer: Michael Niedermayer

lavf: Rewrite metadata printing from dump_metadata().

This code contained several bugs that mis-formated the output.

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=789d6b73cf8120fc411a8862c4ffb7e533607245
---

 libavformat/utils.c |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 71baf58..4989437 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3483,11 +3483,19 @@ static void dump_metadata(void *ctx, AVDictionary *m, const char *indent)
         av_log(ctx, AV_LOG_INFO, "%sMetadata:\n", indent);
         while((tag=av_dict_get(m, "", tag, AV_DICT_IGNORE_SUFFIX))) {
             if(strcmp("language", tag->key)){
-                char tmp[256];
-                int i;
-                av_strlcpy(tmp, tag->value, sizeof(tmp));
-                for(i=0; i<strlen(tmp); i++) if(tmp[i]==0xd) tmp[i]=' ';
-                av_log(ctx, AV_LOG_INFO, "%s  %-16s: %s\n", indent, tag->key, tmp);
+                const char *p = tag->value;
+                av_log(ctx, AV_LOG_INFO, "%s  %-16s: ", indent, tag->key);
+                while(*p) {
+                    char tmp[256];
+                    size_t len = strcspn(p, "\xd\xa");
+                    av_strlcpy(tmp, p, FFMIN(sizeof(tmp), len+1));
+                    av_log(ctx, AV_LOG_INFO, "%s", tmp);
+                    p += len;
+                    if (*p == 0xd) av_log(ctx, AV_LOG_INFO, " ");
+                    if (*p == 0xa) av_log(ctx, AV_LOG_INFO, "\n%s  %-16s: ", indent, "");
+                    if (*p) p++;
+                }
+                av_log(ctx, AV_LOG_INFO, "\n");
             }
         }
     }



More information about the ffmpeg-cvslog mailing list