diff mbox

[FFmpeg-devel,1/2] avfilter/vf_bilateral: add seperate function to init lut

Message ID 1573703489-128899-1-git-send-email-leozhang@qiyi.com
State New
Headers show

Commit Message

Leo Zhang Nov. 14, 2019, 3:51 a.m. UTC
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: leozhang <leozhang@qiyi.com>
---
 libavfilter/vf_bilateral.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
diff mbox

Patch

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);