[FFmpeg-devel] [PATCH v11 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESS and hide addresses by default

softworkz ffmpegagent at gmail.com
Fri Jun 6 23:29:28 EEST 2025


From: softworkz <softworkz at hotmail.com>

Memory addresses are no longer printed by default.
With this flag set, memory addresses are included like
in earlier versions.

Signed-off-by: softworkz <softworkz at hotmail.com>
---
 doc/APIchanges      | 3 +++
 libavutil/log.c     | 6 ++++--
 libavutil/log.h     | 5 +++++
 libavutil/version.h | 2 +-
 4 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 91710bb27d..244fff4e1c 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.4.100 - log.h
+  Add flag AV_LOG_PRINT_MEMADDRESS
+
 API changes, most recent first:
 
 2025-05-21 - xxxxxxxxxx - lavu 60.3.100 - avassert.h
diff --git a/libavutil/log.c b/libavutil/log.c
index 2b721aea5a..d09db1ebf6 100644
--- a/libavutil/log.c
+++ b/libavutil/log.c
@@ -328,16 +328,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_MEMADDRESS ? "[%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 ac5b08b632..79e44d97d9 100644
--- a/libavutil/log.h
+++ b/libavutil/log.h
@@ -417,6 +417,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 of context instances.
+ */
+#define AV_LOG_PRINT_MEMADDRESS 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 2979f80233..6e82f039c5 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  60
-#define LIBAVUTIL_VERSION_MINOR   3
+#define LIBAVUTIL_VERSION_MINOR   4
 #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