[FFmpeg-devel] [PATCH 1/2] avfilter/vf_bilateral: add seperate function to init lut
leozhang
leozhang at qiyi.com
Thu Nov 14 05:51:29 EET 2019
Reviewed-by: Paul B Mahol <onemda at gmail.com>
Signed-off-by: leozhang <leozhang at qiyi.com>
---
libavfilter/vf_bilateral.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/libavfilter/vf_bilateral.c b/libavfilter/vf_bilateral.c
index 3c9d800..36e53d2 100644
--- a/libavfilter/vf_bilateral.c
+++ b/libavfilter/vf_bilateral.c
@@ -91,19 +91,27 @@ static int query_formats(AVFilterContext *ctx)
return ff_set_common_formats(ctx, ff_make_format_list(pix_fmts));
}
-static int config_input(AVFilterLink *inlink)
+static int init_lut(BilateralContext *s)
{
- BilateralContext *s = inlink->dst->priv;
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
float inv_sigma_range;
- s->depth = desc->comp[0].depth;
inv_sigma_range = 1.0f / (s->sigmaR * ((1 << s->depth) - 1));
//compute a lookup table
for (int i = 0; i < (1 << s->depth); i++)
s->range_table[i] = expf(-i * inv_sigma_range);
+ return 0;
+}
+
+static int config_input(AVFilterLink *inlink)
+{
+ BilateralContext *s = inlink->dst->priv;
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
+
+ s->depth = desc->comp[0].depth;
+ init_lut(s);
+
s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
s->planewidth[0] = s->planewidth[3] = inlink->w;
s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
--
1.8.3.1
More information about the ffmpeg-devel
mailing list