diff options
author | Paul B Mahol <onemda@gmail.com> | 2019-06-02 11:58:49 +0200 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2019-06-02 11:58:49 +0200 |
commit | b5355774652cfbef3fd3f2c77d1403661e5222a5 (patch) | |
tree | aa6cabc44d76d2700cea7f130db861a36711139e /libavfilter | |
parent | cbaa60329a73d1479a697cb83e82b1b97261d879 (diff) | |
download | ffmpeg-b5355774652cfbef3fd3f2c77d1403661e5222a5.tar.gz |
avfilter/af_anlmdn: add smooth factor option
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/af_anlmdn.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/libavfilter/af_anlmdn.c b/libavfilter/af_anlmdn.c index 87c49c63b1..06e9736cc2 100644 --- a/libavfilter/af_anlmdn.c +++ b/libavfilter/af_anlmdn.c @@ -29,7 +29,6 @@ #include "af_anlmdndsp.h" -#define MAX_DIFF 11.f #define WEIGHT_LUT_NBITS 20 #define WEIGHT_LUT_SIZE (1<<WEIGHT_LUT_NBITS) @@ -41,6 +40,7 @@ typedef struct AudioNLMeansContext { float a; int64_t pd; int64_t rd; + float m; int om; float pdiff_lut_scale; @@ -81,6 +81,7 @@ static const AVOption anlmdn_options[] = { { "i", "input", 0, AV_OPT_TYPE_CONST, {.i64=IN_MODE}, 0, 0, AF, "mode" }, { "o", "output", 0, AV_OPT_TYPE_CONST, {.i64=OUT_MODE}, 0, 0, AF, "mode" }, { "n", "noise", 0, AV_OPT_TYPE_CONST, {.i64=NOISE_MODE},0, 0, AF, "mode" }, + { "m", "set smooth factor", OFFSET(m), AV_OPT_TYPE_FLOAT, {.dbl=11.}, 1, 15, AF }, { NULL } }; @@ -178,7 +179,7 @@ static int config_output(AVFilterLink *outlink) if (ret < 0) return ret; - s->pdiff_lut_scale = 1.f / MAX_DIFF * WEIGHT_LUT_SIZE; + s->pdiff_lut_scale = 1.f / s->m * WEIGHT_LUT_SIZE; for (int i = 0; i < WEIGHT_LUT_SIZE; i++) { float w = -i / s->pdiff_lut_scale; @@ -201,6 +202,7 @@ static int filter_channel(AVFilterContext *ctx, void *arg, int ch, int nb_jobs) float *cache = (float *)s->cache->extended_data[ch]; const float sw = (65536.f / (4 * K + 2)) / sqrtf(s->a); float *dst = (float *)out->extended_data[ch] + s->offset; + const float smooth = s->m; for (int i = S; i < s->H + S; i++) { float P = 0.f, Q = 0.f; @@ -224,7 +226,7 @@ static int filter_channel(AVFilterContext *ctx, void *arg, int ch, int nb_jobs) av_assert2(distance >= 0.f); w = distance * sw; - if (w >= MAX_DIFF) + if (w >= smooth) continue; weight_lut_idx = w * s->pdiff_lut_scale; av_assert2(weight_lut_idx < WEIGHT_LUT_SIZE); |