[FFmpeg-devel] [PATCH] ffprobe: prefer lower cased section names over upper cased names

Stefano Sabatini stefasab at gmail.com
Sun Oct 9 00:46:17 CEST 2011


This is consistent with the chapter names. The default writer section
names are converted to upper case for keeping backward compatibility.
---
 ffprobe.c |   25 +++++++++++++++++--------
 1 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/ffprobe.c b/ffprobe.c
index 82a8f54..1568d2b 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -336,16 +336,25 @@ static void default_print_chapter_header(WriterContext *wctx, const char *chapte
         printf("\n");
 }
 
+/* lame uppercasing routine, assumes the string is lower case ASCII */
+static void print_upcased(const char *s)
+{
+    while (*s) {
+        printf("%c", *s - 32);
+        s++;
+    }
+}
+
 static void default_print_section_header(WriterContext *wctx, const char *section)
 {
     if (wctx->nb_section)
         printf("\n");
-    printf("[%s]\n", section);
+    printf("["); print_upcased(section); printf("]\n");
 }
 
 static void default_print_section_footer(WriterContext *wctx, const char *section)
 {
-    printf("[/%s]", section);
+    printf("[/"); print_upcased(section); printf("]");
 }
 
 static void default_print_str(WriterContext *wctx, const char *key, const char *value)
@@ -550,7 +559,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 +571,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 +597,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 +660,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 +677,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 +687,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);
 }
-- 
1.7.4.1



More information about the ffmpeg-devel mailing list