History

avfilter/af_anlmdn: add output mode option

Paul B Mahol committed 7 years ago

Commit 007c13e1 parent 85051fe2 files · +35 −1Browse files

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

Unified · Split

libavfilter/af_anlmdn.c+18−1
@@ -41,6 +41,7 @@ typedef struct AudioNLMeansContext { · 40 unmodified lines
4141 float a;
4242 int64_t pd;
4343 int64_t rd;
44+ int om;
4445
4546 float pdiff_lut_scale;
4647 float weight_lut[WEIGHT_LUT_SIZE];
@@ -62,6 +63,13 @@ typedef struct AudioNLMeansContext { · 15 unmodified lines
6263 AudioNLMDNDSPContext dsp;
6364 } AudioNLMeansContext;
6465
66+enum OutModes {
67+ IN_MODE,
68+ OUT_MODE,
69+ NOISE_MODE,
70+ NB_MODES
71+};
72+
6573 #define OFFSET(x) offsetof(AudioNLMeansContext, x)
6674 #define AF AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
6775
@@ -69,6 +77,10 @@ static const AVOption anlmdn_options[] = { · 1 unmodified line
6977 { "s", "set denoising strength", OFFSET(a), AV_OPT_TYPE_FLOAT, {.dbl=0.00001},0.00001, 10, AF },
7078 { "p", "set patch duration", OFFSET(pd), AV_OPT_TYPE_DURATION, {.i64=2000}, 1000, 100000, AF },
7179 { "r", "set research duration", OFFSET(rd), AV_OPT_TYPE_DURATION, {.i64=6000}, 2000, 300000, AF },
80+ { "o", "set output mode", OFFSET(om), AV_OPT_TYPE_INT, {.i64=OUT_MODE}, 0, NB_MODES-1, 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" },
83+ { "n", "noise", 0, AV_OPT_TYPE_CONST, {.i64=NOISE_MODE},0, 0, AF, "mode" },
7284 { NULL }
7385 };
7486
@@ -184,6 +196,7 @@ static int filter_channel(AVFilterContext *ctx, void *arg, int ch, int nb_jobs) · 109 unmodified lines
184196 AVFrame *out = arg;
185197 const int S = s->S;
186198 const int K = s->K;
199+ const int om = s->om;
187200 const float *f = (const float *)(s->in->extended_data[ch]) + K;
188201 float *cache = (float *)s->cache->extended_data[ch];
189202 const float sw = (65536.f / (4 * K + 2)) / sqrtf(s->a);
@@ -223,7 +236,11 @@ static int filter_channel(AVFilterContext *ctx, void *arg, int ch, int nb_jobs) · 33 unmodified lines
223236 P += f[i];
224237 Q += 1;
225238
226− dst[i - S] = P / Q;
239+ switch (om) {
240+ case IN_MODE: dst[i - S] = f[i]; break;
241+ case OUT_MODE: dst[i - S] = P / Q; break;
242+ case NOISE_MODE: dst[i - S] = f[i] - (P / Q); break;
243+ }
227244 }
228245
229246 return 0;

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