History

avfilter/af_anlmdn: add smooth factor option

Paul B Mahol committed 7 years ago

Commit b5355771 parent cbaa6032 files · +8 −3Browse files

Showing the changes to libavfilter (1 of 2 files). Show all

Unified · Split

libavfilter/af_anlmdn.c+5−3
@@ -29,7 +29,6 @@ · 28 unmodified lines
2929
3030 #include "af_anlmdndsp.h"
3131
32−#define MAX_DIFF 11.f
3332 #define WEIGHT_LUT_NBITS 20
3433 #define WEIGHT_LUT_SIZE (1<<WEIGHT_LUT_NBITS)
3534
@@ -41,6 +40,7 @@ typedef struct AudioNLMeansContext { · 5 unmodified lines
4140 float a;
4241 int64_t pd;
4342 int64_t rd;
43+ float m;
4444 int om;
4545
4646 float pdiff_lut_scale;
@@ -81,6 +81,7 @@ static const AVOption anlmdn_options[] = { · 34 unmodified lines
8181 { "i", "input", 0, AV_OPT_TYPE_CONST, {.i64=IN_MODE}, 0, 0, AF, "mode" },
8282 { "o", "output", 0, AV_OPT_TYPE_CONST, {.i64=OUT_MODE}, 0, 0, AF, "mode" },
8383 { "n", "noise", 0, AV_OPT_TYPE_CONST, {.i64=NOISE_MODE},0, 0, AF, "mode" },
84+ { "m", "set smooth factor", OFFSET(m), AV_OPT_TYPE_FLOAT, {.dbl=11.}, 1, 15, AF },
8485 { NULL }
8586 };
8687
@@ -178,7 +179,7 @@ static int config_output(AVFilterLink *outlink) · 91 unmodified lines
178179 if (ret < 0)
179180 return ret;
180181
181− s->pdiff_lut_scale = 1.f / MAX_DIFF * WEIGHT_LUT_SIZE;
182+ s->pdiff_lut_scale = 1.f / s->m * WEIGHT_LUT_SIZE;
182183 for (int i = 0; i < WEIGHT_LUT_SIZE; i++) {
183184 float w = -i / s->pdiff_lut_scale;
184185
@@ -201,6 +202,7 @@ static int filter_channel(AVFilterContext *ctx, void *arg, int ch, int nb_jobs) · 16 unmodified lines
201202 float *cache = (float *)s->cache->extended_data[ch];
202203 const float sw = (65536.f / (4 * K + 2)) / sqrtf(s->a);
203204 float *dst = (float *)out->extended_data[ch] + s->offset;
205+ const float smooth = s->m;
204206
205207 for (int i = S; i < s->H + S; i++) {
206208 float P = 0.f, Q = 0.f;
@@ -224,7 +226,7 @@ static int filter_channel(AVFilterContext *ctx, void *arg, int ch, int nb_jobs) · 17 unmodified lines
224226
225227 av_assert2(distance >= 0.f);
226228 w = distance * sw;
227− if (w >= MAX_DIFF)
229+ if (w >= smooth)
228230 continue;
229231 weight_lut_idx = w * s->pdiff_lut_scale;
230232 av_assert2(weight_lut_idx < WEIGHT_LUT_SIZE);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t