Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: James Almer <jamrial@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH] avcodec/libvvenc: use av_vlog to print external library log messages
Date: Thu, 17 Apr 2025 13:41:58 -0300
Message-ID: <20250417164158.7904-1-jamrial@gmail.com> (raw)

And improve the vvencMsgLevel <-> AV_LOG_* mapping.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavcodec/libvvenc.c | 35 +++++++++++++++++++++++++++--------
 1 file changed, 27 insertions(+), 8 deletions(-)

diff --git a/libavcodec/libvvenc.c b/libavcodec/libvvenc.c
index 29a49ba091..c71fd78f1e 100644
--- a/libavcodec/libvvenc.c
+++ b/libavcodec/libvvenc.c
@@ -63,14 +63,29 @@ typedef struct VVenCContext {
 static void vvenc_log_callback(void *ctx, int level,
                                const char *fmt, va_list args)
 {
-    vvenc_config params;
-    vvencEncoder *encoder = ctx;
-    if (encoder) {
-        vvenc_config_default(&params);
-        vvenc_get_config(encoder, &params);
-        if ((int)params.m_verbosity >= level)
-            vfprintf(level == 1 ? stderr : stdout, fmt, args);
+    AVCodecContext *avctx = ctx;
+
+    switch (level) {
+    case VVENC_ERROR:
+        level = AV_LOG_ERROR;
+        break;
+    case VVENC_WARNING:
+        level = AV_LOG_WARNING;
+        break;
+    case VVENC_INFO:
+        level = AV_LOG_INFO;
+        break;
+    case VVENC_NOTICE:
+    case VVENC_VERBOSE:
+        level = AV_LOG_VERBOSE;
+        break;
+    case VVENC_DETAILS:
+        level = AV_LOG_DEBUG;
+        break;
+    default:
+        return;
     }
+    av_vlog(avctx, level, fmt, args);
 }
 
 static void vvenc_set_verbository(vvenc_config *params)
@@ -82,7 +97,11 @@ static void vvenc_set_verbository(vvenc_config *params)
     else if (loglevel >= AV_LOG_VERBOSE)
         params->m_verbosity = VVENC_NOTICE;
     else if (loglevel >= AV_LOG_INFO)
+        params->m_verbosity = VVENC_INFO;
+    else if (loglevel >= AV_LOG_WARNING)
         params->m_verbosity = VVENC_WARNING;
+    else if (loglevel >= AV_LOG_ERROR)
+        params->m_verbosity = VVENC_ERROR;
 }
 
 static void vvenc_set_pic_format(AVCodecContext *avctx, vvenc_config *params)
@@ -300,7 +319,7 @@ static av_cold int vvenc_init(AVCodecContext *avctx)
         return AVERROR(ENOMEM);
     }
 
-    vvenc_set_msg_callback(&params, s->encoder, vvenc_log_callback);
+    vvenc_set_msg_callback(&params, avctx, vvenc_log_callback);
     ret = vvenc_encoder_open(s->encoder, &params);
     if (ret != 0) {
         av_log(avctx, AV_LOG_ERROR, "cannot open libvvenc encoder: %s\n",
-- 
2.49.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".

             reply	other threads:[~2025-04-17 16:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-17 16:41 James Almer [this message]
2025-04-19  1:25 ` Nuo Mi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250417164158.7904-1-jamrial@gmail.com \
    --to=jamrial@gmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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