[FFmpeg-devel] [PATCH v4 2/3] lavc/libdavs2.c: fix decoder info level setting

hwrenx hwrenx at 126.com
Mon Jul 22 07:23:37 EEST 2019


Mapping log level from av_log_level to davs3_log_level_e:

[AV_LOG_QUIET, AV_LOG_ERROR]   => DAVS2_LOG_ERROR
[AV_LOG_WARNING]               => DAVS2_LOG_WARNING
[AV_LOG_INFO]                  => DAVS2_LOG_INFO
[AV_LOG_VERBOSE, AV_LOG_TRACE] => DAVS2_LOG_DEBUG

in values:

[-8, 16] => 3
[17, 24] => 2
[25, 32] => 1
[33, 56] => 0

After clip into [AV_LOG_FATAL + 1, AV_LOG_VERBOSE]([9, 40]), davs2 log
level can be expressed as (4-(((av_log_level)-1)>>3)).

Signed-off-by: hwrenx <hwrenx at 126.com>
---
 libavcodec/libdavs2.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c
index 218f3ec..79b3e4f 100644
--- a/libavcodec/libdavs2.c
+++ b/libavcodec/libdavs2.c
@@ -25,6 +25,9 @@
 #include "avcodec.h"
 #include "davs2.h"
 
+/* map log_level from 16/24/32/40 to 3/2/1/0 */
+#define DAVS2_GET_LEVEL(x) (4-(((x)-1)>>3))
+
 typedef struct DAVS2Context {
     void *decoder;
 
@@ -41,10 +44,14 @@ static av_cold int davs2_init(AVCodecContext *avctx)
 {
     DAVS2Context *cad = avctx->priv_data;
     int cpu_flags = av_get_cpu_flags();
+    int log_level = av_log_get_level();
+
+    /* fix for davs2 level range */
+    log_level = av_clip(log_level, AV_LOG_FATAL + 1, AV_LOG_VERBOSE);
 
     /* init the decoder */
     cad->param.threads      = avctx->thread_count;
-    cad->param.info_level   = 0;
+    cad->param.info_level   = DAVS2_GET_LEVEL(log_level);
     cad->param.disable_avx  = !(cpu_flags & AV_CPU_FLAG_AVX &&
                                 cpu_flags & AV_CPU_FLAG_AVX2);
     cad->decoder            = davs2_decoder_open(&cad->param);
-- 
2.7.4



More information about the ffmpeg-devel mailing list