[FFmpeg-devel] [PATCH v2 0/3] avutil/log: Replace addresses in log output with simple ids

ffmpegagent ffmpegagent at gmail.com
Wed Mar 5 20:19:40 EET 2025


..and individual numbering. The benefits are:

 * Smaller log file sizes
 * The disambiguation is much easier to recognize and to follow
 * It eventually allows comparing and viewing log file diffs without almost
   every line being different due to those addresses


Before
======

[hevc @ 0000018e72a89cc0] nal_unit_type:
[hevc @ 0000018e72a89cc0] Decoding PPS
[hevc @ 0000018e72a89cc0] nal_unit_type: 39(SEI_P.. [hevc @
0000018e72a89cc0] Decoding SEI
[mp4 @ 0000018e72a8e240] All [mp4 @ 0000018e72a8e240] Afte [hevc @
0000018e742f6b40] Decoded frame with POC .. detected 16 logical cores
[Parsed_scale_0 @ 0000018e74382f40] Setting 'w' t.. [Parsed_scale_0 @
0000018e74382f40] Setting 'h' t.. [Parsed_scale_1 @ 0000018e74382440]
Setting 'w' t.. [mjpeg @ 0000018e743210c0] Forcing thread count t.. [mjpeg @
0000018e743210c0] intra_quant_bias = 96


After
=====

[hevc #0] nal_unit_type: [hevc #0] Decoding PPS
[hevc #0] nal_unit_type: 39(SEI_P.. [hevc #0] Decoding SEI
[mp4 #0] All info found
[mp4 #0] After avformat_find_ [hevc #1] Decoded frame with POC 2.
[Parsed_scale_0 #0] Setting 'w' t.. [Parsed_scale_0 #0] Setting 'h' t..
[Parsed_scale_1 #1] Setting 'w' t.. [mjpeg #2] Forcing thread count t..
[mjpeg #2] intra_quant_bias = 96


Versions
========


V2
==

 * Added log flag for optionally restoring the previous behavior (as
   requested by Gyan)

softworkz (3):
  avutil/log: Replace addresses in log output with simple ids
  fftools/opt_common: add memaddresses log flag
  doc/fftools-common-opts: document memaddresses log flag

 doc/APIchanges               |  3 ++
 doc/fftools-common-opts.texi |  2 ++
 fftools/opt_common.c         |  6 ++++
 libavutil/log.c              | 68 ++++++++++++++++++++++++++++++++----
 libavutil/log.h              |  5 +++
 libavutil/version.h          |  2 +-
 6 files changed, 79 insertions(+), 7 deletions(-)


base-commit: 5c5be37daff4f4ecbe0c20d6a9f0fdad6eadc9c8
Published-As: https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-59%2Fsoftworkz%2Fsubmit_logaddresses-v2
Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg pr-ffstaging-59/softworkz/submit_logaddresses-v2
Pull-Request: https://github.com/ffstaging/FFmpeg/pull/59

Range-diff vs v1:

 1:  e686825b2a ! 1:  3a289533a7 avutil/log: Replace addresses in log output with simple ids
     @@ Commit message
      
          Signed-off-by: softworkz <softworkz at hotmail.com>
      
     + ## doc/APIchanges ##
     +@@
     + The last version increases of all libraries were on 2024-03-07
     + 
     ++2025-03-xx - xxxxxxxxxx - lavu 59.59.100 - log.h
     ++  Add flag AV_LOG_PRINT_MEMADDRESSES.
     ++
     + API changes, most recent first:
     + 
     + 2025-03-01 - xxxxxxxxxx - lavu 59.58.100 - pixfmt.h
     +
       ## libavutil/log.c ##
      @@ libavutil/log.c: static AVMutex mutex = AV_MUTEX_INITIALIZER;
       
     @@ libavutil/log.c: static AVMutex mutex = AV_MUTEX_INITIALIZER;
       #define NB_LEVELS 8
       #if defined(_WIN32) && HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
      @@ libavutil/log.c: static void format_line(void *avcl, int level, const char *fmt, va_list vl,
     -             AVClass** parent = *(AVClass ***) (((uint8_t *) avcl) +
     -                                    avc->parent_log_context_offset);
     + 
     +     if(type) type[0] = type[1] = AV_CLASS_CATEGORY_NA + 16;
     +     if (*print_prefix && avc) {
     ++        const int print_mem = flags & AV_LOG_PRINT_MEMADDRESSES;
     ++
     +         if (avc->parent_log_context_offset) {
     +-            AVClass** parent = *(AVClass ***) (((uint8_t *) avcl) +
     +-                                   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] ",
      -                           item_name(parent, *parent), parent);
     -+                av_bprintf(part+0, "[%s #%u] ",
     -+                           item_name(parent, *parent), get_class_id(parent));
     ++                if (print_mem)
     ++                    av_bprintf(part+0, "[%s @ %p] ", item_name(parent, *parent), parent);
     ++                else
     ++                    av_bprintf(part+0, "[%s #%u] ", item_name(parent, *parent), get_class_id(parent));
     ++
                       if(type) type[0] = get_category(parent);
                   }
               }
      -        av_bprintf(part+1, "[%s @ %p] ",
      -                   item_name(avcl, avc), avcl);
     -+        av_bprintf(part+1, "[%s #%u] ",
     -+                   item_name(avcl, avc), get_class_id(avcl));
     ++        if (print_mem)
     ++            av_bprintf(part+1, "[%s @ %p] ", item_name(avcl, avc), avcl);
     ++        else
     ++            av_bprintf(part+1, "[%s #%u] ", item_name(avcl, avc), get_class_id(avcl));
     ++
               if(type) type[1] = get_category(avcl);
           }
       
     +
     + ## libavutil/log.h ##
     +@@ libavutil/log.h: 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);
     + 
     +
     + ## libavutil/version.h ##
     +@@
     +  */
     + 
     + #define LIBAVUTIL_VERSION_MAJOR  59
     +-#define LIBAVUTIL_VERSION_MINOR  58
     ++#define LIBAVUTIL_VERSION_MINOR  59
     + #define LIBAVUTIL_VERSION_MICRO 100
     + 
     + #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
 -:  ---------- > 2:  858e2cca9c fftools/opt_common: add memaddresses log flag
 -:  ---------- > 3:  411c77bdeb doc/fftools-common-opts: document memaddresses log flag

-- 
ffmpeg-codebot


More information about the ffmpeg-devel mailing list