* [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; 92+ 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] 92+ 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; 92+ 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] 92+ 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; 92+ 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] 92+ 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; 92+ 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] 92+ 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
2025-03-06 10:08 ` Nicolas George
1 sibling, 1 reply; 92+ 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] 92+ 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; 92+ 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] 92+ 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; 92+ 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] 92+ 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; 92+ 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] 92+ 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
` (4 more replies)
3 siblings, 5 replies; 92+ 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] 92+ 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
` (3 subsequent siblings)
4 siblings, 0 replies; 92+ 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] 92+ 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 subsequent siblings)
4 siblings, 0 replies; 92+ 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] 92+ 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
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 20:59 ` [FFmpeg-devel] [PATCH v3 0/4] " ffmpegagent
4 siblings, 0 replies; 92+ 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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 0/3] avutil/log: Replace addresses in log output with simple ids
2025-03-05 18:19 ` [FFmpeg-devel] [PATCH v2 0/3] " ffmpegagent
` (2 preceding siblings ...)
2025-03-05 18:19 ` [FFmpeg-devel] [PATCH v2 3/3] doc/fftools-common-opts: document " softworkz
@ 2025-03-06 10:04 ` Nicolas George
2025-03-06 16:38 ` Soft Works
2025-03-06 20:59 ` [FFmpeg-devel] [PATCH v3 0/4] " ffmpegagent
4 siblings, 1 reply; 92+ messages in thread
From: Nicolas George @ 2025-03-06 10:04 UTC (permalink / raw)
To: FFmpeg development discussions and patches
ffmpegagent (HE12025-03-05):
> Cc: softworkz <softworkz@hotmail.com>, Soft Works
> <softworkz-at-hotmail.com@ffmpeg.org>, Nicolas George <george@nsup.org>,
> Gyan Doshi <ffmpeg@gyani.pro>
Please do not Cc people who did not ask for it. Especially when headers
say not to.
> Date: Wed, 05 Mar 2025 18:19:40 +0000
> From: ffmpegagent <ffmpegagent@gmail.com>
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH v2 0/3] avutil/log: Replace addresses in log
> output with simple ids
Sending a new version so soon when comments are still pending is a waste
of everybody's time.
--
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avutil/log: Replace addresses in log output with simple ids
2025-03-05 15:48 ` Soft Works
@ 2025-03-06 10:08 ` Nicolas George
2025-03-06 17:02 ` Soft Works
2025-03-06 20:56 ` Soft Works
0 siblings, 2 replies; 92+ messages in thread
From: Nicolas George @ 2025-03-06 10:08 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Soft Works (HE12025-03-05):
> Sorry. So - seriously: what would be your recipe then?
I see not just a little of non-trivial code for a very minor feature,
that might be a hint that it would be best to let it go.
Also, if somebody is debugging a program using the libraries, the
pointers are relevant for that program. For that reason, I think the
change is a bad idea in the library.
On the other hand, you could do that change in the fftools. The point
about pointers being relevant does not apply for them, and they can have
as much global state as they want.
--
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 0/3] avutil/log: Replace addresses in log output with simple ids
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
0 siblings, 1 reply; 92+ messages in thread
From: Soft Works @ 2025-03-06 16:38 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: Donnerstag, 6. März 2025 11:04
> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH v2 0/3] avutil/log: Replace addresses
> in log output with simple ids
>
> ffmpegagent (HE12025-03-05):
> > Cc: softworkz <softworkz@hotmail.com>, Soft Works
> > <softworkz-at-hotmail.com@ffmpeg.org>, Nicolas George
> <george@nsup.org>,
> > Gyan Doshi <ffmpeg@gyani.pro>
>
> Please do not Cc people who did not ask for it. Especially when headers
> say not to.
It is the GitGitGadget system which does this this automatically.
Each time when somebody replies, GGG adds the person to the CC list.
But I have removed you now and try to remove you again each time when you reply.
>
> > Date: Wed, 05 Mar 2025 18:19:40 +0000
> > From: ffmpegagent <ffmpegagent@gmail.com>
> > To: ffmpeg-devel@ffmpeg.org
> > Subject: [FFmpeg-devel] [PATCH v2 0/3] avutil/log: Replace addresses
> in log
> > output with simple ids
>
> Sending a new version so soon when comments are still pending is a waste
> of everybody's time.
Gyan had asked to provide the ability for controlling this via a log flag. This was a substantial change to the patchset (1 => 3 commits, 1 => 6 changed files).
Isn't it rather wasting people's time when letting them review the first patchset even when knowing that V2 is substantially different?
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 0/3] avutil/log: Replace addresses in log output with simple ids
2025-03-06 16:38 ` Soft Works
@ 2025-03-06 16:43 ` Nicolas George
2025-03-06 17:05 ` Soft Works
0 siblings, 1 reply; 92+ messages in thread
From: Nicolas George @ 2025-03-06 16:43 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Soft Works (HE12025-03-06):
> It is the GitGitGadget system which does this this automatically.
Your choice to use that thing, your responsibility to not let it
misbehave.
> But I have removed you now and try to remove you again each time when you reply.
Do not Cc other people either if they did not ask for it.
> Isn't it rather wasting people's time when letting them review the
> first patchset even when knowing that V2 is substantially different?
When you already know a V3 is coming, yes, of course it is wasting
people's time.
--
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avutil/log: Replace addresses in log output with simple ids
2025-03-06 10:08 ` Nicolas George
@ 2025-03-06 17:02 ` Soft Works
2025-03-06 17:38 ` Marvin Scholz
2025-03-06 20:56 ` Soft Works
1 sibling, 1 reply; 92+ messages in thread
From: Soft Works @ 2025-03-06 17:02 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: Donnerstag, 6. März 2025 11:09
> 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
>
> Soft Works (HE12025-03-05):
> > Sorry. So - seriously: what would be your recipe then?
>
> I see not just a little of non-trivial code for a very minor feature,
Whether trivial or non-trivial, it's definitely just very little code.
> that might be a hint that it would be best to let it go.
This is not a helpful comment. I'm trying hard to be friendly and productive and I think it's not asked too much to at least try doing as well.
> Also, if somebody is debugging a program using the libraries, the
> pointers are relevant for that program. For that reason, I think the
> change is a bad idea in the library.
It's a valid point, I have acknowledged that already and added a log flag in V2 which allows to control it.
As a further compromise, we could also enable it by default in case when DEBUG is defined, how about that?
Generally, debugging is important without doubt, but it doesn't mean that Millions of users need to see something in the output which is only ever relevant to developers - that's the premise of this patchset.
And even as a developer, those addresses are interesting only in a very narrow range of cases.
These addresses have been a major pain point for myself and many others over years when comparing logfiles. Even the best diffing algorithms are getting confused by these addresses and I think this patchset provides a huge benefit for both, users and developers in the future, making their work a lot easier.
> On the other hand, you could do that change in the fftools. The point
> about pointers being relevant does not apply for them, and they can have
> as much global state as they want.
You know that it's not easily possible to do it from within fftools because all libs are logging directly to avutil, so it's not quite clear to me what you are up to.
Do you mean something like a int(* av_log_format_prefix)(...) callback that fftools could register to?
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 0/3] avutil/log: Replace addresses in log output with simple ids
2025-03-06 16:43 ` Nicolas George
@ 2025-03-06 17:05 ` Soft Works
2025-03-06 17:38 ` Soft Works
0 siblings, 1 reply; 92+ messages in thread
From: Soft Works @ 2025-03-06 17:05 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: Donnerstag, 6. März 2025 17:43
> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH v2 0/3] avutil/log: Replace addresses
> in log output with simple ids
>
> Soft Works (HE12025-03-06):
> > It is the GitGitGadget system which does this this automatically.
>
> Your choice to use that thing, your responsibility to not let it
> misbehave.
>
> > But I have removed you now and try to remove you again each time when
> you reply.
>
> Do not Cc other people either if they did not ask for it.
Ok, I'll try to disable that behavior altogether.
> When you already know a V3 is coming, yes, of course it is wasting
> people's time.
We're not talking about V3. Your criticism was about V2. I submitted it because I knew it was coming, so thanks for acknowledging that my submission of V2 was not wasting people's time.
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 0/3] avutil/log: Replace addresses in log output with simple ids
2025-03-06 17:05 ` Soft Works
@ 2025-03-06 17:38 ` Soft Works
0 siblings, 0 replies; 92+ messages in thread
From: Soft Works @ 2025-03-06 17:38 UTC (permalink / raw)
To: FFmpeg development discussions and patches
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Soft
> Works
> Sent: Donnerstag, 6. März 2025 18:05
> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH v2 0/3] avutil/log: Replace addresses
> in log output with simple ids
>
>
>
> > -----Original Message-----
> > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> > Nicolas George
> > Sent: Donnerstag, 6. März 2025 17:43
> > To: FFmpeg development discussions and patches <ffmpeg-
> devel@ffmpeg.org>
> > Subject: Re: [FFmpeg-devel] [PATCH v2 0/3] avutil/log: Replace
> addresses
> > in log output with simple ids
> >
> > Soft Works (HE12025-03-06):
> > > It is the GitGitGadget system which does this this automatically.
> >
> > Your choice to use that thing, your responsibility to not let it
> > misbehave.
> >
> > > But I have removed you now and try to remove you again each time
> when
> > you reply.
> >
> > Do not Cc other people either if they did not ask for it.
>
> Ok, I'll try to disable that behavior altogether.
About 60 patchsets have been submitted via this path already (not counting versions) and you are the first one complaining, that's why I haven't paid much attention on that part before.
The auto-cc feature is disabled now. Thanks for the feedback and apologies for the inconvenience.
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avutil/log: Replace addresses in log output with simple ids
2025-03-06 17:02 ` Soft Works
@ 2025-03-06 17:38 ` Marvin Scholz
2025-03-06 17:44 ` Soft Works
0 siblings, 1 reply; 92+ messages in thread
From: Marvin Scholz @ 2025-03-06 17:38 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On 6 Mar 2025, at 18:02, Soft Works wrote:
>> -----Original Message-----
>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
>> Nicolas George
>> Sent: Donnerstag, 6. März 2025 11:09
>> 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
>>
>> Soft Works (HE12025-03-05):
>>> Sorry. So - seriously: what would be your recipe then?
>>
>> I see not just a little of non-trivial code for a very minor feature,
>
> Whether trivial or non-trivial, it's definitely just very little code.
>
>> that might be a hint that it would be best to let it go.
>
> This is not a helpful comment. I'm trying hard to be friendly and productive and I think it's not asked too much to at least try doing as well.
>
>
>> Also, if somebody is debugging a program using the libraries, the
>> pointers are relevant for that program. For that reason, I think the
>> change is a bad idea in the library.
>
> It's a valid point, I have acknowledged that already and added a log flag in V2 which allows to control it.
>
> As a further compromise, we could also enable it by default in case when DEBUG is defined, how about that?
>
> Generally, debugging is important without doubt, but it doesn't mean that Millions of users need to see something in the output which is only ever relevant to developers - that's the premise of this patchset.
>
> And even as a developer, those addresses are interesting only in a very narrow range of cases.
> These addresses have been a major pain point for myself and many others over years when comparing logfiles. Even the best diffing algorithms are getting confused by these addresses and I think this patchset provides a huge benefit for both, users and developers in the future, making their work a lot easier.
>
>
>> On the other hand, you could do that change in the fftools. The point
>> about pointers being relevant does not apply for them, and they can have
>> as much global state as they want.
>
> You know that it's not easily possible to do it from within fftools because all libs are logging directly to avutil, so it's not quite clear to me what you are up to.
> Do you mean something like a int(* av_log_format_prefix)(...) callback that fftools could register to?
>
First of all I want to say I like the idea of having cleaner logs, but...
IMHO "complex" logging formatting should be handled by fftools especially if
they need global state. Even though thats not the case right now, but just
like Nicolas I also would prefer to not add even more global state for logging
to the library...
All the fancy log formatting should be done in a log callback in the
fftools and the default library logging callback should just be a very basic
one, is my opinion on this.
>
> 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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avutil/log: Replace addresses in log output with simple ids
2025-03-06 17:38 ` Marvin Scholz
@ 2025-03-06 17:44 ` Soft Works
2025-03-06 17:49 ` Marvin Scholz
0 siblings, 1 reply; 92+ messages in thread
From: Soft Works @ 2025-03-06 17:44 UTC (permalink / raw)
To: FFmpeg development discussions and patches
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Marvin
> Scholz
> Sent: Donnerstag, 6. März 2025 18:38
> 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
>
>
>
> On 6 Mar 2025, at 18:02, Soft Works wrote:
>
> >> -----Original Message-----
> >> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> >> Nicolas George
> >> Sent: Donnerstag, 6. März 2025 11:09
> >> 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
> >>
> >> Soft Works (HE12025-03-05):
> >>> Sorry. So - seriously: what would be your recipe then?
> >>
> >> I see not just a little of non-trivial code for a very minor feature,
> >
> > Whether trivial or non-trivial, it's definitely just very little code.
> >
> >> that might be a hint that it would be best to let it go.
> >
> > This is not a helpful comment. I'm trying hard to be friendly and
> productive and I think it's not asked too much to at least try doing as
> well.
> >
> >
> >> Also, if somebody is debugging a program using the libraries, the
> >> pointers are relevant for that program. For that reason, I think the
> >> change is a bad idea in the library.
> >
> > It's a valid point, I have acknowledged that already and added a log
> flag in V2 which allows to control it.
> >
> > As a further compromise, we could also enable it by default in case
> when DEBUG is defined, how about that?
> >
> > Generally, debugging is important without doubt, but it doesn't mean
> that Millions of users need to see something in the output which is only
> ever relevant to developers - that's the premise of this patchset.
> >
> > And even as a developer, those addresses are interesting only in a
> very narrow range of cases.
> > These addresses have been a major pain point for myself and many
> others over years when comparing logfiles. Even the best diffing
> algorithms are getting confused by these addresses and I think this
> patchset provides a huge benefit for both, users and developers in the
> future, making their work a lot easier.
> >
> >
> >> On the other hand, you could do that change in the fftools. The point
> >> about pointers being relevant does not apply for them, and they can
> have
> >> as much global state as they want.
> >
> > You know that it's not easily possible to do it from within fftools
> because all libs are logging directly to avutil, so it's not quite clear
> to me what you are up to.
> > Do you mean something like a int(* av_log_format_prefix)(...) callback
> that fftools could register to?
> >
>
> First of all I want to say I like the idea of having cleaner logs,
> but...
>
> IMHO "complex" logging formatting should be handled by fftools
> especially if
> they need global state. Even though thats not the case right now, but
> just
> like Nicolas I also would prefer to not add even more global state for
> logging
> to the library...
>
> All the fancy log formatting should be done in a log callback in the
> fftools and the default library logging callback should just be a very
> basic
> one, is my opinion on this.
That's all fine and probably reasonable. But is it fair to block a small change because some major rework would be desired at some point?
When that change will be made, it will of course move out this little change as well.
But are you really saying that this small change cannot be made because you don't like the general way of the current implementation?
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avutil/log: Replace addresses in log output with simple ids
2025-03-06 17:44 ` Soft Works
@ 2025-03-06 17:49 ` Marvin Scholz
2025-03-06 18:16 ` Soft Works
0 siblings, 1 reply; 92+ messages in thread
From: Marvin Scholz @ 2025-03-06 17:49 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On 6 Mar 2025, at 18:44, Soft Works wrote:
>> -----Original Message-----
>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Marvin
>> Scholz
>> Sent: Donnerstag, 6. März 2025 18:38
>> 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
>>
>>
>>
>> On 6 Mar 2025, at 18:02, Soft Works wrote:
>>
>>>> -----Original Message-----
>>>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
>>>> Nicolas George
>>>> Sent: Donnerstag, 6. März 2025 11:09
>>>> 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
>>>>
>>>> Soft Works (HE12025-03-05):
>>>>> Sorry. So - seriously: what would be your recipe then?
>>>>
>>>> I see not just a little of non-trivial code for a very minor feature,
>>>
>>> Whether trivial or non-trivial, it's definitely just very little code.
>>>
>>>> that might be a hint that it would be best to let it go.
>>>
>>> This is not a helpful comment. I'm trying hard to be friendly and
>> productive and I think it's not asked too much to at least try doing as
>> well.
>>>
>>>
>>>> Also, if somebody is debugging a program using the libraries, the
>>>> pointers are relevant for that program. For that reason, I think the
>>>> change is a bad idea in the library.
>>>
>>> It's a valid point, I have acknowledged that already and added a log
>> flag in V2 which allows to control it.
>>>
>>> As a further compromise, we could also enable it by default in case
>> when DEBUG is defined, how about that?
>>>
>>> Generally, debugging is important without doubt, but it doesn't mean
>> that Millions of users need to see something in the output which is only
>> ever relevant to developers - that's the premise of this patchset.
>>>
>>> And even as a developer, those addresses are interesting only in a
>> very narrow range of cases.
>>> These addresses have been a major pain point for myself and many
>> others over years when comparing logfiles. Even the best diffing
>> algorithms are getting confused by these addresses and I think this
>> patchset provides a huge benefit for both, users and developers in the
>> future, making their work a lot easier.
>>>
>>>
>>>> On the other hand, you could do that change in the fftools. The point
>>>> about pointers being relevant does not apply for them, and they can
>> have
>>>> as much global state as they want.
>>>
>>> You know that it's not easily possible to do it from within fftools
>> because all libs are logging directly to avutil, so it's not quite clear
>> to me what you are up to.
>>> Do you mean something like a int(* av_log_format_prefix)(...) callback
>> that fftools could register to?
>>>
>>
>> First of all I want to say I like the idea of having cleaner logs,
>> but...
>>
>> IMHO "complex" logging formatting should be handled by fftools
>> especially if
>> they need global state. Even though thats not the case right now, but
>> just
>> like Nicolas I also would prefer to not add even more global state for
>> logging
>> to the library...
>>
>> All the fancy log formatting should be done in a log callback in the
>> fftools and the default library logging callback should just be a very
>> basic
>> one, is my opinion on this.
>
> That's all fine and probably reasonable. But is it fair to block a small change because some major rework would be desired at some point?
>
> When that change will be made, it will of course move out this little change as well.
>
> But are you really saying that this small change cannot be made because you don't like the general way of the current implementation?
>
Just to be clear, I am not blocking this, just wanted to give my perspective on the topic.
So if others think its fine and want it, lets go for it.
> 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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avutil/log: Replace addresses in log output with simple ids
2025-03-06 17:49 ` Marvin Scholz
@ 2025-03-06 18:16 ` Soft Works
2025-03-06 18:58 ` Marvin Scholz
0 siblings, 1 reply; 92+ messages in thread
From: Soft Works @ 2025-03-06 18:16 UTC (permalink / raw)
To: FFmpeg development discussions and patches
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Marvin
> Scholz
> Sent: Donnerstag, 6. März 2025 18:49
> 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
>
>
>
> On 6 Mar 2025, at 18:44, Soft Works wrote:
>
> >> -----Original Message-----
> >> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Marvin
> >> Scholz
> >> Sent: Donnerstag, 6. März 2025 18:38
> >> 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
> >>
> >>
> >>
> >> On 6 Mar 2025, at 18:02, Soft Works wrote:
> >>
> >>>> -----Original Message-----
> >>>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> >>>> Nicolas George
> >>>> Sent: Donnerstag, 6. März 2025 11:09
> >>>> 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
> >>>>
> >>>> Soft Works (HE12025-03-05):
> >>>>> Sorry. So - seriously: what would be your recipe then?
> >>>>
> >>>> I see not just a little of non-trivial code for a very minor
> feature,
> >>>
> >>> Whether trivial or non-trivial, it's definitely just very little
> code.
> >>>
> >>>> that might be a hint that it would be best to let it go.
> >>>
> >>> This is not a helpful comment. I'm trying hard to be friendly and
> >> productive and I think it's not asked too much to at least try doing
> as
> >> well.
> >>>
> >>>
> >>>> Also, if somebody is debugging a program using the libraries, the
> >>>> pointers are relevant for that program. For that reason, I think
> the
> >>>> change is a bad idea in the library.
> >>>
> >>> It's a valid point, I have acknowledged that already and added a log
> >> flag in V2 which allows to control it.
> >>>
> >>> As a further compromise, we could also enable it by default in case
> >> when DEBUG is defined, how about that?
> >>>
> >>> Generally, debugging is important without doubt, but it doesn't mean
> >> that Millions of users need to see something in the output which is
> only
> >> ever relevant to developers - that's the premise of this patchset.
> >>>
> >>> And even as a developer, those addresses are interesting only in a
> >> very narrow range of cases.
> >>> These addresses have been a major pain point for myself and many
> >> others over years when comparing logfiles. Even the best diffing
> >> algorithms are getting confused by these addresses and I think this
> >> patchset provides a huge benefit for both, users and developers in
> the
> >> future, making their work a lot easier.
> >>>
> >>>
> >>>> On the other hand, you could do that change in the fftools. The
> point
> >>>> about pointers being relevant does not apply for them, and they can
> >> have
> >>>> as much global state as they want.
> >>>
> >>> You know that it's not easily possible to do it from within fftools
> >> because all libs are logging directly to avutil, so it's not quite
> clear
> >> to me what you are up to.
> >>> Do you mean something like a int(* av_log_format_prefix)(...)
> callback
> >> that fftools could register to?
> >>>
> >>
> >> First of all I want to say I like the idea of having cleaner logs,
> >> but...
> >>
> >> IMHO "complex" logging formatting should be handled by fftools
> >> especially if
> >> they need global state. Even though thats not the case right now, but
> >> just
> >> like Nicolas I also would prefer to not add even more global state
> for
> >> logging
> >> to the library...
> >>
> >> All the fancy log formatting should be done in a log callback in the
> >> fftools and the default library logging callback should just be a
> very
> >> basic
> >> one, is my opinion on this.
> >
> > That's all fine and probably reasonable. But is it fair to block a
> small change because some major rework would be desired at some point?
> >
> > When that change will be made, it will of course move out this little
> change as well.
> >
> > But are you really saying that this small change cannot be made
> because you don't like the general way of the current implementation?
> >
>
> Just to be clear, I am not blocking this, just wanted to give my
> perspective on the topic.
> So if others think its fine and want it, lets go for it.
Thanks - and sorry for my retardation, I just realized why it's bad to do it this way with regards to library usage. I'll add a callback so that fftools can do the prefix formatting.
For the idea of moving all the formatting to fftools, wouldn't this be a major breakage for library consumers who are used to getting the log output formatted like now?
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avutil/log: Replace addresses in log output with simple ids
2025-03-06 18:16 ` Soft Works
@ 2025-03-06 18:58 ` Marvin Scholz
2025-03-06 19:27 ` Soft Works
0 siblings, 1 reply; 92+ messages in thread
From: Marvin Scholz @ 2025-03-06 18:58 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On 6 Mar 2025, at 19:16, Soft Works wrote:
>> -----Original Message-----
>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Marvin
>> Scholz
>> Sent: Donnerstag, 6. März 2025 18:49
>> 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
>>
>>
>>
>> On 6 Mar 2025, at 18:44, Soft Works wrote:
>>
>>>> -----Original Message-----
>>>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
>> Marvin
>>>> Scholz
>>>> Sent: Donnerstag, 6. März 2025 18:38
>>>> 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
>>>>
>>>>
>>>>
>>>> On 6 Mar 2025, at 18:02, Soft Works wrote:
>>>>
>>>>>> -----Original Message-----
>>>>>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
>>>>>> Nicolas George
>>>>>> Sent: Donnerstag, 6. März 2025 11:09
>>>>>> 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
>>>>>>
>>>>>> Soft Works (HE12025-03-05):
>>>>>>> Sorry. So - seriously: what would be your recipe then?
>>>>>>
>>>>>> I see not just a little of non-trivial code for a very minor
>> feature,
>>>>>
>>>>> Whether trivial or non-trivial, it's definitely just very little
>> code.
>>>>>
>>>>>> that might be a hint that it would be best to let it go.
>>>>>
>>>>> This is not a helpful comment. I'm trying hard to be friendly and
>>>> productive and I think it's not asked too much to at least try doing
>> as
>>>> well.
>>>>>
>>>>>
>>>>>> Also, if somebody is debugging a program using the libraries, the
>>>>>> pointers are relevant for that program. For that reason, I think
>> the
>>>>>> change is a bad idea in the library.
>>>>>
>>>>> It's a valid point, I have acknowledged that already and added a log
>>>> flag in V2 which allows to control it.
>>>>>
>>>>> As a further compromise, we could also enable it by default in case
>>>> when DEBUG is defined, how about that?
>>>>>
>>>>> Generally, debugging is important without doubt, but it doesn't mean
>>>> that Millions of users need to see something in the output which is
>> only
>>>> ever relevant to developers - that's the premise of this patchset.
>>>>>
>>>>> And even as a developer, those addresses are interesting only in a
>>>> very narrow range of cases.
>>>>> These addresses have been a major pain point for myself and many
>>>> others over years when comparing logfiles. Even the best diffing
>>>> algorithms are getting confused by these addresses and I think this
>>>> patchset provides a huge benefit for both, users and developers in
>> the
>>>> future, making their work a lot easier.
>>>>>
>>>>>
>>>>>> On the other hand, you could do that change in the fftools. The
>> point
>>>>>> about pointers being relevant does not apply for them, and they can
>>>> have
>>>>>> as much global state as they want.
>>>>>
>>>>> You know that it's not easily possible to do it from within fftools
>>>> because all libs are logging directly to avutil, so it's not quite
>> clear
>>>> to me what you are up to.
>>>>> Do you mean something like a int(* av_log_format_prefix)(...)
>> callback
>>>> that fftools could register to?
>>>>>
>>>>
>>>> First of all I want to say I like the idea of having cleaner logs,
>>>> but...
>>>>
>>>> IMHO "complex" logging formatting should be handled by fftools
>>>> especially if
>>>> they need global state. Even though thats not the case right now, but
>>>> just
>>>> like Nicolas I also would prefer to not add even more global state
>> for
>>>> logging
>>>> to the library...
>>>>
>>>> All the fancy log formatting should be done in a log callback in the
>>>> fftools and the default library logging callback should just be a
>> very
>>>> basic
>>>> one, is my opinion on this.
>>>
>>> That's all fine and probably reasonable. But is it fair to block a
>> small change because some major rework would be desired at some point?
>>>
>>> When that change will be made, it will of course move out this little
>> change as well.
>>>
>>> But are you really saying that this small change cannot be made
>> because you don't like the general way of the current implementation?
>>>
>>
>> Just to be clear, I am not blocking this, just wanted to give my
>> perspective on the topic.
>> So if others think its fine and want it, lets go for it.
>
> Thanks - and sorry for my retardation, I just realized why it's bad to do it this way with regards to library usage. I'll add a callback so that fftools can do the prefix formatting.
>
> For the idea of moving all the formatting to fftools, wouldn't this be a major breakage for library consumers who are used to getting the log output formatted like now?
>
Yeah, one of the reasons why I did not really do any work on this yet as I am really
not sure whats the best way to go about this to not be too surprising for existing
library users...
>
> 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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avutil/log: Replace addresses in log output with simple ids
2025-03-06 18:58 ` Marvin Scholz
@ 2025-03-06 19:27 ` Soft Works
2025-03-06 20:01 ` Marvin Scholz
0 siblings, 1 reply; 92+ messages in thread
From: Soft Works @ 2025-03-06 19:27 UTC (permalink / raw)
To: FFmpeg development discussions and patches
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Marvin
> Scholz
> Sent: Donnerstag, 6. März 2025 19:59
> 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
>
>
>
> On 6 Mar 2025, at 19:16, Soft Works wrote:
>
> >> -----Original Message-----
> >> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Marvin
> >> Scholz
> >> Sent: Donnerstag, 6. März 2025 18:49
> >> 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
> >>
> >>
> >>
> >> On 6 Mar 2025, at 18:44, Soft Works wrote:
> >>
> >>>> -----Original Message-----
> >>>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> >> Marvin
> >>>> Scholz
> >>>> Sent: Donnerstag, 6. März 2025 18:38
> >>>> 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
> >>>>
> >>>>
> >>>>
> >>>> On 6 Mar 2025, at 18:02, Soft Works wrote:
> >>>>
> >>>>>> -----Original Message-----
> >>>>>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> >>>>>> Nicolas George
> >>>>>> Sent: Donnerstag, 6. März 2025 11:09
> >>>>>> To: FFmpeg development discussions and patches <ffmpeg-
> >>>> devel@ffmpeg.org>
> >>>>>> Subject: Re: [FFmpeg-devel] [PATCH] avutil/log: Replace addresses
[..]
> >>>>
> >>>> First of all I want to say I like the idea of having cleaner logs,
> >>>> but...
> >>>>
> >>>> IMHO "complex" logging formatting should be handled by fftools
> >>>> especially if
> >>>> they need global state. Even though thats not the case right now,
> but
> >>>> just
> >>>> like Nicolas I also would prefer to not add even more global state
> >> for
> >>>> logging
> >>>> to the library...
> >>>>
> >>>> All the fancy log formatting should be done in a log callback in
> the
> >>>> fftools and the default library logging callback should just be a
> >> very
> >>>> basic
> >>>> one, is my opinion on this.
> >>>
> >>> That's all fine and probably reasonable. But is it fair to block a
> >> small change because some major rework would be desired at some
> point?
> >>>
> >>> When that change will be made, it will of course move out this
> little
> >> change as well.
> >>>
> >>> But are you really saying that this small change cannot be made
> >> because you don't like the general way of the current implementation?
> >>>
> >>
> >> Just to be clear, I am not blocking this, just wanted to give my
> >> perspective on the topic.
> >> So if others think its fine and want it, lets go for it.
> >
> > Thanks - and sorry for my retardation, I just realized why it's bad to
> do it this way with regards to library usage. I'll add a callback so
> that fftools can do the prefix formatting.
> >
> > For the idea of moving all the formatting to fftools, wouldn't this be
> a major breakage for library consumers who are used to getting the log
> output formatted like now?
> >
>
> Yeah, one of the reasons why I did not really do any work on this yet as
> I am really
> not sure whats the best way to go about this to not be too surprising
> for existing
> library users...
I think, people _do_ want the formatting even when using the libs directly, so while separating formatting from the plain logging might make sense, it would probably still need to be in avutil - otherwise most consumers would probably be annoyed and have to copy the formatting code from fftools to their own code base (or similar) - which wouldn't be a win for anybody.
I see why the global state is bad with regards to this patchset's feature (and V3 will remedy), but avoidance of global state would be much easier and also make more sense if there was some kind of "local state" as a replacement, so that people could for example have separate log outputs when performing separate and independent operations.
I suppose that's not easy to achieve with the current architecture?
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avutil/log: Replace addresses in log output with simple ids
2025-03-06 19:27 ` Soft Works
@ 2025-03-06 20:01 ` Marvin Scholz
2025-03-06 20:48 ` Soft Works
0 siblings, 1 reply; 92+ messages in thread
From: Marvin Scholz @ 2025-03-06 20:01 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On 6 Mar 2025, at 20:27, Soft Works wrote:
>> -----Original Message-----
>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Marvin
>> Scholz
>> Sent: Donnerstag, 6. März 2025 19:59
>> 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
>>
>>
>>
>> On 6 Mar 2025, at 19:16, Soft Works wrote:
>>
>>>> -----Original Message-----
>>>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
>> Marvin
>>>> Scholz
>>>> Sent: Donnerstag, 6. März 2025 18:49
>>>> 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
>>>>
>>>>
>>>>
>>>> On 6 Mar 2025, at 18:44, Soft Works wrote:
>>>>
>>>>>> -----Original Message-----
>>>>>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
>>>> Marvin
>>>>>> Scholz
>>>>>> Sent: Donnerstag, 6. März 2025 18:38
>>>>>> 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
>>>>>>
>>>>>>
>>>>>>
>>>>>> On 6 Mar 2025, at 18:02, Soft Works wrote:
>>>>>>
>>>>>>>> -----Original Message-----
>>>>>>>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
>>>>>>>> Nicolas George
>>>>>>>> Sent: Donnerstag, 6. März 2025 11:09
>>>>>>>> To: FFmpeg development discussions and patches <ffmpeg-
>>>>>> devel@ffmpeg.org>
>>>>>>>> Subject: Re: [FFmpeg-devel] [PATCH] avutil/log: Replace addresses
>
> [..]
>
>>>>>>
>>>>>> First of all I want to say I like the idea of having cleaner logs,
>>>>>> but...
>>>>>>
>>>>>> IMHO "complex" logging formatting should be handled by fftools
>>>>>> especially if
>>>>>> they need global state. Even though thats not the case right now,
>> but
>>>>>> just
>>>>>> like Nicolas I also would prefer to not add even more global state
>>>> for
>>>>>> logging
>>>>>> to the library...
>>>>>>
>>>>>> All the fancy log formatting should be done in a log callback in
>> the
>>>>>> fftools and the default library logging callback should just be a
>>>> very
>>>>>> basic
>>>>>> one, is my opinion on this.
>>>>>
>>>>> That's all fine and probably reasonable. But is it fair to block a
>>>> small change because some major rework would be desired at some
>> point?
>>>>>
>>>>> When that change will be made, it will of course move out this
>> little
>>>> change as well.
>>>>>
>>>>> But are you really saying that this small change cannot be made
>>>> because you don't like the general way of the current implementation?
>>>>>
>>>>
>>>> Just to be clear, I am not blocking this, just wanted to give my
>>>> perspective on the topic.
>>>> So if others think its fine and want it, lets go for it.
>>>
>>> Thanks - and sorry for my retardation, I just realized why it's bad to
>> do it this way with regards to library usage. I'll add a callback so
>> that fftools can do the prefix formatting.
>>>
>>> For the idea of moving all the formatting to fftools, wouldn't this be
>> a major breakage for library consumers who are used to getting the log
>> output formatted like now?
>>>
>>
>> Yeah, one of the reasons why I did not really do any work on this yet as
>> I am really
>> not sure whats the best way to go about this to not be too surprising
>> for existing
>> library users...
>
> I think, people _do_ want the formatting even when using the libs directly, so while separating formatting from the plain logging might make sense, it would probably still need to be in avutil - otherwise most consumers would probably be annoyed and have to copy the formatting code from fftools to their own code base (or similar) - which wouldn't be a win for anybody.
Right, I do think it might be useful to have helpers to make log formatting easier for library users (especially because as the final
consumer you can then decide where to put some eventual state needed), and maybe also some to make it easier to obtain logging details from
AVClass as this is right now somewhat hard to get right and I had to check the source code last time to figure out how its done.
> I see why the global state is bad with regards to this patchset's feature (and V3 will remedy), but avoidance of global state would be much easier and also make more sense if there was some kind of "local state" as a replacement, so that people could for example have separate log outputs when performing separate and independent operations.
> I suppose that's not easy to achieve with the current architecture?
Yeah, I think the end goal should be to have a way to not have a global log callback, however that would require quite a bit of
redesign. (This is especially useful if you run independent FFmpeg tasks in different threads and want to get separate logs for
each of them.)
A sort of hacky way right now to do this is use of thread local storage and then "demultiplex" the messages in the log callback
based on that. However that only works as long as the message does not come from a "child" thread internally spawned by FFmpeg.
>
> 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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avutil/log: Replace addresses in log output with simple ids
2025-03-06 20:01 ` Marvin Scholz
@ 2025-03-06 20:48 ` Soft Works
0 siblings, 0 replies; 92+ messages in thread
From: Soft Works @ 2025-03-06 20:48 UTC (permalink / raw)
To: FFmpeg development discussions and patches
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Marvin
> Scholz
> Sent: Donnerstag, 6. März 2025 21:02
> 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
>
>
>
> On 6 Mar 2025, at 20:27, Soft Works wrote:
>
> >> -----Original Message-----
> >> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Marvin
> >> Scholz
> >> Sent: Donnerstag, 6. März 2025 19:59
> >> 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
> >>
> >>
> >>
> >> On 6 Mar 2025, at 19:16, Soft Works wrote:
> >>
> >>>> -----Original Message-----
> >>>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> >> Marvin
> >>>> Scholz
> >>>> Sent: Donnerstag, 6. März 2025 18:49
> >>>> 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
> >>>>
> >>>>
> >>>>
> >>>> On 6 Mar 2025, at 18:44, Soft Works wrote:
> >>>>
> >>>>>> -----Original Message-----
> >>>>>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> >>>> Marvin
> >>>>>> Scholz
> >>>>>> Sent: Donnerstag, 6. März 2025 18:38
> >>>>>> 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
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> On 6 Mar 2025, at 18:02, Soft Works wrote:
> >>>>>>
> >>>>>>>> -----Original Message-----
> >>>>>>>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf
> Of
> >>>>>>>> Nicolas George
> >>>>>>>> Sent: Donnerstag, 6. März 2025 11:09
> >>>>>>>> To: FFmpeg development discussions and patches <ffmpeg-
> >>>>>> devel@ffmpeg.org>
> >>>>>>>> Subject: Re: [FFmpeg-devel] [PATCH] avutil/log: Replace
> addresses
> >
> > [..]
> >
> >>>>>>
> >>>>>> First of all I want to say I like the idea of having cleaner
> logs,
> >>>>>> but...
> >>>>>>
> >>>>>> IMHO "complex" logging formatting should be handled by fftools
> >>>>>> especially if
> >>>>>> they need global state. Even though thats not the case right now,
> >> but
> >>>>>> just
> >>>>>> like Nicolas I also would prefer to not add even more global
> state
> >>>> for
> >>>>>> logging
> >>>>>> to the library...
> >>>>>>
> >>>>>> All the fancy log formatting should be done in a log callback in
> >> the
> >>>>>> fftools and the default library logging callback should just be a
> >>>> very
> >>>>>> basic
> >>>>>> one, is my opinion on this.
> >>>>>
> >>>>> That's all fine and probably reasonable. But is it fair to block a
> >>>> small change because some major rework would be desired at some
> >> point?
> >>>>>
> >>>>> When that change will be made, it will of course move out this
> >> little
> >>>> change as well.
> >>>>>
> >>>>> But are you really saying that this small change cannot be made
> >>>> because you don't like the general way of the current
> implementation?
> >>>>>
> >>>>
> >>>> Just to be clear, I am not blocking this, just wanted to give my
> >>>> perspective on the topic.
> >>>> So if others think its fine and want it, lets go for it.
> >>>
> >>> Thanks - and sorry for my retardation, I just realized why it's bad
> to
> >> do it this way with regards to library usage. I'll add a callback so
> >> that fftools can do the prefix formatting.
> >>>
> >>> For the idea of moving all the formatting to fftools, wouldn't this
> be
> >> a major breakage for library consumers who are used to getting the
> log
> >> output formatted like now?
> >>>
> >>
> >> Yeah, one of the reasons why I did not really do any work on this yet
> as
> >> I am really
> >> not sure whats the best way to go about this to not be too surprising
> >> for existing
> >> library users...
> >
> > I think, people _do_ want the formatting even when using the libs
> directly, so while separating formatting from the plain logging might
> make sense, it would probably still need to be in avutil - otherwise
> most consumers would probably be annoyed and have to copy the formatting
> code from fftools to their own code base (or similar) - which wouldn't
> be a win for anybody.
>
> Right, I do think it might be useful to have helpers to make log
> formatting easier for library users (especially because as the final
> consumer you can then decide where to put some eventual state needed),
> and maybe also some to make it easier to obtain logging details from
> AVClass as this is right now somewhat hard to get right and I had to
> check the source code last time to figure out how its done.
>
> > I see why the global state is bad with regards to this patchset's
> feature (and V3 will remedy), but avoidance of global state would be
> much easier and also make more sense if there was some kind of "local
> state" as a replacement, so that people could for example have separate
> log outputs when performing separate and independent operations.
> > I suppose that's not easy to achieve with the current architecture?
>
> Yeah, I think the end goal should be to have a way to not have a global
> log callback, however that would require quite a bit of
> redesign.
Alright I thought so, just questionmarked because - with my patterns of thinking being dominated by object-oriented logic - I've been sometimes surprised by approaches in procedural languages to achieve similar things.
> A sort of hacky way right now to do this is use of thread local storage
> and then "demultiplex" the messages in the log callback
> based on that. However that only works as long as the message does not
> come from a "child" thread internally spawned by FFmpeg.
That's probably only feasible in very specific cases where you (as the consumer) know that it works.
The absolute minimum of an approach I can think of would be something like a "context_id", but it would need to (more or less) "auto-propagate" from context to context for all contexts that are being created - which sounds like a major change.
So, down to earth, for V3 of the patchset I have added a callback (av_log_formatprefix_callback) and a function to register (av_log_set_formatprefix_callback()) to log.c and the actual formatting (plus global state) is done in fftools now.
I realize that this is a much better way. Thanks for the feedback.
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avutil/log: Replace addresses in log output with simple ids
2025-03-06 10:08 ` Nicolas George
2025-03-06 17:02 ` Soft Works
@ 2025-03-06 20:56 ` Soft Works
1 sibling, 0 replies; 92+ messages in thread
From: Soft Works @ 2025-03-06 20:56 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: Donnerstag, 6. März 2025 11:09
> 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
>
> Soft Works (HE12025-03-05):
> > Sorry. So - seriously: what would be your recipe then?
>
> I see not just a little of non-trivial code for a very minor feature,
> that might be a hint that it would be best to let it go.
>
> Also, if somebody is debugging a program using the libraries, the
> pointers are relevant for that program. For that reason, I think the
> change is a bad idea in the library.
>
> On the other hand, you could do that change in the fftools. The point
> about pointers being relevant does not apply for them, and they can have
> as much global state as they want.
HI Nicolas,
initially I failed to see the impact of the array being global, I tend to forget about direct usages of the libs, sorry about that.
V3 of the patchset goes the route you are suggesting by introducing a callback for formatting of the context prefixes, so the global state lives in fftools only.
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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v3 0/4] avutil/log: Replace addresses in log output with simple ids
2025-03-05 18:19 ` [FFmpeg-devel] [PATCH v2 0/3] " ffmpegagent
` (3 preceding siblings ...)
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 20:59 ` ffmpegagent
2025-03-06 20:59 ` [FFmpeg-devel] [PATCH v3 1/4] avutil/log: Add callback for context prefix formatting softworkz
` (4 more replies)
4 siblings, 5 replies; 92+ messages in thread
From: ffmpegagent @ 2025-03-06 20:59 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
..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 (4):
avutil/log: Add callback for context prefix formatting
fftools/opt_common: add memaddresses log flag
fftools: Provide a log formatting callback for context prefixes
doc/fftools-common-opts: document memaddresses log flag
doc/APIchanges | 4 +++
doc/fftools-common-opts.texi | 2 ++
fftools/cmdutils.c | 69 ++++++++++++++++++++++++++++++++++++
fftools/cmdutils.h | 5 +++
fftools/ffmpeg.c | 1 +
fftools/ffplay.c | 1 +
fftools/ffprobe.c | 1 +
fftools/opt_common.c | 6 ++++
libavutil/log.c | 24 +++++++++----
libavutil/log.h | 29 +++++++++++++++
libavutil/version.h | 2 +-
11 files changed, 137 insertions(+), 7 deletions(-)
base-commit: 5c5be37daff4f4ecbe0c20d6a9f0fdad6eadc9c8
Published-As: https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-59%2Fsoftworkz%2Fsubmit_logaddresses-v3
Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg pr-ffstaging-59/softworkz/submit_logaddresses-v3
Pull-Request: https://github.com/ffstaging/FFmpeg/pull/59
Range-diff vs v2:
-: ---------- > 1: b8702de13b avutil/log: Add callback for context prefix formatting
2: 858e2cca9c = 2: 84c0848afc fftools/opt_common: add memaddresses log flag
1: 3a289533a7 ! 3: 105adac4ba avutil/log: Replace addresses in log output with simple ids
@@ Metadata
Author: softworkz <softworkz@hotmail.com>
## Commit message ##
- avutil/log: Replace addresses in log output with simple ids
+ fftools: Provide a log formatting callback for context prefixes
- ..and individual numbering. The benefits are:
+ This allows to print logical ids instead of memory addresses.
+ 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 ##
-@@
- 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:
+ ## fftools/cmdutils.c ##
+@@ fftools/cmdutils.c: AVDictionary *format_opts, *codec_opts;
- 2025-03-01 - xxxxxxxxxx - lavu 59.58.100 - pixfmt.h
-
- ## libavutil/log.c ##
-@@ libavutil/log.c: static AVMutex mutex = AV_MUTEX_INITIALIZER;
+ int hide_banner = 0;
- static int av_log_level = AV_LOG_INFO;
- static int flags;
+static int nb_class_ids;
+
+#define NB_CLASS_IDS 1000
@@ libavutil/log.c: static AVMutex mutex = AV_MUTEX_INITIALIZER;
+ // exceeded NB_CLASS_IDS entries in class_ids[]
+ return 0;
+}
++
+ void uninit_opts(void)
+ {
+ av_dict_free(&swr_opts);
+@@ fftools/cmdutils.c: static void check_options(const OptionDef *po)
+ }
+ }
- #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 int print_mem = flags & AV_LOG_PRINT_MEMADDRESSES;
++static const char *item_name(void *obj, const AVClass *cls)
++{
++ return (cls->item_name ? cls->item_name : av_default_item_name)(obj);
++}
+
- 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));
++static void log_formatprefix_callback(AVBPrint* buffer, AVClass** avcl, int log_flags)
++{
++ const int print_mem = log_flags & AV_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));
++}
+
- 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));
++void init_logformatting(void)
++{
++ av_log_set_formatprefix_callback(&log_formatprefix_callback);
++}
+
- if(type) type[1] = get_category(avcl);
- }
-
+ void parse_loglevel(int argc, char **argv, const OptionDef *options)
+ {
+ int idx;
- ## libavutil/log.h ##
-@@ libavutil/log.h: int av_log_format_line2(void *ptr, int level, const char *fmt, va_list vl,
+ ## fftools/cmdutils.h ##
+@@ fftools/cmdutils.h: int split_commandline(OptionParseContext *octx, int argc, char *argv[],
*/
- #define AV_LOG_PRINT_DATETIME 8
+ void uninit_parse_context(OptionParseContext *octx);
+/**
-+ * Print memory addresses instead of logical ids in the AVClass prefix.
++ * Sets up formatting callbacks for logging
+ */
-+#define AV_LOG_PRINT_MEMADDRESSES 16
++void init_logformatting(void);
+
- void av_log_set_flags(int arg);
- int av_log_get_flags(void);
+ /**
+ * Find the '-loglevel' option in the command line args and apply it.
+ */
+
+ ## fftools/ffmpeg.c ##
+@@ fftools/ffmpeg.c: int main(int argc, char **argv)
+ setvbuf(stderr,NULL,_IONBF,0); /* win32 runtime needs this */
+ av_log_set_flags(AV_LOG_SKIP_REPEATED);
++ init_logformatting();
+ parse_loglevel(argc, argv, options);
+
+ #if CONFIG_AVDEVICE
- ## libavutil/version.h ##
-@@
- */
+ ## fftools/ffplay.c ##
+@@ fftools/ffplay.c: int main(int argc, char **argv)
+ init_dynload();
+
+ av_log_set_flags(AV_LOG_SKIP_REPEATED);
++ init_logformatting();
+ parse_loglevel(argc, argv, options);
+
+ /* register all codecs, demux and protocols */
+
+ ## fftools/ffprobe.c ##
+@@ fftools/ffprobe.c: int main(int argc, char **argv)
+ init_dynload();
- #define LIBAVUTIL_VERSION_MAJOR 59
--#define LIBAVUTIL_VERSION_MINOR 58
-+#define LIBAVUTIL_VERSION_MINOR 59
- #define LIBAVUTIL_VERSION_MICRO 100
+ av_log_set_flags(AV_LOG_SKIP_REPEATED);
++ init_logformatting();
- #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
+ options = real_options;
+ parse_loglevel(argc, argv, options);
3: 411c77bdeb = 4: 9dc2cbe5ca 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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v3 1/4] avutil/log: Add callback for context prefix formatting
2025-03-06 20:59 ` [FFmpeg-devel] [PATCH v3 0/4] " ffmpegagent
@ 2025-03-06 20:59 ` softworkz
2025-03-07 9:44 ` Nicolas George
2025-03-06 20:59 ` [FFmpeg-devel] [PATCH v3 2/4] fftools/opt_common: add memaddresses log flag softworkz
` (3 subsequent siblings)
4 siblings, 1 reply; 92+ messages in thread
From: softworkz @ 2025-03-06 20:59 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
From: softworkz <softworkz@hotmail.com>
also adds a log flag AV_LOG_PRINT_MEMADDRESSES, which is meant to
control prefix formatting. The actual formatting has to be performed
by the consuming application which needs to provide a formatting
callback via av_log_set_formatprefix_callback.
Signed-off-by: softworkz <softworkz@hotmail.com>
---
doc/APIchanges | 4 ++++
libavutil/log.c | 24 ++++++++++++++++++------
libavutil/log.h | 29 +++++++++++++++++++++++++++++
libavutil/version.h | 2 +-
4 files changed, 52 insertions(+), 7 deletions(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index 5a64836e25..92e4a2e055 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -1,5 +1,9 @@
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, av_log_set_formatprefix_callback,
+ av_log_formatprefix_default_callback
+
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..6697bdba70 100644
--- a/libavutil/log.c
+++ b/libavutil/log.c
@@ -315,6 +315,14 @@ static void format_date_now(AVBPrint* bp_time, int include_date)
}
}
+void av_log_formatprefix_default_callback(AVBPrint* buffer, AVClass** avcl, int log_flags)
+{
+ av_bprintf(buffer+0, "[%s @ %p] ", item_name(avcl, *avcl), avcl);
+}
+
+static void (*av_log_formatprefix_callback)(AVBPrint* part, AVClass** avcl, int log_flags) =
+ av_log_formatprefix_default_callback;
+
static void format_line(void *avcl, int level, const char *fmt, va_list vl,
AVBPrint part[5], int *print_prefix, int type[2])
{
@@ -327,17 +335,16 @@ 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) {
+
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_log_formatprefix_callback(part, parent, flags);
if(type) type[0] = get_category(parent);
}
}
- av_bprintf(part+1, "[%s @ %p] ",
- item_name(avcl, avc), avcl);
+ av_log_formatprefix_callback(part, avcl, flags);
+
if(type) type[1] = get_category(avcl);
}
@@ -485,6 +492,11 @@ int av_log_get_flags(void)
return flags;
}
+void av_log_set_formatprefix_callback(void (*callback)(AVBPrint* buffer, AVClass** avcl, int log_flags))
+{
+ av_log_formatprefix_callback = callback;
+}
+
void av_log_set_callback(void (*callback)(void*, int, const char*, va_list))
{
av_log_callback = callback;
diff --git a/libavutil/log.h b/libavutil/log.h
index dd094307ce..a69888c1ad 100644
--- a/libavutil/log.h
+++ b/libavutil/log.h
@@ -24,6 +24,7 @@
#include <stdarg.h>
#include "attributes.h"
#include "version.h"
+#include "bprint.h"
typedef enum {
AV_CLASS_CATEGORY_NA = 0,
@@ -323,6 +324,29 @@ int av_log_get_level(void);
*/
void av_log_set_level(int level);
+/**
+ * Set the prefix formatting callback
+ *
+ * @note The callback must be thread safe, even if the application does not use
+ * threads itself as some codecs are multithreaded.
+ *
+ * @see av_log_formatprefix_default_callback
+ *
+ * @param callback A formatting function with a compatible signature.
+ */
+void av_log_set_formatprefix_callback(void (*callback)(AVBPrint* buffer, AVClass** avcl, int log_flags));
+
+/**
+ * Default prefix formatting callback
+ *
+ * It prints the message to stderr, optionally colorizing it.
+ *
+ * @param buffer A pointer to the print buffer.
+ * @param avcl The AVClass reference for which to format the prefix.
+ * @param log_flags The enabled logging flags
+ */
+void av_log_formatprefix_default_callback(AVBPrint* buffer, AVClass** avcl, int log_flags);
+
/**
* Set the logging callback
*
@@ -416,6 +440,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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v3 2/4] fftools/opt_common: add memaddresses log flag
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 ` softworkz
2025-03-06 20:59 ` [FFmpeg-devel] [PATCH v3 3/4] fftools: Provide a log formatting callback for context prefixes softworkz
` (2 subsequent siblings)
4 siblings, 0 replies; 92+ messages in thread
From: softworkz @ 2025-03-06 20:59 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v3 3/4] fftools: Provide a log formatting callback for context prefixes
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 ` softworkz
2025-03-06 20:59 ` [FFmpeg-devel] [PATCH v3 4/4] doc/fftools-common-opts: document memaddresses log flag softworkz
2025-03-08 23:02 ` [FFmpeg-devel] [PATCH v4 0/4] avutil/log: Replace addresses in log output with simple ids ffmpegagent
4 siblings, 0 replies; 92+ messages in thread
From: softworkz @ 2025-03-06 20:59 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
From: softworkz <softworkz@hotmail.com>
This allows to print logical ids instead of memory addresses.
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
---
fftools/cmdutils.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++
fftools/cmdutils.h | 5 ++++
fftools/ffmpeg.c | 1 +
fftools/ffplay.c | 1 +
fftools/ffprobe.c | 1 +
5 files changed, 77 insertions(+)
diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 8ac20bf049..9f93eb6523 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -59,6 +59,56 @@ AVDictionary *format_opts, *codec_opts;
int hide_banner = 0;
+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;
+}
+
void uninit_opts(void)
{
av_dict_free(&swr_opts);
@@ -550,6 +600,25 @@ static void check_options(const OptionDef *po)
}
}
+static const char *item_name(void *obj, const AVClass *cls)
+{
+ return (cls->item_name ? cls->item_name : av_default_item_name)(obj);
+}
+
+static void log_formatprefix_callback(AVBPrint* buffer, AVClass** avcl, int log_flags)
+{
+ const int print_mem = log_flags & AV_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));
+}
+
+void init_logformatting(void)
+{
+ av_log_set_formatprefix_callback(&log_formatprefix_callback);
+}
+
void parse_loglevel(int argc, char **argv, const OptionDef *options)
{
int idx;
diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h
index 316b6a8c64..182d894ff9 100644
--- a/fftools/cmdutils.h
+++ b/fftools/cmdutils.h
@@ -401,6 +401,11 @@ int split_commandline(OptionParseContext *octx, int argc, char *argv[],
*/
void uninit_parse_context(OptionParseContext *octx);
+/**
+ * Sets up formatting callbacks for logging
+ */
+void init_logformatting(void);
+
/**
* Find the '-loglevel' option in the command line args and apply it.
*/
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index dc321fb4a2..f84a7024be 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -955,6 +955,7 @@ int main(int argc, char **argv)
setvbuf(stderr,NULL,_IONBF,0); /* win32 runtime needs this */
av_log_set_flags(AV_LOG_SKIP_REPEATED);
+ init_logformatting();
parse_loglevel(argc, argv, options);
#if CONFIG_AVDEVICE
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 2a572fc3aa..2e093c0069 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -3762,6 +3762,7 @@ int main(int argc, char **argv)
init_dynload();
av_log_set_flags(AV_LOG_SKIP_REPEATED);
+ init_logformatting();
parse_loglevel(argc, argv, options);
/* register all codecs, demux and protocols */
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 7341731d2f..3a9f2128fd 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -4652,6 +4652,7 @@ int main(int argc, char **argv)
init_dynload();
av_log_set_flags(AV_LOG_SKIP_REPEATED);
+ init_logformatting();
options = real_options;
parse_loglevel(argc, argv, options);
--
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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v3 4/4] doc/fftools-common-opts: document memaddresses log flag
2025-03-06 20:59 ` [FFmpeg-devel] [PATCH v3 0/4] " ffmpegagent
` (2 preceding siblings ...)
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 ` softworkz
2025-03-08 23:02 ` [FFmpeg-devel] [PATCH v4 0/4] avutil/log: Replace addresses in log output with simple ids ffmpegagent
4 siblings, 0 replies; 92+ messages in thread
From: softworkz @ 2025-03-06 20:59 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v3 1/4] avutil/log: Add callback for context prefix formatting
2025-03-06 20:59 ` [FFmpeg-devel] [PATCH v3 1/4] avutil/log: Add callback for context prefix formatting softworkz
@ 2025-03-07 9:44 ` Nicolas George
2025-03-07 17:23 ` Soft Works
0 siblings, 1 reply; 92+ messages in thread
From: Nicolas George @ 2025-03-07 9:44 UTC (permalink / raw)
To: FFmpeg development discussions and patches
softworkz (HE12025-03-06):
> From: softworkz <softworkz@hotmail.com>
>
> also adds a log flag AV_LOG_PRINT_MEMADDRESSES, which is meant to
> control prefix formatting. The actual formatting has to be performed
> by the consuming application which needs to provide a formatting
> callback via av_log_set_formatprefix_callback.
Still more global state in the libraries.
Also, inconsistent style.
--
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v3 1/4] avutil/log: Add callback for context prefix formatting
2025-03-07 9:44 ` Nicolas George
@ 2025-03-07 17:23 ` Soft Works
2025-03-07 17:30 ` Hendrik Leppkes
0 siblings, 1 reply; 92+ messages in thread
From: Soft Works @ 2025-03-07 17:23 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: Freitag, 7. März 2025 10:44
> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH v3 1/4] avutil/log: Add callback for
> context prefix formatting
>
> softworkz (HE12025-03-06):
> > From: softworkz <softworkz@hotmail.com>
> >
> > also adds a log flag AV_LOG_PRINT_MEMADDRESSES, which is meant to
> > control prefix formatting. The actual formatting has to be performed
> > by the consuming application which needs to provide a formatting
> > callback via av_log_set_formatprefix_callback.
>
> Still more global state in the libraries.
You mean the callback?
> Also, inconsistent style.
Could you please be more specific?
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v3 1/4] avutil/log: Add callback for context prefix formatting
2025-03-07 17:23 ` Soft Works
@ 2025-03-07 17:30 ` Hendrik Leppkes
2025-03-07 18:02 ` Soft Works
0 siblings, 1 reply; 92+ messages in thread
From: Hendrik Leppkes @ 2025-03-07 17:30 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Fri, Mar 7, 2025 at 6:23 PM Soft Works
<softworkz-at-hotmail.com@ffmpeg.org> wrote:
>
>
>
> > -----Original Message-----
> > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> > Nicolas George
> > Sent: Freitag, 7. März 2025 10:44
> > To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
> > Subject: Re: [FFmpeg-devel] [PATCH v3 1/4] avutil/log: Add callback for
> > context prefix formatting
> >
> > softworkz (HE12025-03-06):
> > > From: softworkz <softworkz@hotmail.com>
> > >
> > > also adds a log flag AV_LOG_PRINT_MEMADDRESSES, which is meant to
> > > control prefix formatting. The actual formatting has to be performed
> > > by the consuming application which needs to provide a formatting
> > > callback via av_log_set_formatprefix_callback.
> >
> > Still more global state in the libraries.
>
> You mean the callback?
>
Yes. You are also adding a new callback thats used from within a
callback, if someone uses av_log_set_callback then it might just not
get used.
So instead, why not provide a different implementation of the log
callback and use the existing av_log_set_callback function? Then no
library changes are needed at all.
- Hendrik
_______________________________________________
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v3 1/4] avutil/log: Add callback for context prefix formatting
2025-03-07 17:30 ` Hendrik Leppkes
@ 2025-03-07 18:02 ` Soft Works
0 siblings, 0 replies; 92+ messages in thread
From: Soft Works @ 2025-03-07 18:02 UTC (permalink / raw)
To: FFmpeg development discussions and patches
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Hendrik Leppkes
> Sent: Freitag, 7. März 2025 18:31
> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH v3 1/4] avutil/log: Add callback for
> context prefix formatting
>
> On Fri, Mar 7, 2025 at 6:23 PM Soft Works
> <softworkz-at-hotmail.com@ffmpeg.org> wrote:
> >
> >
> >
> > > -----Original Message-----
> > > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> > > Nicolas George
> > > Sent: Freitag, 7. März 2025 10:44
> > > To: FFmpeg development discussions and patches <ffmpeg-
> devel@ffmpeg.org>
> > > Subject: Re: [FFmpeg-devel] [PATCH v3 1/4] avutil/log: Add callback
> for
> > > context prefix formatting
> > >
> > > softworkz (HE12025-03-06):
> > > > From: softworkz <softworkz@hotmail.com>
> > > >
> > > > also adds a log flag AV_LOG_PRINT_MEMADDRESSES, which is meant to
> > > > control prefix formatting. The actual formatting has to be
> performed
> > > > by the consuming application which needs to provide a formatting
> > > > callback via av_log_set_formatprefix_callback.
> > >
> > > Still more global state in the libraries.
Hi Hendrik,
> > You mean the callback?
> >
>
> Yes. You are also adding a new callback thats used from within a
> callback, if someone uses av_log_set_callback then it might just not
> get used.
Yes, that's true. fftools are sometimes setting it to some "simple" implementation like in cases when printing help information, yet there's no prefix formatting needed - that's why I didn't see it as a problem, but indeed it's kind of going around 2 corners here.
> So instead, why not provide a different implementation of the log
> callback and use the existing av_log_set_callback function? Then no
> library changes are needed at all.
I like the idea. I had thought about it for a moment but disregarded it (maybe too) early, being afraid of people criticizing the code duplication involved in doing so.
But I'm open to go that way.
The option for printing date and time on log lines has just recently been added and not included in any release yet. Maybe that's something that should only be done in the fftools version of the logging callback as well?
Thanks for your suggestion,
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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v4 0/4] avutil/log: Replace addresses in log output with simple ids
2025-03-06 20:59 ` [FFmpeg-devel] [PATCH v3 0/4] " ffmpegagent
` (3 preceding siblings ...)
2025-03-06 20:59 ` [FFmpeg-devel] [PATCH v3 4/4] doc/fftools-common-opts: document memaddresses log flag softworkz
@ 2025-03-08 23:02 ` ffmpegagent
2025-03-08 23:02 ` [FFmpeg-devel] [PATCH v4 1/4] avutil/log: Add AV_LOG_PRINT_MEMADDRESSES logging flag softworkz
` (4 more replies)
4 siblings, 5 replies; 92+ messages in thread
From: ffmpegagent @ 2025-03-08 23:02 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
..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)
softworkz (4):
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
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 | 480 +++++++++++++++++++++++++++++++++++
fftools/fftools_log.h | 44 ++++
fftools/opt_common.c | 6 +
libavutil/log.h | 5 +
libavutil/version.h | 2 +-
12 files changed, 554 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-v4
Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg pr-ffstaging-59/softworkz/submit_logaddresses-v4
Pull-Request: https://github.com/ffstaging/FFmpeg/pull/59
Range-diff vs v3:
1: b8702de13b ! 1: 4be966796c avutil/log: Add callback for context prefix formatting
@@ Metadata
Author: softworkz <softworkz@hotmail.com>
## Commit message ##
- avutil/log: Add callback for context prefix formatting
+ avutil/log: Add AV_LOG_PRINT_MEMADDRESSES logging flag
- also adds a log flag AV_LOG_PRINT_MEMADDRESSES, which is meant to
- control prefix formatting. The actual formatting has to be performed
- by the consuming application which needs to provide a formatting
- callback via av_log_set_formatprefix_callback.
+ which is meant to control prefix formatting. The actual formatting
+ has to be performed by the consuming application which needs to provide
+ a custom logging callback via av_log_set_callback().
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, av_log_set_formatprefix_callback,
-+ av_log_formatprefix_default_callback
++ 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 void format_date_now(AVBPrint* bp_time, int include_date)
- }
- }
-
-+void av_log_formatprefix_default_callback(AVBPrint* buffer, AVClass** avcl, int log_flags)
-+{
-+ av_bprintf(buffer+0, "[%s @ %p] ", item_name(avcl, *avcl), avcl);
-+}
-+
-+static void (*av_log_formatprefix_callback)(AVBPrint* part, AVClass** avcl, int log_flags) =
-+ av_log_formatprefix_default_callback;
-+
- static void format_line(void *avcl, int level, const char *fmt, va_list vl,
- AVBPrint part[5], int *print_prefix, int type[2])
- {
-@@ 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) {
-+
- 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_log_formatprefix_callback(part, parent, flags);
- if(type) type[0] = get_category(parent);
- }
- }
-- av_bprintf(part+1, "[%s @ %p] ",
-- item_name(avcl, avc), avcl);
-+ av_log_formatprefix_callback(part, avcl, flags);
-+
- if(type) type[1] = get_category(avcl);
- }
-
-@@ libavutil/log.c: int av_log_get_flags(void)
- return flags;
- }
-
-+void av_log_set_formatprefix_callback(void (*callback)(AVBPrint* buffer, AVClass** avcl, int log_flags))
-+{
-+ av_log_formatprefix_callback = callback;
-+}
-+
- void av_log_set_callback(void (*callback)(void*, int, const char*, va_list))
- {
- av_log_callback = callback;
-
## libavutil/log.h ##
-@@
- #include <stdarg.h>
- #include "attributes.h"
- #include "version.h"
-+#include "bprint.h"
-
- typedef enum {
- AV_CLASS_CATEGORY_NA = 0,
-@@ libavutil/log.h: int av_log_get_level(void);
- */
- void av_log_set_level(int level);
-
-+/**
-+ * Set the prefix formatting callback
-+ *
-+ * @note The callback must be thread safe, even if the application does not use
-+ * threads itself as some codecs are multithreaded.
-+ *
-+ * @see av_log_formatprefix_default_callback
-+ *
-+ * @param callback A formatting function with a compatible signature.
-+ */
-+void av_log_set_formatprefix_callback(void (*callback)(AVBPrint* buffer, AVClass** avcl, int log_flags));
-+
-+/**
-+ * Default prefix formatting callback
-+ *
-+ * It prints the message to stderr, optionally colorizing it.
-+ *
-+ * @param buffer A pointer to the print buffer.
-+ * @param avcl The AVClass reference for which to format the prefix.
-+ * @param log_flags The enabled logging flags
-+ */
-+void av_log_formatprefix_default_callback(AVBPrint* buffer, AVClass** avcl, int log_flags);
-+
- /**
- * Set the logging callback
- *
@@ libavutil/log.h: int av_log_format_line2(void *ptr, int level, const char *fmt, va_list vl,
*/
#define AV_LOG_PRINT_DATETIME 8
2: 84c0848afc = 2: e4f8213c24 fftools/opt_common: add memaddresses log flag
3: 105adac4ba ! 3: fa1ae9231a fftools: Provide a log formatting callback for context prefixes
@@ Metadata
Author: softworkz <softworkz@hotmail.com>
## Commit message ##
- fftools: Provide a log formatting callback for context prefixes
+ fftools: Provide a an fftools-specific logging callback function
- This allows to print logical ids instead of memory addresses.
+ This goes together with a change to logging of context prefixes, which
+ is printing logical ids instead of memory addresses.
The benefits are:
- Smaller log file sizes
@@ Commit message
- It eventually allows comparing and viewing log file diffs
without almost every line being different due to those addresses
- ## fftools/cmdutils.c ##
-@@ fftools/cmdutils.c: AVDictionary *format_opts, *codec_opts;
+ ## fftools/Makefile ##
+@@ fftools/Makefile: OBJS-ffmpeg += \
+ fftools/ffmpeg_mux_init.o \
+ fftools/ffmpeg_opt.o \
+ fftools/ffmpeg_sched.o \
++ fftools/fftools_log.o \
+ fftools/sync_queue.o \
+ fftools/thread_queue.o \
- int hide_banner = 0;
+-OBJS-ffplay += fftools/ffplay_renderer.o
++OBJS-ffprobe += \
++ fftools/fftools_log.o \
++
++OBJS-ffplay += fftools/ffplay_renderer.o \
++ fftools/fftools_log.o \
+
+ define DOFFTOOL
+ OBJS-$(1) += fftools/cmdutils.o fftools/opt_common.o fftools/$(1).o $(OBJS-$(1)-yes)
+
+ ## fftools/ffmpeg.c ##
+@@
+ #include "ffmpeg.h"
+ #include "ffmpeg_sched.h"
+ #include "ffmpeg_utils.h"
++#include "fftools_log.h"
+
+ const char program_name[] = "ffmpeg";
+ const int program_birth_year = 2000;
+@@ fftools/ffmpeg.c: int main(int argc, char **argv)
+ setvbuf(stderr,NULL,_IONBF,0); /* win32 runtime needs this */
+
+ av_log_set_flags(AV_LOG_SKIP_REPEATED);
++ init_logging();
+ parse_loglevel(argc, argv, options);
+
+ #if CONFIG_AVDEVICE
+
+ ## fftools/ffmpeg_filter.c ##
+@@
+ /*
+- * ffmpeg filter configuration
++ * Copyright (c) The FFmpeg developers
+ *
+ * This file is part of FFmpeg.
+ *
+
+ ## fftools/ffplay.c ##
+@@
+ #include "cmdutils.h"
+ #include "ffplay_renderer.h"
+ #include "opt_common.h"
++#include "fftools_log.h"
+
+ const char program_name[] = "ffplay";
+ const int program_birth_year = 2003;
+@@ fftools/ffplay.c: int main(int argc, char **argv)
+ init_dynload();
+
+ av_log_set_flags(AV_LOG_SKIP_REPEATED);
++ init_logging();
+ parse_loglevel(argc, argv, options);
+ /* register all codecs, demux and protocols */
+
+ ## fftools/ffprobe.c ##
+@@
+ #include "libavfilter/version.h"
+ #include "cmdutils.h"
+ #include "opt_common.h"
++#include "fftools_log.h"
+
+ #include "libavutil/thread.h"
+
+@@ fftools/ffprobe.c: int main(int argc, char **argv)
+ init_dynload();
+
+ av_log_set_flags(AV_LOG_SKIP_REPEATED);
++ init_logging();
+
+ options = real_options;
+ parse_loglevel(argc, argv, options);
+
+ ## fftools/fftools_log.c (new) ##
+@@
++/*
++ * Copyright (c) The FFmpeg developers
++ *
++ * This file is part of FFmpeg.
++ *
++ * FFmpeg is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2.1 of the License, or (at your option) any later version.
++ *
++ * FFmpeg is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with FFmpeg; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++
++#include "config.h"
++
++#if HAVE_UNISTD_H
++#include <unistd.h>
++#endif
++#if HAVE_IO_H
++#include <io.h>
++#endif
++#include <inttypes.h>
++#include <stdarg.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include "libavutil/bprint.h"
++#include "libavutil/common.h"
++//#include "libavutil/internal.h"
++#include "libavutil/log.h"
++#include "libavutil/thread.h"
++#include "libavutil/time.h"
++//#include "libavutil/time_internal.h"
++
++#include "fftools_log.h"
++
++
++#if !HAVE_LOCALTIME_R && !defined(localtime_r)
++static inline struct tm *ff_localtime_r(const time_t* clock, struct tm *result)
++{
++ struct tm *ptr = localtime(clock);
++ if (!ptr)
++ return NULL;
++ *result = *ptr;
++ return result;
++}
++#define localtime_r ff_localtime_r
++#endif
++
+static int nb_class_ids;
+
+#define NB_CLASS_IDS 1000
@@ fftools/cmdutils.c: AVDictionary *format_opts, *codec_opts;
+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;
+
@@ fftools/cmdutils.c: AVDictionary *format_opts, *codec_opts;
+ return 0;
+}
+
- void uninit_opts(void)
- {
- av_dict_free(&swr_opts);
-@@ fftools/cmdutils.c: static void check_options(const OptionDef *po)
- }
- }
-
++static AVMutex mutex = AV_MUTEX_INITIALIZER;
++
++#define LINE_SZ 1024
++
++#if HAVE_VALGRIND_VALGRIND_H && CONFIG_VALGRIND_BACKTRACE
++#include <valgrind/valgrind.h>
++/* this is the log level at which valgrind will output a full backtrace */
++#define BACKTRACE_LOGLEVEL AV_LOG_ERROR
++#endif
++
++#define NB_LEVELS 8
++#if defined(_WIN32) && HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
++#include <windows.h>
++static const uint8_t color[16 + AV_CLASS_CATEGORY_NB] = {
++ [AV_LOG_PANIC /8] = 12,
++ [AV_LOG_FATAL /8] = 12,
++ [AV_LOG_ERROR /8] = 12,
++ [AV_LOG_WARNING/8] = 14,
++ [AV_LOG_INFO /8] = 7,
++ [AV_LOG_VERBOSE/8] = 10,
++ [AV_LOG_DEBUG /8] = 10,
++ [AV_LOG_TRACE /8] = 8,
++ [16+AV_CLASS_CATEGORY_NA ] = 7,
++ [16+AV_CLASS_CATEGORY_INPUT ] = 13,
++ [16+AV_CLASS_CATEGORY_OUTPUT ] = 5,
++ [16+AV_CLASS_CATEGORY_MUXER ] = 13,
++ [16+AV_CLASS_CATEGORY_DEMUXER ] = 5,
++ [16+AV_CLASS_CATEGORY_ENCODER ] = 11,
++ [16+AV_CLASS_CATEGORY_DECODER ] = 3,
++ [16+AV_CLASS_CATEGORY_FILTER ] = 10,
++ [16+AV_CLASS_CATEGORY_BITSTREAM_FILTER] = 9,
++ [16+AV_CLASS_CATEGORY_SWSCALER ] = 7,
++ [16+AV_CLASS_CATEGORY_SWRESAMPLER ] = 7,
++ [16+AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT ] = 13,
++ [16+AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT ] = 5,
++ [16+AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT ] = 13,
++ [16+AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT ] = 5,
++ [16+AV_CLASS_CATEGORY_DEVICE_OUTPUT ] = 13,
++ [16+AV_CLASS_CATEGORY_DEVICE_INPUT ] = 5,
++};
++
++static int16_t background, attr_orig;
++static HANDLE con;
++#else
++
++static const uint32_t color[16 + AV_CLASS_CATEGORY_NB] = {
++ [AV_LOG_PANIC /8] = 52 << 16 | 196 << 8 | 0x41,
++ [AV_LOG_FATAL /8] = 208 << 8 | 0x41,
++ [AV_LOG_ERROR /8] = 196 << 8 | 0x11,
++ [AV_LOG_WARNING/8] = 226 << 8 | 0x03,
++ [AV_LOG_INFO /8] = 253 << 8 | 0x09,
++ [AV_LOG_VERBOSE/8] = 40 << 8 | 0x02,
++ [AV_LOG_DEBUG /8] = 34 << 8 | 0x02,
++ [AV_LOG_TRACE /8] = 34 << 8 | 0x07,
++ [16+AV_CLASS_CATEGORY_NA ] = 250 << 8 | 0x09,
++ [16+AV_CLASS_CATEGORY_INPUT ] = 219 << 8 | 0x15,
++ [16+AV_CLASS_CATEGORY_OUTPUT ] = 201 << 8 | 0x05,
++ [16+AV_CLASS_CATEGORY_MUXER ] = 213 << 8 | 0x15,
++ [16+AV_CLASS_CATEGORY_DEMUXER ] = 207 << 8 | 0x05,
++ [16+AV_CLASS_CATEGORY_ENCODER ] = 51 << 8 | 0x16,
++ [16+AV_CLASS_CATEGORY_DECODER ] = 39 << 8 | 0x06,
++ [16+AV_CLASS_CATEGORY_FILTER ] = 155 << 8 | 0x12,
++ [16+AV_CLASS_CATEGORY_BITSTREAM_FILTER] = 192 << 8 | 0x14,
++ [16+AV_CLASS_CATEGORY_SWSCALER ] = 153 << 8 | 0x14,
++ [16+AV_CLASS_CATEGORY_SWRESAMPLER ] = 147 << 8 | 0x14,
++ [16+AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT ] = 213 << 8 | 0x15,
++ [16+AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT ] = 207 << 8 | 0x05,
++ [16+AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT ] = 213 << 8 | 0x15,
++ [16+AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT ] = 207 << 8 | 0x05,
++ [16+AV_CLASS_CATEGORY_DEVICE_OUTPUT ] = 213 << 8 | 0x15,
++ [16+AV_CLASS_CATEGORY_DEVICE_INPUT ] = 207 << 8 | 0x05,
++};
++
++#endif
++static int use_color = -1;
++
++#if defined(_WIN32) && HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
++static void win_console_puts(const char *str)
++{
++ const uint8_t *q = str;
++ uint16_t line[LINE_SZ];
++
++ while (*q) {
++ uint16_t *buf = line;
++ DWORD nb_chars = 0;
++ DWORD written;
++
++ while (*q && nb_chars < LINE_SZ - 1) {
++ uint32_t ch;
++ uint16_t tmp;
++
++ GET_UTF8(ch, *q ? *q++ : 0, ch = 0xfffd; goto continue_on_invalid;)
++continue_on_invalid:
++ PUT_UTF16(ch, tmp, *buf++ = tmp; nb_chars++;)
++ }
++
++ WriteConsoleW(con, line, nb_chars, &written, NULL);
++ }
++}
++#endif
++
++static void check_color_terminal(void)
++{
++ char *term = getenv("TERM");
++
++#if defined(_WIN32) && HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
++ CONSOLE_SCREEN_BUFFER_INFO con_info;
++ DWORD dummy;
++ con = GetStdHandle(STD_ERROR_HANDLE);
++ if (con != INVALID_HANDLE_VALUE && !GetConsoleMode(con, &dummy))
++ con = INVALID_HANDLE_VALUE;
++ if (con != INVALID_HANDLE_VALUE) {
++ GetConsoleScreenBufferInfo(con, &con_info);
++ attr_orig = con_info.wAttributes;
++ background = attr_orig & 0xF0;
++ }
++#endif
++
++ if (getenv("AV_LOG_FORCE_NOCOLOR")) {
++ use_color = 0;
++ } else if (getenv("AV_LOG_FORCE_COLOR")) {
++ use_color = 1;
++ } else {
++#if defined(_WIN32) && HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
++ use_color = (con != INVALID_HANDLE_VALUE);
++#elif HAVE_ISATTY
++ use_color = (term && isatty(2));
++#else
++ use_color = 0;
++#endif
++ }
++
++ if (getenv("AV_LOG_FORCE_256COLOR") || term && strstr(term, "256color"))
++ use_color *= 256;
++}
++
++static void ansi_fputs(int level, int tint, const char *str, int local_use_color)
++{
++ if (local_use_color == 1) {
++ fprintf(stderr,
++ "\033[%"PRIu32";3%"PRIu32"m%s\033[0m",
++ (color[level] >> 4) & 15,
++ color[level] & 15,
++ str);
++ } else if (tint && use_color == 256) {
++ fprintf(stderr,
++ "\033[48;5;%"PRIu32"m\033[38;5;%dm%s\033[0m",
++ (color[level] >> 16) & 0xff,
++ tint,
++ str);
++ } else if (local_use_color == 256) {
++ fprintf(stderr,
++ "\033[48;5;%"PRIu32"m\033[38;5;%"PRIu32"m%s\033[0m",
++ (color[level] >> 16) & 0xff,
++ (color[level] >> 8) & 0xff,
++ str);
++ } else
++ fputs(str, stderr);
++}
++
++static void colored_fputs(int level, int tint, const char *str)
++{
++ int local_use_color;
++ if (!*str)
++ return;
++
++ if (use_color < 0)
++ check_color_terminal();
++
++ if (level == AV_LOG_INFO/8) local_use_color = 0;
++ else local_use_color = use_color;
++
++#if defined(_WIN32) && HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
++ if (con != INVALID_HANDLE_VALUE) {
++ if (local_use_color)
++ SetConsoleTextAttribute(con, background | color[level]);
++ win_console_puts(str);
++ if (local_use_color)
++ SetConsoleTextAttribute(con, attr_orig);
++ } else {
++ ansi_fputs(level, tint, str, local_use_color);
++ }
++#else
++ ansi_fputs(level, tint, str, local_use_color);
++#endif
++
++}
++
++static void sanitize(uint8_t *line){
++ while(*line){
++ if(*line < 0x08 || (*line > 0x0D && *line < 0x20))
++ *line='?';
++ line++;
++ }
++}
++
++static int get_category(void *ptr){
++ AVClass *avc = *(AVClass **) ptr;
++ if( !avc
++ || (avc->version&0xFF)<100
++ || avc->version < (51 << 16 | 59 << 8)
++ || avc->category >= AV_CLASS_CATEGORY_NB) return AV_CLASS_CATEGORY_NA + 16;
++
++ if(avc->get_category)
++ return avc->get_category(ptr) + 16;
++
++ return avc->category + 16;
++}
++
++static const char *get_level_str(int level)
++{
++ switch (level) {
++ case AV_LOG_QUIET:
++ return "quiet";
++ case AV_LOG_DEBUG:
++ return "debug";
++ case AV_LOG_TRACE:
++ return "trace";
++ case AV_LOG_VERBOSE:
++ return "verbose";
++ case AV_LOG_INFO:
++ return "info";
++ case AV_LOG_WARNING:
++ return "warning";
++ case AV_LOG_ERROR:
++ return "error";
++ case AV_LOG_FATAL:
++ return "fatal";
++ case AV_LOG_PANIC:
++ return "panic";
++ default:
++ return "";
++ }
++}
++
+static const char *item_name(void *obj, const AVClass *cls)
+{
+ return (cls->item_name ? cls->item_name : av_default_item_name)(obj);
+}
+
-+static void log_formatprefix_callback(AVBPrint* buffer, AVClass** avcl, int log_flags)
++static void format_date_now(AVBPrint* bp_time, int include_date)
++{
++ struct tm *ptm, tmbuf;
++ const int64_t time_us = av_gettime();
++ const int64_t time_ms = time_us / 1000;
++ const time_t time_s = time_ms / 1000;
++ const int millisec = time_ms - (time_s * 1000);
++ ptm = localtime_r(&time_s, &tmbuf);
++ if (ptm) {
++ if (include_date)
++ av_bprint_strftime(bp_time, "%Y-%m-%d ", ptm);
++
++ av_bprint_strftime(bp_time, "%H:%M:%S", ptm);
++ av_bprintf(bp_time, ".%03d ", millisec);
++ }
++}
++
++static void log_formatprefix(AVBPrint* buffer, AVClass** avcl, int log_flags)
+{
+ const int print_mem = log_flags & AV_LOG_PRINT_MEMADDRESSES;
+ if (print_mem)
@@ fftools/cmdutils.c: static void check_options(const OptionDef *po)
+ av_bprintf(buffer+0, "[%s #%u] ", item_name(avcl, *avcl), get_class_id(avcl));
+}
+
-+void init_logformatting(void)
++static void format_line(void *avcl, int level, const char *fmt, va_list vl,
++ AVBPrint part[5], int *print_prefix, int type[2], int current_flags)
+{
-+ av_log_set_formatprefix_callback(&log_formatprefix_callback);
++ AVClass* avc = avcl ? *(AVClass **) avcl : NULL;
++ av_bprint_init(part+0, 0, AV_BPRINT_SIZE_AUTOMATIC);
++ av_bprint_init(part+1, 0, AV_BPRINT_SIZE_AUTOMATIC);
++ av_bprint_init(part+2, 0, AV_BPRINT_SIZE_AUTOMATIC);
++ av_bprint_init(part+3, 0, 65536);
++ av_bprint_init(part+4, 0, AV_BPRINT_SIZE_AUTOMATIC);
++
++ if(type) type[0] = type[1] = AV_CLASS_CATEGORY_NA + 16;
++ if (*print_prefix && avc) {
++
++ if (avc->parent_log_context_offset) {
++ AVClass** parent = *(AVClass ***) ((uint8_t *)avcl + avc->parent_log_context_offset);
++ if (parent && *parent) {
++ log_formatprefix(part, parent, current_flags);
++ if(type) type[0] = get_category(parent);
++ }
++ }
++ log_formatprefix(part, avcl, current_flags);
++
++ if(type) type[1] = get_category(avcl);
++ }
++
++ if (*print_prefix && (level > AV_LOG_QUIET) && (current_flags & (AV_LOG_PRINT_TIME | AV_LOG_PRINT_DATETIME)))
++ format_date_now(&part[4], current_flags & AV_LOG_PRINT_DATETIME);
++
++ if (*print_prefix && (level > AV_LOG_QUIET) && (current_flags & AV_LOG_PRINT_LEVEL))
++ av_bprintf(part+2, "[%s] ", get_level_str(level));
++
++ av_vbprintf(part+3, fmt, vl);
++
++ if(*part[0].str || *part[1].str || *part[2].str || *part[3].str) {
++ char lastc = part[3].len && part[3].len <= part[3].size ? part[3].str[part[3].len - 1] : 0;
++ *print_prefix = lastc == '\n' || lastc == '\r';
++ }
++}
++
++void fftools_log_callback(void* ptr, int level, const char* fmt, va_list vl)
++{
++ static int print_prefix = 1;
++ static int count;
++ static char prev[LINE_SZ];
++ AVBPrint part[5];
++ char line[LINE_SZ];
++ static int is_atty;
++ int type[2];
++ unsigned tint = 0;
++ int current_flags = 0;
++
++ if (level >= 0) {
++ tint = level & 0xff00;
++ level &= 0xff;
++ }
++
++ if (level > av_log_get_level())
++ return;
++
++ current_flags = av_log_get_flags();
++ ff_mutex_lock(&mutex);
++
++ format_line(ptr, level, fmt, vl, part, &print_prefix, type, current_flags);
++ snprintf(line, sizeof(line), "%s%s%s%s", part[0].str, part[1].str, part[2].str, part[3].str);
++
++#if HAVE_ISATTY
++ if (!is_atty)
++ is_atty = isatty(2) ? 1 : -1;
++#endif
++
++ if (print_prefix && (current_flags & AV_LOG_SKIP_REPEATED) && !strcmp(line, prev) &&
++ *line && line[strlen(line) - 1] != '\r'){
++ count++;
++ if (is_atty == 1)
++ fprintf(stderr, " Last message repeated %d times\r", count);
++ goto end;
++ }
++ if (count > 0) {
++ fprintf(stderr, " Last message repeated %d times\n", count);
++ count = 0;
++ }
++ strcpy(prev, line);
++
++ sanitize(part[4].str);
++ colored_fputs(7, 0, part[4].str);
++ sanitize(part[0].str);
++ colored_fputs(type[0], 0, part[0].str);
++ sanitize(part[1].str);
++ colored_fputs(type[1], 0, part[1].str);
++ sanitize(part[2].str);
++ colored_fputs(av_clip(level >> 3, 0, NB_LEVELS - 1), tint >> 8, part[2].str);
++ sanitize(part[3].str);
++ colored_fputs(av_clip(level >> 3, 0, NB_LEVELS - 1), tint >> 8, part[3].str);
++
++#if CONFIG_VALGRIND_BACKTRACE
++ if (level <= BACKTRACE_LOGLEVEL)
++ VALGRIND_PRINTF_BACKTRACE("%s", "");
++#endif
++end:
++ av_bprint_finalize(part+3, NULL);
++ ff_mutex_unlock(&mutex);
+}
+
- void parse_loglevel(int argc, char **argv, const OptionDef *options)
- {
- int idx;
++
++void init_logging(void)
++{
++ av_log_set_callback(&fftools_log_callback);
++}
- ## fftools/cmdutils.h ##
-@@ fftools/cmdutils.h: int split_commandline(OptionParseContext *octx, int argc, char *argv[],
- */
- void uninit_parse_context(OptionParseContext *octx);
-
+ ## fftools/fftools_log.h (new) ##
+@@
++/*
++ * Copyright (c) The FFmpeg developers
++ *
++ * This file is part of FFmpeg.
++ *
++ * FFmpeg is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2.1 of the License, or (at your option) any later version.
++ *
++ * FFmpeg is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with FFmpeg; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++#ifndef FFTOOLS_FFTOOLS_LOG_H
++#define FFTOOLS_FFTOOLS_LOG_H
++
++#include <stdint.h>
++
++#include "config.h"
++#include "libavcodec/avcodec.h"
++#include "libavfilter/avfilter.h"
++#include "libavformat/avformat.h"
++#include "libswscale/swscale.h"
++
++
+/**
-+ * Sets up formatting callbacks for logging
++ * Custom logging callback for fftools.
+ */
-+void init_logformatting(void);
++void fftools_log_callback(void* ptr, int level, const char* fmt, va_list vl);
+
- /**
- * Find the '-loglevel' option in the command line args and apply it.
- */
-
- ## fftools/ffmpeg.c ##
-@@ fftools/ffmpeg.c: int main(int argc, char **argv)
- setvbuf(stderr,NULL,_IONBF,0); /* win32 runtime needs this */
-
- av_log_set_flags(AV_LOG_SKIP_REPEATED);
-+ init_logformatting();
- parse_loglevel(argc, argv, options);
-
- #if CONFIG_AVDEVICE
-
- ## fftools/ffplay.c ##
-@@ fftools/ffplay.c: int main(int argc, char **argv)
- init_dynload();
-
- av_log_set_flags(AV_LOG_SKIP_REPEATED);
-+ init_logformatting();
- parse_loglevel(argc, argv, options);
-
- /* register all codecs, demux and protocols */
-
- ## fftools/ffprobe.c ##
-@@ fftools/ffprobe.c: int main(int argc, char **argv)
- init_dynload();
-
- av_log_set_flags(AV_LOG_SKIP_REPEATED);
-+ init_logformatting();
-
- options = real_options;
- parse_loglevel(argc, argv, options);
++/**
++ * Sets the logging callback function.
++ */
++void init_logging(void);
++
++
++#endif /* FFTOOLS_FFTOOLS_LOG_H */
4: 9dc2cbe5ca = 4: 68a9ee6fbe 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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v4 1/4] avutil/log: Add AV_LOG_PRINT_MEMADDRESSES logging flag
2025-03-08 23:02 ` [FFmpeg-devel] [PATCH v4 0/4] avutil/log: Replace addresses in log output with simple ids ffmpegagent
@ 2025-03-08 23:02 ` softworkz
2025-03-08 23:02 ` [FFmpeg-devel] [PATCH v4 2/4] fftools/opt_common: add memaddresses log flag softworkz
` (3 subsequent siblings)
4 siblings, 0 replies; 92+ messages in thread
From: softworkz @ 2025-03-08 23:02 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
From: softworkz <softworkz@hotmail.com>
which is meant to control prefix formatting. The actual formatting
has to be performed by the consuming application which needs to provide
a custom logging callback via av_log_set_callback().
Signed-off-by: softworkz <softworkz@hotmail.com>
---
doc/APIchanges | 3 +++
libavutil/log.h | 5 +++++
libavutil/version.h | 2 +-
3 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index 5a64836e25..79fb9c1cc6 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.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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v4 2/4] fftools/opt_common: add memaddresses log flag
2025-03-08 23:02 ` [FFmpeg-devel] [PATCH v4 0/4] avutil/log: Replace addresses in log output with simple ids ffmpegagent
2025-03-08 23:02 ` [FFmpeg-devel] [PATCH v4 1/4] avutil/log: Add AV_LOG_PRINT_MEMADDRESSES logging flag softworkz
@ 2025-03-08 23:02 ` softworkz
2025-03-08 23:02 ` [FFmpeg-devel] [PATCH v4 3/4] fftools: Provide a an fftools-specific logging callback function softworkz
` (2 subsequent siblings)
4 siblings, 0 replies; 92+ messages in thread
From: softworkz @ 2025-03-08 23:02 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v4 3/4] fftools: Provide a an fftools-specific logging callback function
2025-03-08 23:02 ` [FFmpeg-devel] [PATCH v4 0/4] avutil/log: Replace addresses in log output with simple ids ffmpegagent
2025-03-08 23:02 ` [FFmpeg-devel] [PATCH v4 1/4] avutil/log: Add AV_LOG_PRINT_MEMADDRESSES logging flag softworkz
2025-03-08 23:02 ` [FFmpeg-devel] [PATCH v4 2/4] fftools/opt_common: add memaddresses log flag softworkz
@ 2025-03-08 23:02 ` softworkz
2025-03-09 17:52 ` Michael Niedermayer
2025-03-08 23:02 ` [FFmpeg-devel] [PATCH v4 4/4] doc/fftools-common-opts: document memaddresses log flag softworkz
2025-03-09 19:01 ` [FFmpeg-devel] [PATCH v5 0/5] avutil/log: Replace addresses in log output with simple ids ffmpegagent
4 siblings, 1 reply; 92+ messages in thread
From: softworkz @ 2025-03-08 23:02 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
From: softworkz <softworkz@hotmail.com>
This goes together with a change to logging of context prefixes, which
is printing logical ids instead of memory addresses.
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
---
fftools/Makefile | 7 +-
fftools/ffmpeg.c | 2 +
fftools/ffmpeg_filter.c | 2 +-
fftools/ffplay.c | 2 +
fftools/ffprobe.c | 2 +
fftools/fftools_log.c | 480 ++++++++++++++++++++++++++++++++++++++++
fftools/fftools_log.h | 44 ++++
7 files changed, 537 insertions(+), 2 deletions(-)
create mode 100644 fftools/fftools_log.c
create mode 100644 fftools/fftools_log.h
diff --git a/fftools/Makefile b/fftools/Makefile
index 4499799818..5ae3e7af10 100644
--- a/fftools/Makefile
+++ b/fftools/Makefile
@@ -19,10 +19,15 @@ OBJS-ffmpeg += \
fftools/ffmpeg_mux_init.o \
fftools/ffmpeg_opt.o \
fftools/ffmpeg_sched.o \
+ fftools/fftools_log.o \
fftools/sync_queue.o \
fftools/thread_queue.o \
-OBJS-ffplay += fftools/ffplay_renderer.o
+OBJS-ffprobe += \
+ fftools/fftools_log.o \
+
+OBJS-ffplay += fftools/ffplay_renderer.o \
+ fftools/fftools_log.o \
define DOFFTOOL
OBJS-$(1) += fftools/cmdutils.o fftools/opt_common.o fftools/$(1).o $(OBJS-$(1)-yes)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index dc321fb4a2..dc73d38f1f 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -81,6 +81,7 @@
#include "ffmpeg.h"
#include "ffmpeg_sched.h"
#include "ffmpeg_utils.h"
+#include "fftools_log.h"
const char program_name[] = "ffmpeg";
const int program_birth_year = 2000;
@@ -955,6 +956,7 @@ int main(int argc, char **argv)
setvbuf(stderr,NULL,_IONBF,0); /* win32 runtime needs this */
av_log_set_flags(AV_LOG_SKIP_REPEATED);
+ init_logging();
parse_loglevel(argc, argv, options);
#if CONFIG_AVDEVICE
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index cd8a4abc52..57a83f6e3a 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1,5 +1,5 @@
/*
- * ffmpeg filter configuration
+ * Copyright (c) The FFmpeg developers
*
* This file is part of FFmpeg.
*
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 2a572fc3aa..e4e90187f5 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -57,6 +57,7 @@
#include "cmdutils.h"
#include "ffplay_renderer.h"
#include "opt_common.h"
+#include "fftools_log.h"
const char program_name[] = "ffplay";
const int program_birth_year = 2003;
@@ -3762,6 +3763,7 @@ int main(int argc, char **argv)
init_dynload();
av_log_set_flags(AV_LOG_SKIP_REPEATED);
+ init_logging();
parse_loglevel(argc, argv, options);
/* register all codecs, demux and protocols */
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 7341731d2f..2e4d6d0f3e 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -68,6 +68,7 @@
#include "libavfilter/version.h"
#include "cmdutils.h"
#include "opt_common.h"
+#include "fftools_log.h"
#include "libavutil/thread.h"
@@ -4652,6 +4653,7 @@ int main(int argc, char **argv)
init_dynload();
av_log_set_flags(AV_LOG_SKIP_REPEATED);
+ init_logging();
options = real_options;
parse_loglevel(argc, argv, options);
diff --git a/fftools/fftools_log.c b/fftools/fftools_log.c
new file mode 100644
index 0000000000..206dffe56f
--- /dev/null
+++ b/fftools/fftools_log.c
@@ -0,0 +1,480 @@
+/*
+ * Copyright (c) The FFmpeg developers
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#include "config.h"
+
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#if HAVE_IO_H
+#include <io.h>
+#endif
+#include <inttypes.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "libavutil/bprint.h"
+#include "libavutil/common.h"
+//#include "libavutil/internal.h"
+#include "libavutil/log.h"
+#include "libavutil/thread.h"
+#include "libavutil/time.h"
+//#include "libavutil/time_internal.h"
+
+#include "fftools_log.h"
+
+
+#if !HAVE_LOCALTIME_R && !defined(localtime_r)
+static inline struct tm *ff_localtime_r(const time_t* clock, struct tm *result)
+{
+ struct tm *ptr = localtime(clock);
+ if (!ptr)
+ return NULL;
+ *result = *ptr;
+ return result;
+}
+#define localtime_r ff_localtime_r
+#endif
+
+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;
+ 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;
+}
+
+static AVMutex mutex = AV_MUTEX_INITIALIZER;
+
+#define LINE_SZ 1024
+
+#if HAVE_VALGRIND_VALGRIND_H && CONFIG_VALGRIND_BACKTRACE
+#include <valgrind/valgrind.h>
+/* this is the log level at which valgrind will output a full backtrace */
+#define BACKTRACE_LOGLEVEL AV_LOG_ERROR
+#endif
+
+#define NB_LEVELS 8
+#if defined(_WIN32) && HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
+#include <windows.h>
+static const uint8_t color[16 + AV_CLASS_CATEGORY_NB] = {
+ [AV_LOG_PANIC /8] = 12,
+ [AV_LOG_FATAL /8] = 12,
+ [AV_LOG_ERROR /8] = 12,
+ [AV_LOG_WARNING/8] = 14,
+ [AV_LOG_INFO /8] = 7,
+ [AV_LOG_VERBOSE/8] = 10,
+ [AV_LOG_DEBUG /8] = 10,
+ [AV_LOG_TRACE /8] = 8,
+ [16+AV_CLASS_CATEGORY_NA ] = 7,
+ [16+AV_CLASS_CATEGORY_INPUT ] = 13,
+ [16+AV_CLASS_CATEGORY_OUTPUT ] = 5,
+ [16+AV_CLASS_CATEGORY_MUXER ] = 13,
+ [16+AV_CLASS_CATEGORY_DEMUXER ] = 5,
+ [16+AV_CLASS_CATEGORY_ENCODER ] = 11,
+ [16+AV_CLASS_CATEGORY_DECODER ] = 3,
+ [16+AV_CLASS_CATEGORY_FILTER ] = 10,
+ [16+AV_CLASS_CATEGORY_BITSTREAM_FILTER] = 9,
+ [16+AV_CLASS_CATEGORY_SWSCALER ] = 7,
+ [16+AV_CLASS_CATEGORY_SWRESAMPLER ] = 7,
+ [16+AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT ] = 13,
+ [16+AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT ] = 5,
+ [16+AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT ] = 13,
+ [16+AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT ] = 5,
+ [16+AV_CLASS_CATEGORY_DEVICE_OUTPUT ] = 13,
+ [16+AV_CLASS_CATEGORY_DEVICE_INPUT ] = 5,
+};
+
+static int16_t background, attr_orig;
+static HANDLE con;
+#else
+
+static const uint32_t color[16 + AV_CLASS_CATEGORY_NB] = {
+ [AV_LOG_PANIC /8] = 52 << 16 | 196 << 8 | 0x41,
+ [AV_LOG_FATAL /8] = 208 << 8 | 0x41,
+ [AV_LOG_ERROR /8] = 196 << 8 | 0x11,
+ [AV_LOG_WARNING/8] = 226 << 8 | 0x03,
+ [AV_LOG_INFO /8] = 253 << 8 | 0x09,
+ [AV_LOG_VERBOSE/8] = 40 << 8 | 0x02,
+ [AV_LOG_DEBUG /8] = 34 << 8 | 0x02,
+ [AV_LOG_TRACE /8] = 34 << 8 | 0x07,
+ [16+AV_CLASS_CATEGORY_NA ] = 250 << 8 | 0x09,
+ [16+AV_CLASS_CATEGORY_INPUT ] = 219 << 8 | 0x15,
+ [16+AV_CLASS_CATEGORY_OUTPUT ] = 201 << 8 | 0x05,
+ [16+AV_CLASS_CATEGORY_MUXER ] = 213 << 8 | 0x15,
+ [16+AV_CLASS_CATEGORY_DEMUXER ] = 207 << 8 | 0x05,
+ [16+AV_CLASS_CATEGORY_ENCODER ] = 51 << 8 | 0x16,
+ [16+AV_CLASS_CATEGORY_DECODER ] = 39 << 8 | 0x06,
+ [16+AV_CLASS_CATEGORY_FILTER ] = 155 << 8 | 0x12,
+ [16+AV_CLASS_CATEGORY_BITSTREAM_FILTER] = 192 << 8 | 0x14,
+ [16+AV_CLASS_CATEGORY_SWSCALER ] = 153 << 8 | 0x14,
+ [16+AV_CLASS_CATEGORY_SWRESAMPLER ] = 147 << 8 | 0x14,
+ [16+AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT ] = 213 << 8 | 0x15,
+ [16+AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT ] = 207 << 8 | 0x05,
+ [16+AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT ] = 213 << 8 | 0x15,
+ [16+AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT ] = 207 << 8 | 0x05,
+ [16+AV_CLASS_CATEGORY_DEVICE_OUTPUT ] = 213 << 8 | 0x15,
+ [16+AV_CLASS_CATEGORY_DEVICE_INPUT ] = 207 << 8 | 0x05,
+};
+
+#endif
+static int use_color = -1;
+
+#if defined(_WIN32) && HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
+static void win_console_puts(const char *str)
+{
+ const uint8_t *q = str;
+ uint16_t line[LINE_SZ];
+
+ while (*q) {
+ uint16_t *buf = line;
+ DWORD nb_chars = 0;
+ DWORD written;
+
+ while (*q && nb_chars < LINE_SZ - 1) {
+ uint32_t ch;
+ uint16_t tmp;
+
+ GET_UTF8(ch, *q ? *q++ : 0, ch = 0xfffd; goto continue_on_invalid;)
+continue_on_invalid:
+ PUT_UTF16(ch, tmp, *buf++ = tmp; nb_chars++;)
+ }
+
+ WriteConsoleW(con, line, nb_chars, &written, NULL);
+ }
+}
+#endif
+
+static void check_color_terminal(void)
+{
+ char *term = getenv("TERM");
+
+#if defined(_WIN32) && HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
+ CONSOLE_SCREEN_BUFFER_INFO con_info;
+ DWORD dummy;
+ con = GetStdHandle(STD_ERROR_HANDLE);
+ if (con != INVALID_HANDLE_VALUE && !GetConsoleMode(con, &dummy))
+ con = INVALID_HANDLE_VALUE;
+ if (con != INVALID_HANDLE_VALUE) {
+ GetConsoleScreenBufferInfo(con, &con_info);
+ attr_orig = con_info.wAttributes;
+ background = attr_orig & 0xF0;
+ }
+#endif
+
+ if (getenv("AV_LOG_FORCE_NOCOLOR")) {
+ use_color = 0;
+ } else if (getenv("AV_LOG_FORCE_COLOR")) {
+ use_color = 1;
+ } else {
+#if defined(_WIN32) && HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
+ use_color = (con != INVALID_HANDLE_VALUE);
+#elif HAVE_ISATTY
+ use_color = (term && isatty(2));
+#else
+ use_color = 0;
+#endif
+ }
+
+ if (getenv("AV_LOG_FORCE_256COLOR") || term && strstr(term, "256color"))
+ use_color *= 256;
+}
+
+static void ansi_fputs(int level, int tint, const char *str, int local_use_color)
+{
+ if (local_use_color == 1) {
+ fprintf(stderr,
+ "\033[%"PRIu32";3%"PRIu32"m%s\033[0m",
+ (color[level] >> 4) & 15,
+ color[level] & 15,
+ str);
+ } else if (tint && use_color == 256) {
+ fprintf(stderr,
+ "\033[48;5;%"PRIu32"m\033[38;5;%dm%s\033[0m",
+ (color[level] >> 16) & 0xff,
+ tint,
+ str);
+ } else if (local_use_color == 256) {
+ fprintf(stderr,
+ "\033[48;5;%"PRIu32"m\033[38;5;%"PRIu32"m%s\033[0m",
+ (color[level] >> 16) & 0xff,
+ (color[level] >> 8) & 0xff,
+ str);
+ } else
+ fputs(str, stderr);
+}
+
+static void colored_fputs(int level, int tint, const char *str)
+{
+ int local_use_color;
+ if (!*str)
+ return;
+
+ if (use_color < 0)
+ check_color_terminal();
+
+ if (level == AV_LOG_INFO/8) local_use_color = 0;
+ else local_use_color = use_color;
+
+#if defined(_WIN32) && HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
+ if (con != INVALID_HANDLE_VALUE) {
+ if (local_use_color)
+ SetConsoleTextAttribute(con, background | color[level]);
+ win_console_puts(str);
+ if (local_use_color)
+ SetConsoleTextAttribute(con, attr_orig);
+ } else {
+ ansi_fputs(level, tint, str, local_use_color);
+ }
+#else
+ ansi_fputs(level, tint, str, local_use_color);
+#endif
+
+}
+
+static void sanitize(uint8_t *line){
+ while(*line){
+ if(*line < 0x08 || (*line > 0x0D && *line < 0x20))
+ *line='?';
+ line++;
+ }
+}
+
+static int get_category(void *ptr){
+ AVClass *avc = *(AVClass **) ptr;
+ if( !avc
+ || (avc->version&0xFF)<100
+ || avc->version < (51 << 16 | 59 << 8)
+ || avc->category >= AV_CLASS_CATEGORY_NB) return AV_CLASS_CATEGORY_NA + 16;
+
+ if(avc->get_category)
+ return avc->get_category(ptr) + 16;
+
+ return avc->category + 16;
+}
+
+static const char *get_level_str(int level)
+{
+ switch (level) {
+ case AV_LOG_QUIET:
+ return "quiet";
+ case AV_LOG_DEBUG:
+ return "debug";
+ case AV_LOG_TRACE:
+ return "trace";
+ case AV_LOG_VERBOSE:
+ return "verbose";
+ case AV_LOG_INFO:
+ return "info";
+ case AV_LOG_WARNING:
+ return "warning";
+ case AV_LOG_ERROR:
+ return "error";
+ case AV_LOG_FATAL:
+ return "fatal";
+ case AV_LOG_PANIC:
+ return "panic";
+ default:
+ return "";
+ }
+}
+
+static const char *item_name(void *obj, const AVClass *cls)
+{
+ return (cls->item_name ? cls->item_name : av_default_item_name)(obj);
+}
+
+static void format_date_now(AVBPrint* bp_time, int include_date)
+{
+ struct tm *ptm, tmbuf;
+ const int64_t time_us = av_gettime();
+ const int64_t time_ms = time_us / 1000;
+ const time_t time_s = time_ms / 1000;
+ const int millisec = time_ms - (time_s * 1000);
+ ptm = localtime_r(&time_s, &tmbuf);
+ if (ptm) {
+ if (include_date)
+ av_bprint_strftime(bp_time, "%Y-%m-%d ", ptm);
+
+ av_bprint_strftime(bp_time, "%H:%M:%S", ptm);
+ av_bprintf(bp_time, ".%03d ", millisec);
+ }
+}
+
+static void log_formatprefix(AVBPrint* buffer, AVClass** avcl, int log_flags)
+{
+ const int print_mem = log_flags & AV_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], int current_flags)
+{
+ AVClass* avc = avcl ? *(AVClass **) avcl : NULL;
+ av_bprint_init(part+0, 0, AV_BPRINT_SIZE_AUTOMATIC);
+ av_bprint_init(part+1, 0, AV_BPRINT_SIZE_AUTOMATIC);
+ av_bprint_init(part+2, 0, AV_BPRINT_SIZE_AUTOMATIC);
+ av_bprint_init(part+3, 0, 65536);
+ av_bprint_init(part+4, 0, AV_BPRINT_SIZE_AUTOMATIC);
+
+ if(type) type[0] = type[1] = AV_CLASS_CATEGORY_NA + 16;
+ if (*print_prefix && avc) {
+
+ if (avc->parent_log_context_offset) {
+ AVClass** parent = *(AVClass ***) ((uint8_t *)avcl + avc->parent_log_context_offset);
+ if (parent && *parent) {
+ log_formatprefix(part, parent, current_flags);
+ if(type) type[0] = get_category(parent);
+ }
+ }
+ log_formatprefix(part, avcl, current_flags);
+
+ if(type) type[1] = get_category(avcl);
+ }
+
+ if (*print_prefix && (level > AV_LOG_QUIET) && (current_flags & (AV_LOG_PRINT_TIME | AV_LOG_PRINT_DATETIME)))
+ format_date_now(&part[4], current_flags & AV_LOG_PRINT_DATETIME);
+
+ if (*print_prefix && (level > AV_LOG_QUIET) && (current_flags & AV_LOG_PRINT_LEVEL))
+ av_bprintf(part+2, "[%s] ", get_level_str(level));
+
+ av_vbprintf(part+3, fmt, vl);
+
+ if(*part[0].str || *part[1].str || *part[2].str || *part[3].str) {
+ char lastc = part[3].len && part[3].len <= part[3].size ? part[3].str[part[3].len - 1] : 0;
+ *print_prefix = lastc == '\n' || lastc == '\r';
+ }
+}
+
+void fftools_log_callback(void* ptr, int level, const char* fmt, va_list vl)
+{
+ static int print_prefix = 1;
+ static int count;
+ static char prev[LINE_SZ];
+ AVBPrint part[5];
+ char line[LINE_SZ];
+ static int is_atty;
+ int type[2];
+ unsigned tint = 0;
+ int current_flags = 0;
+
+ if (level >= 0) {
+ tint = level & 0xff00;
+ level &= 0xff;
+ }
+
+ if (level > av_log_get_level())
+ return;
+
+ current_flags = av_log_get_flags();
+ ff_mutex_lock(&mutex);
+
+ format_line(ptr, level, fmt, vl, part, &print_prefix, type, current_flags);
+ snprintf(line, sizeof(line), "%s%s%s%s", part[0].str, part[1].str, part[2].str, part[3].str);
+
+#if HAVE_ISATTY
+ if (!is_atty)
+ is_atty = isatty(2) ? 1 : -1;
+#endif
+
+ if (print_prefix && (current_flags & AV_LOG_SKIP_REPEATED) && !strcmp(line, prev) &&
+ *line && line[strlen(line) - 1] != '\r'){
+ count++;
+ if (is_atty == 1)
+ fprintf(stderr, " Last message repeated %d times\r", count);
+ goto end;
+ }
+ if (count > 0) {
+ fprintf(stderr, " Last message repeated %d times\n", count);
+ count = 0;
+ }
+ strcpy(prev, line);
+
+ sanitize(part[4].str);
+ colored_fputs(7, 0, part[4].str);
+ sanitize(part[0].str);
+ colored_fputs(type[0], 0, part[0].str);
+ sanitize(part[1].str);
+ colored_fputs(type[1], 0, part[1].str);
+ sanitize(part[2].str);
+ colored_fputs(av_clip(level >> 3, 0, NB_LEVELS - 1), tint >> 8, part[2].str);
+ sanitize(part[3].str);
+ colored_fputs(av_clip(level >> 3, 0, NB_LEVELS - 1), tint >> 8, part[3].str);
+
+#if CONFIG_VALGRIND_BACKTRACE
+ if (level <= BACKTRACE_LOGLEVEL)
+ VALGRIND_PRINTF_BACKTRACE("%s", "");
+#endif
+end:
+ av_bprint_finalize(part+3, NULL);
+ ff_mutex_unlock(&mutex);
+}
+
+
+void init_logging(void)
+{
+ av_log_set_callback(&fftools_log_callback);
+}
diff --git a/fftools/fftools_log.h b/fftools/fftools_log.h
new file mode 100644
index 0000000000..da24866045
--- /dev/null
+++ b/fftools/fftools_log.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) The FFmpeg developers
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef FFTOOLS_FFTOOLS_LOG_H
+#define FFTOOLS_FFTOOLS_LOG_H
+
+#include <stdint.h>
+
+#include "config.h"
+#include "libavcodec/avcodec.h"
+#include "libavfilter/avfilter.h"
+#include "libavformat/avformat.h"
+#include "libswscale/swscale.h"
+
+
+/**
+ * Custom logging callback for fftools.
+ */
+void fftools_log_callback(void* ptr, int level, const char* fmt, va_list vl);
+
+/**
+ * Sets the logging callback function.
+ */
+void init_logging(void);
+
+
+#endif /* FFTOOLS_FFTOOLS_LOG_H */
--
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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v4 4/4] doc/fftools-common-opts: document memaddresses log flag
2025-03-08 23:02 ` [FFmpeg-devel] [PATCH v4 0/4] avutil/log: Replace addresses in log output with simple ids ffmpegagent
` (2 preceding siblings ...)
2025-03-08 23:02 ` [FFmpeg-devel] [PATCH v4 3/4] fftools: Provide a an fftools-specific logging callback function softworkz
@ 2025-03-08 23:02 ` softworkz
2025-03-09 19:01 ` [FFmpeg-devel] [PATCH v5 0/5] avutil/log: Replace addresses in log output with simple ids ffmpegagent
4 siblings, 0 replies; 92+ messages in thread
From: softworkz @ 2025-03-08 23:02 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v4 3/4] fftools: Provide a an fftools-specific logging callback function
2025-03-08 23:02 ` [FFmpeg-devel] [PATCH v4 3/4] fftools: Provide a an fftools-specific logging callback function softworkz
@ 2025-03-09 17:52 ` Michael Niedermayer
2025-03-09 18:59 ` Soft Works
0 siblings, 1 reply; 92+ messages in thread
From: Michael Niedermayer @ 2025-03-09 17:52 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 2243 bytes --]
On Sat, Mar 08, 2025 at 11:02:43PM +0000, softworkz wrote:
> From: softworkz <softworkz@hotmail.com>
>
> This goes together with a change to logging of context prefixes, which
> is printing logical ids instead of memory addresses.
> 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
> ---
> fftools/Makefile | 7 +-
> fftools/ffmpeg.c | 2 +
> fftools/ffmpeg_filter.c | 2 +-
> fftools/ffplay.c | 2 +
> fftools/ffprobe.c | 2 +
> fftools/fftools_log.c | 480 ++++++++++++++++++++++++++++++++++++++++
> fftools/fftools_log.h | 44 ++++
> 7 files changed, 537 insertions(+), 2 deletions(-)
> create mode 100644 fftools/fftools_log.c
> create mode 100644 fftools/fftools_log.h
breaks build for ppc
CC fftools/fftools_log.o
src/fftools/fftools_log.c: In function ‘format_date_now’:
src/fftools/fftools_log.c:349:21: error: storage size of ‘tmbuf’ isn’t known
struct tm *ptm, tmbuf;
^~~~~
src/fftools/fftools_log.c:354:29: error: implicit declaration of function ‘localtime_r’ [-Werror=implicit-function-declaration]
ptm = localtime_r(&time_s, &tmbuf);
^~~~~~~~~~~
src/fftools/fftools_log.c:349:21: warning: unused variable ‘tmbuf’ [-Wunused-variable]
struct tm *ptm, tmbuf;
^~~~~
At top level:
src/fftools/fftools_log.c:58:12: warning: ‘nb_class_ids’ defined but not used [-Wunused-variable]
static int nb_class_ids;
^~~~~~~~~~~~
cc1: some warnings being treated as errors
make: *** [src/ffbuild/common.mak:81: fftools/fftools_log.o] Error 1
make: Target 'all' not remade because of errors.
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The day soldiers stop bringing you their problems is the day you have stopped
leading them. They have either lost confidence that you can help or concluded
you do not care. Either case is a failure of leadership. - Colin Powell
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v4 3/4] fftools: Provide a an fftools-specific logging callback function
2025-03-09 17:52 ` Michael Niedermayer
@ 2025-03-09 18:59 ` Soft Works
0 siblings, 0 replies; 92+ messages in thread
From: Soft Works @ 2025-03-09 18:59 UTC (permalink / raw)
To: FFmpeg development discussions and patches
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Michael Niedermayer
> Sent: Sonntag, 9. März 2025 18:52
> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH v4 3/4] fftools: Provide a an
> fftools-specific logging callback function
>
> On Sat, Mar 08, 2025 at 11:02:43PM +0000, softworkz wrote:
> > From: softworkz <softworkz@hotmail.com>
> >
[...]
> breaks build for ppc
>
> CC fftools/fftools_log.o
> src/fftools/fftools_log.c: In function ‘format_date_now’:
> src/fftools/fftools_log.c:349:21: error: storage size of ‘tmbuf’ isn’t
> known
> struct tm *ptm, tmbuf;
> ^~~~~
> src/fftools/fftools_log.c:354:29: error: implicit declaration of
> function ‘localtime_r’ [-Werror=implicit-function-declaration]
> ptm = localtime_r(&time_s, &tmbuf);
> ^~~~~~~~~~~
> src/fftools/fftools_log.c:349:21: warning: unused variable ‘tmbuf’ [-
> Wunused-variable]
> struct tm *ptm, tmbuf;
> ^~~~~
> At top level:
> src/fftools/fftools_log.c:58:12: warning: ‘nb_class_ids’ defined but not
> used [-Wunused-variable]
> static int nb_class_ids;
> ^~~~~~~~~~~~
Thanks Michael, should be fixed in V5.
BTW, is Patchwork broken, it seems it doesn't update anymore?
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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v5 0/5] avutil/log: Replace addresses in log output with simple ids
2025-03-08 23:02 ` [FFmpeg-devel] [PATCH v4 0/4] avutil/log: Replace addresses in log output with simple ids ffmpegagent
` (3 preceding siblings ...)
2025-03-08 23:02 ` [FFmpeg-devel] [PATCH v4 4/4] doc/fftools-common-opts: document memaddresses log flag softworkz
@ 2025-03-09 19:01 ` ffmpegagent
2025-03-09 19:01 ` [FFmpeg-devel] [PATCH v5 1/5] avutil/log: Add AV_LOG_PRINT_MEMADDRESSES logging flag softworkz
` (5 more replies)
4 siblings, 6 replies; 92+ messages in thread
From: ffmpegagent @ 2025-03-09 19:01 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
..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
_______________________________________________
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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v5 1/5] avutil/log: Add AV_LOG_PRINT_MEMADDRESSES logging flag
2025-03-09 19:01 ` [FFmpeg-devel] [PATCH v5 0/5] avutil/log: Replace addresses in log output with simple ids ffmpegagent
@ 2025-03-09 19:01 ` softworkz
2025-03-09 19:05 ` Nicolas George
2025-03-09 19:01 ` [FFmpeg-devel] [PATCH v5 2/5] fftools/opt_common: add memaddresses log flag softworkz
` (4 subsequent siblings)
5 siblings, 1 reply; 92+ messages in thread
From: softworkz @ 2025-03-09 19:01 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
From: softworkz <softworkz@hotmail.com>
which is meant to control prefix formatting. The actual formatting
has to be performed by the consuming application which needs to provide
a custom logging callback via av_log_set_callback().
Signed-off-by: softworkz <softworkz@hotmail.com>
---
doc/APIchanges | 3 +++
libavutil/log.h | 5 +++++
libavutil/version.h | 2 +-
3 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index 5a64836e25..79fb9c1cc6 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.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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v5 2/5] fftools/opt_common: add memaddresses log flag
2025-03-09 19:01 ` [FFmpeg-devel] [PATCH v5 0/5] avutil/log: Replace addresses in log output with simple ids ffmpegagent
2025-03-09 19:01 ` [FFmpeg-devel] [PATCH v5 1/5] avutil/log: Add AV_LOG_PRINT_MEMADDRESSES logging flag softworkz
@ 2025-03-09 19:01 ` softworkz
2025-03-09 19:01 ` [FFmpeg-devel] [PATCH v5 3/5] fftools: Provide a an fftools-specific logging callback function softworkz
` (3 subsequent siblings)
5 siblings, 0 replies; 92+ messages in thread
From: softworkz @ 2025-03-09 19:01 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v5 3/5] fftools: Provide a an fftools-specific logging callback function
2025-03-09 19:01 ` [FFmpeg-devel] [PATCH v5 0/5] avutil/log: Replace addresses in log output with simple ids ffmpegagent
2025-03-09 19:01 ` [FFmpeg-devel] [PATCH v5 1/5] avutil/log: Add AV_LOG_PRINT_MEMADDRESSES logging flag softworkz
2025-03-09 19:01 ` [FFmpeg-devel] [PATCH v5 2/5] fftools/opt_common: add memaddresses log flag softworkz
@ 2025-03-09 19:01 ` softworkz
2025-03-09 19:01 ` [FFmpeg-devel] [PATCH v5 4/5] doc/fftools-common-opts: document memaddresses log flag softworkz
` (2 subsequent siblings)
5 siblings, 0 replies; 92+ messages in thread
From: softworkz @ 2025-03-09 19:01 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
From: softworkz <softworkz@hotmail.com>
This goes together with a change to logging of context prefixes, which
is printing logical ids instead of memory addresses.
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
---
fftools/Makefile | 7 +-
fftools/ffmpeg.c | 2 +
fftools/ffmpeg_filter.c | 2 +-
fftools/ffplay.c | 2 +
fftools/ffprobe.c | 2 +
fftools/fftools_log.c | 480 ++++++++++++++++++++++++++++++++++++++++
fftools/fftools_log.h | 44 ++++
7 files changed, 537 insertions(+), 2 deletions(-)
create mode 100644 fftools/fftools_log.c
create mode 100644 fftools/fftools_log.h
diff --git a/fftools/Makefile b/fftools/Makefile
index 4499799818..5ae3e7af10 100644
--- a/fftools/Makefile
+++ b/fftools/Makefile
@@ -19,10 +19,15 @@ OBJS-ffmpeg += \
fftools/ffmpeg_mux_init.o \
fftools/ffmpeg_opt.o \
fftools/ffmpeg_sched.o \
+ fftools/fftools_log.o \
fftools/sync_queue.o \
fftools/thread_queue.o \
-OBJS-ffplay += fftools/ffplay_renderer.o
+OBJS-ffprobe += \
+ fftools/fftools_log.o \
+
+OBJS-ffplay += fftools/ffplay_renderer.o \
+ fftools/fftools_log.o \
define DOFFTOOL
OBJS-$(1) += fftools/cmdutils.o fftools/opt_common.o fftools/$(1).o $(OBJS-$(1)-yes)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index dc321fb4a2..dc73d38f1f 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -81,6 +81,7 @@
#include "ffmpeg.h"
#include "ffmpeg_sched.h"
#include "ffmpeg_utils.h"
+#include "fftools_log.h"
const char program_name[] = "ffmpeg";
const int program_birth_year = 2000;
@@ -955,6 +956,7 @@ int main(int argc, char **argv)
setvbuf(stderr,NULL,_IONBF,0); /* win32 runtime needs this */
av_log_set_flags(AV_LOG_SKIP_REPEATED);
+ init_logging();
parse_loglevel(argc, argv, options);
#if CONFIG_AVDEVICE
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index cd8a4abc52..57a83f6e3a 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1,5 +1,5 @@
/*
- * ffmpeg filter configuration
+ * Copyright (c) The FFmpeg developers
*
* This file is part of FFmpeg.
*
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 2a572fc3aa..e4e90187f5 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -57,6 +57,7 @@
#include "cmdutils.h"
#include "ffplay_renderer.h"
#include "opt_common.h"
+#include "fftools_log.h"
const char program_name[] = "ffplay";
const int program_birth_year = 2003;
@@ -3762,6 +3763,7 @@ int main(int argc, char **argv)
init_dynload();
av_log_set_flags(AV_LOG_SKIP_REPEATED);
+ init_logging();
parse_loglevel(argc, argv, options);
/* register all codecs, demux and protocols */
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 7341731d2f..2e4d6d0f3e 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -68,6 +68,7 @@
#include "libavfilter/version.h"
#include "cmdutils.h"
#include "opt_common.h"
+#include "fftools_log.h"
#include "libavutil/thread.h"
@@ -4652,6 +4653,7 @@ int main(int argc, char **argv)
init_dynload();
av_log_set_flags(AV_LOG_SKIP_REPEATED);
+ init_logging();
options = real_options;
parse_loglevel(argc, argv, options);
diff --git a/fftools/fftools_log.c b/fftools/fftools_log.c
new file mode 100644
index 0000000000..c44541f9fb
--- /dev/null
+++ b/fftools/fftools_log.c
@@ -0,0 +1,480 @@
+/*
+ * Copyright (c) The FFmpeg developers
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#include "config.h"
+
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#if HAVE_IO_H
+#include <io.h>
+#endif
+#include <inttypes.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#include "libavutil/bprint.h"
+#include "libavutil/common.h"
+//#include "libavutil/internal.h"
+#include "libavutil/log.h"
+#include "libavutil/thread.h"
+#include "libavutil/time.h"
+//#include "libavutil/time_internal.h"
+
+#include "fftools_log.h"
+
+
+#if !HAVE_LOCALTIME_R && !defined(localtime_r)
+static inline struct tm *ff_localtime_r(const time_t* clock, struct tm *result)
+{
+ struct tm *ptr = localtime(clock);
+ if (!ptr)
+ return NULL;
+ *result = *ptr;
+ return result;
+}
+#define localtime_r ff_localtime_r
+#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;
+
+#define LINE_SZ 1024
+
+#if HAVE_VALGRIND_VALGRIND_H && CONFIG_VALGRIND_BACKTRACE
+#include <valgrind/valgrind.h>
+/* this is the log level at which valgrind will output a full backtrace */
+#define BACKTRACE_LOGLEVEL AV_LOG_ERROR
+#endif
+
+#define NB_LEVELS 8
+#if defined(_WIN32) && HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
+#include <windows.h>
+static const uint8_t color[16 + AV_CLASS_CATEGORY_NB] = {
+ [AV_LOG_PANIC /8] = 12,
+ [AV_LOG_FATAL /8] = 12,
+ [AV_LOG_ERROR /8] = 12,
+ [AV_LOG_WARNING/8] = 14,
+ [AV_LOG_INFO /8] = 7,
+ [AV_LOG_VERBOSE/8] = 10,
+ [AV_LOG_DEBUG /8] = 10,
+ [AV_LOG_TRACE /8] = 8,
+ [16+AV_CLASS_CATEGORY_NA ] = 7,
+ [16+AV_CLASS_CATEGORY_INPUT ] = 13,
+ [16+AV_CLASS_CATEGORY_OUTPUT ] = 5,
+ [16+AV_CLASS_CATEGORY_MUXER ] = 13,
+ [16+AV_CLASS_CATEGORY_DEMUXER ] = 5,
+ [16+AV_CLASS_CATEGORY_ENCODER ] = 11,
+ [16+AV_CLASS_CATEGORY_DECODER ] = 3,
+ [16+AV_CLASS_CATEGORY_FILTER ] = 10,
+ [16+AV_CLASS_CATEGORY_BITSTREAM_FILTER] = 9,
+ [16+AV_CLASS_CATEGORY_SWSCALER ] = 7,
+ [16+AV_CLASS_CATEGORY_SWRESAMPLER ] = 7,
+ [16+AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT ] = 13,
+ [16+AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT ] = 5,
+ [16+AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT ] = 13,
+ [16+AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT ] = 5,
+ [16+AV_CLASS_CATEGORY_DEVICE_OUTPUT ] = 13,
+ [16+AV_CLASS_CATEGORY_DEVICE_INPUT ] = 5,
+};
+
+static int16_t background, attr_orig;
+static HANDLE con;
+#else
+
+static const uint32_t color[16 + AV_CLASS_CATEGORY_NB] = {
+ [AV_LOG_PANIC /8] = 52 << 16 | 196 << 8 | 0x41,
+ [AV_LOG_FATAL /8] = 208 << 8 | 0x41,
+ [AV_LOG_ERROR /8] = 196 << 8 | 0x11,
+ [AV_LOG_WARNING/8] = 226 << 8 | 0x03,
+ [AV_LOG_INFO /8] = 253 << 8 | 0x09,
+ [AV_LOG_VERBOSE/8] = 40 << 8 | 0x02,
+ [AV_LOG_DEBUG /8] = 34 << 8 | 0x02,
+ [AV_LOG_TRACE /8] = 34 << 8 | 0x07,
+ [16+AV_CLASS_CATEGORY_NA ] = 250 << 8 | 0x09,
+ [16+AV_CLASS_CATEGORY_INPUT ] = 219 << 8 | 0x15,
+ [16+AV_CLASS_CATEGORY_OUTPUT ] = 201 << 8 | 0x05,
+ [16+AV_CLASS_CATEGORY_MUXER ] = 213 << 8 | 0x15,
+ [16+AV_CLASS_CATEGORY_DEMUXER ] = 207 << 8 | 0x05,
+ [16+AV_CLASS_CATEGORY_ENCODER ] = 51 << 8 | 0x16,
+ [16+AV_CLASS_CATEGORY_DECODER ] = 39 << 8 | 0x06,
+ [16+AV_CLASS_CATEGORY_FILTER ] = 155 << 8 | 0x12,
+ [16+AV_CLASS_CATEGORY_BITSTREAM_FILTER] = 192 << 8 | 0x14,
+ [16+AV_CLASS_CATEGORY_SWSCALER ] = 153 << 8 | 0x14,
+ [16+AV_CLASS_CATEGORY_SWRESAMPLER ] = 147 << 8 | 0x14,
+ [16+AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT ] = 213 << 8 | 0x15,
+ [16+AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT ] = 207 << 8 | 0x05,
+ [16+AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT ] = 213 << 8 | 0x15,
+ [16+AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT ] = 207 << 8 | 0x05,
+ [16+AV_CLASS_CATEGORY_DEVICE_OUTPUT ] = 213 << 8 | 0x15,
+ [16+AV_CLASS_CATEGORY_DEVICE_INPUT ] = 207 << 8 | 0x05,
+};
+
+#endif
+static int use_color = -1;
+
+#if defined(_WIN32) && HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
+static void win_console_puts(const char *str)
+{
+ const uint8_t *q = str;
+ uint16_t line[LINE_SZ];
+
+ while (*q) {
+ uint16_t *buf = line;
+ DWORD nb_chars = 0;
+ DWORD written;
+
+ while (*q && nb_chars < LINE_SZ - 1) {
+ uint32_t ch;
+ uint16_t tmp;
+
+ GET_UTF8(ch, *q ? *q++ : 0, ch = 0xfffd; goto continue_on_invalid;)
+continue_on_invalid:
+ PUT_UTF16(ch, tmp, *buf++ = tmp; nb_chars++;)
+ }
+
+ WriteConsoleW(con, line, nb_chars, &written, NULL);
+ }
+}
+#endif
+
+static void check_color_terminal(void)
+{
+ char *term = getenv("TERM");
+
+#if defined(_WIN32) && HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
+ CONSOLE_SCREEN_BUFFER_INFO con_info;
+ DWORD dummy;
+ con = GetStdHandle(STD_ERROR_HANDLE);
+ if (con != INVALID_HANDLE_VALUE && !GetConsoleMode(con, &dummy))
+ con = INVALID_HANDLE_VALUE;
+ if (con != INVALID_HANDLE_VALUE) {
+ GetConsoleScreenBufferInfo(con, &con_info);
+ attr_orig = con_info.wAttributes;
+ background = attr_orig & 0xF0;
+ }
+#endif
+
+ if (getenv("AV_LOG_FORCE_NOCOLOR")) {
+ use_color = 0;
+ } else if (getenv("AV_LOG_FORCE_COLOR")) {
+ use_color = 1;
+ } else {
+#if defined(_WIN32) && HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
+ use_color = (con != INVALID_HANDLE_VALUE);
+#elif HAVE_ISATTY
+ use_color = (term && isatty(2));
+#else
+ use_color = 0;
+#endif
+ }
+
+ if (getenv("AV_LOG_FORCE_256COLOR") || term && strstr(term, "256color"))
+ use_color *= 256;
+}
+
+static void ansi_fputs(int level, int tint, const char *str, int local_use_color)
+{
+ if (local_use_color == 1) {
+ fprintf(stderr,
+ "\033[%"PRIu32";3%"PRIu32"m%s\033[0m",
+ (color[level] >> 4) & 15,
+ color[level] & 15,
+ str);
+ } else if (tint && use_color == 256) {
+ fprintf(stderr,
+ "\033[48;5;%"PRIu32"m\033[38;5;%dm%s\033[0m",
+ (color[level] >> 16) & 0xff,
+ tint,
+ str);
+ } else if (local_use_color == 256) {
+ fprintf(stderr,
+ "\033[48;5;%"PRIu32"m\033[38;5;%"PRIu32"m%s\033[0m",
+ (color[level] >> 16) & 0xff,
+ (color[level] >> 8) & 0xff,
+ str);
+ } else
+ fputs(str, stderr);
+}
+
+static void colored_fputs(int level, int tint, const char *str)
+{
+ int local_use_color;
+ if (!*str)
+ return;
+
+ if (use_color < 0)
+ check_color_terminal();
+
+ if (level == AV_LOG_INFO/8) local_use_color = 0;
+ else local_use_color = use_color;
+
+#if defined(_WIN32) && HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
+ if (con != INVALID_HANDLE_VALUE) {
+ if (local_use_color)
+ SetConsoleTextAttribute(con, background | color[level]);
+ win_console_puts(str);
+ if (local_use_color)
+ SetConsoleTextAttribute(con, attr_orig);
+ } else {
+ ansi_fputs(level, tint, str, local_use_color);
+ }
+#else
+ ansi_fputs(level, tint, str, local_use_color);
+#endif
+
+}
+
+static void sanitize(uint8_t *line){
+ while(*line){
+ if(*line < 0x08 || (*line > 0x0D && *line < 0x20))
+ *line='?';
+ line++;
+ }
+}
+
+static int get_category(void *ptr){
+ AVClass *avc = *(AVClass **) ptr;
+ if( !avc
+ || (avc->version&0xFF)<100
+ || avc->version < (51 << 16 | 59 << 8)
+ || avc->category >= AV_CLASS_CATEGORY_NB) return AV_CLASS_CATEGORY_NA + 16;
+
+ if(avc->get_category)
+ return avc->get_category(ptr) + 16;
+
+ return avc->category + 16;
+}
+
+static const char *get_level_str(int level)
+{
+ switch (level) {
+ case AV_LOG_QUIET:
+ return "quiet";
+ case AV_LOG_DEBUG:
+ return "debug";
+ case AV_LOG_TRACE:
+ return "trace";
+ case AV_LOG_VERBOSE:
+ return "verbose";
+ case AV_LOG_INFO:
+ return "info";
+ case AV_LOG_WARNING:
+ return "warning";
+ case AV_LOG_ERROR:
+ return "error";
+ case AV_LOG_FATAL:
+ return "fatal";
+ case AV_LOG_PANIC:
+ return "panic";
+ default:
+ return "";
+ }
+}
+
+static const char *item_name(void *obj, const AVClass *cls)
+{
+ return (cls->item_name ? cls->item_name : av_default_item_name)(obj);
+}
+
+static void format_date_now(AVBPrint* bp_time, int include_date)
+{
+ struct tm *ptm, tmbuf;
+ const int64_t time_us = av_gettime();
+ const int64_t time_ms = time_us / 1000;
+ const time_t time_s = time_ms / 1000;
+ const int millisec = time_ms - (time_s * 1000);
+ ptm = localtime_r(&time_s, &tmbuf);
+ if (ptm) {
+ if (include_date)
+ av_bprint_strftime(bp_time, "%Y-%m-%d ", ptm);
+
+ av_bprint_strftime(bp_time, "%H:%M:%S", ptm);
+ av_bprintf(bp_time, ".%03d ", millisec);
+ }
+}
+
+static void log_formatprefix(AVBPrint* buffer, AVClass** avcl, int log_flags)
+{
+ const int print_mem = log_flags & AV_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], int current_flags)
+{
+ AVClass* avc = avcl ? *(AVClass **) avcl : NULL;
+ av_bprint_init(part+0, 0, AV_BPRINT_SIZE_AUTOMATIC);
+ av_bprint_init(part+1, 0, AV_BPRINT_SIZE_AUTOMATIC);
+ av_bprint_init(part+2, 0, AV_BPRINT_SIZE_AUTOMATIC);
+ av_bprint_init(part+3, 0, 65536);
+ av_bprint_init(part+4, 0, AV_BPRINT_SIZE_AUTOMATIC);
+
+ if(type) type[0] = type[1] = AV_CLASS_CATEGORY_NA + 16;
+ if (*print_prefix && avc) {
+
+ if (avc->parent_log_context_offset) {
+ AVClass** parent = *(AVClass ***) ((uint8_t *)avcl + avc->parent_log_context_offset);
+ if (parent && *parent) {
+ log_formatprefix(part, parent, current_flags);
+ if(type) type[0] = get_category(parent);
+ }
+ }
+ log_formatprefix(part, avcl, current_flags);
+
+ if(type) type[1] = get_category(avcl);
+ }
+
+ if (*print_prefix && (level > AV_LOG_QUIET) && (current_flags & (AV_LOG_PRINT_TIME | AV_LOG_PRINT_DATETIME)))
+ format_date_now(&part[4], current_flags & AV_LOG_PRINT_DATETIME);
+
+ if (*print_prefix && (level > AV_LOG_QUIET) && (current_flags & AV_LOG_PRINT_LEVEL))
+ av_bprintf(part+2, "[%s] ", get_level_str(level));
+
+ av_vbprintf(part+3, fmt, vl);
+
+ if(*part[0].str || *part[1].str || *part[2].str || *part[3].str) {
+ char lastc = part[3].len && part[3].len <= part[3].size ? part[3].str[part[3].len - 1] : 0;
+ *print_prefix = lastc == '\n' || lastc == '\r';
+ }
+}
+
+void fftools_log_callback(void* ptr, int level, const char* fmt, va_list vl)
+{
+ static int print_prefix = 1;
+ static int count;
+ static char prev[LINE_SZ];
+ AVBPrint part[5];
+ char line[LINE_SZ];
+ static int is_atty;
+ int type[2];
+ unsigned tint = 0;
+ int current_flags = 0;
+
+ if (level >= 0) {
+ tint = level & 0xff00;
+ level &= 0xff;
+ }
+
+ if (level > av_log_get_level())
+ return;
+
+ current_flags = av_log_get_flags();
+ ff_mutex_lock(&mutex);
+
+ format_line(ptr, level, fmt, vl, part, &print_prefix, type, current_flags);
+ snprintf(line, sizeof(line), "%s%s%s%s", part[0].str, part[1].str, part[2].str, part[3].str);
+
+#if HAVE_ISATTY
+ if (!is_atty)
+ is_atty = isatty(2) ? 1 : -1;
+#endif
+
+ if (print_prefix && (current_flags & AV_LOG_SKIP_REPEATED) && !strcmp(line, prev) &&
+ *line && line[strlen(line) - 1] != '\r'){
+ count++;
+ if (is_atty == 1)
+ fprintf(stderr, " Last message repeated %d times\r", count);
+ goto end;
+ }
+ if (count > 0) {
+ fprintf(stderr, " Last message repeated %d times\n", count);
+ count = 0;
+ }
+ strcpy(prev, line);
+
+ sanitize(part[4].str);
+ colored_fputs(7, 0, part[4].str);
+ sanitize(part[0].str);
+ colored_fputs(type[0], 0, part[0].str);
+ sanitize(part[1].str);
+ colored_fputs(type[1], 0, part[1].str);
+ sanitize(part[2].str);
+ colored_fputs(av_clip(level >> 3, 0, NB_LEVELS - 1), tint >> 8, part[2].str);
+ sanitize(part[3].str);
+ colored_fputs(av_clip(level >> 3, 0, NB_LEVELS - 1), tint >> 8, part[3].str);
+
+#if CONFIG_VALGRIND_BACKTRACE
+ if (level <= BACKTRACE_LOGLEVEL)
+ VALGRIND_PRINTF_BACKTRACE("%s", "");
+#endif
+end:
+ av_bprint_finalize(part+3, NULL);
+ ff_mutex_unlock(&mutex);
+}
+
+
+void init_logging(void)
+{
+ av_log_set_callback(&fftools_log_callback);
+}
diff --git a/fftools/fftools_log.h b/fftools/fftools_log.h
new file mode 100644
index 0000000000..da24866045
--- /dev/null
+++ b/fftools/fftools_log.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) The FFmpeg developers
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef FFTOOLS_FFTOOLS_LOG_H
+#define FFTOOLS_FFTOOLS_LOG_H
+
+#include <stdint.h>
+
+#include "config.h"
+#include "libavcodec/avcodec.h"
+#include "libavfilter/avfilter.h"
+#include "libavformat/avformat.h"
+#include "libswscale/swscale.h"
+
+
+/**
+ * Custom logging callback for fftools.
+ */
+void fftools_log_callback(void* ptr, int level, const char* fmt, va_list vl);
+
+/**
+ * Sets the logging callback function.
+ */
+void init_logging(void);
+
+
+#endif /* FFTOOLS_FFTOOLS_LOG_H */
--
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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v5 4/5] doc/fftools-common-opts: document memaddresses log flag
2025-03-09 19:01 ` [FFmpeg-devel] [PATCH v5 0/5] avutil/log: Replace addresses in log output with simple ids ffmpegagent
` (2 preceding siblings ...)
2025-03-09 19:01 ` [FFmpeg-devel] [PATCH v5 3/5] fftools: Provide a an fftools-specific logging callback function softworkz
@ 2025-03-09 19:01 ` softworkz
2025-03-09 19:01 ` [FFmpeg-devel] [PATCH v5 5/5] Remove commented lines softworkz
2025-03-13 9:30 ` [FFmpeg-devel] [PATCH v6 0/3] avutil/log: Replace addresses in log output with simple ids ffmpegagent
5 siblings, 0 replies; 92+ messages in thread
From: softworkz @ 2025-03-09 19:01 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v5 5/5] Remove commented lines
2025-03-09 19:01 ` [FFmpeg-devel] [PATCH v5 0/5] avutil/log: Replace addresses in log output with simple ids ffmpegagent
` (3 preceding siblings ...)
2025-03-09 19:01 ` [FFmpeg-devel] [PATCH v5 4/5] doc/fftools-common-opts: document memaddresses log flag softworkz
@ 2025-03-09 19:01 ` softworkz
2025-03-13 9:30 ` [FFmpeg-devel] [PATCH v6 0/3] avutil/log: Replace addresses in log output with simple ids ffmpegagent
5 siblings, 0 replies; 92+ messages in thread
From: softworkz @ 2025-03-09 19:01 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
From: softworkz <softworkz@hotmail.com>
---
fftools/fftools_log.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/fftools/fftools_log.c b/fftools/fftools_log.c
index c44541f9fb..87930a3121 100644
--- a/fftools/fftools_log.c
+++ b/fftools/fftools_log.c
@@ -36,11 +36,9 @@
#include "libavutil/bprint.h"
#include "libavutil/common.h"
-//#include "libavutil/internal.h"
#include "libavutil/log.h"
#include "libavutil/thread.h"
#include "libavutil/time.h"
-//#include "libavutil/time_internal.h"
#include "fftools_log.h"
--
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v5 1/5] avutil/log: Add AV_LOG_PRINT_MEMADDRESSES logging flag
2025-03-09 19:01 ` [FFmpeg-devel] [PATCH v5 1/5] avutil/log: Add AV_LOG_PRINT_MEMADDRESSES logging flag softworkz
@ 2025-03-09 19:05 ` Nicolas George
2025-03-09 19:11 ` Soft Works
0 siblings, 1 reply; 92+ messages in thread
From: Nicolas George @ 2025-03-09 19:05 UTC (permalink / raw)
To: FFmpeg development discussions and patches
softworkz (HE12025-03-09):
> From: softworkz <softworkz@hotmail.com>
>
> which is meant to control prefix formatting. The actual formatting
> has to be performed by the consuming application which needs to provide
> a custom logging callback via av_log_set_callback().
>
> Signed-off-by: softworkz <softworkz@hotmail.com>
> ---
> doc/APIchanges | 3 +++
> libavutil/log.h | 5 +++++
> libavutil/version.h | 2 +-
> 3 files changed, 9 insertions(+), 1 deletion(-)
<sigh>
This has nothing to do in libavutil.
--
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v5 1/5] avutil/log: Add AV_LOG_PRINT_MEMADDRESSES logging flag
2025-03-09 19:05 ` Nicolas George
@ 2025-03-09 19:11 ` Soft Works
0 siblings, 0 replies; 92+ messages in thread
From: Soft Works @ 2025-03-09 19:11 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: Sonntag, 9. März 2025 20:06
> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH v5 1/5] avutil/log: Add
> AV_LOG_PRINT_MEMADDRESSES logging flag
>
> softworkz (HE12025-03-09):
> > From: softworkz <softworkz@hotmail.com>
> >
> > which is meant to control prefix formatting. The actual formatting
> > has to be performed by the consuming application which needs to
> provide
> > a custom logging callback via av_log_set_callback().
> >
> > Signed-off-by: softworkz <softworkz@hotmail.com>
> > ---
> > doc/APIchanges | 3 +++
> > libavutil/log.h | 5 +++++
> > libavutil/version.h | 2 +-
> > 3 files changed, 9 insertions(+), 1 deletion(-)
>
> <sigh>
>
> This has nothing to do in libavutil.
Do you mean that fftools should do its own handling of log level and log flags then, separate from avutil logging?
And another question would be about the printing of date and time in log lines. It has been added just recently and never been in any public release yet. Should I remove this from avutil so that it is only in fftools logging?
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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v6 0/3] avutil/log: Replace addresses in log output with simple ids
2025-03-09 19:01 ` [FFmpeg-devel] [PATCH v5 0/5] avutil/log: Replace addresses in log output with simple ids ffmpegagent
` (4 preceding siblings ...)
2025-03-09 19:01 ` [FFmpeg-devel] [PATCH v5 5/5] Remove commented lines softworkz
@ 2025-03-13 9:30 ` ffmpegagent
2025-03-13 9:30 ` [FFmpeg-devel] [PATCH v6 1/3] fftools: Add a local logging callback function softworkz
` (3 more replies)
5 siblings, 4 replies; 92+ messages in thread
From: ffmpegagent @ 2025-03-13 9:30 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
..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)
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)
softworkz (3):
fftools: Add a local logging callback function
fftools/opt_common: add memaddresses log flag
doc/fftools-common-opts: document memaddresses log flag
doc/fftools-common-opts.texi | 2 +
fftools/Makefile | 7 +-
fftools/cmdutils.c | 4 +-
fftools/ffmpeg.c | 10 +-
fftools/ffplay.c | 6 +-
fftools/ffprobe.c | 4 +-
fftools/fftools_log.c | 503 +++++++++++++++++++++++++++++++++++
fftools/fftools_log.h | 101 +++++++
fftools/opt_common.c | 47 ++--
9 files changed, 655 insertions(+), 29 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-v6
Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg pr-ffstaging-59/softworkz/submit_logaddresses-v6
Pull-Request: https://github.com/ffstaging/FFmpeg/pull/59
Range-diff vs v5:
1: 4be966796c < -: ---------- avutil/log: Add AV_LOG_PRINT_MEMADDRESSES logging flag
2: e4f8213c24 < -: ---------- fftools/opt_common: add memaddresses log flag
3: ba20f5b116 ! 1: 8080f15800 fftools: Provide a an fftools-specific logging callback function
@@ Metadata
Author: softworkz <softworkz@hotmail.com>
## Commit message ##
- fftools: Provide a an fftools-specific logging callback function
+ fftools: Add a local logging callback function
- This goes together with a change to logging of context prefixes, which
- is printing logical ids instead of memory addresses.
- The benefits are:
+ This gets fftools its own management of log level and flags for and
+ provides an fftools-specific logging callback.
+ This makes it easier to implement specific logging behaviors which are
+ incompatible with direct use of the av libs and cannot be done in
+ libavutil.
- - 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>
## fftools/Makefile ##
@@ fftools/Makefile: OBJS-ffmpeg += \
@@ fftools/Makefile: OBJS-ffmpeg += \
define DOFFTOOL
OBJS-$(1) += fftools/cmdutils.o fftools/opt_common.o fftools/$(1).o $(OBJS-$(1)-yes)
+ ## fftools/cmdutils.c ##
+@@
+ #include "libavutil/dict.h"
+ #include "libavutil/opt.h"
+ #include "cmdutils.h"
++#include "fftools_log.h"
+ #include "fopen_utf8.h"
+ #include "opt_common.h"
+ #ifdef _WIN32
+@@ fftools/cmdutils.c: int opt_default(void *optctx, const char *opt, const char *arg)
+ #endif
+
+ if (!strcmp(opt, "debug") || !strcmp(opt, "fdebug"))
+- av_log_set_level(AV_LOG_DEBUG);
++ ff_log_set_level(AV_LOG_DEBUG);
+
+ if (!(p = strchr(opt, ':')))
+ p = opt + strlen(opt);
+
## fftools/ffmpeg.c ##
@@
#include "ffmpeg.h"
@@ fftools/ffmpeg.c
const char program_name[] = "ffmpeg";
const int program_birth_year = 2000;
+@@ fftools/ffmpeg.c: static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
+
+ if (print_stats || is_last_report) {
+ const char end = is_last_report ? '\n' : '\r';
+- if (print_stats==1 && AV_LOG_INFO > av_log_get_level()) {
++ if (print_stats==1 && AV_LOG_INFO > ff_log_get_level()) {
+ fprintf(stderr, "%s %c", buf.str, end);
+ } else
+ av_log(NULL, AV_LOG_INFO, "%s %c", buf.str, end);
+@@ fftools/ffmpeg.c: static int check_keyboard_interaction(int64_t cur_time)
+ av_log(NULL, AV_LOG_INFO, "\n\n[q] command received. Exiting.\n\n");
+ return AVERROR_EXIT;
+ }
+- if (key == '+') av_log_set_level(av_log_get_level()+10);
+- if (key == '-') av_log_set_level(av_log_get_level()-10);
++ if (key == '+') ff_log_set_level(ff_log_get_level()+10);
++ if (key == '-') ff_log_set_level(ff_log_get_level()-10);
+ if (key == 'c' || key == 'C'){
+ char buf[4096], target[64], command[256], arg[256] = {0};
+ double time;
@@ fftools/ffmpeg.c: int main(int argc, char **argv)
+
setvbuf(stderr,NULL,_IONBF,0); /* win32 runtime needs this */
- av_log_set_flags(AV_LOG_SKIP_REPEATED);
+- av_log_set_flags(AV_LOG_SKIP_REPEATED);
++ ff_log_set_flags(FF_LOG_SKIP_REPEATED);
+ init_logging();
parse_loglevel(argc, argv, options);
#if CONFIG_AVDEVICE
- ## fftools/ffmpeg_filter.c ##
-@@
- /*
-- * ffmpeg filter configuration
-+ * Copyright (c) The FFmpeg developers
- *
- * This file is part of FFmpeg.
- *
-
## fftools/ffplay.c ##
@@
#include "cmdutils.h"
@@ fftools/ffplay.c
const char program_name[] = "ffplay";
const int program_birth_year = 2003;
+@@ fftools/ffplay.c: display:
+ vqsize / 1024,
+ sqsize);
+
+- if (show_status == 1 && AV_LOG_INFO > av_log_get_level())
++ if (show_status == 1 && AV_LOG_INFO > ff_log_get_level())
+ fprintf(stderr, "%s", buf.str);
+ else
+ av_log(NULL, AV_LOG_INFO, "%s", buf.str);
@@ fftools/ffplay.c: int main(int argc, char **argv)
+
init_dynload();
- av_log_set_flags(AV_LOG_SKIP_REPEATED);
+- av_log_set_flags(AV_LOG_SKIP_REPEATED);
++ ff_log_set_flags(FF_LOG_SKIP_REPEATED);
+ init_logging();
parse_loglevel(argc, argv, options);
@@ fftools/ffprobe.c
#include "libavutil/thread.h"
@@ fftools/ffprobe.c: int main(int argc, char **argv)
+
init_dynload();
- av_log_set_flags(AV_LOG_SKIP_REPEATED);
+- av_log_set_flags(AV_LOG_SKIP_REPEATED);
++ ff_log_set_flags(FF_LOG_SKIP_REPEATED);
+ init_logging();
options = real_options;
@@ fftools/fftools_log.c (new)
+
+#include "libavutil/bprint.h"
+#include "libavutil/common.h"
-+//#include "libavutil/internal.h"
+#include "libavutil/log.h"
+#include "libavutil/thread.h"
+#include "libavutil/time.h"
-+//#include "libavutil/time_internal.h"
+
+#include "fftools_log.h"
+
+
++static int ff_log_level = AV_LOG_INFO;
++static int ff_log_flags;
++
++
+#if !HAVE_LOCALTIME_R && !defined(localtime_r)
+static inline struct tm *ff_localtime_r(const time_t* clock, struct tm *result)
+{
@@ fftools/fftools_log.c (new)
+#define localtime_r ff_localtime_r
+#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;
+
+#define LINE_SZ 1024
@@ fftools/fftools_log.c (new)
+ }
+}
+
-+static void log_formatprefix(AVBPrint* buffer, AVClass** avcl, int log_flags)
-+{
-+ const int print_mem = log_flags & AV_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], int current_flags)
++ AVBPrint part[5], int *print_prefix, int type[2])
+{
+ AVClass* avc = avcl ? *(AVClass **) avcl : NULL;
+ av_bprint_init(part+0, 0, AV_BPRINT_SIZE_AUTOMATIC);
@@ fftools/fftools_log.c (new)
+
+ if(type) type[0] = type[1] = AV_CLASS_CATEGORY_NA + 16;
+ if (*print_prefix && avc) {
-+
+ 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) {
-+ log_formatprefix(part, parent, current_flags);
++ av_bprintf(part+0, "[%s @ %p] ",
++ item_name(parent, *parent), parent);
+ if(type) type[0] = get_category(parent);
+ }
+ }
-+ log_formatprefix(part, avcl, current_flags);
-+
++ av_bprintf(part+1, "[%s @ %p] ",
++ item_name(avcl, avc), avcl);
+ if(type) type[1] = get_category(avcl);
+ }
+
-+ if (*print_prefix && (level > AV_LOG_QUIET) && (current_flags & (AV_LOG_PRINT_TIME | AV_LOG_PRINT_DATETIME)))
-+ format_date_now(&part[4], current_flags & AV_LOG_PRINT_DATETIME);
++ if (*print_prefix && (level > AV_LOG_QUIET) && (ff_log_flags & (FF_LOG_PRINT_TIME | FF_LOG_PRINT_DATETIME)))
++ format_date_now(&part[4], ff_log_flags & FF_LOG_PRINT_DATETIME);
+
-+ if (*print_prefix && (level > AV_LOG_QUIET) && (current_flags & AV_LOG_PRINT_LEVEL))
++ if (*print_prefix && (level > AV_LOG_QUIET) && (ff_log_flags & FF_LOG_PRINT_LEVEL))
+ av_bprintf(part+2, "[%s] ", get_level_str(level));
+
+ av_vbprintf(part+3, fmt, vl);
@@ fftools/fftools_log.c (new)
+ static int is_atty;
+ int type[2];
+ unsigned tint = 0;
-+ int current_flags = 0;
+
+ if (level >= 0) {
+ tint = level & 0xff00;
+ level &= 0xff;
+ }
+
-+ if (level > av_log_get_level())
++ if (level > ff_log_level)
+ return;
+
-+ current_flags = av_log_get_flags();
+ ff_mutex_lock(&mutex);
+
-+ format_line(ptr, level, fmt, vl, part, &print_prefix, type, current_flags);
++ format_line(ptr, level, fmt, vl, part, &print_prefix, type);
+ snprintf(line, sizeof(line), "%s%s%s%s", part[0].str, part[1].str, part[2].str, part[3].str);
+
+#if HAVE_ISATTY
@@ fftools/fftools_log.c (new)
+ is_atty = isatty(2) ? 1 : -1;
+#endif
+
-+ if (print_prefix && (current_flags & AV_LOG_SKIP_REPEATED) && !strcmp(line, prev) &&
++ if (print_prefix && (ff_log_flags & FF_LOG_SKIP_REPEATED) && !strcmp(line, prev) &&
+ *line && line[strlen(line) - 1] != '\r'){
+ count++;
+ if (is_atty == 1)
@@ fftools/fftools_log.c (new)
+{
+ av_log_set_callback(&fftools_log_callback);
+}
++
++int ff_log_get_level(void)
++{
++ return ff_log_level;
++}
++
++void ff_log_set_level(int level)
++{
++ ff_log_level = level;
++
++ av_log_set_level(level);
++}
++
++void ff_log_set_flags(int arg)
++{
++ ff_log_flags = arg;
++}
++
++int ff_log_get_flags(void)
++{
++ return ff_log_flags;
++}
++
## fftools/fftools_log.h (new) ##
@@
@@ fftools/fftools_log.h (new)
+void init_logging(void);
+
+
++/**
++ * Get the current log level
++ *
++ * @see lavu_log_constants
++ *
++ * @return Current log level
++ */
++int ff_log_get_level(void);
++
++/**
++ * Set the log level
++ *
++ * @see lavu_log_constants
++ *
++ * @param level Logging level
++ */
++void ff_log_set_level(int level);
++
++void ff_log_set_flags(int arg);
++
++int ff_log_get_flags(void);
++
++
++/**
++ * Skip repeated messages, this requires the user app to use av_log() instead of
++ * (f)printf as the 2 would otherwise interfere and lead to
++ * "Last message repeated x times" messages below (f)printf messages with some
++ * bad luck.
++ * Also to receive the last, "last repeated" line if any, the user app must
++ * call av_log(NULL, AV_LOG_QUIET, "%s", ""); at the end
++ */
++#define FF_LOG_SKIP_REPEATED 1
++
++/**
++ * Include the log severity in messages originating from codecs.
++ *
++ * Results in messages such as:
++ * [rawvideo @ 0xDEADBEEF] [error] encode did not produce valid pts
++ */
++#define FF_LOG_PRINT_LEVEL 2
++
++/**
++ * Include system time in log output.
++ */
++#define FF_LOG_PRINT_TIME 4
++
++/**
++ * Include system date and time in log output.
++ */
++#define FF_LOG_PRINT_DATETIME 8
++
++
+#endif /* FFTOOLS_FFTOOLS_LOG_H */
+
+ ## fftools/opt_common.c ##
+@@
+ #include "cmdutils.h"
+ #include "opt_common.h"
+
++#include "fftools_log.h"
+ #include "libavutil/avassert.h"
+ #include "libavutil/avstring.h"
+ #include "libavutil/bprint.h"
+@@ fftools/opt_common.c: int init_report(const char *env, FILE **file)
+ return AVERROR(ENOMEM);
+ }
+
+- prog_loglevel = av_log_get_level();
++ prog_loglevel = ff_log_get_level();
+ if (!envlevel)
+ report_file_level = FFMAX(report_file_level, prog_loglevel);
+
+@@ fftools/opt_common.c: int opt_loglevel(void *optctx, const char *opt, const char *arg)
+ };
+ const char *token;
+ char *tail;
+- int flags = av_log_get_flags();
+- int level = av_log_get_level();
++ int flags = ff_log_get_flags();
++ int level = ff_log_get_level();
+ int cmd, i = 0;
+
+ av_assert0(arg);
+@@ fftools/opt_common.c: int opt_loglevel(void *optctx, const char *opt, const char *arg)
+ }
+ if (av_strstart(token, "repeat", &arg)) {
+ if (cmd == '-') {
+- flags |= AV_LOG_SKIP_REPEATED;
++ flags |= FF_LOG_SKIP_REPEATED;
+ } else {
+- flags &= ~AV_LOG_SKIP_REPEATED;
++ flags &= ~FF_LOG_SKIP_REPEATED;
+ }
+ } else if (av_strstart(token, "level", &arg)) {
+ if (cmd == '-') {
+- flags &= ~AV_LOG_PRINT_LEVEL;
++ flags &= ~FF_LOG_PRINT_LEVEL;
+ } else {
+- flags |= AV_LOG_PRINT_LEVEL;
++ flags |= FF_LOG_PRINT_LEVEL;
+ }
+ } else if (av_strstart(token, "time", &arg)) {
+ if (cmd == '-') {
+- flags &= ~AV_LOG_PRINT_TIME;
++ flags &= ~FF_LOG_PRINT_TIME;
+ } else {
+- flags |= AV_LOG_PRINT_TIME;
++ flags |= FF_LOG_PRINT_TIME;
+ }
+ } else if (av_strstart(token, "datetime", &arg)) {
+ if (cmd == '-') {
+- flags &= ~AV_LOG_PRINT_DATETIME;
++ flags &= ~FF_LOG_PRINT_DATETIME;
+ } else {
+- flags |= AV_LOG_PRINT_DATETIME;
++ flags |= FF_LOG_PRINT_DATETIME;
+ }
+ } else {
+ break;
+@@ fftools/opt_common.c: int opt_loglevel(void *optctx, const char *opt, const char *arg)
+ } else if (*arg == '+') {
+ arg++;
+ } else if (!i) {
+- flags = av_log_get_flags(); /* level value without prefix, reset flags */
++ flags = ff_log_get_flags(); /* level value without prefix, reset flags */
+ }
+
+ for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++) {
+@@ fftools/opt_common.c: int opt_loglevel(void *optctx, const char *opt, const char *arg)
+ }
+
+ end:
+- av_log_set_flags(flags);
+- av_log_set_level(level);
++ ff_log_set_flags(flags);
++ ff_log_set_level(level);
+ return 0;
+ }
+
+@@ fftools/opt_common.c: int show_sources(void *optctx, const char *opt, const char *arg)
+ char *dev = NULL;
+ AVDictionary *opts = NULL;
+ int ret = 0;
+- int error_level = av_log_get_level();
++ int error_level = ff_log_get_level();
+
+- av_log_set_level(AV_LOG_WARNING);
++ ff_log_set_level(AV_LOG_WARNING);
+
+ if ((ret = show_sinks_sources_parse_arg(arg, &dev, &opts)) < 0)
+ goto fail;
+@@ fftools/opt_common.c: int show_sources(void *optctx, const char *opt, const char *arg)
+ fail:
+ av_dict_free(&opts);
+ av_free(dev);
+- av_log_set_level(error_level);
++ ff_log_set_level(error_level);
+ return ret;
+ }
+
+@@ fftools/opt_common.c: int show_sinks(void *optctx, const char *opt, const char *arg)
+ char *dev = NULL;
+ AVDictionary *opts = NULL;
+ int ret = 0;
+- int error_level = av_log_get_level();
++ int error_level = ff_log_get_level();
+
+- av_log_set_level(AV_LOG_WARNING);
++ ff_log_set_level(AV_LOG_WARNING);
+
+ if ((ret = show_sinks_sources_parse_arg(arg, &dev, &opts)) < 0)
+ goto fail;
+@@ fftools/opt_common.c: int show_sinks(void *optctx, const char *opt, const char *arg)
+ fail:
+ av_dict_free(&opts);
+ av_free(dev);
+- av_log_set_level(error_level);
++ ff_log_set_level(error_level);
+ return ret;
+ }
+ #endif /* CONFIG_AVDEVICE */
-: ---------- > 2: bab6b91549 fftools/opt_common: add memaddresses log flag
4: f689a432df = 3: ea2a970d23 doc/fftools-common-opts: document memaddresses log flag
5: 9429d11516 < -: ---------- Remove commented lines
--
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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v6 1/3] fftools: Add a local logging callback function
2025-03-13 9:30 ` [FFmpeg-devel] [PATCH v6 0/3] avutil/log: Replace addresses in log output with simple ids ffmpegagent
@ 2025-03-13 9:30 ` softworkz
2025-03-13 9:30 ` [FFmpeg-devel] [PATCH v6 2/3] fftools/opt_common: add memaddresses log flag softworkz
` (2 subsequent siblings)
3 siblings, 0 replies; 92+ messages in thread
From: softworkz @ 2025-03-13 9:30 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
From: softworkz <softworkz@hotmail.com>
This gets fftools its own management of log level and flags for and
provides an fftools-specific logging callback.
This makes it easier to implement specific logging behaviors which are
incompatible with direct use of the av libs and cannot be done in
libavutil.
Signed-off-by: softworkz <softworkz@hotmail.com>
---
fftools/Makefile | 7 +-
fftools/cmdutils.c | 3 +-
fftools/ffmpeg.c | 10 +-
fftools/ffplay.c | 6 +-
fftools/ffprobe.c | 4 +-
fftools/fftools_log.c | 448 ++++++++++++++++++++++++++++++++++++++++++
fftools/fftools_log.h | 96 +++++++++
fftools/opt_common.c | 41 ++--
8 files changed, 586 insertions(+), 29 deletions(-)
create mode 100644 fftools/fftools_log.c
create mode 100644 fftools/fftools_log.h
diff --git a/fftools/Makefile b/fftools/Makefile
index 4499799818..5ae3e7af10 100644
--- a/fftools/Makefile
+++ b/fftools/Makefile
@@ -19,10 +19,15 @@ OBJS-ffmpeg += \
fftools/ffmpeg_mux_init.o \
fftools/ffmpeg_opt.o \
fftools/ffmpeg_sched.o \
+ fftools/fftools_log.o \
fftools/sync_queue.o \
fftools/thread_queue.o \
-OBJS-ffplay += fftools/ffplay_renderer.o
+OBJS-ffprobe += \
+ fftools/fftools_log.o \
+
+OBJS-ffplay += fftools/ffplay_renderer.o \
+ fftools/fftools_log.o \
define DOFFTOOL
OBJS-$(1) += fftools/cmdutils.o fftools/opt_common.o fftools/$(1).o $(OBJS-$(1)-yes)
diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 8ac20bf049..0bf453508d 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -46,6 +46,7 @@
#include "libavutil/dict.h"
#include "libavutil/opt.h"
#include "cmdutils.h"
+#include "fftools_log.h"
#include "fopen_utf8.h"
#include "opt_common.h"
#ifdef _WIN32
@@ -608,7 +609,7 @@ int opt_default(void *optctx, const char *opt, const char *arg)
#endif
if (!strcmp(opt, "debug") || !strcmp(opt, "fdebug"))
- av_log_set_level(AV_LOG_DEBUG);
+ ff_log_set_level(AV_LOG_DEBUG);
if (!(p = strchr(opt, ':')))
p = opt + strlen(opt);
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index dc321fb4a2..b845fa2ba4 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -81,6 +81,7 @@
#include "ffmpeg.h"
#include "ffmpeg_sched.h"
#include "ffmpeg_utils.h"
+#include "fftools_log.h"
const char program_name[] = "ffmpeg";
const int program_birth_year = 2000;
@@ -671,7 +672,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
if (print_stats || is_last_report) {
const char end = is_last_report ? '\n' : '\r';
- if (print_stats==1 && AV_LOG_INFO > av_log_get_level()) {
+ if (print_stats==1 && AV_LOG_INFO > ff_log_get_level()) {
fprintf(stderr, "%s %c", buf.str, end);
} else
av_log(NULL, AV_LOG_INFO, "%s %c", buf.str, end);
@@ -801,8 +802,8 @@ static int check_keyboard_interaction(int64_t cur_time)
av_log(NULL, AV_LOG_INFO, "\n\n[q] command received. Exiting.\n\n");
return AVERROR_EXIT;
}
- if (key == '+') av_log_set_level(av_log_get_level()+10);
- if (key == '-') av_log_set_level(av_log_get_level()-10);
+ if (key == '+') ff_log_set_level(ff_log_get_level()+10);
+ if (key == '-') ff_log_set_level(ff_log_get_level()-10);
if (key == 'c' || key == 'C'){
char buf[4096], target[64], command[256], arg[256] = {0};
double time;
@@ -954,7 +955,8 @@ int main(int argc, char **argv)
setvbuf(stderr,NULL,_IONBF,0); /* win32 runtime needs this */
- av_log_set_flags(AV_LOG_SKIP_REPEATED);
+ ff_log_set_flags(FF_LOG_SKIP_REPEATED);
+ init_logging();
parse_loglevel(argc, argv, options);
#if CONFIG_AVDEVICE
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 2a572fc3aa..1d4870fd99 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -57,6 +57,7 @@
#include "cmdutils.h"
#include "ffplay_renderer.h"
#include "opt_common.h"
+#include "fftools_log.h"
const char program_name[] = "ffplay";
const int program_birth_year = 2003;
@@ -1735,7 +1736,7 @@ display:
vqsize / 1024,
sqsize);
- if (show_status == 1 && AV_LOG_INFO > av_log_get_level())
+ if (show_status == 1 && AV_LOG_INFO > ff_log_get_level())
fprintf(stderr, "%s", buf.str);
else
av_log(NULL, AV_LOG_INFO, "%s", buf.str);
@@ -3761,7 +3762,8 @@ int main(int argc, char **argv)
init_dynload();
- av_log_set_flags(AV_LOG_SKIP_REPEATED);
+ ff_log_set_flags(FF_LOG_SKIP_REPEATED);
+ init_logging();
parse_loglevel(argc, argv, options);
/* register all codecs, demux and protocols */
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 7341731d2f..98540982c4 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -68,6 +68,7 @@
#include "libavfilter/version.h"
#include "cmdutils.h"
#include "opt_common.h"
+#include "fftools_log.h"
#include "libavutil/thread.h"
@@ -4651,7 +4652,8 @@ int main(int argc, char **argv)
init_dynload();
- av_log_set_flags(AV_LOG_SKIP_REPEATED);
+ ff_log_set_flags(FF_LOG_SKIP_REPEATED);
+ init_logging();
options = real_options;
parse_loglevel(argc, argv, options);
diff --git a/fftools/fftools_log.c b/fftools/fftools_log.c
new file mode 100644
index 0000000000..f8f098fef9
--- /dev/null
+++ b/fftools/fftools_log.c
@@ -0,0 +1,448 @@
+/*
+ * Copyright (c) The FFmpeg developers
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#include "config.h"
+
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#if HAVE_IO_H
+#include <io.h>
+#endif
+#include <inttypes.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#include "libavutil/bprint.h"
+#include "libavutil/common.h"
+#include "libavutil/log.h"
+#include "libavutil/thread.h"
+#include "libavutil/time.h"
+
+#include "fftools_log.h"
+
+
+static int ff_log_level = AV_LOG_INFO;
+static int ff_log_flags;
+
+
+#if !HAVE_LOCALTIME_R && !defined(localtime_r)
+static inline struct tm *ff_localtime_r(const time_t* clock, struct tm *result)
+{
+ struct tm *ptr = localtime(clock);
+ if (!ptr)
+ return NULL;
+ *result = *ptr;
+ return result;
+}
+#define localtime_r ff_localtime_r
+#endif
+
+static AVMutex mutex = AV_MUTEX_INITIALIZER;
+
+#define LINE_SZ 1024
+
+#if HAVE_VALGRIND_VALGRIND_H && CONFIG_VALGRIND_BACKTRACE
+#include <valgrind/valgrind.h>
+/* this is the log level at which valgrind will output a full backtrace */
+#define BACKTRACE_LOGLEVEL AV_LOG_ERROR
+#endif
+
+#define NB_LEVELS 8
+#if defined(_WIN32) && HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
+#include <windows.h>
+static const uint8_t color[16 + AV_CLASS_CATEGORY_NB] = {
+ [AV_LOG_PANIC /8] = 12,
+ [AV_LOG_FATAL /8] = 12,
+ [AV_LOG_ERROR /8] = 12,
+ [AV_LOG_WARNING/8] = 14,
+ [AV_LOG_INFO /8] = 7,
+ [AV_LOG_VERBOSE/8] = 10,
+ [AV_LOG_DEBUG /8] = 10,
+ [AV_LOG_TRACE /8] = 8,
+ [16+AV_CLASS_CATEGORY_NA ] = 7,
+ [16+AV_CLASS_CATEGORY_INPUT ] = 13,
+ [16+AV_CLASS_CATEGORY_OUTPUT ] = 5,
+ [16+AV_CLASS_CATEGORY_MUXER ] = 13,
+ [16+AV_CLASS_CATEGORY_DEMUXER ] = 5,
+ [16+AV_CLASS_CATEGORY_ENCODER ] = 11,
+ [16+AV_CLASS_CATEGORY_DECODER ] = 3,
+ [16+AV_CLASS_CATEGORY_FILTER ] = 10,
+ [16+AV_CLASS_CATEGORY_BITSTREAM_FILTER] = 9,
+ [16+AV_CLASS_CATEGORY_SWSCALER ] = 7,
+ [16+AV_CLASS_CATEGORY_SWRESAMPLER ] = 7,
+ [16+AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT ] = 13,
+ [16+AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT ] = 5,
+ [16+AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT ] = 13,
+ [16+AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT ] = 5,
+ [16+AV_CLASS_CATEGORY_DEVICE_OUTPUT ] = 13,
+ [16+AV_CLASS_CATEGORY_DEVICE_INPUT ] = 5,
+};
+
+static int16_t background, attr_orig;
+static HANDLE con;
+#else
+
+static const uint32_t color[16 + AV_CLASS_CATEGORY_NB] = {
+ [AV_LOG_PANIC /8] = 52 << 16 | 196 << 8 | 0x41,
+ [AV_LOG_FATAL /8] = 208 << 8 | 0x41,
+ [AV_LOG_ERROR /8] = 196 << 8 | 0x11,
+ [AV_LOG_WARNING/8] = 226 << 8 | 0x03,
+ [AV_LOG_INFO /8] = 253 << 8 | 0x09,
+ [AV_LOG_VERBOSE/8] = 40 << 8 | 0x02,
+ [AV_LOG_DEBUG /8] = 34 << 8 | 0x02,
+ [AV_LOG_TRACE /8] = 34 << 8 | 0x07,
+ [16+AV_CLASS_CATEGORY_NA ] = 250 << 8 | 0x09,
+ [16+AV_CLASS_CATEGORY_INPUT ] = 219 << 8 | 0x15,
+ [16+AV_CLASS_CATEGORY_OUTPUT ] = 201 << 8 | 0x05,
+ [16+AV_CLASS_CATEGORY_MUXER ] = 213 << 8 | 0x15,
+ [16+AV_CLASS_CATEGORY_DEMUXER ] = 207 << 8 | 0x05,
+ [16+AV_CLASS_CATEGORY_ENCODER ] = 51 << 8 | 0x16,
+ [16+AV_CLASS_CATEGORY_DECODER ] = 39 << 8 | 0x06,
+ [16+AV_CLASS_CATEGORY_FILTER ] = 155 << 8 | 0x12,
+ [16+AV_CLASS_CATEGORY_BITSTREAM_FILTER] = 192 << 8 | 0x14,
+ [16+AV_CLASS_CATEGORY_SWSCALER ] = 153 << 8 | 0x14,
+ [16+AV_CLASS_CATEGORY_SWRESAMPLER ] = 147 << 8 | 0x14,
+ [16+AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT ] = 213 << 8 | 0x15,
+ [16+AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT ] = 207 << 8 | 0x05,
+ [16+AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT ] = 213 << 8 | 0x15,
+ [16+AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT ] = 207 << 8 | 0x05,
+ [16+AV_CLASS_CATEGORY_DEVICE_OUTPUT ] = 213 << 8 | 0x15,
+ [16+AV_CLASS_CATEGORY_DEVICE_INPUT ] = 207 << 8 | 0x05,
+};
+
+#endif
+static int use_color = -1;
+
+#if defined(_WIN32) && HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
+static void win_console_puts(const char *str)
+{
+ const uint8_t *q = str;
+ uint16_t line[LINE_SZ];
+
+ while (*q) {
+ uint16_t *buf = line;
+ DWORD nb_chars = 0;
+ DWORD written;
+
+ while (*q && nb_chars < LINE_SZ - 1) {
+ uint32_t ch;
+ uint16_t tmp;
+
+ GET_UTF8(ch, *q ? *q++ : 0, ch = 0xfffd; goto continue_on_invalid;)
+continue_on_invalid:
+ PUT_UTF16(ch, tmp, *buf++ = tmp; nb_chars++;)
+ }
+
+ WriteConsoleW(con, line, nb_chars, &written, NULL);
+ }
+}
+#endif
+
+static void check_color_terminal(void)
+{
+ char *term = getenv("TERM");
+
+#if defined(_WIN32) && HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
+ CONSOLE_SCREEN_BUFFER_INFO con_info;
+ DWORD dummy;
+ con = GetStdHandle(STD_ERROR_HANDLE);
+ if (con != INVALID_HANDLE_VALUE && !GetConsoleMode(con, &dummy))
+ con = INVALID_HANDLE_VALUE;
+ if (con != INVALID_HANDLE_VALUE) {
+ GetConsoleScreenBufferInfo(con, &con_info);
+ attr_orig = con_info.wAttributes;
+ background = attr_orig & 0xF0;
+ }
+#endif
+
+ if (getenv("AV_LOG_FORCE_NOCOLOR")) {
+ use_color = 0;
+ } else if (getenv("AV_LOG_FORCE_COLOR")) {
+ use_color = 1;
+ } else {
+#if defined(_WIN32) && HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
+ use_color = (con != INVALID_HANDLE_VALUE);
+#elif HAVE_ISATTY
+ use_color = (term && isatty(2));
+#else
+ use_color = 0;
+#endif
+ }
+
+ if (getenv("AV_LOG_FORCE_256COLOR") || term && strstr(term, "256color"))
+ use_color *= 256;
+}
+
+static void ansi_fputs(int level, int tint, const char *str, int local_use_color)
+{
+ if (local_use_color == 1) {
+ fprintf(stderr,
+ "\033[%"PRIu32";3%"PRIu32"m%s\033[0m",
+ (color[level] >> 4) & 15,
+ color[level] & 15,
+ str);
+ } else if (tint && use_color == 256) {
+ fprintf(stderr,
+ "\033[48;5;%"PRIu32"m\033[38;5;%dm%s\033[0m",
+ (color[level] >> 16) & 0xff,
+ tint,
+ str);
+ } else if (local_use_color == 256) {
+ fprintf(stderr,
+ "\033[48;5;%"PRIu32"m\033[38;5;%"PRIu32"m%s\033[0m",
+ (color[level] >> 16) & 0xff,
+ (color[level] >> 8) & 0xff,
+ str);
+ } else
+ fputs(str, stderr);
+}
+
+static void colored_fputs(int level, int tint, const char *str)
+{
+ int local_use_color;
+ if (!*str)
+ return;
+
+ if (use_color < 0)
+ check_color_terminal();
+
+ if (level == AV_LOG_INFO/8) local_use_color = 0;
+ else local_use_color = use_color;
+
+#if defined(_WIN32) && HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
+ if (con != INVALID_HANDLE_VALUE) {
+ if (local_use_color)
+ SetConsoleTextAttribute(con, background | color[level]);
+ win_console_puts(str);
+ if (local_use_color)
+ SetConsoleTextAttribute(con, attr_orig);
+ } else {
+ ansi_fputs(level, tint, str, local_use_color);
+ }
+#else
+ ansi_fputs(level, tint, str, local_use_color);
+#endif
+
+}
+
+static void sanitize(uint8_t *line){
+ while(*line){
+ if(*line < 0x08 || (*line > 0x0D && *line < 0x20))
+ *line='?';
+ line++;
+ }
+}
+
+static int get_category(void *ptr){
+ AVClass *avc = *(AVClass **) ptr;
+ if( !avc
+ || (avc->version&0xFF)<100
+ || avc->version < (51 << 16 | 59 << 8)
+ || avc->category >= AV_CLASS_CATEGORY_NB) return AV_CLASS_CATEGORY_NA + 16;
+
+ if(avc->get_category)
+ return avc->get_category(ptr) + 16;
+
+ return avc->category + 16;
+}
+
+static const char *get_level_str(int level)
+{
+ switch (level) {
+ case AV_LOG_QUIET:
+ return "quiet";
+ case AV_LOG_DEBUG:
+ return "debug";
+ case AV_LOG_TRACE:
+ return "trace";
+ case AV_LOG_VERBOSE:
+ return "verbose";
+ case AV_LOG_INFO:
+ return "info";
+ case AV_LOG_WARNING:
+ return "warning";
+ case AV_LOG_ERROR:
+ return "error";
+ case AV_LOG_FATAL:
+ return "fatal";
+ case AV_LOG_PANIC:
+ return "panic";
+ default:
+ return "";
+ }
+}
+
+static const char *item_name(void *obj, const AVClass *cls)
+{
+ return (cls->item_name ? cls->item_name : av_default_item_name)(obj);
+}
+
+static void format_date_now(AVBPrint* bp_time, int include_date)
+{
+ struct tm *ptm, tmbuf;
+ const int64_t time_us = av_gettime();
+ const int64_t time_ms = time_us / 1000;
+ const time_t time_s = time_ms / 1000;
+ const int millisec = time_ms - (time_s * 1000);
+ ptm = localtime_r(&time_s, &tmbuf);
+ if (ptm) {
+ if (include_date)
+ av_bprint_strftime(bp_time, "%Y-%m-%d ", ptm);
+
+ av_bprint_strftime(bp_time, "%H:%M:%S", ptm);
+ av_bprintf(bp_time, ".%03d ", millisec);
+ }
+}
+
+static void format_line(void *avcl, int level, const char *fmt, va_list vl,
+ AVBPrint part[5], int *print_prefix, int type[2])
+{
+ AVClass* avc = avcl ? *(AVClass **) avcl : NULL;
+ av_bprint_init(part+0, 0, AV_BPRINT_SIZE_AUTOMATIC);
+ av_bprint_init(part+1, 0, AV_BPRINT_SIZE_AUTOMATIC);
+ av_bprint_init(part+2, 0, AV_BPRINT_SIZE_AUTOMATIC);
+ av_bprint_init(part+3, 0, 65536);
+ av_bprint_init(part+4, 0, AV_BPRINT_SIZE_AUTOMATIC);
+
+ if(type) type[0] = type[1] = AV_CLASS_CATEGORY_NA + 16;
+ if (*print_prefix && avc) {
+ if (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(type) type[0] = get_category(parent);
+ }
+ }
+ av_bprintf(part+1, "[%s @ %p] ",
+ item_name(avcl, avc), avcl);
+ if(type) type[1] = get_category(avcl);
+ }
+
+ if (*print_prefix && (level > AV_LOG_QUIET) && (ff_log_flags & (FF_LOG_PRINT_TIME | FF_LOG_PRINT_DATETIME)))
+ format_date_now(&part[4], ff_log_flags & FF_LOG_PRINT_DATETIME);
+
+ if (*print_prefix && (level > AV_LOG_QUIET) && (ff_log_flags & FF_LOG_PRINT_LEVEL))
+ av_bprintf(part+2, "[%s] ", get_level_str(level));
+
+ av_vbprintf(part+3, fmt, vl);
+
+ if(*part[0].str || *part[1].str || *part[2].str || *part[3].str) {
+ char lastc = part[3].len && part[3].len <= part[3].size ? part[3].str[part[3].len - 1] : 0;
+ *print_prefix = lastc == '\n' || lastc == '\r';
+ }
+}
+
+void fftools_log_callback(void* ptr, int level, const char* fmt, va_list vl)
+{
+ static int print_prefix = 1;
+ static int count;
+ static char prev[LINE_SZ];
+ AVBPrint part[5];
+ char line[LINE_SZ];
+ static int is_atty;
+ int type[2];
+ unsigned tint = 0;
+
+ if (level >= 0) {
+ tint = level & 0xff00;
+ level &= 0xff;
+ }
+
+ if (level > ff_log_level)
+ return;
+
+ ff_mutex_lock(&mutex);
+
+ format_line(ptr, level, fmt, vl, part, &print_prefix, type);
+ snprintf(line, sizeof(line), "%s%s%s%s", part[0].str, part[1].str, part[2].str, part[3].str);
+
+#if HAVE_ISATTY
+ if (!is_atty)
+ is_atty = isatty(2) ? 1 : -1;
+#endif
+
+ if (print_prefix && (ff_log_flags & FF_LOG_SKIP_REPEATED) && !strcmp(line, prev) &&
+ *line && line[strlen(line) - 1] != '\r'){
+ count++;
+ if (is_atty == 1)
+ fprintf(stderr, " Last message repeated %d times\r", count);
+ goto end;
+ }
+ if (count > 0) {
+ fprintf(stderr, " Last message repeated %d times\n", count);
+ count = 0;
+ }
+ strcpy(prev, line);
+
+ sanitize(part[4].str);
+ colored_fputs(7, 0, part[4].str);
+ sanitize(part[0].str);
+ colored_fputs(type[0], 0, part[0].str);
+ sanitize(part[1].str);
+ colored_fputs(type[1], 0, part[1].str);
+ sanitize(part[2].str);
+ colored_fputs(av_clip(level >> 3, 0, NB_LEVELS - 1), tint >> 8, part[2].str);
+ sanitize(part[3].str);
+ colored_fputs(av_clip(level >> 3, 0, NB_LEVELS - 1), tint >> 8, part[3].str);
+
+#if CONFIG_VALGRIND_BACKTRACE
+ if (level <= BACKTRACE_LOGLEVEL)
+ VALGRIND_PRINTF_BACKTRACE("%s", "");
+#endif
+end:
+ av_bprint_finalize(part+3, NULL);
+ ff_mutex_unlock(&mutex);
+}
+
+
+void init_logging(void)
+{
+ av_log_set_callback(&fftools_log_callback);
+}
+
+int ff_log_get_level(void)
+{
+ return ff_log_level;
+}
+
+void ff_log_set_level(int level)
+{
+ ff_log_level = level;
+
+ av_log_set_level(level);
+}
+
+void ff_log_set_flags(int arg)
+{
+ ff_log_flags = arg;
+}
+
+int ff_log_get_flags(void)
+{
+ return ff_log_flags;
+}
+
diff --git a/fftools/fftools_log.h b/fftools/fftools_log.h
new file mode 100644
index 0000000000..4dba15ff7f
--- /dev/null
+++ b/fftools/fftools_log.h
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) The FFmpeg developers
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef FFTOOLS_FFTOOLS_LOG_H
+#define FFTOOLS_FFTOOLS_LOG_H
+
+#include <stdint.h>
+
+#include "config.h"
+#include "libavcodec/avcodec.h"
+#include "libavfilter/avfilter.h"
+#include "libavformat/avformat.h"
+#include "libswscale/swscale.h"
+
+
+/**
+ * Custom logging callback for fftools.
+ */
+void fftools_log_callback(void* ptr, int level, const char* fmt, va_list vl);
+
+/**
+ * Sets the logging callback function.
+ */
+void init_logging(void);
+
+
+/**
+ * Get the current log level
+ *
+ * @see lavu_log_constants
+ *
+ * @return Current log level
+ */
+int ff_log_get_level(void);
+
+/**
+ * Set the log level
+ *
+ * @see lavu_log_constants
+ *
+ * @param level Logging level
+ */
+void ff_log_set_level(int level);
+
+void ff_log_set_flags(int arg);
+
+int ff_log_get_flags(void);
+
+
+/**
+ * Skip repeated messages, this requires the user app to use av_log() instead of
+ * (f)printf as the 2 would otherwise interfere and lead to
+ * "Last message repeated x times" messages below (f)printf messages with some
+ * bad luck.
+ * Also to receive the last, "last repeated" line if any, the user app must
+ * call av_log(NULL, AV_LOG_QUIET, "%s", ""); at the end
+ */
+#define FF_LOG_SKIP_REPEATED 1
+
+/**
+ * Include the log severity in messages originating from codecs.
+ *
+ * Results in messages such as:
+ * [rawvideo @ 0xDEADBEEF] [error] encode did not produce valid pts
+ */
+#define FF_LOG_PRINT_LEVEL 2
+
+/**
+ * Include system time in log output.
+ */
+#define FF_LOG_PRINT_TIME 4
+
+/**
+ * Include system date and time in log output.
+ */
+#define FF_LOG_PRINT_DATETIME 8
+
+
+#endif /* FFTOOLS_FFTOOLS_LOG_H */
diff --git a/fftools/opt_common.c b/fftools/opt_common.c
index 2ac3fd4fb3..702f62a6fe 100644
--- a/fftools/opt_common.c
+++ b/fftools/opt_common.c
@@ -25,6 +25,7 @@
#include "cmdutils.h"
#include "opt_common.h"
+#include "fftools_log.h"
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/bprint.h"
@@ -1203,7 +1204,7 @@ int init_report(const char *env, FILE **file)
return AVERROR(ENOMEM);
}
- prog_loglevel = av_log_get_level();
+ prog_loglevel = ff_log_get_level();
if (!envlevel)
report_file_level = FFMAX(report_file_level, prog_loglevel);
@@ -1265,8 +1266,8 @@ int opt_loglevel(void *optctx, const char *opt, const char *arg)
};
const char *token;
char *tail;
- int flags = av_log_get_flags();
- int level = av_log_get_level();
+ int flags = ff_log_get_flags();
+ int level = ff_log_get_level();
int cmd, i = 0;
av_assert0(arg);
@@ -1282,27 +1283,27 @@ int opt_loglevel(void *optctx, const char *opt, const char *arg)
}
if (av_strstart(token, "repeat", &arg)) {
if (cmd == '-') {
- flags |= AV_LOG_SKIP_REPEATED;
+ flags |= FF_LOG_SKIP_REPEATED;
} else {
- flags &= ~AV_LOG_SKIP_REPEATED;
+ flags &= ~FF_LOG_SKIP_REPEATED;
}
} else if (av_strstart(token, "level", &arg)) {
if (cmd == '-') {
- flags &= ~AV_LOG_PRINT_LEVEL;
+ flags &= ~FF_LOG_PRINT_LEVEL;
} else {
- flags |= AV_LOG_PRINT_LEVEL;
+ flags |= FF_LOG_PRINT_LEVEL;
}
} else if (av_strstart(token, "time", &arg)) {
if (cmd == '-') {
- flags &= ~AV_LOG_PRINT_TIME;
+ flags &= ~FF_LOG_PRINT_TIME;
} else {
- flags |= AV_LOG_PRINT_TIME;
+ flags |= FF_LOG_PRINT_TIME;
}
} else if (av_strstart(token, "datetime", &arg)) {
if (cmd == '-') {
- flags &= ~AV_LOG_PRINT_DATETIME;
+ flags &= ~FF_LOG_PRINT_DATETIME;
} else {
- flags |= AV_LOG_PRINT_DATETIME;
+ flags |= FF_LOG_PRINT_DATETIME;
}
} else {
break;
@@ -1314,7 +1315,7 @@ int opt_loglevel(void *optctx, const char *opt, const char *arg)
} else if (*arg == '+') {
arg++;
} else if (!i) {
- flags = av_log_get_flags(); /* level value without prefix, reset flags */
+ flags = ff_log_get_flags(); /* level value without prefix, reset flags */
}
for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++) {
@@ -1339,8 +1340,8 @@ int opt_loglevel(void *optctx, const char *opt, const char *arg)
}
end:
- av_log_set_flags(flags);
- av_log_set_level(level);
+ ff_log_set_flags(flags);
+ ff_log_set_level(level);
return 0;
}
@@ -1436,9 +1437,9 @@ int show_sources(void *optctx, const char *opt, const char *arg)
char *dev = NULL;
AVDictionary *opts = NULL;
int ret = 0;
- int error_level = av_log_get_level();
+ int error_level = ff_log_get_level();
- av_log_set_level(AV_LOG_WARNING);
+ ff_log_set_level(AV_LOG_WARNING);
if ((ret = show_sinks_sources_parse_arg(arg, &dev, &opts)) < 0)
goto fail;
@@ -1464,7 +1465,7 @@ int show_sources(void *optctx, const char *opt, const char *arg)
fail:
av_dict_free(&opts);
av_free(dev);
- av_log_set_level(error_level);
+ ff_log_set_level(error_level);
return ret;
}
@@ -1474,9 +1475,9 @@ int show_sinks(void *optctx, const char *opt, const char *arg)
char *dev = NULL;
AVDictionary *opts = NULL;
int ret = 0;
- int error_level = av_log_get_level();
+ int error_level = ff_log_get_level();
- av_log_set_level(AV_LOG_WARNING);
+ ff_log_set_level(AV_LOG_WARNING);
if ((ret = show_sinks_sources_parse_arg(arg, &dev, &opts)) < 0)
goto fail;
@@ -1500,7 +1501,7 @@ int show_sinks(void *optctx, const char *opt, const char *arg)
fail:
av_dict_free(&opts);
av_free(dev);
- av_log_set_level(error_level);
+ ff_log_set_level(error_level);
return ret;
}
#endif /* CONFIG_AVDEVICE */
--
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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v6 2/3] fftools/opt_common: add memaddresses log flag
2025-03-13 9:30 ` [FFmpeg-devel] [PATCH v6 0/3] avutil/log: Replace addresses in log output with simple ids ffmpegagent
2025-03-13 9:30 ` [FFmpeg-devel] [PATCH v6 1/3] fftools: Add a local logging callback function softworkz
@ 2025-03-13 9:30 ` softworkz
2025-03-13 9:30 ` [FFmpeg-devel] [PATCH v6 3/3] doc/fftools-common-opts: document " softworkz
2025-04-09 5:54 ` [FFmpeg-devel] [PATCH v7 0/3] avutil/log: Add log flag to control printing of memory addresses ffmpegagent
3 siblings, 0 replies; 92+ messages in thread
From: softworkz @ 2025-03-13 9:30 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
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.
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] .....
Signed-off-by: softworkz <softworkz@hotmail.com>
---
fftools/cmdutils.c | 1 +
fftools/fftools_log.c | 67 +++++++++++++++++++++++++++++++++++++++----
fftools/fftools_log.h | 5 ++++
fftools/opt_common.c | 6 ++++
4 files changed, 73 insertions(+), 6 deletions(-)
diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 0bf453508d..fb05f3fd2f 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -46,6 +46,7 @@
#include "libavutil/dict.h"
#include "libavutil/opt.h"
#include "cmdutils.h"
+
#include "fftools_log.h"
#include "fopen_utf8.h"
#include "opt_common.h"
diff --git a/fftools/fftools_log.c b/fftools/fftools_log.c
index f8f098fef9..b83c8abcaa 100644
--- a/fftools/fftools_log.c
+++ b/fftools/fftools_log.c
@@ -59,6 +59,53 @@ static inline struct tm *ff_localtime_r(const time_t* clock, struct tm *result)
#define localtime_r ff_localtime_r
#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;
#define LINE_SZ 1024
@@ -316,6 +363,15 @@ 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])
{
@@ -328,17 +384,16 @@ 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) {
+
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);
+ log_formatprefix(part, parent);
if(type) type[0] = get_category(parent);
}
}
- av_bprintf(part+1, "[%s @ %p] ",
- item_name(avcl, avc), avcl);
+ log_formatprefix(part, avcl);
+
if(type) type[1] = get_category(avcl);
}
diff --git a/fftools/fftools_log.h b/fftools/fftools_log.h
index 4dba15ff7f..6333e4d3c1 100644
--- a/fftools/fftools_log.h
+++ b/fftools/fftools_log.h
@@ -92,5 +92,10 @@ int ff_log_get_flags(void);
*/
#define FF_LOG_PRINT_DATETIME 8
+/**
+ * Print memory addresses instead of logical ids in the AVClass prefix.
+ */
+#define FF_LOG_PRINT_MEMADDRESSES 16
+
#endif /* FFTOOLS_FFTOOLS_LOG_H */
diff --git a/fftools/opt_common.c b/fftools/opt_common.c
index 702f62a6fe..53b6fb2257 100644
--- a/fftools/opt_common.c
+++ b/fftools/opt_common.c
@@ -1305,6 +1305,12 @@ 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;
}
--
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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v6 3/3] doc/fftools-common-opts: document memaddresses log flag
2025-03-13 9:30 ` [FFmpeg-devel] [PATCH v6 0/3] avutil/log: Replace addresses in log output with simple ids ffmpegagent
2025-03-13 9:30 ` [FFmpeg-devel] [PATCH v6 1/3] fftools: Add a local logging callback function softworkz
2025-03-13 9:30 ` [FFmpeg-devel] [PATCH v6 2/3] fftools/opt_common: add memaddresses log flag softworkz
@ 2025-03-13 9:30 ` softworkz
2025-04-09 5:54 ` [FFmpeg-devel] [PATCH v7 0/3] avutil/log: Add log flag to control printing of memory addresses ffmpegagent
3 siblings, 0 replies; 92+ messages in thread
From: softworkz @ 2025-03-13 9:30 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v7 0/3] avutil/log: Add log flag to control printing of memory addresses
2025-03-13 9:30 ` [FFmpeg-devel] [PATCH v6 0/3] avutil/log: Replace addresses in log output with simple ids ffmpegagent
` (2 preceding siblings ...)
2025-03-13 9:30 ` [FFmpeg-devel] [PATCH v6 3/3] doc/fftools-common-opts: document " softworkz
@ 2025-04-09 5:54 ` ffmpegagent
2025-04-09 5:55 ` [FFmpeg-devel] [PATCH v7 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES softworkz
` (3 more replies)
3 siblings, 4 replies; 92+ messages in thread
From: ffmpegagent @ 2025-04-09 5:54 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
--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".
^ permalink raw reply [flat|nested] 92+ messages in thread
* [FFmpeg-devel] [PATCH v7 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES
2025-04-09 5:54 ` [FFmpeg-devel] [PATCH v7 0/3] avutil/log: Add log flag to control printing of memory addresses ffmpegagent
@ 2025-04-09 5:55 ` softworkz
2025-04-09 7:27 ` Andreas Rheinhardt
2025-04-09 5:55 ` [FFmpeg-devel] [PATCH v7 2/3] fftools/opt_common: add memaddresses log flag softworkz
` (2 subsequent siblings)
3 siblings, 1 reply; 92+ messages in thread
From: softworkz @ 2025-04-09 5:55 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
From: softworkz <softworkz@hotmail.com>
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>
---
doc/APIchanges | 3 +++
libavutil/log.c | 8 +++++---
libavutil/log.h | 5 +++++
libavutil/version.h | 2 +-
4 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index 65bf5a9419..27afa5ba81 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -1,5 +1,8 @@
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
+
API changes, most recent first:
2025-04-07 - 19e9a203b7 - lavu 60.01.100 - dict.h
diff --git a/libavutil/log.c b/libavutil/log.c
index c5ee876a88..7ce23cc31f 100644
--- a/libavutil/log.c
+++ b/libavutil/log.c
@@ -56,7 +56,7 @@ static AVMutex mutex = AV_MUTEX_INITIALIZER;
#endif
static int av_log_level = AV_LOG_INFO;
-static int flags;
+static int flags = AV_LOG_PRINT_MEMADDRESSES;
#define NB_LEVELS 8
#if defined(_WIN32) && HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
@@ -327,16 +327,18 @@ 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);
if (parent && *parent) {
- av_bprintf(part+0, "[%s @ %p] ",
+ av_bprintf(part+0, p_fmt,
item_name(parent, *parent), parent);
if(type) type[0] = get_category(parent);
}
}
- av_bprintf(part+1, "[%s @ %p] ",
+ av_bprintf(part+1, p_fmt,
item_name(avcl, avc), 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 5139883569..4717cd562b 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
*/
#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, \
--
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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v7 2/3] fftools/opt_common: add memaddresses log flag
2025-04-09 5:54 ` [FFmpeg-devel] [PATCH v7 0/3] avutil/log: Add log flag to control printing of memory addresses ffmpegagent
2025-04-09 5:55 ` [FFmpeg-devel] [PATCH v7 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES softworkz
@ 2025-04-09 5:55 ` softworkz
2025-04-09 5:55 ` [FFmpeg-devel] [PATCH v7 3/3] doc/fftools-common-opts: document " softworkz
2025-04-09 9:25 ` [FFmpeg-devel] [PATCH v8 0/3] avutil/log: Add log flag to control printing of memory addresses ffmpegagent
3 siblings, 0 replies; 92+ messages in thread
From: softworkz @ 2025-04-09 5:55 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
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] .....
Signed-off-by: softworkz <softworkz@hotmail.com>
---
fftools/opt_common.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/fftools/opt_common.c b/fftools/opt_common.c
index 2ac3fd4fb3..77f3554727 100644
--- a/fftools/opt_common.c
+++ b/fftools/opt_common.c
@@ -1269,6 +1269,9 @@ int opt_loglevel(void *optctx, const char *opt, const char *arg)
int level = av_log_get_level();
int cmd, i = 0;
+ // libavutil has this enabled by default, fftools sets this off by default
+ flags &= ~AV_LOG_PRINT_MEMADDRESSES;
+
av_assert0(arg);
while (*arg) {
token = arg;
@@ -1304,6 +1307,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;
}
@@ -1315,6 +1324,7 @@ int opt_loglevel(void *optctx, const char *opt, const char *arg)
arg++;
} else if (!i) {
flags = av_log_get_flags(); /* level value without prefix, reset flags */
+ flags &= ~AV_LOG_PRINT_MEMADDRESSES;
}
for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++) {
--
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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v7 3/3] doc/fftools-common-opts: document memaddresses log flag
2025-04-09 5:54 ` [FFmpeg-devel] [PATCH v7 0/3] avutil/log: Add log flag to control printing of memory addresses ffmpegagent
2025-04-09 5:55 ` [FFmpeg-devel] [PATCH v7 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES softworkz
2025-04-09 5:55 ` [FFmpeg-devel] [PATCH v7 2/3] fftools/opt_common: add memaddresses log flag softworkz
@ 2025-04-09 5:55 ` softworkz
2025-04-09 9:25 ` [FFmpeg-devel] [PATCH v8 0/3] avutil/log: Add log flag to control printing of memory addresses ffmpegagent
3 siblings, 0 replies; 92+ messages in thread
From: softworkz @ 2025-04-09 5:55 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
From: softworkz <softworkz@hotmail.com>
Signed-off-by: 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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v7 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES
2025-04-09 5:55 ` [FFmpeg-devel] [PATCH v7 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES softworkz
@ 2025-04-09 7:27 ` Andreas Rheinhardt
2025-04-09 7:50 ` softworkz .
0 siblings, 1 reply; 92+ messages in thread
From: Andreas Rheinhardt @ 2025-04-09 7:27 UTC (permalink / raw)
To: ffmpeg-devel
softworkz:
> From: softworkz <softworkz@hotmail.com>
>
> 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.
The implementation of this flag is counter to the usual one: It is
enabled by default, but every av_log_set_flags() that does not set
AV_LOG_PRINT_MEMADDRESSES implicitly disables printing memory addresses.
This means that it will affect users that do not opt into this. I don't
think this is intended or that the new system makes sense.
(Due to the av_log_set_flags(AV_LOG_SKIP_REPEATED) performed early in
the main function of the fftools, they are of this kind even with this
patch alone.)
>
> Signed-off-by: softworkz <softworkz@hotmail.com>
> ---
> doc/APIchanges | 3 +++
> libavutil/log.c | 8 +++++---
> libavutil/log.h | 5 +++++
> libavutil/version.h | 2 +-
> 4 files changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 65bf5a9419..27afa5ba81 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -1,5 +1,8 @@
> 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
> +
> API changes, most recent first:
>
> 2025-04-07 - 19e9a203b7 - lavu 60.01.100 - dict.h
> diff --git a/libavutil/log.c b/libavutil/log.c
> index c5ee876a88..7ce23cc31f 100644
> --- a/libavutil/log.c
> +++ b/libavutil/log.c
> @@ -56,7 +56,7 @@ static AVMutex mutex = AV_MUTEX_INITIALIZER;
> #endif
>
> static int av_log_level = AV_LOG_INFO;
> -static int flags;
> +static int flags = AV_LOG_PRINT_MEMADDRESSES;
>
> #define NB_LEVELS 8
> #if defined(_WIN32) && HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
> @@ -327,16 +327,18 @@ 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);
> if (parent && *parent) {
> - av_bprintf(part+0, "[%s @ %p] ",
> + av_bprintf(part+0, p_fmt,
> item_name(parent, *parent), parent);
> if(type) type[0] = get_category(parent);
> }
> }
> - av_bprintf(part+1, "[%s @ %p] ",
> + av_bprintf(part+1, p_fmt,
> item_name(avcl, avc), 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.
The logical id system has been removed from this patchset.
> + */
> +#define AV_LOG_PRINT_MEMADDRESSES 16
AV_LOG_PRINT_MEMADDRESS seems better given that every av_log() will
likely only print one memaddress.
> +
> void av_log_set_flags(int arg);
> int av_log_get_flags(void);
>
> diff --git a/libavutil/version.h b/libavutil/version.h
> index 5139883569..4717cd562b 100644
> --- a/libavutil/version.h
> +++ b/libavutil/version.h
> @@ -79,7 +79,7 @@
> */
>
> #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, \
_______________________________________________
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v7 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES
2025-04-09 7:27 ` Andreas Rheinhardt
@ 2025-04-09 7:50 ` softworkz .
2025-04-09 8:02 ` softworkz .
2025-04-09 8:15 ` Andreas Rheinhardt
0 siblings, 2 replies; 92+ messages in thread
From: softworkz . @ 2025-04-09 7:50 UTC (permalink / raw)
To: FFmpeg development discussions and patches
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Andreas Rheinhardt
> Sent: Mittwoch, 9. April 2025 09:28
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH v7 1/3] avutil/log: Add log flag
> AV_LOG_PRINT_MEMADDRESSES
>
> softworkz:
> > From: softworkz <softworkz@hotmail.com>
> >
> > 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.
>
> The implementation of this flag is counter to the usual one: It is
> enabled by default, but every av_log_set_flags() that does not set
> AV_LOG_PRINT_MEMADDRESSES implicitly disables printing memory addresses.
Hi Andreas,
thanks for looking at the patchset.
The intention is that memadress printing is enabled by default for library use of avutil (so that there's no change in behavior) but not for fftools (following the suggestion from Marton).
For fftools, the default is to _not_ print memory addresses _unless_ a user specifies something like:
./ffmpeg -v +memaddresses .....
> This means that it will affect users that do not opt into this. I don't
> think this is intended
Yes, it is.
> or that the new system makes sense.
Do you think it would make more sense to negate the flag semantic?
> AV_LOG_PRINT_MEMADDRESS seems better given that every av_log() will
> likely only print one memaddress.
It can be more than a single address per log line since it also prints the parent's memory address in case it specifies parent_log_context_offset.
see: https://github.com/ffstaging/FFmpeg/blob/02eda84bf2fcf0db7793872204b0f564a6557232/libavutil/log.c#L329-L337
Also, thanks a lot for the other hints!
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v7 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES
2025-04-09 7:50 ` softworkz .
@ 2025-04-09 8:02 ` softworkz .
2025-04-09 8:11 ` Andreas Rheinhardt
2025-04-09 8:15 ` Andreas Rheinhardt
1 sibling, 1 reply; 92+ messages in thread
From: softworkz . @ 2025-04-09 8:02 UTC (permalink / raw)
To: FFmpeg development discussions and patches
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> softworkz .
> Sent: Mittwoch, 9. April 2025 09:51
> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH v7 1/3] avutil/log: Add log flag
> AV_LOG_PRINT_MEMADDRESSES
>
>
>
> > -----Original Message-----
> > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> > Andreas Rheinhardt
> > Sent: Mittwoch, 9. April 2025 09:28
> > To: ffmpeg-devel@ffmpeg.org
> > Subject: Re: [FFmpeg-devel] [PATCH v7 1/3] avutil/log: Add log flag
> > AV_LOG_PRINT_MEMADDRESSES
> >
> > softworkz:
> > > From: softworkz <softworkz@hotmail.com>
> > >
> > > 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.
> >
> > The implementation of this flag is counter to the usual one: It is
> > enabled by default, but every av_log_set_flags() that does not set
> > AV_LOG_PRINT_MEMADDRESSES implicitly disables printing memory
> addresses.
>
> Hi Andreas,
>
> thanks for looking at the patchset.
[..]
> > AV_LOG_PRINT_MEMADDRESS seems better given that every av_log() will
> > likely only print one memaddress.
>
> It can be more than a single address per log line since it also prints
> the parent's memory address in case it specifies
> parent_log_context_offset.
>
> see:
> https://github.com/ffstaging/FFmpeg/blob/02eda84bf2fcf0db7793872204b0f56
> 4a6557232/libavutil/log.c#L329-L337
But the reason - from my thinking - why I made it plural is because it's a global flag that controls whether all memory addresses ( <- pl.) should be printed or not. If it was a flag that is conveyed as part of a log invocation (like av_log), controlling whether the memory address should be printed for that single log line, then I'd think it should be singular - probably even despite the nit regarding the parent address.
Does it make sense? 😊
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v7 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES
2025-04-09 8:02 ` softworkz .
@ 2025-04-09 8:11 ` Andreas Rheinhardt
2025-04-09 8:24 ` softworkz .
0 siblings, 1 reply; 92+ messages in thread
From: Andreas Rheinhardt @ 2025-04-09 8:11 UTC (permalink / raw)
To: ffmpeg-devel
softworkz .:
>
>
>> -----Original Message-----
>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
>> softworkz .
>> Sent: Mittwoch, 9. April 2025 09:51
>> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
>> Subject: Re: [FFmpeg-devel] [PATCH v7 1/3] avutil/log: Add log flag
>> AV_LOG_PRINT_MEMADDRESSES
>>
>>
>>
>>> -----Original Message-----
>>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
>>> Andreas Rheinhardt
>>> Sent: Mittwoch, 9. April 2025 09:28
>>> To: ffmpeg-devel@ffmpeg.org
>>> Subject: Re: [FFmpeg-devel] [PATCH v7 1/3] avutil/log: Add log flag
>>> AV_LOG_PRINT_MEMADDRESSES
>>>
>>> softworkz:
>>>> From: softworkz <softworkz@hotmail.com>
>>>>
>>>> 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.
>>>
>>> The implementation of this flag is counter to the usual one: It is
>>> enabled by default, but every av_log_set_flags() that does not set
>>> AV_LOG_PRINT_MEMADDRESSES implicitly disables printing memory
>> addresses.
>>
>> Hi Andreas,
>>
>> thanks for looking at the patchset.
>
> [..]
>
>>> AV_LOG_PRINT_MEMADDRESS seems better given that every av_log() will
>>> likely only print one memaddress.
>>
>> It can be more than a single address per log line since it also prints
>> the parent's memory address in case it specifies
>> parent_log_context_offset.
I know. That's why my statement contained a "likely".
>>
>> see:
>> https://github.com/ffstaging/FFmpeg/blob/02eda84bf2fcf0db7793872204b0f56
>> 4a6557232/libavutil/log.c#L329-L337
>
> But the reason - from my thinking - why I made it plural is because it's a global flag that controls whether all memory addresses ( <- pl.) should be printed or not. If it was a flag that is conveyed as part of a log invocation (like av_log), controlling whether the memory address should be printed for that single log line, then I'd think it should be singular - probably even despite the nit regarding the parent address.
>
> Does it make sense? 😊
>
I get your thinking, but it is not consistent with the other flags:
There is no AV_LOG_PRINT_TIMES after all.
- Andreas
_______________________________________________
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v7 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES
2025-04-09 7:50 ` softworkz .
2025-04-09 8:02 ` softworkz .
@ 2025-04-09 8:15 ` Andreas Rheinhardt
1 sibling, 0 replies; 92+ messages in thread
From: Andreas Rheinhardt @ 2025-04-09 8:15 UTC (permalink / raw)
To: ffmpeg-devel
softworkz .:
>
>
>> -----Original Message-----
>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
>> Andreas Rheinhardt
>> Sent: Mittwoch, 9. April 2025 09:28
>> To: ffmpeg-devel@ffmpeg.org
>> Subject: Re: [FFmpeg-devel] [PATCH v7 1/3] avutil/log: Add log flag
>> AV_LOG_PRINT_MEMADDRESSES
>>
>> softworkz:
>>> From: softworkz <softworkz@hotmail.com>
>>>
>>> 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.
>>
>> The implementation of this flag is counter to the usual one: It is
>> enabled by default, but every av_log_set_flags() that does not set
>> AV_LOG_PRINT_MEMADDRESSES implicitly disables printing memory addresses.
>
> Hi Andreas,
>
> thanks for looking at the patchset.
>
> The intention is that memadress printing is enabled by default for library use of avutil (so that there's no change in behavior) but not for fftools (following the suggestion from Marton).
>
> For fftools, the default is to _not_ print memory addresses _unless_ a user specifies something like:
>
> ./ffmpeg -v +memaddresses .....
>
>
>> This means that it will affect users that do not opt into this. I don't
>> think this is intended
>
> Yes, it is.
So this new behavior is intended? Because this clashes with your
statement above that there is no change in behavior for avutil users.
>
>
>> or that the new system makes sense.
>
> Do you think it would make more sense to negate the flag semantic?
Yes.
- Andreas
_______________________________________________
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v7 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES
2025-04-09 8:11 ` Andreas Rheinhardt
@ 2025-04-09 8:24 ` softworkz .
2025-04-09 8:27 ` Andreas Rheinhardt
0 siblings, 1 reply; 92+ messages in thread
From: softworkz . @ 2025-04-09 8:24 UTC (permalink / raw)
To: FFmpeg development discussions and patches
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Andreas Rheinhardt
> Sent: Mittwoch, 9. April 2025 10:12
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH v7 1/3] avutil/log: Add log flag
> AV_LOG_PRINT_MEMADDRESSES
>
> softworkz .:
> >
> >
> >> -----Original Message-----
> >> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> >> softworkz .
> >> Sent: Mittwoch, 9. April 2025 09:51
> >> To: FFmpeg development discussions and patches <ffmpeg-
> devel@ffmpeg.org>
> >> Subject: Re: [FFmpeg-devel] [PATCH v7 1/3] avutil/log: Add log flag
> >> AV_LOG_PRINT_MEMADDRESSES
> >>
> >>
> >>
> >>> -----Original Message-----
> >>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> >>> Andreas Rheinhardt
> >>> Sent: Mittwoch, 9. April 2025 09:28
> >>> To: ffmpeg-devel@ffmpeg.org
> >>> Subject: Re: [FFmpeg-devel] [PATCH v7 1/3] avutil/log: Add log flag
> >>> AV_LOG_PRINT_MEMADDRESSES
> >>>
> >>> softworkz:
> >>>> From: softworkz <softworkz@hotmail.com>
> >>>>
> >>>> 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.
> >>>
> >>> The implementation of this flag is counter to the usual one: It is
> >>> enabled by default, but every av_log_set_flags() that does not set
> >>> AV_LOG_PRINT_MEMADDRESSES implicitly disables printing memory
> >> addresses.
> >>
> >> Hi Andreas,
> >>
> >> thanks for looking at the patchset.
> >
> > [..]
> >
> >>> AV_LOG_PRINT_MEMADDRESS seems better given that every av_log() will
> >>> likely only print one memaddress.
> >>
> >> It can be more than a single address per log line since it also
> prints
> >> the parent's memory address in case it specifies
> >> parent_log_context_offset.
>
> I know. That's why my statement contained a "likely".
Sorry, of course you know. My bad.
> https://github.com/ffstaging/FFmpeg/blob/02eda84bf2fcf0db7793872204b0f56
> >> 4a6557232/libavutil/log.c#L329-L337
> >
> > But the reason - from my thinking - why I made it plural is because
> it's a global flag that controls whether all memory addresses ( <- pl.)
> should be printed or not. If it was a flag that is conveyed as part of a
> log invocation (like av_log), controlling whether the memory address
> should be printed for that single log line, then I'd think it should be
> singular - probably even despite the nit regarding the parent address.
> >
> > Does it make sense? 😊
> >
>
> I get your thinking, but it is not consistent with the other flags:
> There is no AV_LOG_PRINT_TIMES after all.
Okay, singular it will be!
> > Do you think it would make more sense to negate the flag semantic?
>
> Yes.
Fine, let's do it that way round. To be clear, you only mean to negate the internal logic of that flag, i.e. making it AV_LOG_NO_PRINT_MEMADDRESS internally, but for the fftools CLI, it will still be:
./ffmpeg -v memaddress
to enable it, right?
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v7 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES
2025-04-09 8:24 ` softworkz .
@ 2025-04-09 8:27 ` Andreas Rheinhardt
2025-04-09 9:56 ` softworkz .
0 siblings, 1 reply; 92+ messages in thread
From: Andreas Rheinhardt @ 2025-04-09 8:27 UTC (permalink / raw)
To: ffmpeg-devel
softworkz .:
>
>
>> -----Original Message-----
>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
>> Andreas Rheinhardt
>> Sent: Mittwoch, 9. April 2025 10:12
>> To: ffmpeg-devel@ffmpeg.org
>> Subject: Re: [FFmpeg-devel] [PATCH v7 1/3] avutil/log: Add log flag
>> AV_LOG_PRINT_MEMADDRESSES
>>
>> softworkz .:
>>>
>>>
>>>> -----Original Message-----
>>>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
>>>> softworkz .
>>>> Sent: Mittwoch, 9. April 2025 09:51
>>>> To: FFmpeg development discussions and patches <ffmpeg-
>> devel@ffmpeg.org>
>>>> Subject: Re: [FFmpeg-devel] [PATCH v7 1/3] avutil/log: Add log flag
>>>> AV_LOG_PRINT_MEMADDRESSES
>>>>
>>>>
>>>>
>>>>> -----Original Message-----
>>>>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
>>>>> Andreas Rheinhardt
>>>>> Sent: Mittwoch, 9. April 2025 09:28
>>>>> To: ffmpeg-devel@ffmpeg.org
>>>>> Subject: Re: [FFmpeg-devel] [PATCH v7 1/3] avutil/log: Add log flag
>>>>> AV_LOG_PRINT_MEMADDRESSES
>>>>>
>>>>> softworkz:
>>>>>> From: softworkz <softworkz@hotmail.com>
>>>>>>
>>>>>> 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.
>>>>>
>>>>> The implementation of this flag is counter to the usual one: It is
>>>>> enabled by default, but every av_log_set_flags() that does not set
>>>>> AV_LOG_PRINT_MEMADDRESSES implicitly disables printing memory
>>>> addresses.
>>>>
>>>> Hi Andreas,
>>>>
>>>> thanks for looking at the patchset.
>>>
>>> [..]
>>>
>>>>> AV_LOG_PRINT_MEMADDRESS seems better given that every av_log() will
>>>>> likely only print one memaddress.
>>>>
>>>> It can be more than a single address per log line since it also
>> prints
>>>> the parent's memory address in case it specifies
>>>> parent_log_context_offset.
>>
>> I know. That's why my statement contained a "likely".
>
> Sorry, of course you know. My bad.
>
>
>> https://github.com/ffstaging/FFmpeg/blob/02eda84bf2fcf0db7793872204b0f56
>>>> 4a6557232/libavutil/log.c#L329-L337
>>>
>>> But the reason - from my thinking - why I made it plural is because
>> it's a global flag that controls whether all memory addresses ( <- pl.)
>> should be printed or not. If it was a flag that is conveyed as part of a
>> log invocation (like av_log), controlling whether the memory address
>> should be printed for that single log line, then I'd think it should be
>> singular - probably even despite the nit regarding the parent address.
>>>
>>> Does it make sense? 😊
>>>
>>
>> I get your thinking, but it is not consistent with the other flags:
>> There is no AV_LOG_PRINT_TIMES after all.
>
> Okay, singular it will be!
>
>
>>> Do you think it would make more sense to negate the flag semantic?
>>
>> Yes.
>
> Fine, let's do it that way round. To be clear, you only mean to negate the internal logic of that flag, i.e. making it AV_LOG_NO_PRINT_MEMADDRESS internally,
The flag is public, not internal.
but for the fftools CLI, it will still be:
>
> ./ffmpeg -v memaddress
>
> to enable it, right?
Given that the default for the fftools is different from the default for
lavu, it makes sense to handle it differently.
- Andreas
_______________________________________________
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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v8 0/3] avutil/log: Add log flag to control printing of memory addresses
2025-04-09 5:54 ` [FFmpeg-devel] [PATCH v7 0/3] avutil/log: Add log flag to control printing of memory addresses ffmpegagent
` (2 preceding siblings ...)
2025-04-09 5:55 ` [FFmpeg-devel] [PATCH v7 3/3] doc/fftools-common-opts: document " softworkz
@ 2025-04-09 9:25 ` ffmpegagent
2025-04-09 9:25 ` [FFmpeg-devel] [PATCH v8 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES softworkz
` (3 more replies)
3 siblings, 4 replies; 92+ messages in thread
From: ffmpegagent @ 2025-04-09 9:25 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
--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
V8
==
* Negated flag logic
* Use singular naming
* Fix flag doc text (thanks, Andreas!)
softworkz (3):
avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES
fftools: add memaddress log flag and disable printing addresses by
default
doc/fftools-common-opts: document memaddress log flag
doc/APIchanges | 3 +++
doc/fftools-common-opts.texi | 2 ++
fftools/ffmpeg.c | 2 +-
fftools/ffplay.c | 2 +-
fftools/ffprobe.c | 2 +-
fftools/opt_common.c | 6 ++++++
libavutil/log.c | 6 ++++--
libavutil/log.h | 5 +++++
libavutil/version.h | 2 +-
9 files changed, 24 insertions(+), 6 deletions(-)
base-commit: 02eda84bf2fcf0db7793872204b0f564a6557232
Published-As: https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-59%2Fsoftworkz%2Fsubmit_logaddresses-v8
Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg pr-ffstaging-59/softworkz/submit_logaddresses-v8
Pull-Request: https://github.com/ffstaging/FFmpeg/pull/59
Range-diff vs v7:
1: 6c2d6f1e97 ! 1: 0ce5bd11d7 avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES
@@ Commit message
avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES
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.
+ printed without the memory address, otherwise it is included.
Signed-off-by: softworkz <softworkz@hotmail.com>
@@ doc/APIchanges
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
++ Add flag AV_LOG_NO_PRINT_MEMADDRESS
+
API changes, most recent first:
2025-04-07 - 19e9a203b7 - lavu 60.01.100 - dict.h
## libavutil/log.c ##
-@@ libavutil/log.c: static AVMutex mutex = AV_MUTEX_INITIALIZER;
- #endif
-
- static int av_log_level = AV_LOG_INFO;
--static int flags;
-+static int flags = AV_LOG_PRINT_MEMADDRESSES;
-
- #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] ";
++ const char *p_fmt = flags & AV_LOG_NO_PRINT_MEMADDRESS ? "[%s] " : "[%s @ %p] ";
+
if (avc->parent_log_context_offset) {
AVClass** parent = *(AVClass ***) (((uint8_t *) avcl) +
@@ libavutil/log.h: int av_log_format_line2(void *ptr, int level, const char *fmt,
#define AV_LOG_PRINT_DATETIME 8
+/**
-+ * Print memory addresses instead of logical ids in the AVClass prefix.
++ * Do not print memory addresses of context instances.
+ */
-+#define AV_LOG_PRINT_MEMADDRESSES 16
++#define AV_LOG_NO_PRINT_MEMADDRESS 16
+
void av_log_set_flags(int arg);
int av_log_get_flags(void);
2: 7c4cfd5f67 ! 2: 527cf5fa56 fftools/opt_common: add memaddresses log flag
@@ Metadata
Author: softworkz <softworkz@hotmail.com>
## Commit message ##
- fftools/opt_common: add memaddresses log flag
+ fftools: add memaddress log flag and disable printing addresses by default
- This commit adds the memaddresses log flag.
+ This commit adds the memaddress log flag.
When specifying this flag at the command line, context prefixes will
be printed with memory addresses like in earlier ffmpeg versions.
@@ Commit message
Signed-off-by: softworkz <softworkz@hotmail.com>
+ ## fftools/ffmpeg.c ##
+@@ fftools/ffmpeg.c: int main(int argc, char **argv)
+
+ setvbuf(stderr,NULL,_IONBF,0); /* win32 runtime needs this */
+
+- av_log_set_flags(AV_LOG_SKIP_REPEATED);
++ av_log_set_flags(AV_LOG_SKIP_REPEATED | AV_LOG_NO_PRINT_MEMADDRESS);
+ parse_loglevel(argc, argv, options);
+
+ #if CONFIG_AVDEVICE
+
+ ## fftools/ffplay.c ##
+@@ fftools/ffplay.c: int main(int argc, char **argv)
+
+ init_dynload();
+
+- av_log_set_flags(AV_LOG_SKIP_REPEATED);
++ av_log_set_flags(AV_LOG_SKIP_REPEATED | AV_LOG_NO_PRINT_MEMADDRESS);
+ parse_loglevel(argc, argv, options);
+
+ /* register all codecs, demux and protocols */
+
+ ## fftools/ffprobe.c ##
+@@ fftools/ffprobe.c: int main(int argc, char **argv)
+
+ init_dynload();
+
+- av_log_set_flags(AV_LOG_SKIP_REPEATED);
++ av_log_set_flags(AV_LOG_SKIP_REPEATED | AV_LOG_NO_PRINT_MEMADDRESS);
+
+ options = real_options;
+ parse_loglevel(argc, argv, options);
+
## fftools/opt_common.c ##
-@@ fftools/opt_common.c: int opt_loglevel(void *optctx, const char *opt, const char *arg)
- int level = av_log_get_level();
- int cmd, i = 0;
-
-+ // libavutil has this enabled by default, fftools sets this off by default
-+ flags &= ~AV_LOG_PRINT_MEMADDRESSES;
-+
- av_assert0(arg);
- while (*arg) {
- token = arg;
@@ fftools/opt_common.c: int opt_loglevel(void *optctx, const char *opt, const char *arg)
} else {
flags |= AV_LOG_PRINT_DATETIME;
}
-+ } else if (av_strstart(token, "memaddresses", &arg)) {
++ } else if (av_strstart(token, "memaddress", &arg)) {
+ if (cmd == '-') {
-+ flags &= ~AV_LOG_PRINT_MEMADDRESSES;
++ flags |= AV_LOG_NO_PRINT_MEMADDRESS;
+ } else {
-+ flags |= AV_LOG_PRINT_MEMADDRESSES;
++ flags &= ~AV_LOG_NO_PRINT_MEMADDRESS;
+ }
} else {
break;
}
-@@ fftools/opt_common.c: int opt_loglevel(void *optctx, const char *opt, const char *arg)
- arg++;
- } else if (!i) {
- flags = av_log_get_flags(); /* level value without prefix, reset flags */
-+ flags &= ~AV_LOG_PRINT_MEMADDRESSES;
- }
-
- for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++) {
3: 6d3f305d0f ! 3: 22c51897c1 doc/fftools-common-opts: document memaddresses log flag
@@ Metadata
Author: softworkz <softworkz@hotmail.com>
## Commit message ##
- doc/fftools-common-opts: document memaddresses log flag
+ doc/fftools-common-opts: document memaddress log flag
Signed-off-by: softworkz <softworkz@hotmail.com>
@@ doc/fftools-common-opts.texi: 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.
++@item memaddress
++Indicates that context prefixes should be printed with memory address.
@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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v8 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES
2025-04-09 9:25 ` [FFmpeg-devel] [PATCH v8 0/3] avutil/log: Add log flag to control printing of memory addresses ffmpegagent
@ 2025-04-09 9:25 ` softworkz
2025-04-09 9:25 ` [FFmpeg-devel] [PATCH v8 2/3] fftools: add memaddress log flag and disable printing addresses by default softworkz
` (2 subsequent siblings)
3 siblings, 0 replies; 92+ messages in thread
From: softworkz @ 2025-04-09 9:25 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
From: softworkz <softworkz@hotmail.com>
which is controls prefix formatting. With this flag set, the prefix is
printed without the memory address, otherwise it is included.
Signed-off-by: softworkz <softworkz@hotmail.com>
---
doc/APIchanges | 3 +++
libavutil/log.c | 6 ++++--
libavutil/log.h | 5 +++++
libavutil/version.h | 2 +-
4 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index 65bf5a9419..db832f8b19 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -1,5 +1,8 @@
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_NO_PRINT_MEMADDRESS
+
API changes, most recent first:
2025-04-07 - 19e9a203b7 - lavu 60.01.100 - dict.h
diff --git a/libavutil/log.c b/libavutil/log.c
index c5ee876a88..1949a797e7 100644
--- a/libavutil/log.c
+++ b/libavutil/log.c
@@ -327,16 +327,18 @@ 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_NO_PRINT_MEMADDRESS ? "[%s] " : "[%s @ %p] ";
+
if (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] ",
+ av_bprintf(part+0, p_fmt,
item_name(parent, *parent), parent);
if(type) type[0] = get_category(parent);
}
}
- av_bprintf(part+1, "[%s @ %p] ",
+ av_bprintf(part+1, p_fmt,
item_name(avcl, avc), avcl);
if(type) type[1] = get_category(avcl);
}
diff --git a/libavutil/log.h b/libavutil/log.h
index dd094307ce..499c5d71ab 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
+/**
+ * Do not print memory addresses of context instances.
+ */
+#define AV_LOG_NO_PRINT_MEMADDRESS 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 5139883569..4717cd562b 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
*/
#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, \
--
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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v8 2/3] fftools: add memaddress log flag and disable printing addresses by default
2025-04-09 9:25 ` [FFmpeg-devel] [PATCH v8 0/3] avutil/log: Add log flag to control printing of memory addresses ffmpegagent
2025-04-09 9:25 ` [FFmpeg-devel] [PATCH v8 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES softworkz
@ 2025-04-09 9:25 ` softworkz
2025-04-09 14:28 ` Gyan Doshi
2025-04-09 9:25 ` [FFmpeg-devel] [PATCH v8 3/3] doc/fftools-common-opts: document memaddress log flag softworkz
2025-04-09 18:19 ` [FFmpeg-devel] [PATCH v9 0/3] avutil/log: Add log flag to control printing of memory addresses ffmpegagent
3 siblings, 1 reply; 92+ messages in thread
From: softworkz @ 2025-04-09 9:25 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
From: softworkz <softworkz@hotmail.com>
This commit adds the memaddress 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] .....
Signed-off-by: softworkz <softworkz@hotmail.com>
---
fftools/ffmpeg.c | 2 +-
fftools/ffplay.c | 2 +-
fftools/ffprobe.c | 2 +-
fftools/opt_common.c | 6 ++++++
4 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index dc321fb4a2..72887d6c5e 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -954,7 +954,7 @@ int main(int argc, char **argv)
setvbuf(stderr,NULL,_IONBF,0); /* win32 runtime needs this */
- av_log_set_flags(AV_LOG_SKIP_REPEATED);
+ av_log_set_flags(AV_LOG_SKIP_REPEATED | AV_LOG_NO_PRINT_MEMADDRESS);
parse_loglevel(argc, argv, options);
#if CONFIG_AVDEVICE
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 2a572fc3aa..9bd1fc2f22 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -3761,7 +3761,7 @@ int main(int argc, char **argv)
init_dynload();
- av_log_set_flags(AV_LOG_SKIP_REPEATED);
+ av_log_set_flags(AV_LOG_SKIP_REPEATED | AV_LOG_NO_PRINT_MEMADDRESS);
parse_loglevel(argc, argv, options);
/* register all codecs, demux and protocols */
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index abbd1dcf36..106435b827 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -4672,7 +4672,7 @@ int main(int argc, char **argv)
init_dynload();
- av_log_set_flags(AV_LOG_SKIP_REPEATED);
+ av_log_set_flags(AV_LOG_SKIP_REPEATED | AV_LOG_NO_PRINT_MEMADDRESS);
options = real_options;
parse_loglevel(argc, argv, options);
diff --git a/fftools/opt_common.c b/fftools/opt_common.c
index 2ac3fd4fb3..73a591acd8 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, "memaddress", &arg)) {
+ if (cmd == '-') {
+ flags |= AV_LOG_NO_PRINT_MEMADDRESS;
+ } else {
+ flags &= ~AV_LOG_NO_PRINT_MEMADDRESS;
+ }
} 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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v8 3/3] doc/fftools-common-opts: document memaddress log flag
2025-04-09 9:25 ` [FFmpeg-devel] [PATCH v8 0/3] avutil/log: Add log flag to control printing of memory addresses ffmpegagent
2025-04-09 9:25 ` [FFmpeg-devel] [PATCH v8 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES softworkz
2025-04-09 9:25 ` [FFmpeg-devel] [PATCH v8 2/3] fftools: add memaddress log flag and disable printing addresses by default softworkz
@ 2025-04-09 9:25 ` softworkz
2025-04-09 18:19 ` [FFmpeg-devel] [PATCH v9 0/3] avutil/log: Add log flag to control printing of memory addresses ffmpegagent
3 siblings, 0 replies; 92+ messages in thread
From: softworkz @ 2025-04-09 9:25 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
From: softworkz <softworkz@hotmail.com>
Signed-off-by: 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..15a54fdbb6 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 memaddress
+Indicates that context prefixes should be printed with memory address.
@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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v7 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES
2025-04-09 8:27 ` Andreas Rheinhardt
@ 2025-04-09 9:56 ` softworkz .
0 siblings, 0 replies; 92+ messages in thread
From: softworkz . @ 2025-04-09 9:56 UTC (permalink / raw)
To: FFmpeg development discussions and patches
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Andreas Rheinhardt
> Sent: Mittwoch, 9. April 2025 10:28
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH v7 1/3] avutil/log: Add log flag
> AV_LOG_PRINT_MEMADDRESSES
>
> softworkz .:
> >
> >
> >> -----Original Message-----
> >> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> >> Andreas Rheinhardt
> >> Sent: Mittwoch, 9. April 2025 10:12
> >> To: ffmpeg-devel@ffmpeg.org
> >> Subject: Re: [FFmpeg-devel] [PATCH v7 1/3] avutil/log: Add log flag
> >> AV_LOG_PRINT_MEMADDRESSES
> >>
> >> softworkz .:
> >>>
> >>>
> >>>> -----Original Message-----
> >>>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> >>>> softworkz .
> >>>> Sent: Mittwoch, 9. April 2025 09:51
> >>>> To: FFmpeg development discussions and patches <ffmpeg-
> >> devel@ffmpeg.org>
> >>>> Subject: Re: [FFmpeg-devel] [PATCH v7 1/3] avutil/log: Add log flag
> >>>> AV_LOG_PRINT_MEMADDRESSES
> >>>>
> >>>>
> >>>>
> >>>>> -----Original Message-----
> >>>>> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> >>>>> Andreas Rheinhardt
> >>>>> Sent: Mittwoch, 9. April 2025 09:28
> >>>>> To: ffmpeg-devel@ffmpeg.org
> >>>>> Subject: Re: [FFmpeg-devel] [PATCH v7 1/3] avutil/log: Add log
> flag
> >>>>> AV_LOG_PRINT_MEMADDRESSES
> >>>>>
> >>>>> softworkz:
> >>>>>> From: softworkz <softworkz@hotmail.com>
> >>>>>>
> >>>>>> 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.
> >>>>>
> >>>>> The implementation of this flag is counter to the usual one: It is
> >>>>> enabled by default, but every av_log_set_flags() that does not set
> >>>>> AV_LOG_PRINT_MEMADDRESSES implicitly disables printing memory
> >>>> addresses.
> >>>>
> >>>> Hi Andreas,
> >>>>
> >>>> thanks for looking at the patchset.
> >>>
> >>> [..]
> >>>
> >>>>> AV_LOG_PRINT_MEMADDRESS seems better given that every av_log()
> will
> >>>>> likely only print one memaddress.
> >>>>
> >>>> It can be more than a single address per log line since it also
> >> prints
> >>>> the parent's memory address in case it specifies
> >>>> parent_log_context_offset.
> >>
> >> I know. That's why my statement contained a "likely".
> >
> > Sorry, of course you know. My bad.
> >
> >
> >>
> https://github.com/ffstaging/FFmpeg/blob/02eda84bf2fcf0db7793872204b0f56
> >>>> 4a6557232/libavutil/log.c#L329-L337
> >>>
> >>> But the reason - from my thinking - why I made it plural is because
> >> it's a global flag that controls whether all memory addresses ( <-
> pl.)
> >> should be printed or not. If it was a flag that is conveyed as part
> of a
> >> log invocation (like av_log), controlling whether the memory address
> >> should be printed for that single log line, then I'd think it should
> be
> >> singular - probably even despite the nit regarding the parent
> address.
> >>>
> >>> Does it make sense? 😊
> >>>
> >>
> >> I get your thinking, but it is not consistent with the other flags:
> >> There is no AV_LOG_PRINT_TIMES after all.
> >
> > Okay, singular it will be!
> >
> >
> >>> Do you think it would make more sense to negate the flag semantic?
> >>
> >> Yes.
> >
> > Fine, let's do it that way round. To be clear, you only mean to negate
> the internal logic of that flag, i.e. making it
> AV_LOG_NO_PRINT_MEMADDRESS internally,
>
> The flag is public, not internal.
Hi Andreas,
I meant "internal" from the pov of a cli user, but public API of course, yea.
> but for the fftools CLI, it will still be:
> >
> > ./ffmpeg -v memaddress
> >
> > to enable it, right?
>
> Given that the default for the fftools is different from the default for
> lavu, it makes sense to handle it differently.
I've just pushed v8, I hope that's how you meant it to be like?
I also realized a flaw in the previous version in a way that the flag got lost when log params are specified multiple times (e.g. ./ffmpeg -v -memaddress -v verbose ...), but that doesn't happen anymore now.
Thanks again,
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v8 2/3] fftools: add memaddress log flag and disable printing addresses by default
2025-04-09 9:25 ` [FFmpeg-devel] [PATCH v8 2/3] fftools: add memaddress log flag and disable printing addresses by default softworkz
@ 2025-04-09 14:28 ` Gyan Doshi
2025-04-09 14:41 ` softworkz .
0 siblings, 1 reply; 92+ messages in thread
From: Gyan Doshi @ 2025-04-09 14:28 UTC (permalink / raw)
To: ffmpeg-devel
On 2025-04-09 02:55 pm, softworkz wrote:
> From: softworkz <softworkz@hotmail.com>
>
> This commit adds the memaddress 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] .....
>
> Signed-off-by: softworkz <softworkz@hotmail.com>
> ---
> fftools/ffmpeg.c | 2 +-
> fftools/ffplay.c | 2 +-
> fftools/ffprobe.c | 2 +-
> fftools/opt_common.c | 6 ++++++
> 4 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> index dc321fb4a2..72887d6c5e 100644
> --- a/fftools/ffmpeg.c
> +++ b/fftools/ffmpeg.c
> @@ -954,7 +954,7 @@ int main(int argc, char **argv)
>
> setvbuf(stderr,NULL,_IONBF,0); /* win32 runtime needs this */
>
> - av_log_set_flags(AV_LOG_SKIP_REPEATED);
> + av_log_set_flags(AV_LOG_SKIP_REPEATED | AV_LOG_NO_PRINT_MEMADDRESS);
> parse_loglevel(argc, argv, options);
>
> #if CONFIG_AVDEVICE
> diff --git a/fftools/ffplay.c b/fftools/ffplay.c
> index 2a572fc3aa..9bd1fc2f22 100644
> --- a/fftools/ffplay.c
> +++ b/fftools/ffplay.c
> @@ -3761,7 +3761,7 @@ int main(int argc, char **argv)
>
> init_dynload();
>
> - av_log_set_flags(AV_LOG_SKIP_REPEATED);
> + av_log_set_flags(AV_LOG_SKIP_REPEATED | AV_LOG_NO_PRINT_MEMADDRESS);
> parse_loglevel(argc, argv, options);
>
> /* register all codecs, demux and protocols */
> diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
> index abbd1dcf36..106435b827 100644
> --- a/fftools/ffprobe.c
> +++ b/fftools/ffprobe.c
> @@ -4672,7 +4672,7 @@ int main(int argc, char **argv)
>
> init_dynload();
>
> - av_log_set_flags(AV_LOG_SKIP_REPEATED);
> + av_log_set_flags(AV_LOG_SKIP_REPEATED | AV_LOG_NO_PRINT_MEMADDRESS);
>
> options = real_options;
> parse_loglevel(argc, argv, options);
> diff --git a/fftools/opt_common.c b/fftools/opt_common.c
> index 2ac3fd4fb3..73a591acd8 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, "memaddress", &arg)) {
Too verbose a label. How about just 'mem'?
Regards,
Gyan
> + if (cmd == '-') {
> + flags |= AV_LOG_NO_PRINT_MEMADDRESS;
> + } else {
> + flags &= ~AV_LOG_NO_PRINT_MEMADDRESS;
> + }
> } else {
> break;
> }
_______________________________________________
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v8 2/3] fftools: add memaddress log flag and disable printing addresses by default
2025-04-09 14:28 ` Gyan Doshi
@ 2025-04-09 14:41 ` softworkz .
0 siblings, 0 replies; 92+ messages in thread
From: softworkz . @ 2025-04-09 14:41 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, 9. April 2025 16:28
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH v8 2/3] fftools: add memaddress log
> flag and disable printing addresses by default
>
>
>
> On 2025-04-09 02:55 pm, softworkz wrote:
> > From: softworkz <softworkz@hotmail.com>
> >
> > This commit adds the memaddress 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] .....
> >
> > Signed-off-by: softworkz <softworkz@hotmail.com>
> > ---
> > fftools/ffmpeg.c | 2 +-
> > fftools/ffplay.c | 2 +-
> > fftools/ffprobe.c | 2 +-
> > fftools/opt_common.c | 6 ++++++
> > 4 files changed, 9 insertions(+), 3 deletions(-)
> >
> > diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> > index dc321fb4a2..72887d6c5e 100644
> > --- a/fftools/ffmpeg.c
> > +++ b/fftools/ffmpeg.c
> > @@ -954,7 +954,7 @@ int main(int argc, char **argv)
> >
> > setvbuf(stderr,NULL,_IONBF,0); /* win32 runtime needs this */
> >
> > - av_log_set_flags(AV_LOG_SKIP_REPEATED);
> > + av_log_set_flags(AV_LOG_SKIP_REPEATED |
> AV_LOG_NO_PRINT_MEMADDRESS);
> > parse_loglevel(argc, argv, options);
> >
> > #if CONFIG_AVDEVICE
> > diff --git a/fftools/ffplay.c b/fftools/ffplay.c
> > index 2a572fc3aa..9bd1fc2f22 100644
> > --- a/fftools/ffplay.c
> > +++ b/fftools/ffplay.c
> > @@ -3761,7 +3761,7 @@ int main(int argc, char **argv)
> >
> > init_dynload();
> >
> > - av_log_set_flags(AV_LOG_SKIP_REPEATED);
> > + av_log_set_flags(AV_LOG_SKIP_REPEATED |
> AV_LOG_NO_PRINT_MEMADDRESS);
> > parse_loglevel(argc, argv, options);
> >
> > /* register all codecs, demux and protocols */
> > diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
> > index abbd1dcf36..106435b827 100644
> > --- a/fftools/ffprobe.c
> > +++ b/fftools/ffprobe.c
> > @@ -4672,7 +4672,7 @@ int main(int argc, char **argv)
> >
> > init_dynload();
> >
> > - av_log_set_flags(AV_LOG_SKIP_REPEATED);
> > + av_log_set_flags(AV_LOG_SKIP_REPEATED |
> AV_LOG_NO_PRINT_MEMADDRESS);
> >
> > options = real_options;
> > parse_loglevel(argc, argv, options);
> > diff --git a/fftools/opt_common.c b/fftools/opt_common.c
> > index 2ac3fd4fb3..73a591acd8 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, "memaddress", &arg)) {
>
> Too verbose a label. How about just 'mem'?
>
> Regards,
> Gyan
Hi Gyan,
I'm fine with that, will update!
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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v9 0/3] avutil/log: Add log flag to control printing of memory addresses
2025-04-09 9:25 ` [FFmpeg-devel] [PATCH v8 0/3] avutil/log: Add log flag to control printing of memory addresses ffmpegagent
` (2 preceding siblings ...)
2025-04-09 9:25 ` [FFmpeg-devel] [PATCH v8 3/3] doc/fftools-common-opts: document memaddress log flag softworkz
@ 2025-04-09 18:19 ` ffmpegagent
2025-04-09 18:19 ` [FFmpeg-devel] [PATCH v9 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES softworkz
` (3 more replies)
3 siblings, 4 replies; 92+ messages in thread
From: ffmpegagent @ 2025-04-09 18:19 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
--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
V8
==
* Negated flag logic
* Use singular naming
* Fix flag doc text (thanks, Andreas!)
V9
==
* Rename 'memaddress' to 'mem' for CLI (as suggested by Gyan)
softworkz (3):
avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES
fftools: add mem log flag and disable printing addresses by default
doc/fftools-common-opts: document mem log flag
doc/APIchanges | 3 +++
doc/fftools-common-opts.texi | 2 ++
fftools/ffmpeg.c | 2 +-
fftools/ffplay.c | 2 +-
fftools/ffprobe.c | 2 +-
fftools/opt_common.c | 6 ++++++
libavutil/log.c | 6 ++++--
libavutil/log.h | 5 +++++
libavutil/version.h | 2 +-
9 files changed, 24 insertions(+), 6 deletions(-)
base-commit: 02eda84bf2fcf0db7793872204b0f564a6557232
Published-As: https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-59%2Fsoftworkz%2Fsubmit_logaddresses-v9
Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg pr-ffstaging-59/softworkz/submit_logaddresses-v9
Pull-Request: https://github.com/ffstaging/FFmpeg/pull/59
Range-diff vs v8:
1: 0ce5bd11d7 = 1: 0ce5bd11d7 avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES
2: 527cf5fa56 ! 2: 0780dd080c fftools: add memaddress log flag and disable printing addresses by default
@@ Metadata
Author: softworkz <softworkz@hotmail.com>
## Commit message ##
- fftools: add memaddress log flag and disable printing addresses by default
+ fftools: add mem log flag and disable printing addresses by default
- This commit adds the memaddress log flag.
+ This commit adds the mem 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:
+ Example with mem flag:
[hevc @ 0000018e72a89cc0] .....
@@ fftools/opt_common.c: int opt_loglevel(void *optctx, const char *opt, const char
} else {
flags |= AV_LOG_PRINT_DATETIME;
}
-+ } else if (av_strstart(token, "memaddress", &arg)) {
++ } else if (av_strstart(token, "mem", &arg)) {
+ if (cmd == '-') {
+ flags |= AV_LOG_NO_PRINT_MEMADDRESS;
+ } else {
3: 22c51897c1 ! 3: bfe2e51860 doc/fftools-common-opts: document memaddress log flag
@@ Metadata
Author: softworkz <softworkz@hotmail.com>
## Commit message ##
- doc/fftools-common-opts: document memaddress log flag
+ doc/fftools-common-opts: document mem log flag
Signed-off-by: softworkz <softworkz@hotmail.com>
@@ doc/fftools-common-opts.texi: 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 memaddress
++@item mem
+Indicates that context prefixes should be printed with memory address.
@end table
Flags can also be used alone by adding a '+'/'-' prefix to set/reset a single
--
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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v9 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES
2025-04-09 18:19 ` [FFmpeg-devel] [PATCH v9 0/3] avutil/log: Add log flag to control printing of memory addresses ffmpegagent
@ 2025-04-09 18:19 ` softworkz
2025-04-09 18:19 ` [FFmpeg-devel] [PATCH v9 2/3] fftools: add mem log flag and disable printing addresses by default softworkz
` (2 subsequent siblings)
3 siblings, 0 replies; 92+ messages in thread
From: softworkz @ 2025-04-09 18:19 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
From: softworkz <softworkz@hotmail.com>
which is controls prefix formatting. With this flag set, the prefix is
printed without the memory address, otherwise it is included.
Signed-off-by: softworkz <softworkz@hotmail.com>
---
doc/APIchanges | 3 +++
libavutil/log.c | 6 ++++--
libavutil/log.h | 5 +++++
libavutil/version.h | 2 +-
4 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index 65bf5a9419..db832f8b19 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -1,5 +1,8 @@
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_NO_PRINT_MEMADDRESS
+
API changes, most recent first:
2025-04-07 - 19e9a203b7 - lavu 60.01.100 - dict.h
diff --git a/libavutil/log.c b/libavutil/log.c
index c5ee876a88..1949a797e7 100644
--- a/libavutil/log.c
+++ b/libavutil/log.c
@@ -327,16 +327,18 @@ 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_NO_PRINT_MEMADDRESS ? "[%s] " : "[%s @ %p] ";
+
if (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] ",
+ av_bprintf(part+0, p_fmt,
item_name(parent, *parent), parent);
if(type) type[0] = get_category(parent);
}
}
- av_bprintf(part+1, "[%s @ %p] ",
+ av_bprintf(part+1, p_fmt,
item_name(avcl, avc), avcl);
if(type) type[1] = get_category(avcl);
}
diff --git a/libavutil/log.h b/libavutil/log.h
index dd094307ce..499c5d71ab 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
+/**
+ * Do not print memory addresses of context instances.
+ */
+#define AV_LOG_NO_PRINT_MEMADDRESS 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 5139883569..4717cd562b 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
*/
#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, \
--
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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v9 2/3] fftools: add mem log flag and disable printing addresses by default
2025-04-09 18:19 ` [FFmpeg-devel] [PATCH v9 0/3] avutil/log: Add log flag to control printing of memory addresses ffmpegagent
2025-04-09 18:19 ` [FFmpeg-devel] [PATCH v9 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES softworkz
@ 2025-04-09 18:19 ` softworkz
2025-04-09 18:26 ` Gyan Doshi
2025-04-09 18:19 ` [FFmpeg-devel] [PATCH v9 3/3] doc/fftools-common-opts: document mem log flag softworkz
2025-04-10 0:38 ` [FFmpeg-devel] [PATCH v10 0/3] avutil/log: Add log flag to control printing of memory addresses ffmpegagent
3 siblings, 1 reply; 92+ messages in thread
From: softworkz @ 2025-04-09 18:19 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
From: softworkz <softworkz@hotmail.com>
This commit adds the mem 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 mem flag:
[hevc @ 0000018e72a89cc0] .....
without (new behavior):
[hevc] .....
Signed-off-by: softworkz <softworkz@hotmail.com>
---
fftools/ffmpeg.c | 2 +-
fftools/ffplay.c | 2 +-
fftools/ffprobe.c | 2 +-
fftools/opt_common.c | 6 ++++++
4 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index dc321fb4a2..72887d6c5e 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -954,7 +954,7 @@ int main(int argc, char **argv)
setvbuf(stderr,NULL,_IONBF,0); /* win32 runtime needs this */
- av_log_set_flags(AV_LOG_SKIP_REPEATED);
+ av_log_set_flags(AV_LOG_SKIP_REPEATED | AV_LOG_NO_PRINT_MEMADDRESS);
parse_loglevel(argc, argv, options);
#if CONFIG_AVDEVICE
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 2a572fc3aa..9bd1fc2f22 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -3761,7 +3761,7 @@ int main(int argc, char **argv)
init_dynload();
- av_log_set_flags(AV_LOG_SKIP_REPEATED);
+ av_log_set_flags(AV_LOG_SKIP_REPEATED | AV_LOG_NO_PRINT_MEMADDRESS);
parse_loglevel(argc, argv, options);
/* register all codecs, demux and protocols */
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index abbd1dcf36..106435b827 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -4672,7 +4672,7 @@ int main(int argc, char **argv)
init_dynload();
- av_log_set_flags(AV_LOG_SKIP_REPEATED);
+ av_log_set_flags(AV_LOG_SKIP_REPEATED | AV_LOG_NO_PRINT_MEMADDRESS);
options = real_options;
parse_loglevel(argc, argv, options);
diff --git a/fftools/opt_common.c b/fftools/opt_common.c
index 2ac3fd4fb3..edf2f49d0b 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, "mem", &arg)) {
+ if (cmd == '-') {
+ flags |= AV_LOG_NO_PRINT_MEMADDRESS;
+ } else {
+ flags &= ~AV_LOG_NO_PRINT_MEMADDRESS;
+ }
} 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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v9 3/3] doc/fftools-common-opts: document mem log flag
2025-04-09 18:19 ` [FFmpeg-devel] [PATCH v9 0/3] avutil/log: Add log flag to control printing of memory addresses ffmpegagent
2025-04-09 18:19 ` [FFmpeg-devel] [PATCH v9 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES softworkz
2025-04-09 18:19 ` [FFmpeg-devel] [PATCH v9 2/3] fftools: add mem log flag and disable printing addresses by default softworkz
@ 2025-04-09 18:19 ` softworkz
2025-04-10 0:38 ` [FFmpeg-devel] [PATCH v10 0/3] avutil/log: Add log flag to control printing of memory addresses ffmpegagent
3 siblings, 0 replies; 92+ messages in thread
From: softworkz @ 2025-04-09 18:19 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
From: softworkz <softworkz@hotmail.com>
Signed-off-by: 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..5d66af6b02 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 mem
+Indicates that context prefixes should be printed with memory address.
@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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v9 2/3] fftools: add mem log flag and disable printing addresses by default
2025-04-09 18:19 ` [FFmpeg-devel] [PATCH v9 2/3] fftools: add mem log flag and disable printing addresses by default softworkz
@ 2025-04-09 18:26 ` Gyan Doshi
2025-04-09 18:40 ` softworkz .
0 siblings, 1 reply; 92+ messages in thread
From: Gyan Doshi @ 2025-04-09 18:26 UTC (permalink / raw)
To: ffmpeg-devel
On 2025-04-09 11:49 pm, softworkz wrote:
> diff --git a/fftools/opt_common.c b/fftools/opt_common.c
> index 2ac3fd4fb3..edf2f49d0b 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, "mem", &arg)) {
> + if (cmd == '-') {
> + flags |= AV_LOG_NO_PRINT_MEMADDRESS;
> + } else {
> + flags &= ~AV_LOG_NO_PRINT_MEMADDRESS;
> + }
> } else {
> break;
> }
You also need to update the block just before the end jump.
Regards,
Gyan
_______________________________________________
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v9 2/3] fftools: add mem log flag and disable printing addresses by default
2025-04-09 18:26 ` Gyan Doshi
@ 2025-04-09 18:40 ` softworkz .
0 siblings, 0 replies; 92+ messages in thread
From: softworkz . @ 2025-04-09 18:40 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, 9. April 2025 20:27
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH v9 2/3] fftools: add mem log flag and
> disable printing addresses by default
>
>
>
> On 2025-04-09 11:49 pm, softworkz wrote:
> > diff --git a/fftools/opt_common.c b/fftools/opt_common.c
> > index 2ac3fd4fb3..edf2f49d0b 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, "mem", &arg)) {
> > + if (cmd == '-') {
> > + flags |= AV_LOG_NO_PRINT_MEMADDRESS;
> > + } else {
> > + flags &= ~AV_LOG_NO_PRINT_MEMADDRESS;
> > + }
> > } else {
> > break;
> > }
>
> You also need to update the block just before the end jump.
>
> Regards,
> Gyan
>
> _______________________________________________
Oh, that's embarrassing - 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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v10 0/3] avutil/log: Add log flag to control printing of memory addresses
2025-04-09 18:19 ` [FFmpeg-devel] [PATCH v9 0/3] avutil/log: Add log flag to control printing of memory addresses ffmpegagent
` (2 preceding siblings ...)
2025-04-09 18:19 ` [FFmpeg-devel] [PATCH v9 3/3] doc/fftools-common-opts: document mem log flag softworkz
@ 2025-04-10 0:38 ` ffmpegagent
2025-04-10 0:38 ` [FFmpeg-devel] [PATCH v10 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES softworkz
` (2 more replies)
3 siblings, 3 replies; 92+ messages in thread
From: ffmpegagent @ 2025-04-10 0:38 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
--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
V8
==
* Negated flag logic
* Use singular naming
* Fix flag doc text (thanks, Andreas!)
V9
==
* Rename 'memaddress' to 'mem' for CLI (as suggested by Gyan)
V10
===
* Print 'mem' flag in help outrput (thanks, Gyan)
softworkz (3):
avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES
fftools: add mem log flag and disable printing addresses by default
doc/fftools-common-opts: document mem log flag
doc/APIchanges | 3 +++
doc/fftools-common-opts.texi | 2 ++
fftools/ffmpeg.c | 2 +-
fftools/ffplay.c | 2 +-
fftools/ffprobe.c | 2 +-
fftools/opt_common.c | 7 +++++++
libavutil/log.c | 6 ++++--
libavutil/log.h | 5 +++++
libavutil/version.h | 2 +-
9 files changed, 25 insertions(+), 6 deletions(-)
base-commit: 02eda84bf2fcf0db7793872204b0f564a6557232
Published-As: https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-59%2Fsoftworkz%2Fsubmit_logaddresses-v10
Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg pr-ffstaging-59/softworkz/submit_logaddresses-v10
Pull-Request: https://github.com/ffstaging/FFmpeg/pull/59
Range-diff vs v9:
1: 0ce5bd11d7 = 1: 0ce5bd11d7 avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES
2: 0780dd080c ! 2: 207dedbff6 fftools: add mem log flag and disable printing addresses by default
@@ fftools/opt_common.c: int opt_loglevel(void *optctx, const char *opt, const char
} else {
break;
}
+@@ fftools/opt_common.c: int opt_loglevel(void *optctx, const char *opt, const char *arg)
+ av_log(NULL, AV_LOG_FATAL, "\"level\"\n");
+ av_log(NULL, AV_LOG_FATAL, "\"time\"\n");
+ av_log(NULL, AV_LOG_FATAL, "\"datetime\"\n");
++ av_log(NULL, AV_LOG_FATAL, "\"mem\"\n");
+ return AVERROR(EINVAL);
+ }
+
3: bfe2e51860 = 3: dc334f3eeb doc/fftools-common-opts: document mem 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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v10 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES
2025-04-10 0:38 ` [FFmpeg-devel] [PATCH v10 0/3] avutil/log: Add log flag to control printing of memory addresses ffmpegagent
@ 2025-04-10 0:38 ` softworkz
2025-04-10 7:38 ` Andreas Rheinhardt
2025-04-10 0:38 ` [FFmpeg-devel] [PATCH v10 2/3] fftools: add mem log flag and disable printing addresses by default softworkz
2025-04-10 0:38 ` [FFmpeg-devel] [PATCH v10 3/3] doc/fftools-common-opts: document mem log flag softworkz
2 siblings, 1 reply; 92+ messages in thread
From: softworkz @ 2025-04-10 0:38 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
From: softworkz <softworkz@hotmail.com>
which is controls prefix formatting. With this flag set, the prefix is
printed without the memory address, otherwise it is included.
Signed-off-by: softworkz <softworkz@hotmail.com>
---
doc/APIchanges | 3 +++
libavutil/log.c | 6 ++++--
libavutil/log.h | 5 +++++
libavutil/version.h | 2 +-
4 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index 65bf5a9419..db832f8b19 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -1,5 +1,8 @@
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_NO_PRINT_MEMADDRESS
+
API changes, most recent first:
2025-04-07 - 19e9a203b7 - lavu 60.01.100 - dict.h
diff --git a/libavutil/log.c b/libavutil/log.c
index c5ee876a88..1949a797e7 100644
--- a/libavutil/log.c
+++ b/libavutil/log.c
@@ -327,16 +327,18 @@ 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_NO_PRINT_MEMADDRESS ? "[%s] " : "[%s @ %p] ";
+
if (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] ",
+ av_bprintf(part+0, p_fmt,
item_name(parent, *parent), parent);
if(type) type[0] = get_category(parent);
}
}
- av_bprintf(part+1, "[%s @ %p] ",
+ av_bprintf(part+1, p_fmt,
item_name(avcl, avc), avcl);
if(type) type[1] = get_category(avcl);
}
diff --git a/libavutil/log.h b/libavutil/log.h
index dd094307ce..499c5d71ab 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
+/**
+ * Do not print memory addresses of context instances.
+ */
+#define AV_LOG_NO_PRINT_MEMADDRESS 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 5139883569..4717cd562b 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
*/
#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, \
--
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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v10 2/3] fftools: add mem log flag and disable printing addresses by default
2025-04-10 0:38 ` [FFmpeg-devel] [PATCH v10 0/3] avutil/log: Add log flag to control printing of memory addresses ffmpegagent
2025-04-10 0:38 ` [FFmpeg-devel] [PATCH v10 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES softworkz
@ 2025-04-10 0:38 ` softworkz
2025-04-10 6:51 ` Nicolas George
2025-04-10 0:38 ` [FFmpeg-devel] [PATCH v10 3/3] doc/fftools-common-opts: document mem log flag softworkz
2 siblings, 1 reply; 92+ messages in thread
From: softworkz @ 2025-04-10 0:38 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
From: softworkz <softworkz@hotmail.com>
This commit adds the mem 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 mem flag:
[hevc @ 0000018e72a89cc0] .....
without (new behavior):
[hevc] .....
Signed-off-by: softworkz <softworkz@hotmail.com>
---
fftools/ffmpeg.c | 2 +-
fftools/ffplay.c | 2 +-
fftools/ffprobe.c | 2 +-
fftools/opt_common.c | 7 +++++++
4 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index dc321fb4a2..72887d6c5e 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -954,7 +954,7 @@ int main(int argc, char **argv)
setvbuf(stderr,NULL,_IONBF,0); /* win32 runtime needs this */
- av_log_set_flags(AV_LOG_SKIP_REPEATED);
+ av_log_set_flags(AV_LOG_SKIP_REPEATED | AV_LOG_NO_PRINT_MEMADDRESS);
parse_loglevel(argc, argv, options);
#if CONFIG_AVDEVICE
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 2a572fc3aa..9bd1fc2f22 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -3761,7 +3761,7 @@ int main(int argc, char **argv)
init_dynload();
- av_log_set_flags(AV_LOG_SKIP_REPEATED);
+ av_log_set_flags(AV_LOG_SKIP_REPEATED | AV_LOG_NO_PRINT_MEMADDRESS);
parse_loglevel(argc, argv, options);
/* register all codecs, demux and protocols */
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index abbd1dcf36..106435b827 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -4672,7 +4672,7 @@ int main(int argc, char **argv)
init_dynload();
- av_log_set_flags(AV_LOG_SKIP_REPEATED);
+ av_log_set_flags(AV_LOG_SKIP_REPEATED | AV_LOG_NO_PRINT_MEMADDRESS);
options = real_options;
parse_loglevel(argc, argv, options);
diff --git a/fftools/opt_common.c b/fftools/opt_common.c
index 2ac3fd4fb3..570842b816 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, "mem", &arg)) {
+ if (cmd == '-') {
+ flags |= AV_LOG_NO_PRINT_MEMADDRESS;
+ } else {
+ flags &= ~AV_LOG_NO_PRINT_MEMADDRESS;
+ }
} else {
break;
}
@@ -1335,6 +1341,7 @@ int opt_loglevel(void *optctx, const char *opt, const char *arg)
av_log(NULL, AV_LOG_FATAL, "\"level\"\n");
av_log(NULL, AV_LOG_FATAL, "\"time\"\n");
av_log(NULL, AV_LOG_FATAL, "\"datetime\"\n");
+ av_log(NULL, AV_LOG_FATAL, "\"mem\"\n");
return AVERROR(EINVAL);
}
--
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] 92+ messages in thread
* [FFmpeg-devel] [PATCH v10 3/3] doc/fftools-common-opts: document mem log flag
2025-04-10 0:38 ` [FFmpeg-devel] [PATCH v10 0/3] avutil/log: Add log flag to control printing of memory addresses ffmpegagent
2025-04-10 0:38 ` [FFmpeg-devel] [PATCH v10 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES softworkz
2025-04-10 0:38 ` [FFmpeg-devel] [PATCH v10 2/3] fftools: add mem log flag and disable printing addresses by default softworkz
@ 2025-04-10 0:38 ` softworkz
2 siblings, 0 replies; 92+ messages in thread
From: softworkz @ 2025-04-10 0:38 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: softworkz
From: softworkz <softworkz@hotmail.com>
Signed-off-by: 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..5d66af6b02 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 mem
+Indicates that context prefixes should be printed with memory address.
@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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v10 2/3] fftools: add mem log flag and disable printing addresses by default
2025-04-10 0:38 ` [FFmpeg-devel] [PATCH v10 2/3] fftools: add mem log flag and disable printing addresses by default softworkz
@ 2025-04-10 6:51 ` Nicolas George
2025-04-10 18:02 ` softworkz .
2025-04-16 13:43 ` Michael Niedermayer
0 siblings, 2 replies; 92+ messages in thread
From: Nicolas George @ 2025-04-10 6:51 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: softworkz
softworkz (HE12025-04-10):
> From: softworkz <softworkz@hotmail.com>
>
> This commit adds the mem 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 mem flag:
>
> [hevc @ 0000018e72a89cc0] .....
As explained recently, strong opposition to this being the default.
--
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v10 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES
2025-04-10 0:38 ` [FFmpeg-devel] [PATCH v10 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES softworkz
@ 2025-04-10 7:38 ` Andreas Rheinhardt
2025-04-10 18:06 ` softworkz .
0 siblings, 1 reply; 92+ messages in thread
From: Andreas Rheinhardt @ 2025-04-10 7:38 UTC (permalink / raw)
To: ffmpeg-devel
softworkz:
> From: softworkz <softworkz@hotmail.com>
>
> which is controls prefix formatting. With this flag set, the prefix is
> printed without the memory address, otherwise it is included.
>
> Signed-off-by: softworkz <softworkz@hotmail.com>
> ---
> doc/APIchanges | 3 +++
> libavutil/log.c | 6 ++++--
> libavutil/log.h | 5 +++++
> libavutil/version.h | 2 +-
> 4 files changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 65bf5a9419..db832f8b19 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -1,5 +1,8 @@
> 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_NO_PRINT_MEMADDRESS
> +
> API changes, most recent first:
>
> 2025-04-07 - 19e9a203b7 - lavu 60.01.100 - dict.h
> diff --git a/libavutil/log.c b/libavutil/log.c
> index c5ee876a88..1949a797e7 100644
> --- a/libavutil/log.c
> +++ b/libavutil/log.c
> @@ -327,16 +327,18 @@ 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_NO_PRINT_MEMADDRESS ? "[%s] " : "[%s @ %p] ";
> +
> if (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] ",
> + av_bprintf(part+0, p_fmt,
> item_name(parent, *parent), parent);
> if(type) type[0] = get_category(parent);
> }
> }
> - av_bprintf(part+1, "[%s @ %p] ",
> + av_bprintf(part+1, p_fmt,
> item_name(avcl, avc), avcl);
> if(type) type[1] = get_category(avcl);
> }
> diff --git a/libavutil/log.h b/libavutil/log.h
> index dd094307ce..499c5d71ab 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
>
> +/**
> + * Do not print memory addresses of context instances.
> + */
> +#define AV_LOG_NO_PRINT_MEMADDRESS 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 5139883569..4717cd562b 100644
> --- a/libavutil/version.h
> +++ b/libavutil/version.h
> @@ -79,7 +79,7 @@
> */
>
> #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, \
The commit message needs an update.
- Andreas
_______________________________________________
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v10 2/3] fftools: add mem log flag and disable printing addresses by default
2025-04-10 6:51 ` Nicolas George
@ 2025-04-10 18:02 ` softworkz .
2025-04-16 13:43 ` Michael Niedermayer
1 sibling, 0 replies; 92+ messages in thread
From: softworkz . @ 2025-04-10 18:02 UTC (permalink / raw)
To: ffmpeg-devel
> -----Original Message-----
> From: Nicolas George <george@nsup.org>
> Sent: Donnerstag, 10. April 2025 08:51
> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
> Cc: softworkz <softworkz@hotmail.com>
> Subject: Re: [FFmpeg-devel] [PATCH v10 2/3] fftools: add mem log flag
> and disable printing addresses by default
>
> softworkz (HE12025-04-10):
> > From: softworkz <softworkz@hotmail.com>
> >
> > This commit adds the mem 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 mem flag:
> >
> > [hevc @ 0000018e72a89cc0] .....
>
> As explained recently, strong opposition to this being the default.
>
> --
> Nicolas George
Hi Nicolas,
other than your previous comments, questioning the default behavior is an acceptable concern.
I think in this case it makes sense to just put it up for a vote.
It's a significant change which should be backed by a majority opinion.
Best,
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v10 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES
2025-04-10 7:38 ` Andreas Rheinhardt
@ 2025-04-10 18:06 ` softworkz .
0 siblings, 0 replies; 92+ messages in thread
From: softworkz . @ 2025-04-10 18:06 UTC (permalink / raw)
To: FFmpeg development discussions and patches
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Andreas Rheinhardt
> Sent: Donnerstag, 10. April 2025 09:39
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH v10 1/3] avutil/log: Add log flag
> AV_LOG_PRINT_MEMADDRESSES
>
> softworkz:
> > From: softworkz <softworkz@hotmail.com>
> >
> > which is controls prefix formatting. With this flag set, the prefix is
> > printed without the memory address, otherwise it is included.
> >
> > Signed-off-by: softworkz <softworkz@hotmail.com>
> > ---
> > doc/APIchanges | 3 +++
> > libavutil/log.c | 6 ++++--
> > libavutil/log.h | 5 +++++
> > libavutil/version.h | 2 +-
> > 4 files changed, 13 insertions(+), 3 deletions(-)
> >
> > diff --git a/doc/APIchanges b/doc/APIchanges
> > index 65bf5a9419..db832f8b19 100644
> > --- a/doc/APIchanges
> > +++ b/doc/APIchanges
> > @@ -1,5 +1,8 @@
> > 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_NO_PRINT_MEMADDRESS
> > +
> > API changes, most recent first:
> >
> > 2025-04-07 - 19e9a203b7 - lavu 60.01.100 - dict.h
> > diff --git a/libavutil/log.c b/libavutil/log.c
> > index c5ee876a88..1949a797e7 100644
> > --- a/libavutil/log.c
> > +++ b/libavutil/log.c
> > @@ -327,16 +327,18 @@ 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_NO_PRINT_MEMADDRESS ?
> "[%s] " : "[%s @ %p] ";
> > +
> > if (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] ",
> > + av_bprintf(part+0, p_fmt,
> > item_name(parent, *parent), parent);
> > if(type) type[0] = get_category(parent);
> > }
> > }
> > - av_bprintf(part+1, "[%s @ %p] ",
> > + av_bprintf(part+1, p_fmt,
> > item_name(avcl, avc), avcl);
> > if(type) type[1] = get_category(avcl);
> > }
> > diff --git a/libavutil/log.h b/libavutil/log.h
> > index dd094307ce..499c5d71ab 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
> >
> > +/**
> > + * Do not print memory addresses of context instances.
> > + */
> > +#define AV_LOG_NO_PRINT_MEMADDRESS 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 5139883569..4717cd562b 100644
> > --- a/libavutil/version.h
> > +++ b/libavutil/version.h
> > @@ -79,7 +79,7 @@
> > */
> >
> > #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, \
>
> The commit message needs an update.
>
> - Andreas
>
> _______________________________________________
Thanks! Fixed locally.
_______________________________________________
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v10 2/3] fftools: add mem log flag and disable printing addresses by default
2025-04-10 6:51 ` Nicolas George
2025-04-10 18:02 ` softworkz .
@ 2025-04-16 13:43 ` Michael Niedermayer
2025-04-16 13:50 ` Nicolas George
2025-04-16 14:26 ` softworkz .
1 sibling, 2 replies; 92+ messages in thread
From: Michael Niedermayer @ 2025-04-16 13:43 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 1630 bytes --]
Hi
On Thu, Apr 10, 2025 at 08:51:04AM +0200, Nicolas George wrote:
> softworkz (HE12025-04-10):
> > From: softworkz <softworkz@hotmail.com>
> >
> > This commit adds the mem 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 mem flag:
> >
> > [hevc @ 0000018e72a89cc0] .....
>
> As explained recently, strong opposition to this being the default.
just some random comments:
I think some way to distingish two different "hevc" instances
with high probability should remain.
About the addresses. Iam curious how frequently do people use them ?
and for what exactly ?
I do think *item_name() should be used more often. The "hevc" is a
quite bland identifcation of the instance.
in absence of a item_name(), that is *av_default_item_name()
which prints just the class name. I think printing the address by default
is reasonable otherwsie instances would be always indistingishable
beyond that, i dont remember using the addresses and would not
mind if it gets replaced by something more usefull more repeatable
with maybe some mem flag that could force them to be printed in all
cases
but i dont know, really depends on what the community prefers
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Breaking DRM is a little like attempting to break through a door even
though the window is wide open and the only thing in the house is a bunch
of things you dont want and which you would get tomorrow for free anyway
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v10 2/3] fftools: add mem log flag and disable printing addresses by default
2025-04-16 13:43 ` Michael Niedermayer
@ 2025-04-16 13:50 ` Nicolas George
2025-04-16 14:25 ` Gyan Doshi
2025-04-16 14:26 ` softworkz .
1 sibling, 1 reply; 92+ messages in thread
From: Nicolas George @ 2025-04-16 13:50 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Michael Niedermayer (HE12025-04-16):
> I think some way to distingish two different "hevc" instances
> with high probability should remain.
This is exactly my point. The address is meaningless¹, but it is a sure
way to distinguish instances of the same components without tons of
fragile code.
1: In a debugger, the address would be available without printing.
> I do think *item_name() should be used more often.
Making sure it returns something different for different instances
without the code getting complex and/or the name getting long is quite a
challenge.
This fruit is neither low-hanging nor tasty. My position on this: leave
the address alone unless one has a very good idea to achieve the goal.
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v10 2/3] fftools: add mem log flag and disable printing addresses by default
2025-04-16 13:50 ` Nicolas George
@ 2025-04-16 14:25 ` Gyan Doshi
0 siblings, 0 replies; 92+ messages in thread
From: Gyan Doshi @ 2025-04-16 14:25 UTC (permalink / raw)
To: ffmpeg-devel
On 2025-04-16 07:20 pm, Nicolas George wrote:
> Michael Niedermayer (HE12025-04-16):
>> I think some way to distingish two different "hevc" instances
>> with high probability should remain.
> This is exactly my point. The address is meaningless¹, but it is a sure
> way to distinguish instances of the same components without tons of
> fragile code.
For CLI users, the fftool log prefixes already identify the input file
and the stream in many msgs, e.g.
e.g. [vist#0:0/h264 @ 000002485a204540] [dec:h264 @ 000002485a36e900]
Decoder thread received EOF packet
So, an opt-in flag should be added even if it's not made the default, or
no UUID replacement is found for the memaddr.
Regards,
Gyan
_______________________________________________
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] 92+ messages in thread
* Re: [FFmpeg-devel] [PATCH v10 2/3] fftools: add mem log flag and disable printing addresses by default
2025-04-16 13:43 ` Michael Niedermayer
2025-04-16 13:50 ` Nicolas George
@ 2025-04-16 14:26 ` softworkz .
1 sibling, 0 replies; 92+ messages in thread
From: softworkz . @ 2025-04-16 14:26 UTC (permalink / raw)
To: FFmpeg development discussions and patches
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Michael Niedermayer
> Sent: Mittwoch, 16. April 2025 15:43
> To: FFmpeg development discussions and patches <ffmpeg-
> devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH v10 2/3] fftools: add mem log flag
> and disable printing addresses by default
>
> Hi
>
> On Thu, Apr 10, 2025 at 08:51:04AM +0200, Nicolas George wrote:
> > softworkz (HE12025-04-10):
> > > From: softworkz <softworkz@hotmail.com>
> > >
> > > This commit adds the mem 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 mem flag:
> > >
> > > [hevc @ 0000018e72a89cc0] .....
> >
> > As explained recently, strong opposition to this being the default.
>
> just some random comments:
>
> I think some way to distingish two different "hevc" instances
> with high probability should remain.
>
> About the addresses. Iam curious how frequently do people use them ?
> and for what exactly ?
>
> I do think *item_name() should be used more often. The "hevc" is a
> quite bland identifcation of the instance.
>
> in absence of a item_name(), that is *av_default_item_name()
> which prints just the class name. I think printing the address by
> default
> is reasonable otherwsie instances would be always indistingishable
>
> beyond that, i dont remember using the addresses and would not
> mind if it gets replaced by something more usefull more repeatable
> with maybe some mem flag that could force them to be printed in all
> cases
>
> but i dont know, really depends on what the community prefers
Thanks Michael,
I'm gonna keep myself out of arguing, I believe that this is a decision
that should be based on what the community (majority) will prefer.
I just want to summarize the different implementations that are available
already while the patchset has walked its way through the various comments
that were made.
-----------------------------------------
1. Implementation in avutil with replacement Ids
The replacement Ids are a direct projection of the mem addresses, which
means that they are equally evident - yet subject to the same limitations
as the mem-addresses.
But other than the mem-addresses, this creates the identical log output
when repeating the same command.
Reviews:
- It has been criticized that this introduces global state which is
undesired in case of library use
- It has been suggested to implement this in fftools only, in a way that
fftools has its own and independent logging implementation, no longer
using the one in avutil. It was also based on the idea that this would
allow to do other things in the future which cannot reasonably be
implemented in avutil
This has led to the second variant:
-----------------------------------------
2. Implementation in fftools with replacement Ids
Replacement Id behavior is the same as in (1).
Obviously, there's no point in writing this from scratch, so the starting
point was the logging code from avutil
Reviews:
- This has raised criticism due to the copied logging code
- It was suggested to drop the replacement Ids and then it could be
implemented in avutil only
This has led to the third version:
-----------------------------------------
3. Implementation back in avutil without Ids
Means you switch the mem addresses on or off, when off, no Ids are printed
-----------------------------------------
Best regards,
softworkz
_______________________________________________
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] 92+ messages in thread
end of thread, other threads:[~2025-04-16 14:26 UTC | newest]
Thread overview: 92+ 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-07 9:44 ` Nicolas George
2025-03-07 17:23 ` Soft Works
2025-03-07 17:30 ` Hendrik Leppkes
2025-03-07 18:02 ` Soft Works
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
2025-03-08 23:02 ` [FFmpeg-devel] [PATCH v4 0/4] avutil/log: Replace addresses in log output with simple ids ffmpegagent
2025-03-08 23:02 ` [FFmpeg-devel] [PATCH v4 1/4] avutil/log: Add AV_LOG_PRINT_MEMADDRESSES logging flag softworkz
2025-03-08 23:02 ` [FFmpeg-devel] [PATCH v4 2/4] fftools/opt_common: add memaddresses log flag softworkz
2025-03-08 23:02 ` [FFmpeg-devel] [PATCH v4 3/4] fftools: Provide a an fftools-specific logging callback function softworkz
2025-03-09 17:52 ` Michael Niedermayer
2025-03-09 18:59 ` Soft Works
2025-03-08 23:02 ` [FFmpeg-devel] [PATCH v4 4/4] doc/fftools-common-opts: document memaddresses log flag softworkz
2025-03-09 19:01 ` [FFmpeg-devel] [PATCH v5 0/5] avutil/log: Replace addresses in log output with simple ids ffmpegagent
2025-03-09 19:01 ` [FFmpeg-devel] [PATCH v5 1/5] avutil/log: Add AV_LOG_PRINT_MEMADDRESSES logging flag softworkz
2025-03-09 19:05 ` Nicolas George
2025-03-09 19:11 ` Soft Works
2025-03-09 19:01 ` [FFmpeg-devel] [PATCH v5 2/5] fftools/opt_common: add memaddresses log flag softworkz
2025-03-09 19:01 ` [FFmpeg-devel] [PATCH v5 3/5] fftools: Provide a an fftools-specific logging callback function softworkz
2025-03-09 19:01 ` [FFmpeg-devel] [PATCH v5 4/5] doc/fftools-common-opts: document memaddresses log flag softworkz
2025-03-09 19:01 ` [FFmpeg-devel] [PATCH v5 5/5] Remove commented lines softworkz
2025-03-13 9:30 ` [FFmpeg-devel] [PATCH v6 0/3] avutil/log: Replace addresses in log output with simple ids ffmpegagent
2025-03-13 9:30 ` [FFmpeg-devel] [PATCH v6 1/3] fftools: Add a local logging callback function softworkz
2025-03-13 9:30 ` [FFmpeg-devel] [PATCH v6 2/3] fftools/opt_common: add memaddresses log flag softworkz
2025-03-13 9:30 ` [FFmpeg-devel] [PATCH v6 3/3] doc/fftools-common-opts: document " softworkz
2025-04-09 5:54 ` [FFmpeg-devel] [PATCH v7 0/3] avutil/log: Add log flag to control printing of memory addresses ffmpegagent
2025-04-09 5:55 ` [FFmpeg-devel] [PATCH v7 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES softworkz
2025-04-09 7:27 ` Andreas Rheinhardt
2025-04-09 7:50 ` softworkz .
2025-04-09 8:02 ` softworkz .
2025-04-09 8:11 ` Andreas Rheinhardt
2025-04-09 8:24 ` softworkz .
2025-04-09 8:27 ` Andreas Rheinhardt
2025-04-09 9:56 ` softworkz .
2025-04-09 8:15 ` Andreas Rheinhardt
2025-04-09 5:55 ` [FFmpeg-devel] [PATCH v7 2/3] fftools/opt_common: add memaddresses log flag softworkz
2025-04-09 5:55 ` [FFmpeg-devel] [PATCH v7 3/3] doc/fftools-common-opts: document " softworkz
2025-04-09 9:25 ` [FFmpeg-devel] [PATCH v8 0/3] avutil/log: Add log flag to control printing of memory addresses ffmpegagent
2025-04-09 9:25 ` [FFmpeg-devel] [PATCH v8 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES softworkz
2025-04-09 9:25 ` [FFmpeg-devel] [PATCH v8 2/3] fftools: add memaddress log flag and disable printing addresses by default softworkz
2025-04-09 14:28 ` Gyan Doshi
2025-04-09 14:41 ` softworkz .
2025-04-09 9:25 ` [FFmpeg-devel] [PATCH v8 3/3] doc/fftools-common-opts: document memaddress log flag softworkz
2025-04-09 18:19 ` [FFmpeg-devel] [PATCH v9 0/3] avutil/log: Add log flag to control printing of memory addresses ffmpegagent
2025-04-09 18:19 ` [FFmpeg-devel] [PATCH v9 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES softworkz
2025-04-09 18:19 ` [FFmpeg-devel] [PATCH v9 2/3] fftools: add mem log flag and disable printing addresses by default softworkz
2025-04-09 18:26 ` Gyan Doshi
2025-04-09 18:40 ` softworkz .
2025-04-09 18:19 ` [FFmpeg-devel] [PATCH v9 3/3] doc/fftools-common-opts: document mem log flag softworkz
2025-04-10 0:38 ` [FFmpeg-devel] [PATCH v10 0/3] avutil/log: Add log flag to control printing of memory addresses ffmpegagent
2025-04-10 0:38 ` [FFmpeg-devel] [PATCH v10 1/3] avutil/log: Add log flag AV_LOG_PRINT_MEMADDRESSES softworkz
2025-04-10 7:38 ` Andreas Rheinhardt
2025-04-10 18:06 ` softworkz .
2025-04-10 0:38 ` [FFmpeg-devel] [PATCH v10 2/3] fftools: add mem log flag and disable printing addresses by default softworkz
2025-04-10 6:51 ` Nicolas George
2025-04-10 18:02 ` softworkz .
2025-04-16 13:43 ` Michael Niedermayer
2025-04-16 13:50 ` Nicolas George
2025-04-16 14:25 ` Gyan Doshi
2025-04-16 14:26 ` softworkz .
2025-04-10 0:38 ` [FFmpeg-devel] [PATCH v10 3/3] doc/fftools-common-opts: document mem 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