]> git.sesse.net Git - ffmpeg/commitdiff
avfilter/af_anlmdn: rework how denoising strength is used
authorPaul B Mahol <onemda@gmail.com>
Sat, 12 Jan 2019 14:33:39 +0000 (15:33 +0100)
committerPaul B Mahol <onemda@gmail.com>
Sat, 12 Jan 2019 14:41:24 +0000 (15:41 +0100)
Make into account patch size.

doc/filters.texi
libavfilter/af_anlmdn.c

index 85d8f6c85bbe17323e903ea1ca1ccbf366c8977a..6a336a71f4ee9396f5bf5a7e515d854f7ece0e03 100644 (file)
@@ -1762,7 +1762,7 @@ The filter accepts the following options.
 
 @table @option
 @item s
-Set denoising strength. Allowed range is from 1 to 9999. Default value is 1.
+Set denoising strength. Allowed range is from 0.00001 to 10. Default value is 0.00001.
 
 @item p
 Set patch radius duration. Allowed range is from 1 to 100 milliseconds.
index 7cd6f2c4770af9219a1c7a7c091a8c0feeac2712..43ceab8e4a48104844be47c8802d829a64a317ca 100644 (file)
@@ -66,7 +66,7 @@ typedef struct AudioNLMeansContext {
 #define AF AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
 static const AVOption anlmdn_options[] = {
-    { "s", "set denoising strength", OFFSET(a),  AV_OPT_TYPE_FLOAT,    {.dbl=1},       1,   9999, AF },
+    { "s", "set denoising strength", OFFSET(a),  AV_OPT_TYPE_FLOAT,    {.dbl=0.00001},0.00001, 10, AF },
     { "p", "set patch duration",     OFFSET(pd), AV_OPT_TYPE_DURATION, {.i64=2000}, 1000, 100000, AF },
     { "r", "set research duration",  OFFSET(rd), AV_OPT_TYPE_DURATION, {.i64=6000}, 2000, 300000, AF },
     { NULL }
@@ -186,7 +186,7 @@ static int filter_channel(AVFilterContext *ctx, void *arg, int ch, int nb_jobs)
     const int K = s->K;
     const float *f = (const float *)(s->in->extended_data[ch]) + K;
     float *cache = (float *)s->cache->extended_data[ch];
-    const float sw = 32768.f / s->a;
+    const float sw = (65536.f / (4 * K + 2)) / sqrtf(s->a);
     float *dst = (float *)out->extended_data[ch] + s->offset;
 
     for (int i = S; i < s->H + S; i++) {