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
29 29
30#include "af_anlmdndsp.h"30#include "af_anlmdndsp.h"
31 31
32#define MAX_DIFF 11.f
33#define WEIGHT_LUT_NBITS 2032#define WEIGHT_LUT_NBITS 20
34#define WEIGHT_LUT_SIZE (1<<WEIGHT_LUT_NBITS)33#define WEIGHT_LUT_SIZE (1<<WEIGHT_LUT_NBITS)
35 34
@@ -41,6 +40,7 @@ typedef struct AudioNLMeansContext { · 5 unmodified lines
41 float a;40 float a;
42 int64_t pd;41 int64_t pd;
43 int64_t rd;42 int64_t rd;
43 float m;
44 int om;44 int om;
45 45
46 float pdiff_lut_scale;46 float pdiff_lut_scale;
@@ -81,6 +81,7 @@ static const AVOption anlmdn_options[] = { · 34 unmodified lines
81 { "i", "input", 0, AV_OPT_TYPE_CONST, {.i64=IN_MODE}, 0, 0, AF, "mode" },81 { "i", "input", 0, AV_OPT_TYPE_CONST, {.i64=IN_MODE}, 0, 0, AF, "mode" },
82 { "o", "output", 0, AV_OPT_TYPE_CONST, {.i64=OUT_MODE}, 0, 0, AF, "mode" },82 { "o", "output", 0, AV_OPT_TYPE_CONST, {.i64=OUT_MODE}, 0, 0, AF, "mode" },
83 { "n", "noise", 0, AV_OPT_TYPE_CONST, {.i64=NOISE_MODE},0, 0, AF, "mode" },83 { "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 },
84 { NULL }85 { NULL }
85};86};
86 87
@@ -178,7 +179,7 @@ static int config_output(AVFilterLink *outlink) · 91 unmodified lines
178 if (ret < 0)179 if (ret < 0)
179 return ret;180 return ret;
180 181
181 s->pdiff_lut_scale = 1.f / MAX_DIFF * WEIGHT_LUT_SIZE;182 s->pdiff_lut_scale = 1.f / s->m * WEIGHT_LUT_SIZE;
182 for (int i = 0; i < WEIGHT_LUT_SIZE; i++) {183 for (int i = 0; i < WEIGHT_LUT_SIZE; i++) {
183 float w = -i / s->pdiff_lut_scale;184 float w = -i / s->pdiff_lut_scale;
184 185
@@ -201,6 +202,7 @@ static int filter_channel(AVFilterContext *ctx, void *arg, int ch, int nb_jobs) · 16 unmodified lines
201 float *cache = (float *)s->cache->extended_data[ch];202 float *cache = (float *)s->cache->extended_data[ch];
202 const float sw = (65536.f / (4 * K + 2)) / sqrtf(s->a);203 const float sw = (65536.f / (4 * K + 2)) / sqrtf(s->a);
203 float *dst = (float *)out->extended_data[ch] + s->offset;204 float *dst = (float *)out->extended_data[ch] + s->offset;
205 const float smooth = s->m;
204 206
205 for (int i = S; i < s->H + S; i++) {207 for (int i = S; i < s->H + S; i++) {
206 float P = 0.f, Q = 0.f;208 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
224 226
225 av_assert2(distance >= 0.f);227 av_assert2(distance >= 0.f);
226 w = distance * sw;228 w = distance * sw;
227 if (w >= MAX_DIFF)229 if (w >= smooth)
228 continue;230 continue;
229 weight_lut_idx = w * s->pdiff_lut_scale;231 weight_lut_idx = w * s->pdiff_lut_scale;
230 av_assert2(weight_lut_idx < WEIGHT_LUT_SIZE);232 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