[FFmpeg-devel] [PATCH 3/4] fftools/ffprobe: Simplify printing xml values
Andreas Rheinhardt
andreas.rheinhardt at outlook.com
Thu Feb 22 02:33:57 EET 2024
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
fftools/ffprobe.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index e63935baba..31081d19e2 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -1860,7 +1860,8 @@ static void xml_print_section_footer(WriterContext *wctx)
}
}
-static void xml_print_value(WriterContext *wctx, const char *key, const void *value, const int is_int)
+static void xml_print_value(WriterContext *wctx, const char *key,
+ const char *str, long long int num, const int is_int)
{
AVBPrint buf;
XMLContext *xml = wctx->priv;
@@ -1878,9 +1879,9 @@ static void xml_print_value(WriterContext *wctx, const char *key, const void *va
av_bprint_clear(&buf);
if (is_int) {
- writer_printf(wctx, " value=\"%lld\"/>\n", *(long long int *)value);
+ writer_printf(wctx, " value=\"%lld\"/>\n", num);
} else {
- av_bprint_escape(&buf, (const char *)value, NULL,
+ av_bprint_escape(&buf, str, NULL,
AV_ESCAPE_MODE_XML, AV_ESCAPE_FLAG_XML_DOUBLE_QUOTES);
writer_printf(wctx, " value=\"%s\"/>\n", buf.str);
}
@@ -1890,9 +1891,9 @@ static void xml_print_value(WriterContext *wctx, const char *key, const void *va
writer_w8(wctx, ' ');
if (is_int) {
- writer_printf(wctx, "%s=\"%lld\"", key, *(long long int *)value);
+ writer_printf(wctx, "%s=\"%lld\"", key, num);
} else {
- av_bprint_escape(&buf, (const char *)value, NULL,
+ av_bprint_escape(&buf, str, NULL,
AV_ESCAPE_MODE_XML, AV_ESCAPE_FLAG_XML_DOUBLE_QUOTES);
writer_printf(wctx, "%s=\"%s\"", key, buf.str);
}
@@ -1902,11 +1903,11 @@ static void xml_print_value(WriterContext *wctx, const char *key, const void *va
}
static inline void xml_print_str(WriterContext *wctx, const char *key, const char *value) {
- xml_print_value(wctx, key, (const void *)value, 0);
+ xml_print_value(wctx, key, value, 0, 0);
}
static inline void xml_print_int(WriterContext *wctx, const char *key, long long int value) {
- xml_print_value(wctx, key, (const void *)&value, 1);
+ xml_print_value(wctx, key, NULL, value, 1);
}
static Writer xml_writer = {
--
2.40.1
More information about the ffmpeg-devel
mailing list