Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] avutil/log: Replace addresses in log output with simple ids
@ 2025-03-05 15:38 softworkz
  2025-03-05 15:40 ` Nicolas George
                   ` (3 more replies)
  0 siblings, 4 replies; 33+ messages in thread
From: softworkz @ 2025-03-05 15:38 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: softworkz

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

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2025-03-06 21:00 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-05 15:38 [FFmpeg-devel] [PATCH] avutil/log: Replace addresses in log output with simple ids softworkz
2025-03-05 15:40 ` Nicolas George
2025-03-05 15:45   ` Soft Works
2025-03-05 15:48   ` Soft Works
2025-03-06 10:08     ` Nicolas George
2025-03-06 17:02       ` Soft Works
2025-03-06 17:38         ` Marvin Scholz
2025-03-06 17:44           ` Soft Works
2025-03-06 17:49             ` Marvin Scholz
2025-03-06 18:16               ` Soft Works
2025-03-06 18:58                 ` Marvin Scholz
2025-03-06 19:27                   ` Soft Works
2025-03-06 20:01                     ` Marvin Scholz
2025-03-06 20:48                       ` Soft Works
2025-03-06 20:56       ` Soft Works
2025-03-05 15:42 ` Soft Works
2025-03-05 16:23 ` Gyan Doshi
2025-03-05 16:30   ` Soft Works
2025-03-05 17:14     ` Gyan Doshi
2025-03-05 18:19 ` [FFmpeg-devel] [PATCH v2 0/3] " ffmpegagent
2025-03-05 18:19   ` [FFmpeg-devel] [PATCH v2 1/3] " softworkz
2025-03-05 18:19   ` [FFmpeg-devel] [PATCH v2 2/3] fftools/opt_common: add memaddresses log flag softworkz
2025-03-05 18:19   ` [FFmpeg-devel] [PATCH v2 3/3] doc/fftools-common-opts: document " softworkz
2025-03-06 10:04   ` [FFmpeg-devel] [PATCH v2 0/3] avutil/log: Replace addresses in log output with simple ids Nicolas George
2025-03-06 16:38     ` Soft Works
2025-03-06 16:43       ` Nicolas George
2025-03-06 17:05         ` Soft Works
2025-03-06 17:38           ` Soft Works
2025-03-06 20:59   ` [FFmpeg-devel] [PATCH v3 0/4] " ffmpegagent
2025-03-06 20:59     ` [FFmpeg-devel] [PATCH v3 1/4] avutil/log: Add callback for context prefix formatting softworkz
2025-03-06 20:59     ` [FFmpeg-devel] [PATCH v3 2/4] fftools/opt_common: add memaddresses log flag softworkz
2025-03-06 20:59     ` [FFmpeg-devel] [PATCH v3 3/4] fftools: Provide a log formatting callback for context prefixes softworkz
2025-03-06 20:59     ` [FFmpeg-devel] [PATCH v3 4/4] doc/fftools-common-opts: document memaddresses log flag softworkz

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git