diff --git a/doc/filters.texi b/doc/filters.texi index a5d5257b24..3c64d13b82 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -2266,7 +2266,7 @@ The filter accepts the following options: @table @option @item strength, s -Set denoising strength. Allowed range is from 0.00001 to 10. Default value is 0.00001. +Set denoising strength. Allowed range is from 0.00001 to 10000. Default value is 0.00001. @item patch, p Set patch radius duration. Allowed range is from 1 to 100 milliseconds. @@ -2294,7 +2294,7 @@ Default value is @var{o}. @end table @item smooth, m -Set smooth factor. Default value is @var{11}. Allowed range is from @var{1} to @var{15}. +Set smooth factor. Default value is @var{11}. Allowed range is from @var{1} to @var{1000}. @end table @subsection Commands diff --git a/libavfilter/af_anlmdn.c b/libavfilter/af_anlmdn.c index 141e5f398e..a2c42393b6 100644 --- a/libavfilter/af_anlmdn.c +++ b/libavfilter/af_anlmdn.c @@ -33,8 +33,6 @@ #define WEIGHT_LUT_NBITS 20 #define WEIGHT_LUT_SIZE (1<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; + const float *const weight_lut = s->weight_lut; + const float pdiff_lut_scale = s->pdiff_lut_scale; + const float smooth = fminf(s->m, WEIGHT_LUT_SIZE / pdiff_lut_scale); for (int i = S; i < s->H + S; i++) { float P = 0.f, Q = 0.f; @@ -231,26 +238,24 @@ static int filter_channel(AVFilterContext *ctx, void *arg, int ch, int nb_jobs) } for (int j = 0; j < 2 * S && !ctx->is_disabled; j++) { - const float distance = cache[j]; + float distance = cache[j]; unsigned weight_lut_idx; float w; - if (distance < 0.f) { - cache[j] = 0.f; - continue; - } + if (distance < 0.f) + cache[j] = distance = 0.f; w = distance * sw; if (w >= smooth) continue; - weight_lut_idx = w * s->pdiff_lut_scale; + weight_lut_idx = w * pdiff_lut_scale; av_assert2(weight_lut_idx < WEIGHT_LUT_SIZE); - w = s->weight_lut[weight_lut_idx]; + w = weight_lut[weight_lut_idx]; P += w * f[i - S + j + (j >= S)]; Q += w; } P += f[i]; - Q += 1; + Q += 1.f; switch (om) { case IN_MODE: dst[i - S] = f[i]; break;