[FFmpeg-devel] [PATCH] avcodec/libvvenc: use av_vlog to print external library log messages
Nuo Mi
nuomi2021 at gmail.com
Sat Apr 19 04:25:36 EEST 2025
LGTM,
Nit: Would a lookup table be better?
On Fri, Apr 18, 2025 at 12:42 AM James Almer <jamrial at gmail.com> wrote:
> And improve the vvencMsgLevel <-> AV_LOG_* mapping.
>
> Signed-off-by: James Almer <jamrial at 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(¶ms);
> - vvenc_get_config(encoder, ¶ms);
> - 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(¶ms, s->encoder, vvenc_log_callback);
> + vvenc_set_msg_callback(¶ms, avctx, vvenc_log_callback);
> ret = vvenc_encoder_open(s->encoder, ¶ms);
> if (ret != 0) {
> av_log(avctx, AV_LOG_ERROR, "cannot open libvvenc encoder: %s\n",
> --
> 2.49.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>
More information about the ffmpeg-devel
mailing list