[FFmpeg-devel] [PATCH] ffprobe: reduce the number of AVBPrint resets.
Clément Bœsch
ubitux at gmail.com
Sat May 26 01:28:45 CEST 2012
---
ffprobe.c | 26 ++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/ffprobe.c b/ffprobe.c
index d53ec11..cbcc708 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -662,19 +662,16 @@ static void compact_show_tags(WriterContext *wctx, AVDictionary *dict)
AVDictionaryEntry *tag = NULL;
AVBPrint buf;
+ av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
while ((tag = av_dict_get(dict, "", tag, AV_DICT_IGNORE_SUFFIX))) {
if (wctx->nb_item) printf("%c", compact->item_sep);
-
- if (!compact->nokey) {
- av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
+ av_bprint_clear(&buf);
+ if (!compact->nokey)
printf("tag:%s=", compact->escape_str(&buf, tag->key, compact->item_sep, wctx));
- av_bprint_finalize(&buf, NULL);
- }
-
- av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
+ av_bprint_clear(&buf);
printf("%s", compact->escape_str(&buf, tag->value, compact->item_sep, wctx));
- av_bprint_finalize(&buf, NULL);
}
+ av_bprint_finalize(&buf, NULL);
}
static const Writer compact_writer = {
@@ -867,9 +864,7 @@ static inline void json_print_item_str(WriterContext *wctx,
av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
printf("\"%s\":", json_escape_str(&buf, key, wctx));
- av_bprint_finalize(&buf, NULL);
-
- av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
+ av_bprint_clear(&buf);
printf(" \"%s\"", json_escape_str(&buf, value, wctx));
av_bprint_finalize(&buf, NULL);
}
@@ -1124,6 +1119,7 @@ static void xml_show_tags(WriterContext *wctx, AVDictionary *dict)
int is_first = 1;
AVBPrint buf;
+ av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
xml->indent_level++;
while ((tag = av_dict_get(dict, "", tag, AV_DICT_IGNORE_SUFFIX))) {
if (is_first) {
@@ -1134,14 +1130,12 @@ static void xml_show_tags(WriterContext *wctx, AVDictionary *dict)
}
XML_INDENT();
- av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
+ av_bprint_clear(&buf);
printf("<tag key=\"%s\"", xml_escape_str(&buf, tag->key, wctx));
- av_bprint_finalize(&buf, NULL);
-
- av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
+ av_bprint_clear(&buf);
printf(" value=\"%s\"/>\n", xml_escape_str(&buf, tag->value, wctx));
- av_bprint_finalize(&buf, NULL);
}
+ av_bprint_finalize(&buf, NULL);
xml->indent_level--;
}
--
1.7.10.2
More information about the ffmpeg-devel
mailing list