[FFmpeg-cvslog] ffprobe: prefer lowercase section names over uppercase ones

Stefano Sabatini git at videolan.org
Tue Oct 11 00:25:55 CEST 2011


ffmpeg | branch: master | Stefano Sabatini <stefasab at gmail.com> | Sun Oct  9 00:38:34 2011 +0200| [fbb8468f205aa118b3701db56b134f3f173a13ad] | committer: Stefano Sabatini

ffprobe: prefer lowercase section names over uppercase ones

This is consistent with chapter names. The default writer section names
are converted to uppercase for keeping backward compatibility.

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

 ffprobe.c |   30 ++++++++++++++++++++++--------
 1 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/ffprobe.c b/ffprobe.c
index 82a8f54..b64f616 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -336,16 +336,30 @@ static void default_print_chapter_header(WriterContext *wctx, const char *chapte
         printf("\n");
 }
 
+/* lame uppercasing routine, assumes the string is lower case ASCII */
+static inline char *upcase_string(char *dst, size_t dst_size, const char *src)
+{
+    int i;
+    for (i = 0; src[i] && i < dst_size-1; i++)
+        dst[i] = src[i]-32;
+    dst[i] = 0;
+    return dst;
+}
+
 static void default_print_section_header(WriterContext *wctx, const char *section)
 {
+    char buf[32];
+
     if (wctx->nb_section)
         printf("\n");
-    printf("[%s]\n", section);
+    printf("[%s]\n", upcase_string(buf, sizeof(buf), section));
 }
 
 static void default_print_section_footer(WriterContext *wctx, const char *section)
 {
-    printf("[/%s]", section);
+    char buf[32];
+
+    printf("[/%s]", upcase_string(buf, sizeof(buf), section));
 }
 
 static void default_print_str(WriterContext *wctx, const char *key, const char *value)
@@ -550,7 +564,7 @@ static void show_packet(WriterContext *w, AVFormatContext *fmt_ctx, AVPacket *pk
     AVStream *st = fmt_ctx->streams[pkt->stream_index];
     struct print_buf pbuf = {.s = NULL};
 
-    print_section_header("PACKET");
+    print_section_header("packet");
     print_str("codec_type",       av_x_if_null(av_get_media_type_string(st->codec->codec_type), "unknown"));
     print_int("stream_index",     pkt->stream_index);
     print_str("pts",              ts_value_string  (val_str, sizeof(val_str), pkt->pts));
@@ -562,7 +576,7 @@ static void show_packet(WriterContext *w, AVFormatContext *fmt_ctx, AVPacket *pk
     print_str("size",             value_string     (val_str, sizeof(val_str), pkt->size, unit_byte_str));
     print_fmt("pos",   "%"PRId64, pkt->pos);
     print_fmt("flags", "%c",      pkt->flags & AV_PKT_FLAG_KEY ? 'K' : '_');
-    print_section_footer("PACKET");
+    print_section_footer("packet");
 
     av_free(pbuf.s);
     fflush(stdout);
@@ -588,7 +602,7 @@ static void show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_i
     AVRational display_aspect_ratio;
     struct print_buf pbuf = {.s = NULL};
 
-    print_section_header("STREAM");
+    print_section_header("stream");
 
     print_int("index", stream->index);
 
@@ -651,7 +665,7 @@ static void show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_i
 
     show_tags(stream->metadata);
 
-    print_section_footer("STREAM");
+    print_section_footer("stream");
     av_free(pbuf.s);
     fflush(stdout);
 }
@@ -668,7 +682,7 @@ static void show_format(WriterContext *w, AVFormatContext *fmt_ctx)
     char val_str[128];
     struct print_buf pbuf = {.s = NULL};
 
-    print_section_header("FORMAT");
+    print_section_header("format");
     print_str("filename",         fmt_ctx->filename);
     print_int("nb_streams",       fmt_ctx->nb_streams);
     print_str("format_name",      fmt_ctx->iformat->name);
@@ -678,7 +692,7 @@ static void show_format(WriterContext *w, AVFormatContext *fmt_ctx)
     print_str("size",             value_string(val_str, sizeof(val_str), fmt_ctx->file_size, unit_byte_str));
     print_str("bit_rate",         value_string(val_str, sizeof(val_str), fmt_ctx->bit_rate,  unit_bit_per_second_str));
     show_tags(fmt_ctx->metadata);
-    print_section_footer("FORMAT");
+    print_section_footer("format");
     av_free(pbuf.s);
     fflush(stdout);
 }



More information about the ffmpeg-cvslog mailing list