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; 12+ 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] 12+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avutil/log: Replace addresses in log output with simple ids
  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-05 15:42 ` Soft Works
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 12+ messages in thread
From: Nicolas George @ 2025-03-05 15:40 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

softworkz (HE12025-03-05):
> +static int nb_class_ids;

We want less mutable global state, not more.

Regards,

-- 
  Nicolas George
_______________________________________________
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] 12+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avutil/log: Replace addresses in log output with simple ids
  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:42 ` Soft Works
  2025-03-05 16:23 ` Gyan Doshi
  2025-03-05 18:19 ` [FFmpeg-devel] [PATCH v2 0/3] " ffmpegagent
  3 siblings, 0 replies; 12+ messages in thread
From: Soft Works @ 2025-03-05 15:42 UTC (permalink / raw)
  To: softworkz, ffmpeg-devel



> -----Original Message-----
> From: softworkz <ffmpegagent@gmail.com>
> Sent: Mittwoch, 5. März 2025 16:38
> To: ffmpeg-devel@ffmpeg.org
> Cc: softworkz <softworkz@hotmail.com>; softworkz <softworkz@hotmail.com>
> Subject: [PATCH] avutil/log: Replace addresses in log output with simple
> ids
> 
> 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


The comparison lines have gotten a somewhat mangled. This should 
look better on the ML:


### 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
_______________________________________________
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] 12+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avutil/log: Replace addresses in log output with simple ids
  2025-03-05 15:40 ` Nicolas George
@ 2025-03-05 15:45   ` Soft Works
  2025-03-05 15:48   ` Soft Works
  1 sibling, 0 replies; 12+ messages in thread
From: Soft Works @ 2025-03-05 15:45 UTC (permalink / raw)
  To: FFmpeg development discussions and patches



> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Nicolas George
> Sent: Mittwoch, 5. März 2025 16:40
> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH] avutil/log: Replace addresses in log
> output with simple ids
> 
> softworkz (HE12025-03-05):
> > +static int nb_class_ids;
> 
> We want less mutable global state, not more.


And I want peace on earth and better logs 😊

sw
_______________________________________________
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] 12+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avutil/log: Replace addresses in log output with simple ids
  2025-03-05 15:40 ` Nicolas George
  2025-03-05 15:45   ` Soft Works
@ 2025-03-05 15:48   ` Soft Works
  1 sibling, 0 replies; 12+ messages in thread
From: Soft Works @ 2025-03-05 15:48 UTC (permalink / raw)
  To: FFmpeg development discussions and patches



> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Nicolas George
> Sent: Mittwoch, 5. März 2025 16:40
> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH] avutil/log: Replace addresses in log
> output with simple ids
> 
> softworkz (HE12025-03-05):
> > +static int nb_class_ids;
> 
> We want less mutable global state, not more.
> 
> Regards,

Sorry. So - seriously: what would be your recipe then?

Thank you,
sw
_______________________________________________
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] 12+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avutil/log: Replace addresses in log output with simple ids
  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:42 ` Soft Works
@ 2025-03-05 16:23 ` Gyan Doshi
  2025-03-05 16:30   ` Soft Works
  2025-03-05 18:19 ` [FFmpeg-devel] [PATCH v2 0/3] " ffmpegagent
  3 siblings, 1 reply; 12+ messages in thread
From: Gyan Doshi @ 2025-03-05 16:23 UTC (permalink / raw)
  To: ffmpeg-devel



On 2025-03-05 09:08 pm, softworkz wrote:
> 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

I like being able to get rid of the addresses, but it should be 
user-selectable via a flag.

Regards,
Gyan


>
> 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-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] 12+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avutil/log: Replace addresses in log output with simple ids
  2025-03-05 16:23 ` Gyan Doshi
@ 2025-03-05 16:30   ` Soft Works
  2025-03-05 17:14     ` Gyan Doshi
  0 siblings, 1 reply; 12+ messages in thread
From: Soft Works @ 2025-03-05 16:30 UTC (permalink / raw)
  To: FFmpeg development discussions and patches



> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Gyan
> Doshi
> Sent: Mittwoch, 5. März 2025 17:23
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH] avutil/log: Replace addresses in log
> output with simple ids
> 
> 
> 
> On 2025-03-05 09:08 pm, softworkz wrote:
> > 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
> 
> I like being able to get rid of the addresses, but it should be
> user-selectable via a flag.
> 
> Regards,
> Gyan

Yea sure. A runtime option (log flag) or preprocessor variable? I'm not sure whether the actual numbers have any value unless you're debugging?
But either way is fine from my pov..

Thanks,
sw





_______________________________________________
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] 12+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avutil/log: Replace addresses in log output with simple ids
  2025-03-05 16:30   ` Soft Works
@ 2025-03-05 17:14     ` Gyan Doshi
  0 siblings, 0 replies; 12+ messages in thread
From: Gyan Doshi @ 2025-03-05 17:14 UTC (permalink / raw)
  To: ffmpeg-devel



On 2025-03-05 10:00 pm, Soft Works wrote:
>
>> -----Original Message-----
>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Gyan
>> Doshi
>> Sent: Mittwoch, 5. März 2025 17:23
>> To: ffmpeg-devel@ffmpeg.org
>> Subject: Re: [FFmpeg-devel] [PATCH] avutil/log: Replace addresses in log
>> output with simple ids
>>
>>
>>
>> On 2025-03-05 09:08 pm, softworkz wrote:
>>> 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
>> I like being able to get rid of the addresses, but it should be
>> user-selectable via a flag.
>>
>> Regards,
>> Gyan
> Yea sure. A runtime option (log flag) or preprocessor variable? I'm not sure whether the actual numbers have any value unless you're debugging?
> But either way is fine from my pov..

Runtime, please

Regards,
Gyan



>
> Thanks,
> sw
>
>
>
>
>
> _______________________________________________
> 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".

_______________________________________________
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] 12+ messages in thread

* [FFmpeg-devel] [PATCH v2 0/3] avutil/log: Replace addresses in log output with simple ids
  2025-03-05 15:38 [FFmpeg-devel] [PATCH] avutil/log: Replace addresses in log output with simple ids softworkz
                   ` (2 preceding siblings ...)
  2025-03-05 16:23 ` Gyan Doshi
@ 2025-03-05 18:19 ` ffmpegagent
  2025-03-05 18:19   ` [FFmpeg-devel] [PATCH v2 1/3] " softworkz
                     ` (2 more replies)
  3 siblings, 3 replies; 12+ messages in thread
From: ffmpegagent @ 2025-03-05 18:19 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: softworkz, Soft Works, Nicolas George, Gyan Doshi

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

softworkz (3):
  avutil/log: Replace addresses in log output with simple ids
  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         |  6 ++++
 libavutil/log.c              | 68 ++++++++++++++++++++++++++++++++----
 libavutil/log.h              |  5 +++
 libavutil/version.h          |  2 +-
 6 files changed, 79 insertions(+), 7 deletions(-)


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

Range-diff vs v1:

 1:  e686825b2a ! 1:  3a289533a7 avutil/log: Replace addresses in log output with simple ids
     @@ Commit message
      
          Signed-off-by: softworkz <softworkz@hotmail.com>
      
     + ## doc/APIchanges ##
     +@@
     + The last version increases of all libraries were on 2024-03-07
     + 
     ++2025-03-xx - xxxxxxxxxx - lavu 59.59.100 - log.h
     ++  Add flag AV_LOG_PRINT_MEMADDRESSES.
     ++
     + API changes, most recent first:
     + 
     + 2025-03-01 - xxxxxxxxxx - lavu 59.58.100 - pixfmt.h
     +
       ## libavutil/log.c ##
      @@ libavutil/log.c: static AVMutex mutex = AV_MUTEX_INITIALIZER;
       
     @@ libavutil/log.c: static AVMutex mutex = AV_MUTEX_INITIALIZER;
       #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,
     -             AVClass** parent = *(AVClass ***) (((uint8_t *) avcl) +
     -                                    avc->parent_log_context_offset);
     + 
     +     if(type) type[0] = type[1] = AV_CLASS_CATEGORY_NA + 16;
     +     if (*print_prefix && avc) {
     ++        const int print_mem = flags & AV_LOG_PRINT_MEMADDRESSES;
     ++
     +         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);
                   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 (print_mem)
     ++                    av_bprintf(part+0, "[%s @ %p] ", item_name(parent, *parent), parent);
     ++                else
     ++                    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 (print_mem)
     ++            av_bprintf(part+1, "[%s @ %p] ", item_name(avcl, avc), avcl);
     ++        else
     ++            av_bprintf(part+1, "[%s #%u] ", item_name(avcl, avc), get_class_id(avcl));
     ++
               if(type) type[1] = get_category(avcl);
           }
       
     +
     + ## libavutil/log.h ##
     +@@ libavutil/log.h: int av_log_format_line2(void *ptr, int level, const char *fmt, va_list vl,
     +  */
     + #define AV_LOG_PRINT_DATETIME 8
     + 
     ++/**
     ++ * Print memory addresses instead of logical ids in the AVClass prefix.
     ++ */
     ++#define AV_LOG_PRINT_MEMADDRESSES 16
     ++
     + void av_log_set_flags(int arg);
     + int av_log_get_flags(void);
     + 
     +
     + ## libavutil/version.h ##
     +@@
     +  */
     + 
     + #define LIBAVUTIL_VERSION_MAJOR  59
     +-#define LIBAVUTIL_VERSION_MINOR  58
     ++#define LIBAVUTIL_VERSION_MINOR  59
     + #define LIBAVUTIL_VERSION_MICRO 100
     + 
     + #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
 -:  ---------- > 2:  858e2cca9c fftools/opt_common: add memaddresses log flag
 -:  ---------- > 3:  411c77bdeb doc/fftools-common-opts: document memaddresses log flag

-- 
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] 12+ messages in thread

* [FFmpeg-devel] [PATCH v2 1/3] avutil/log: Replace addresses in log output with simple ids
  2025-03-05 18:19 ` [FFmpeg-devel] [PATCH v2 0/3] " ffmpegagent
@ 2025-03-05 18:19   ` 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
  2 siblings, 0 replies; 12+ messages in thread
From: softworkz @ 2025-03-05 18:19 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: softworkz, Soft Works, Nicolas George, Gyan Doshi

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>
---
 doc/APIchanges      |  3 ++
 libavutil/log.c     | 68 +++++++++++++++++++++++++++++++++++++++++----
 libavutil/log.h     |  5 ++++
 libavutil/version.h |  2 +-
 4 files changed, 71 insertions(+), 7 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 5a64836e25..76d9b4f71b 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -1,5 +1,8 @@
 The last version increases of all libraries were on 2024-03-07
 
+2025-03-xx - xxxxxxxxxx - lavu 59.59.100 - log.h
+  Add flag AV_LOG_PRINT_MEMADDRESSES.
+
 API changes, most recent first:
 
 2025-03-01 - xxxxxxxxxx - lavu 59.58.100 - pixfmt.h
diff --git a/libavutil/log.c b/libavutil/log.c
index c5ee876a88..6f18943fdd 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
@@ -327,17 +376,24 @@ 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 int print_mem = flags & AV_LOG_PRINT_MEMADDRESSES;
+
         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);
             if (parent && *parent) {
-                av_bprintf(part+0, "[%s @ %p] ",
-                           item_name(parent, *parent), parent);
+                if (print_mem)
+                    av_bprintf(part+0, "[%s @ %p] ", item_name(parent, *parent), parent);
+                else
+                    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);
+        if (print_mem)
+            av_bprintf(part+1, "[%s @ %p] ", item_name(avcl, avc), avcl);
+        else
+            av_bprintf(part+1, "[%s #%u] ", item_name(avcl, avc), get_class_id(avcl));
+
         if(type) type[1] = get_category(avcl);
     }
 
diff --git a/libavutil/log.h b/libavutil/log.h
index dd094307ce..450b4544b9 100644
--- a/libavutil/log.h
+++ b/libavutil/log.h
@@ -416,6 +416,11 @@ int av_log_format_line2(void *ptr, int level, const char *fmt, va_list vl,
  */
 #define AV_LOG_PRINT_DATETIME 8
 
+/**
+ * Print memory addresses instead of logical ids in the AVClass prefix.
+ */
+#define AV_LOG_PRINT_MEMADDRESSES 16
+
 void av_log_set_flags(int arg);
 int av_log_get_flags(void);
 
diff --git a/libavutil/version.h b/libavutil/version.h
index 4b584fd569..b6467e2a6d 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  59
-#define LIBAVUTIL_VERSION_MINOR  58
+#define LIBAVUTIL_VERSION_MINOR  59
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
-- 
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] 12+ messages in thread

* [FFmpeg-devel] [PATCH v2 2/3] fftools/opt_common: add memaddresses log flag
  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   ` softworkz
  2025-03-05 18:19   ` [FFmpeg-devel] [PATCH v2 3/3] doc/fftools-common-opts: document " softworkz
  2 siblings, 0 replies; 12+ messages in thread
From: softworkz @ 2025-03-05 18:19 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: softworkz, Soft Works, Nicolas George, Gyan Doshi

From: softworkz <softworkz@hotmail.com>

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.

Example with memaddresses flag:

[hevc @ 0000018e72a89cc0] .....

without (new behavior):

[hevc #0] .....

Signed-off-by: softworkz <softworkz@hotmail.com>
---
 fftools/opt_common.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fftools/opt_common.c b/fftools/opt_common.c
index 2ac3fd4fb3..b71ecc4b31 100644
--- a/fftools/opt_common.c
+++ b/fftools/opt_common.c
@@ -1304,6 +1304,12 @@ int opt_loglevel(void *optctx, const char *opt, const char *arg)
             } else {
                 flags |= AV_LOG_PRINT_DATETIME;
             }
+        } else if (av_strstart(token, "memaddresses", &arg)) {
+            if (cmd == '-') {
+                flags &= ~AV_LOG_PRINT_MEMADDRESSES;
+            } else {
+                flags |= AV_LOG_PRINT_MEMADDRESSES;
+            }
         } else {
             break;
         }
-- 
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] 12+ messages in thread

* [FFmpeg-devel] [PATCH v2 3/3] doc/fftools-common-opts: document memaddresses log flag
  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   ` softworkz
  2 siblings, 0 replies; 12+ messages in thread
From: softworkz @ 2025-03-05 18:19 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: softworkz, Soft Works, Nicolas George, Gyan Doshi

From: softworkz <softworkz@hotmail.com>

---
 doc/fftools-common-opts.texi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/doc/fftools-common-opts.texi b/doc/fftools-common-opts.texi
index f6d452c40e..756c843c02 100644
--- a/doc/fftools-common-opts.texi
+++ b/doc/fftools-common-opts.texi
@@ -230,6 +230,8 @@ log to file.
 Indicates that log lines should be prefixed with time information.
 @item datetime
 Indicates that log lines should be prefixed with date and time information.
+@item memaddresses
+Indicates that context prefixes should be printed with memory addresses rather than logical ids.
 @end table
 Flags can also be used alone by adding a '+'/'-' prefix to set/reset a single
 flag without affecting other @var{flags} or changing @var{loglevel}. When
-- 
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] 12+ messages in thread

end of thread, other threads:[~2025-03-05 18:20 UTC | newest]

Thread overview: 12+ 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-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

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