Message ID | 20211112192402.75720-1-ffmpeg@haasn.xyz |
---|---|
State | Accepted |
Commit | a943f527a13d2d6afd38593a2dc1de69e6d0972c |
Headers | show |
Series | [FFmpeg-devel] lavfi/vf_libplacebo: pick log level dynamically | expand |
Context | Check | Description |
---|---|---|
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
andriy/make_ppc | success | Make finished |
andriy/make_fate_ppc | success | Make fate finished |
12 Nov 2021, 20:24 by ffmpeg@haasn.xyz: > From: Niklas Haas <git@haasn.dev> > > In particular, allows users to go all the way up to PL_LOG_TRACE if > desired. (While also avoiding some potentially unnecessary callbacks for > filtered messages, including e.g. the CPU cost of printing out shader > sources) > > Response to runtime log level changes by updating it once per > filter_frame(), which should hopefully be often enough. > --- > libavfilter/vf_libplacebo.c | 15 ++++++++++++++- > 1 file changed, 14 insertions(+), 1 deletion(-) > > diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c > index 0590e99093..ede6888bd3 100644 > --- a/libavfilter/vf_libplacebo.c > +++ b/libavfilter/vf_libplacebo.c > @@ -116,6 +116,18 @@ typedef struct LibplaceboContext { > int num_hooks; > } LibplaceboContext; > > +static inline enum pl_log_level get_log_level(void) > +{ > + int av_lev = av_log_get_level(); > + return av_lev >= AV_LOG_TRACE ? PL_LOG_TRACE : > + av_lev >= AV_LOG_DEBUG ? PL_LOG_DEBUG : > + av_lev >= AV_LOG_VERBOSE ? PL_LOG_INFO : > + av_lev >= AV_LOG_WARNING ? PL_LOG_WARN : > + av_lev >= AV_LOG_ERROR ? PL_LOG_ERR : > + av_lev >= AV_LOG_FATAL ? PL_LOG_FATAL : > + PL_LOG_NONE; > +} > + > static void pl_av_log(void *log_ctx, enum pl_log_level level, const char *msg) > { > int av_lev; > @@ -177,7 +189,7 @@ static int libplacebo_init(AVFilterContext *avctx) > > /* Create libplacebo log context */ > s->log = pl_log_create(PL_API_VER, pl_log_params( > - .log_level = PL_LOG_DEBUG, > + .log_level = get_log_level(), > .log_cb = pl_av_log, > .log_priv = s, > )); > @@ -447,6 +459,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) > goto fail; > } > > + pl_log_level_update(s->log, get_log_level()); > if (!s->initialized) > RET(init_vulkan(ctx)); > Patch applied. Thanks for making it dynamic too.
diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index 0590e99093..ede6888bd3 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -116,6 +116,18 @@ typedef struct LibplaceboContext { int num_hooks; } LibplaceboContext; +static inline enum pl_log_level get_log_level(void) +{ + int av_lev = av_log_get_level(); + return av_lev >= AV_LOG_TRACE ? PL_LOG_TRACE : + av_lev >= AV_LOG_DEBUG ? PL_LOG_DEBUG : + av_lev >= AV_LOG_VERBOSE ? PL_LOG_INFO : + av_lev >= AV_LOG_WARNING ? PL_LOG_WARN : + av_lev >= AV_LOG_ERROR ? PL_LOG_ERR : + av_lev >= AV_LOG_FATAL ? PL_LOG_FATAL : + PL_LOG_NONE; +} + static void pl_av_log(void *log_ctx, enum pl_log_level level, const char *msg) { int av_lev; @@ -177,7 +189,7 @@ static int libplacebo_init(AVFilterContext *avctx) /* Create libplacebo log context */ s->log = pl_log_create(PL_API_VER, pl_log_params( - .log_level = PL_LOG_DEBUG, + .log_level = get_log_level(), .log_cb = pl_av_log, .log_priv = s, )); @@ -447,6 +459,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) goto fail; } + pl_log_level_update(s->log, get_log_level()); if (!s->initialized) RET(init_vulkan(ctx));
From: Niklas Haas <git@haasn.dev> In particular, allows users to go all the way up to PL_LOG_TRACE if desired. (While also avoiding some potentially unnecessary callbacks for filtered messages, including e.g. the CPU cost of printing out shader sources) Response to runtime log level changes by updating it once per filter_frame(), which should hopefully be often enough. --- libavfilter/vf_libplacebo.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)