[FFmpeg-devel] [PATCH v7 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES
softworkz
ffmpegagent at gmail.com
Wed Apr 9 08:55:00 EEST 2025
From: softworkz <softworkz at hotmail.com>
which is controls prefix formatting. With this flag set, the prefix is
printed including the memory address, otherwise it is omitted.
In libavutil, the flag is set by default, retaining the previous
behavior. fftools remove the flag as default.
Signed-off-by: softworkz <softworkz at hotmail.com>
---
doc/APIchanges | 3 +++
libavutil/log.c | 8 +++++---
libavutil/log.h | 5 +++++
libavutil/version.h | 2 +-
4 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index 65bf5a9419..27afa5ba81 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -1,5 +1,8 @@
The last version increases of all libraries were on 2025-03-28
+2025-03-xx - xxxxxxxxxx - lavu 60.2.100 - log.h
+ Add flag AV_LOG_PRINT_MEMADDRESSES
+
API changes, most recent first:
2025-04-07 - 19e9a203b7 - lavu 60.01.100 - dict.h
diff --git a/libavutil/log.c b/libavutil/log.c
index c5ee876a88..7ce23cc31f 100644
--- a/libavutil/log.c
+++ b/libavutil/log.c
@@ -56,7 +56,7 @@ static AVMutex mutex = AV_MUTEX_INITIALIZER;
#endif
static int av_log_level = AV_LOG_INFO;
-static int flags;
+static int flags = AV_LOG_PRINT_MEMADDRESSES;
#define NB_LEVELS 8
#if defined(_WIN32) && HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
@@ -327,16 +327,18 @@ static void format_line(void *avcl, int level, const char *fmt, va_list vl,
if(type) type[0] = type[1] = AV_CLASS_CATEGORY_NA + 16;
if (*print_prefix && avc) {
+ const char *p_fmt = flags & AV_LOG_PRINT_MEMADDRESSES ? "[%s @ %p] " : "[%s] ";
+
if (avc->parent_log_context_offset) {
AVClass** parent = *(AVClass ***) (((uint8_t *) avcl) +
avc->parent_log_context_offset);
if (parent && *parent) {
- av_bprintf(part+0, "[%s @ %p] ",
+ av_bprintf(part+0, p_fmt,
item_name(parent, *parent), parent);
if(type) type[0] = get_category(parent);
}
}
- av_bprintf(part+1, "[%s @ %p] ",
+ av_bprintf(part+1, p_fmt,
item_name(avcl, avc), avcl);
if(type) type[1] = get_category(avcl);
}
diff --git a/libavutil/log.h b/libavutil/log.h
index dd094307ce..450b4544b9 100644
--- a/libavutil/log.h
+++ b/libavutil/log.h
@@ -416,6 +416,11 @@ int av_log_format_line2(void *ptr, int level, const char *fmt, va_list vl,
*/
#define AV_LOG_PRINT_DATETIME 8
+/**
+ * Print memory addresses instead of logical ids in the AVClass prefix.
+ */
+#define AV_LOG_PRINT_MEMADDRESSES 16
+
void av_log_set_flags(int arg);
int av_log_get_flags(void);
diff --git a/libavutil/version.h b/libavutil/version.h
index 5139883569..4717cd562b 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 60
-#define LIBAVUTIL_VERSION_MINOR 1
+#define LIBAVUTIL_VERSION_MINOR 2
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
--
ffmpeg-codebot
More information about the ffmpeg-devel
mailing list