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

ffmpegagent ffmpegagent at gmail.com
Sun Mar 9 21:01:22 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)


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)

softworkz (5):
  avutil/log: Add AV_LOG_PRINT_MEMADDRESSES logging flag
  fftools/opt_common: add memaddresses log flag
  fftools: Provide a an fftools-specific logging callback function
  doc/fftools-common-opts: document memaddresses log flag
  Remove commented lines

 doc/APIchanges               |   3 +
 doc/fftools-common-opts.texi |   2 +
 fftools/Makefile             |   7 +-
 fftools/ffmpeg.c             |   2 +
 fftools/ffmpeg_filter.c      |   2 +-
 fftools/ffplay.c             |   2 +
 fftools/ffprobe.c            |   2 +
 fftools/fftools_log.c        | 478 +++++++++++++++++++++++++++++++++++
 fftools/fftools_log.h        |  44 ++++
 fftools/opt_common.c         |   6 +
 libavutil/log.h              |   5 +
 libavutil/version.h          |   2 +-
 12 files changed, 552 insertions(+), 3 deletions(-)
 create mode 100644 fftools/fftools_log.c
 create mode 100644 fftools/fftools_log.h


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

Range-diff vs v4:

 1:  4be966796c = 1:  4be966796c avutil/log: Add AV_LOG_PRINT_MEMADDRESSES logging flag
 2:  e4f8213c24 = 2:  e4f8213c24 fftools/opt_common: add memaddresses log flag
 3:  fa1ae9231a ! 3:  ba20f5b116 fftools: Provide a an fftools-specific logging callback function
     @@ fftools/fftools_log.c (new)
      +#include <stdio.h>
      +#include <stdlib.h>
      +#include <string.h>
     ++#include <time.h>
     ++
      +#include "libavutil/bprint.h"
      +#include "libavutil/common.h"
      +//#include "libavutil/internal.h"
     @@ fftools/fftools_log.c (new)
      +#define localtime_r ff_localtime_r
      +#endif
      +
     -+static int nb_class_ids;
     -+
     -+#define NB_CLASS_IDS 1000
     ++#define MAX_CLASS_IDS 1000
      +static struct class_ids {
      +    void *avcl;
      +    uint64_t class_hash;
      +    unsigned id;
     -+} class_ids[NB_CLASS_IDS];
     ++} class_ids[MAX_CLASS_IDS];
      +
      +static uint64_t fnv_hash(const char *str)
      +{
     @@ fftools/fftools_log.c (new)
      +    unsigned i, nb_ids = 0;
      +    uint64_t class_hash;
      +
     -+    for (i = 0; i < NB_CLASS_IDS && class_ids[i].avcl; i++) {
     ++    for (i = 0; i < MAX_CLASS_IDS && class_ids[i].avcl; i++) {
      +        if (class_ids[i].avcl == avcl)
      +            return class_ids[i].id;
      +    }
      +
      +    class_hash = fnv_hash(avc->class_name);
      +
     -+    for (i = 0; i < NB_CLASS_IDS; i++) {
     ++    for (i = 0; i < MAX_CLASS_IDS; i++) {
      +        if (class_ids[i].class_hash == class_hash)
      +            nb_ids++;
      +
     @@ fftools/fftools_log.c (new)
      +        }
      +    }
      +
     -+    // exceeded NB_CLASS_IDS entries in class_ids[]
     ++    // exceeded MAX_CLASS_IDS entries in class_ids[]
      +    return 0;
      +}
      +
 4:  68a9ee6fbe = 4:  f689a432df doc/fftools-common-opts: document memaddresses log flag
 -:  ---------- > 5:  9429d11516 Remove commented lines

-- 
ffmpeg-codebot


More information about the ffmpeg-devel mailing list