From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <ffmpeg-devel-bounces@ffmpeg.org>
Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100])
	by master.gitmailbox.com (Postfix) with ESMTPS id 34E3A4C707
	for <ffmpegdev@gitmailbox.com>; Wed,  9 Apr 2025 05:55:21 +0000 (UTC)
Received: from [127.0.1.1] (localhost [127.0.0.1])
	by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2F0D4687DC3;
	Wed,  9 Apr 2025 08:55:17 +0300 (EEST)
Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com
 [209.85.214.175])
 by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9C864687DBD
 for <ffmpeg-devel@ffmpeg.org>; Wed,  9 Apr 2025 08:55:10 +0300 (EEST)
Received: by mail-pl1-f175.google.com with SMTP id
 d9443c01a7336-227b650504fso58093725ad.0
 for <ffmpeg-devel@ffmpeg.org>; Tue, 08 Apr 2025 22:55:10 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1744178108; x=1744782908; darn=ffmpeg.org;
 h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from
 :references:in-reply-to:message-id:from:to:cc:subject:date
 :message-id:reply-to;
 bh=Sv8Ku1osKpITBqsuQ8tnknSIxhAUTWv9E/vhUE+3oPE=;
 b=fLFWVgjKUpVUfCbfJ1efYP/Er1/cFdNcECLc445mFJgbFQu5k/VTh+SqagXduRqQu3
 RkwuIEHmE6KiDfAUR9appR3N1ZQgiqLgvu3hnyF1n+ld0HP0vLPDTcBVT+tc4BE5OPux
 Z6GToIXDwYqd3C2++J94Dlm6SE4Ya2xjJ/IHpR5RNGxm1HeL4N4XYK991RglkNiAyU3Z
 hqopp+LQpGjFzlWCHE9oevsD+VA7mH0ZbpC7EFpcuhXveymMIjW6ZOAhFosTsQycLRw6
 cWKBiKh5/iLNmlhFWfyIb7G9bsfjOLKJ07qhb6NIJ3YAW+VoESee1DtETIwptZOneK5N
 jGrQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1744178108; x=1744782908;
 h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from
 :references:in-reply-to:message-id:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=Sv8Ku1osKpITBqsuQ8tnknSIxhAUTWv9E/vhUE+3oPE=;
 b=MBD3PRQhJO9YdO13XMGCTLoo1INxdcaQormYuBb3r/fdRuUW/eFBGzb0GmFvbZ3x7H
 2kV2qjZVcBPyNDA1PdLVCCHvMmFTGNnXaOHe7HHa5o0/ycmu7DSToXIAbB0/0WrbDL5x
 tYY6T+lv99LyBdVXDTHr/5fY6tfNGrRB6MdEOnGofo8mGy9kZdx+1cNgYfarH3A+egSg
 3NOSefk4lFvhP3n1vEFvznl2nVJqBTg3GNY/nJWJuUNg/y+k7y/lgu4iqHEglRfiIHbS
 vNL8zbFKdHJ7TWFNgKVhHLREC0swq6Y+Ji0kNA6E6EhICqnO+iNZ+S4tgoxeTFH5lAxC
 jP9A==
X-Gm-Message-State: AOJu0Yx2mzJ96H8Hp0zrzgm6Vrpuv1OQHCPR6rpFUBGvqzWI0wd36NkC
 cyaXrv+QDW+NEjMAs3I8UX3AUSRgA3mH6dOuaHpzbu7rwEp//fXeSj8JMQ==
X-Gm-Gg: ASbGncvtvUuOSR7iA6Z75PbXYKujL6iFjv+MIRZd9Krh4DkU6DcVthiBpTiPWE6Xf7L
 ag5eZ8Oh1Z2jep9Mms257MIuCqFl7tuO+VbDsEGIKKRxcSsqQcHFXaeDSTcp40DPkqAHBtae7wA
 kHS/XJYQm87f+qdbTicbTLcFbYb2ijLOi8KmDsf8SL9TDC4cAD0ot+2cnftSJ8wih2rexKiuyx3
 1VpzPiEB+ytO+1joibuRrKYOsIE3cVc+7Ep8pHWgJF2mJgwWQW07TCDtzlwfCH0UxexbsVKOD+P
 fhUM/4Elr5KEXDNzeLv3fckViJN/yH44Z9SZWde+2Me50VFIQ1vrmuLUc+E=
X-Google-Smtp-Source: AGHT+IGBoCHZR5O4RA4KsxXuIjhJhuF3nGYPcamS80A5CIcdMKMoBryJzXuk81k3WMZ6ILM5L0uCuQ==
X-Received: by 2002:a17:902:f68a:b0:224:6ee:ad with SMTP id
 d9443c01a7336-22ac400e421mr19499125ad.44.1744178108269; 
 Tue, 08 Apr 2025 22:55:08 -0700 (PDT)
Received: from [127.0.0.1] (master.gitmailbox.com. [34.83.118.50])
 by smtp.gmail.com with ESMTPSA id
 d9443c01a7336-22ac7ccb5basm3257515ad.234.2025.04.08.22.55.07
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Tue, 08 Apr 2025 22:55:07 -0700 (PDT)
Message-Id: <pull.59.v7.ffstaging.FFmpeg.1744178102.ffmpegagent@gmail.com>
In-Reply-To: <pull.59.v6.ffstaging.FFmpeg.1741858241.ffmpegagent@gmail.com>
References: <pull.59.v6.ffstaging.FFmpeg.1741858241.ffmpegagent@gmail.com>
From: ffmpegagent <ffmpegagent@gmail.com>
Date: Wed, 09 Apr 2025 05:54:59 +0000
Fcc: Sent
MIME-Version: 1.0
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH v7 0/3] avutil/log: Add log flag to control
 printing of memory addresses
X-BeenThere: ffmpeg-devel@ffmpeg.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: FFmpeg development discussions and patches <ffmpeg-devel.ffmpeg.org>
List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe>
List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel>
List-Post: <mailto:ffmpeg-devel@ffmpeg.org>
List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help>
List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe>
Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Cc: softworkz <softworkz@hotmail.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: ffmpeg-devel-bounces@ffmpeg.org
Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org>
Archived-At: <https://master.gitmailbox.com/ffmpegdev/pull.59.v7.ffstaging.FFmpeg.1744178102.ffmpegagent@gmail.com/>
List-Archive: <https://master.gitmailbox.com/ffmpegdev/>
List-Post: <mailto:ffmpegdev@gitmailbox.com>

--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

softworkz (3):
  avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES
  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         | 10 ++++++++++
 libavutil/log.c              |  8 +++++---
 libavutil/log.h              |  5 +++++
 libavutil/version.h          |  2 +-
 6 files changed, 26 insertions(+), 4 deletions(-)


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

Range-diff vs v6:

 1:  8080f15800 < -:  ---------- fftools: Add a local logging callback function
 2:  bab6b91549 ! 1:  6c2d6f1e97 fftools/opt_common: add memaddresses log flag
     @@ Metadata
      Author: softworkz <softworkz@hotmail.com>
      
       ## Commit message ##
     -    fftools/opt_common: add memaddresses log flag
     +    avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES
      
     -    This commit adds the memaddresses log flag.
     -    When specifying this flag at the command line, context prefixes will
     -    be printed with memory addresses like in earlier ffmpeg versions.
     -    Memory addresses are no longer printed by default.
     -
     -    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
     -
     -    Example with memaddresses flag:
     -
     -    [hevc @ 0000018e72a89cc0] .....
     -
     -    without (new behavior):
     -
     -    [hevc #0] .....
     +    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@hotmail.com>
      
     - ## fftools/cmdutils.c ##
     + ## doc/APIchanges ##
      @@
     - #include "libavutil/dict.h"
     - #include "libavutil/opt.h"
     - #include "cmdutils.h"
     + 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
      +
     - #include "fftools_log.h"
     - #include "fopen_utf8.h"
     - #include "opt_common.h"
     + API changes, most recent first:
     + 
     + 2025-04-07 - 19e9a203b7 - lavu 60.01.100 - dict.h
      
     - ## fftools/fftools_log.c ##
     -@@ fftools/fftools_log.c: static inline struct tm *ff_localtime_r(const time_t* clock, struct tm *result)
     - #define localtime_r ff_localtime_r
     + ## libavutil/log.c ##
     +@@ libavutil/log.c: static AVMutex mutex = AV_MUTEX_INITIALIZER;
       #endif
       
     -+#define MAX_CLASS_IDS 1000
     -+static struct class_ids {
     -+    void *avcl;
     -+    uint64_t class_hash;
     -+    unsigned id;
     -+} class_ids[MAX_CLASS_IDS];
     -+
     -+static uint64_t fnv_hash(const char *str)
     -+{
     -+    // FNV-1a 64-bit hash algorithm
     -+    uint64_t hash = 0xcbf29ce484222325ULL;
     -+    while (*str) {
     -+        hash ^= (unsigned char)*str++;
     -+        hash *= 0x100000001b3ULL;
     -+    }
     -+    return hash;
     -+}
     -+
     -+static unsigned get_class_id(void* avcl)
     -+{
     -+    AVClass* avc = avcl ? *(AVClass **) avcl : NULL;
     -+    unsigned i, nb_ids = 0;
     -+    uint64_t class_hash;
     -+
     -+    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 < MAX_CLASS_IDS; i++) {
     -+        if (class_ids[i].class_hash == class_hash)
     -+            nb_ids++;
     -+
     -+        if (!class_ids[i].avcl) {
     -+            class_ids[i].avcl = avcl;
     -+            class_ids[i].class_hash = class_hash;
     -+            class_ids[i].id = nb_ids;
     -+            return class_ids[i].id;
     -+        }
     -+    }
     -+
     -+    // exceeded MAX_CLASS_IDS entries in class_ids[]
     -+    return 0;
     -+}
     -+
     - static AVMutex mutex = AV_MUTEX_INITIALIZER;
     + static int av_log_level = AV_LOG_INFO;
     +-static int flags;
     ++static int flags = AV_LOG_PRINT_MEMADDRESSES;
       
     - #define LINE_SZ 1024
     -@@ fftools/fftools_log.c: static void format_date_now(AVBPrint* bp_time, int include_date)
     -     }
     - }
     - 
     -+static void log_formatprefix(AVBPrint* buffer, AVClass** avcl)
     -+{
     -+    const int print_mem = ff_log_flags & FF_LOG_PRINT_MEMADDRESSES;
     -+    if (print_mem)
     -+        av_bprintf(buffer+0, "[%s @ %p] ", item_name(avcl, *avcl), avcl);
     -+    else
     -+        av_bprintf(buffer+0, "[%s #%u] ", item_name(avcl, *avcl), get_class_id(avcl));
     -+}
     -+
     - static void format_line(void *avcl, int level, const char *fmt, va_list vl,
     -                         AVBPrint part[5], int *print_prefix, int type[2])
     - {
     -@@ fftools/fftools_log.c: static void format_line(void *avcl, int level, const char *fmt, va_list vl,
     + #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,
       
           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);
     -+            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);
     -+                log_formatprefix(part, parent);
     ++                av_bprintf(part+0, p_fmt,
     +                            item_name(parent, *parent), parent);
                       if(type) type[0] = get_category(parent);
                   }
               }
      -        av_bprintf(part+1, "[%s @ %p] ",
     --                   item_name(avcl, avc), avcl);
     -+        log_formatprefix(part, avcl);
     -+
     ++        av_bprintf(part+1, p_fmt,
     +                    item_name(avcl, avc), avcl);
               if(type) type[1] = get_category(avcl);
           }
     - 
      
     - ## fftools/fftools_log.h ##
     -@@ fftools/fftools_log.h: int ff_log_get_flags(void);
     + ## libavutil/log.h ##
     +@@ libavutil/log.h: int av_log_format_line2(void *ptr, int level, const char *fmt, va_list vl,
        */
     - #define FF_LOG_PRINT_DATETIME 8
     + #define AV_LOG_PRINT_DATETIME 8
       
      +/**
      + * Print memory addresses instead of logical ids in the AVClass prefix.
      + */
     -+#define FF_LOG_PRINT_MEMADDRESSES 16
     ++#define AV_LOG_PRINT_MEMADDRESSES 16
      +
     + void av_log_set_flags(int arg);
     + int av_log_get_flags(void);
       
     - #endif /* FFTOOLS_FFTOOLS_LOG_H */
      
     - ## fftools/opt_common.c ##
     -@@ fftools/opt_common.c: int opt_loglevel(void *optctx, const char *opt, const char *arg)
     -             } else {
     -                 flags |= FF_LOG_PRINT_DATETIME;
     -             }
     -+        } else if (av_strstart(token, "memaddresses", &arg)) {
     -+            if (cmd == '-') {
     -+                flags &= ~FF_LOG_PRINT_MEMADDRESSES;
     -+            } else {
     -+                flags |= FF_LOG_PRINT_MEMADDRESSES;
     -+            }
     -         } else {
     -             break;
     -         }
     + ## libavutil/version.h ##
     +@@
     +  */
     + 
     + #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, \
 -:  ---------- > 2:  7c4cfd5f67 fftools/opt_common: add memaddresses log flag
 3:  ea2a970d23 ! 3:  6d3f305d0f doc/fftools-common-opts: document memaddresses log flag
     @@ Metadata
       ## Commit message ##
          doc/fftools-common-opts: document memaddresses log flag
      
     +    Signed-off-by: softworkz <softworkz@hotmail.com>
     +
       ## doc/fftools-common-opts.texi ##
      @@ doc/fftools-common-opts.texi: log to file.
       Indicates that log lines should be prefixed with time information.

-- 
ffmpeg-codebot
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".