[FFmpeg-devel] [PATCH v11 0/3] avutil/log: Add log flag to control printing of memory addresses

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


--and disable by default in fftools. The benefits are:

 * Smaller log file sizes
 * Makes log files better readable
 * 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] nal_unit_type: [hevc] Decoding PPS
[hevc] nal_unit_type: 39(SEI_P.. [hevc] Decoding SEI
[mp4] All info found
[mp4] After avformat_find_ [hevc] Decoded frame with POC 2.
[Parsed_scale_0] Setting 'w' t.. [Parsed_scale_0] Setting 'h' t..
[Parsed_scale_1] Setting 'w' t.. [mjpeg] Forcing thread count t.. [mjpeg]
intra_quant_bias = 96


Versions
========


V2
==

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


V3
==

 * Externalize the prefix formatting with a prefix_format callback


V4
==

 * Implement a custom logging callback function for fftools instead of the
   prefix formatting callback (as suggested by Hendrik Leppkes)


V5
==

 * Remove unused var
 * Add missing include to fix build error on PPC (thanks, Michael)


V6
==

 * No more changes to avutil involved
 * Let fftools have its own management of log level and flags (as figured to
   be most likely what Nicolas George was alluding to)


V7
==

 * Minimal version without "simple id" substitution
 * Defaults for printing mem addresses:
   * fftools: off
   * avutil: on


V8
==

 * Negated flag logic
 * Use singular naming
 * Fix flag doc text (thanks, Andreas!)


V9
==

 * Rename 'memaddress' to 'mem' for CLI (as suggested by Gyan)


V10
===

 * Print 'mem' flag in help outrput (thanks, Gyan)


V11
===

 * Reversed logic again and renamed flag back to AV_LOG_PRINT_MEMADDRESS
 * Default behavior: Memory addresses are not printed

.

softworkz (3):
  avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESS and hide addresses by
    default
  fftools: add mem log flag for printing memory addresses
  doc/fftools-common-opts: document mem log flag

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


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

Range-diff vs v10:

 1:  0ce5bd11d7 ! 1:  0253bb9e68 avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES
     @@ Metadata
      Author: softworkz <softworkz at hotmail.com>
      
       ## Commit message ##
     -    avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES
     +    avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESS and hide addresses by default
      
     -    which is controls prefix formatting. With this flag set, the prefix is
     -    printed without the memory address, otherwise it is included.
     +    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
      @@
       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_NO_PRINT_MEMADDRESS
     ++2025-03-xx - xxxxxxxxxx - lavu 60.4.100 - log.h
     ++  Add flag AV_LOG_PRINT_MEMADDRESS
      +
       API changes, most recent first:
       
     - 2025-04-07 - 19e9a203b7 - lavu 60.01.100 - dict.h
     + 2025-05-21 - xxxxxxxxxx - lavu 60.3.100 - avassert.h
      
       ## libavutil/log.c ##
      @@ libavutil/log.c: 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_NO_PRINT_MEMADDRESS ? "[%s] " : "[%s @ %p] ";
     ++        const char *p_fmt = flags & AV_LOG_PRINT_MEMADDRESS ? "[%s @ %p] " : "[%s] ";
      +
               if (avc->parent_log_context_offset) {
                   AVClass** parent = *(AVClass ***) (((uint8_t *) avcl) +
     @@ libavutil/log.h: int av_log_format_line2(void *ptr, int level, const char *fmt,
       #define AV_LOG_PRINT_DATETIME 8
       
      +/**
     -+ * Do not print memory addresses of context instances.
     ++ * Print memory addresses of context instances.
      + */
     -+#define AV_LOG_NO_PRINT_MEMADDRESS 16
     ++#define AV_LOG_PRINT_MEMADDRESS 16
      +
       void av_log_set_flags(int arg);
       int av_log_get_flags(void);
     @@ libavutil/version.h
        */
       
       #define LIBAVUTIL_VERSION_MAJOR  60
     --#define LIBAVUTIL_VERSION_MINOR   1
     -+#define LIBAVUTIL_VERSION_MINOR   2
     +-#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, \
 2:  207dedbff6 ! 2:  fd66ba0b05 fftools: add mem log flag and disable printing addresses by default
     @@ Metadata
      Author: softworkz <softworkz at hotmail.com>
      
       ## Commit message ##
     -    fftools: add mem log flag and disable printing addresses by default
     +    fftools: add mem log flag for printing memory addresses
      
          This commit adds the mem log flag.
          When specifying this flag at the command line, context prefixes will
     @@ Commit message
      
          Signed-off-by: softworkz <softworkz at hotmail.com>
      
     - ## fftools/ffmpeg.c ##
     -@@ fftools/ffmpeg.c: int main(int argc, char **argv)
     - 
     -     setvbuf(stderr,NULL,_IONBF,0); /* win32 runtime needs this */
     - 
     --    av_log_set_flags(AV_LOG_SKIP_REPEATED);
     -+    av_log_set_flags(AV_LOG_SKIP_REPEATED | AV_LOG_NO_PRINT_MEMADDRESS);
     -     parse_loglevel(argc, argv, options);
     - 
     - #if CONFIG_AVDEVICE
     -
     - ## fftools/ffplay.c ##
     -@@ fftools/ffplay.c: int main(int argc, char **argv)
     - 
     -     init_dynload();
     - 
     --    av_log_set_flags(AV_LOG_SKIP_REPEATED);
     -+    av_log_set_flags(AV_LOG_SKIP_REPEATED | AV_LOG_NO_PRINT_MEMADDRESS);
     -     parse_loglevel(argc, argv, options);
     - 
     -     /* register all codecs, demux and protocols */
     -
     - ## fftools/ffprobe.c ##
     -@@ fftools/ffprobe.c: int main(int argc, char **argv)
     - 
     -     init_dynload();
     - 
     --    av_log_set_flags(AV_LOG_SKIP_REPEATED);
     -+    av_log_set_flags(AV_LOG_SKIP_REPEATED | AV_LOG_NO_PRINT_MEMADDRESS);
     - 
     -     options = real_options;
     -     parse_loglevel(argc, argv, options);
     -
       ## fftools/opt_common.c ##
      @@ fftools/opt_common.c: int opt_loglevel(void *optctx, const char *opt, const char *arg)
                   } else {
     @@ fftools/opt_common.c: int opt_loglevel(void *optctx, const char *opt, const char
                   }
      +        } else if (av_strstart(token, "mem", &arg)) {
      +            if (cmd == '-') {
     -+                flags |= AV_LOG_NO_PRINT_MEMADDRESS;
     ++                flags &= ~AV_LOG_PRINT_MEMADDRESS;
      +            } else {
     -+                flags &= ~AV_LOG_NO_PRINT_MEMADDRESS;
     ++                flags |= AV_LOG_PRINT_MEMADDRESS;
      +            }
               } else {
                   break;
 3:  dc334f3eeb = 3:  fd233fb2cf doc/fftools-common-opts: document mem log flag

-- 
ffmpeg-codebot


More information about the ffmpeg-devel mailing list