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 C2A0B4BDAB
	for <ffmpegdev@gitmailbox.com>; Wed,  5 Mar 2025 15:38:44 +0000 (UTC)
Received: from [127.0.1.1] (localhost [127.0.0.1])
	by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A68D468EE66;
	Wed,  5 Mar 2025 17:38:40 +0200 (EET)
Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com
 [209.85.216.47])
 by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7612268DF47
 for <ffmpeg-devel@ffmpeg.org>; Wed,  5 Mar 2025 17:38:34 +0200 (EET)
Received: by mail-pj1-f47.google.com with SMTP id
 98e67ed59e1d1-2fecba90cc3so10193135a91.2
 for <ffmpeg-devel@ffmpeg.org>; Wed, 05 Mar 2025 07:38:34 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1741189112; x=1741793912; darn=ffmpeg.org;
 h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date
 :message-id:from:from:to:cc:subject:date:message-id:reply-to;
 bh=u9HSvSCEbJsKsg+g45yXnB2Cw1QYM8FlkAdvpoj1Koc=;
 b=jU421Vidw0EkfFjw1NlPtr+KMaDQhrpL46aDUWLwRRntruLuNfJmeC36+MSzarclbn
 qxUnRcSLqBrlOYEOk/DlS4FcTU6HfSM7sy9cDStkBiXHtyyorJEAKVbcHzp9Wh0PfbbN
 enY2eWEpTRE0qNZk6ZJLQsHHUZq9jqONXcgnP7L2PjleHXJRXVAyx6zxBQMUKQj6kGhw
 2+aiWgSQdODrU4cfPzQH6dBjr5mqIS2R5QrkAxbf/c4aGpRBklwFEyKcngB5vdXprH1z
 RBekO+qk6TXmlrZTY+XtFhpcGEusmrQeJFRWAZw858XB3WyRO9my95TSAQU9Ni4KTdm7
 6WKQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1741189112; x=1741793912;
 h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date
 :message-id:from:x-gm-message-state:from:to:cc:subject:date
 :message-id:reply-to;
 bh=u9HSvSCEbJsKsg+g45yXnB2Cw1QYM8FlkAdvpoj1Koc=;
 b=WwPpZ3YEG81SMlsZvhhVWfqdnVhv0F3gXnnjDuD78m6Aj3cL/Ru27x6mWxlbCApWPS
 JvK5acOJEznFdss6/J+jhlDtJAGbiTQNt9es+fF0PhN3zpnXtWLyUoQ4AlmentGiPgvG
 ziPgAvpFHC3OvuvWA4I9ORdkw8Dqcxk/OX7ggiKSV6BJWGkGxLbM1sSuOxz5JQorVavH
 fP2/ApEeuNz3dvdpJWXudGUh3kvLyRYfVKgVXDhiIkQOfJg8cz3ZKdZSWTw9TYtVKhHx
 V8QA9Nqn1PRvW8WQhHmryJsoPc9hUG/NXBbW7fZBA33bJxj5SEaD4FJfaNQ09mAxlF7P
 1VhA==
X-Gm-Message-State: AOJu0Yyd6xCzIdaXJsencnHZBhFHIZkGYddKRsGhgPZZ4CCV3DQhhoZm
 Oal4NInyKNItwhvQBkP2n/RMGDRalQjDJqQahgF+g/PnUNsoFX04JhrY5A==
X-Gm-Gg: ASbGncvBK8jalvZKo0dXazx+pHxyCTIi9KQH/YJqppmsr2mRDuwgTtTlpoS4u03XF88
 OTvFeyFs+aYohob2ydNcheRizhniO+Mdch57TYbc+c4iAPNoXcrSxIEAet+A05v2ZTtdcpeyS8q
 I/4F78lG0MS0jUkQM7vkCgl8UCcLg+YZ1+6zMvBHGvrCDw72stz9cP8nR40ZZFEgwMXVynCWdwq
 r7RzrIDtczV7lvNvHW2Fdx4q/Ylg7wklaMogb1knF03ohHl+fSoXG2NnlhaLAlF2aLT3NJEFeBn
 XVbprOYkDBXME2cDxpKHj5iv0k4jeDCrWtS9E9FnptW9zbdZ6AdSkA6O7TsfMYc=
X-Google-Smtp-Source: AGHT+IENOwCnz2xDLMlB6LX2++rqE4inENR/E4UxYCEsfIWh4AHRnZ7A9DUhYcOYPmHTeXdjtsPAEA==
X-Received: by 2002:a17:90b:5688:b0:2ee:9e06:7db0 with SMTP id
 98e67ed59e1d1-2ff497a921amr6305672a91.11.1741189112358; 
 Wed, 05 Mar 2025 07:38:32 -0800 (PST)
Received: from [127.0.0.1] (master.gitmailbox.com. [34.83.118.50])
 by smtp.gmail.com with ESMTPSA id
 d9443c01a7336-22403bea9d2sm4503815ad.256.2025.03.05.07.38.31
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Wed, 05 Mar 2025 07:38:31 -0800 (PST)
From: softworkz <ffmpegagent@gmail.com>
X-Google-Original-From: softworkz <softworkz@hotmail.com>
Message-Id: <pull.59.ffstaging.FFmpeg.1741189106311.ffmpegagent@gmail.com>
Date: Wed, 05 Mar 2025 15:38:26 +0000
Fcc: Sent
MIME-Version: 1.0
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH] avutil/log: Replace addresses in log output
 with simple ids
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.ffstaging.FFmpeg.1741189106311.ffmpegagent@gmail.com/>
List-Archive: <https://master.gitmailbox.com/ffmpegdev/>
List-Post: <mailto:ffmpegdev@gitmailbox.com>

From: softworkz <softworkz@hotmail.com>

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

Signed-off-by: softworkz <softworkz@hotmail.com>
---
    avutil/log: Replace addresses in log output with simple ids
    
    ..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: 34(PPS), nuh_layer_id: 0,
    tempora.. [hevc @ 0000018e72a89cc0] Decoding PPS [hevc @
    0000018e72a89cc0] nal_unit_type: 39(SEI_PREFIX), nuh_layer_id: 0, [hevc
    @ 0000018e72a89cc0] Decoding SEI [mov,mp4,m4a,3gp,3g2,mj2 @
    0000018e72a8e240] All info found [mov,mp4,m4a,3gp,3g2,mj2 @
    0000018e72a8e240] After avformat_find_stream_in.. [hevc @
    0000018e742f6b40] Decoded frame with POC 2. detected 16 logical cores
    [Parsed_scale_0 @ 0000018e74382f40] Setting 'w' to value '320'
    [Parsed_scale_0 @ 0000018e74382f40] Setting 'h' to value '180'
    [Parsed_scale_1 @ 0000018e74382440] Setting 'w' to value '320' [mjpeg @
    0000018e743210c0] Forcing thread count to 1 for MJPEG encoding, u..
    [mjpeg @ 0000018e743210c0] intra_quant_bias = 96 inter_quant_bias = 0
    
    
    After
    =====
    
    [hevc #0] nal_unit_type: 34(PPS), nuh_layer_id: 0, temporal_id: 0 [hevc
    #0] Decoding PPS [hevc #0] nal_unit_type: 39(SEI_PREFIX), nuh_layer_id:
    0, temporal_id: 0 [hevc #0] Decoding SEI [mov,mp4,m4a,3gp,3g2,mj2 #0]
    All info found [mov,mp4,m4a,3gp,3g2,mj2 #0] After
    avformat_find_stream_info() pos: 310096.. [hevc #1] Decoded frame with
    POC 2. [Parsed_scale_0 #0] Setting 'w' to value '320' [Parsed_scale_0
    #0] Setting 'h' to value '180' [Parsed_scale_2 #2] w:320 h:180
    fmt:yuv420p10le sar:0/1 -> w:320 h:180 fmt.. [mjpeg #2] Forcing thread
    count to 1 for MJPEG encoding, use -thread_type [mjpeg #2]
    intra_quant_bias = 96 inter_quant_bias = 0

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

 libavutil/log.c | 57 +++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 53 insertions(+), 4 deletions(-)

diff --git a/libavutil/log.c b/libavutil/log.c
index c5ee876a88..50c8c41ef8 100644
--- a/libavutil/log.c
+++ b/libavutil/log.c
@@ -57,6 +57,55 @@ static AVMutex mutex = AV_MUTEX_INITIALIZER;
 
 static int av_log_level = AV_LOG_INFO;
 static int flags;
+static int nb_class_ids;
+
+#define NB_CLASS_IDS 1000
+static struct class_ids {
+    void *avcl;
+    uint64_t class_hash;
+    unsigned id;
+} class_ids[NB_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;
+    const char* class_name = avc->item_name(avcl);
+    unsigned i, nb_ids = 0;
+    uint64_t class_hash;
+
+    for (i = 0; i < NB_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++) {
+        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 NB_CLASS_IDS entries in class_ids[]
+    return 0;
+}
 
 #define NB_LEVELS 8
 #if defined(_WIN32) && HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
@@ -331,13 +380,13 @@ 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 (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(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(type) type[1] = get_category(avcl);
     }
 

base-commit: 5c5be37daff4f4ecbe0c20d6a9f0fdad6eadc9c8
-- 
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".