This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit 4b23a9093577372ed2641ded975ad9aa7bee7eea
Author:     James Almer <[email protected]>
AuthorDate: Sun Jun 7 12:04:07 2026 -0300
Commit:     James Almer <[email protected]>
CommitDate: Thu Jun 11 17:28:14 2026 -0300

    avcodec/lcevcdec: respect log level from the external library
    
    Signed-off-by: James Almer <[email protected]>
---
 libavcodec/decode.c   |  2 +-
 libavcodec/lcevcdec.c | 44 ++++++++++++++++++++++++++++++++++++++++----
 libavcodec/lcevcdec.h |  3 ++-
 3 files changed, 43 insertions(+), 6 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 92b613f5c0..a18b99e115 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -2140,7 +2140,7 @@ av_cold int ff_decode_preinit(AVCodecContext *avctx)
     if (!(avctx->export_side_data & AV_CODEC_EXPORT_DATA_ENHANCEMENTS)) {
         if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
 #if CONFIG_LIBLCEVC_DEC
-            ret = ff_lcevc_alloc(&dc->lcevc.ctx);
+            ret = ff_lcevc_alloc(&dc->lcevc.ctx, av_log_get_level() + 
avctx->log_level_offset);
             if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE))
                 return ret;
 #endif
diff --git a/libavcodec/lcevcdec.c b/libavcodec/lcevcdec.c
index ae07024fe5..2e16a5a627 100644
--- a/libavcodec/lcevcdec.c
+++ b/libavcodec/lcevcdec.c
@@ -277,14 +277,28 @@ static int lcevc_receive_frame(FFLCEVCFrame *frame_ctx, 
AVFrame *out)
     return lcevc_flush_pictures(lcevc);
 }
 
+static const uint8_t level_map[LCEVC_LogLevelCount] = {
+    [LCEVC_LogFatal]   = AV_LOG_FATAL,
+    [LCEVC_LogError]   = AV_LOG_ERROR,
+    [LCEVC_LogWarning] = AV_LOG_WARNING,
+    [LCEVC_LogInfo]    = AV_LOG_INFO,
+    [LCEVC_LogDebug]   = AV_LOG_DEBUG,
+    [LCEVC_LogTrace]   = AV_LOG_TRACE,
+};
+
 static void event_callback(LCEVC_DecoderHandle dec, LCEVC_Event event,
     LCEVC_PictureHandle pic, const LCEVC_DecodeInformation *info,
     const uint8_t *data, uint32_t size, void *logctx)
 {
     switch (event) {
-    case LCEVC_Log:
-        av_log(logctx, AV_LOG_INFO, "%s\n", data);
+    case LCEVC_Log: {
+        unsigned int level = 0;
+        int ret = sscanf(data, "%u ", &level);
+        if (ret != 1 || level >= LCEVC_LogLevelCount || !level_map[level])
+            break;
+        av_log(logctx, level_map[level], "%s\n", data);
         break;
+    }
     default:
         break;
     }
@@ -331,17 +345,38 @@ static av_cold void 
lcevc_frame_free_entry_cb(AVRefStructOpaque unused, void *ob
     av_frame_free(&frame->frame);
 }
 
+static int get_log_level(int level)
+{
+    if (level <= AV_LOG_QUIET)
+        return LCEVC_LogDisabled;
+    if (level <= AV_LOG_FATAL)
+        return LCEVC_LogFatal;
+    if (level <= AV_LOG_ERROR)
+        return LCEVC_LogError;
+    if (level <= AV_LOG_WARNING)
+        return LCEVC_LogWarning;
+    if (level <= AV_LOG_INFO)
+        return LCEVC_LogInfo;
+    if (level <= AV_LOG_DEBUG)
+        return LCEVC_LogDebug;
+
+    return LCEVC_LogTrace;
+}
+
 static int lcevc_init(FFLCEVCContext *lcevc)
 {
     LCEVC_AccelContextHandle dummy = { 0 };
     const int32_t event = LCEVC_Log;
+    int level;
 
     if (LCEVC_CreateDecoder(&lcevc->decoder, dummy) != LCEVC_Success) {
         av_log(lcevc, AV_LOG_ERROR, "Failed to create LCEVC decoder\n");
         return AVERROR_EXTERNAL;
     }
 
-    LCEVC_ConfigureDecoderInt(lcevc->decoder, "log_level", 4);
+    level = get_log_level(lcevc->loglevel);
+
+    LCEVC_ConfigureDecoderInt(lcevc->decoder, "log_level", level);
     LCEVC_ConfigureDecoderIntArray(lcevc->decoder, "events", 1, &event);
     LCEVC_SetDecoderEventCallback(lcevc->decoder, event_callback, lcevc);
 
@@ -437,7 +472,7 @@ static const AVClass lcevcdec_context_class = {
     .category       = AV_CLASS_CATEGORY_DECODER,
 };
 
-int ff_lcevc_alloc(FFLCEVCContext **plcevc)
+int ff_lcevc_alloc(FFLCEVCContext **plcevc, int loglevel)
 {
     FFLCEVCContext *lcevc = NULL;
     int ret;
@@ -469,6 +504,7 @@ int ff_lcevc_alloc(FFLCEVCContext **plcevc)
     }
 
     lcevc->class = &lcevcdec_context_class;
+    lcevc->loglevel = loglevel;
 
     *plcevc = lcevc;
     return 0;
diff --git a/libavcodec/lcevcdec.h b/libavcodec/lcevcdec.h
index 4b15cbb4aa..e51d3de989 100644
--- a/libavcodec/lcevcdec.h
+++ b/libavcodec/lcevcdec.h
@@ -39,6 +39,7 @@ typedef struct FFLCEVCContext {
     struct CodedBitstreamContext *cbc;
     struct CodedBitstreamFragment *frag;
     struct AVRefStructPool *frame_pool; ///< pool of FFLCEVCFrame
+    int loglevel;
     int initialized;
 } FFLCEVCContext;
 
@@ -49,7 +50,7 @@ typedef struct FFLCEVCFrame {
     struct AVFrame *frame;
 } FFLCEVCFrame;
 
-int ff_lcevc_alloc(FFLCEVCContext **plcevc);
+int ff_lcevc_alloc(FFLCEVCContext **plcevc, int loglevel);
 int ff_lcevc_process(void *logctx, struct AVFrame *frame);
 int ff_lcevc_parse_frame(FFLCEVCContext *lcevc, const struct AVFrame *frame,
                          enum AVPixelFormat *format, int *width, int *height);

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to