Showing the changes to libavfilter (1 of 2 files). Show all
Unified · Split
| @@ -41,6 +41,7 @@ typedef struct AudioNLMeansContext { · 40 unmodified lines | |||
| 41 | float a; | 41 | float a; |
| 42 | int64_t pd; | 42 | int64_t pd; |
| 43 | int64_t rd; | 43 | int64_t rd; |
| 44 | int om; | ||
| 44 | 45 | ||
| 45 | float pdiff_lut_scale; | 46 | float pdiff_lut_scale; |
| 46 | float weight_lut[WEIGHT_LUT_SIZE]; | 47 | float weight_lut[WEIGHT_LUT_SIZE]; |
| @@ -62,6 +63,13 @@ typedef struct AudioNLMeansContext { · 15 unmodified lines | |||
| 62 | AudioNLMDNDSPContext dsp; | 63 | AudioNLMDNDSPContext dsp; |
| 63 | } AudioNLMeansContext; | 64 | } AudioNLMeansContext; |
| 64 | 65 | ||
| 66 | enum OutModes { | ||
| 67 | IN_MODE, | ||
| 68 | OUT_MODE, | ||
| 69 | NOISE_MODE, | ||
| 70 | NB_MODES | ||
| 71 | }; | ||
| 72 | |||
| 65 | #define OFFSET(x) offsetof(AudioNLMeansContext, x) | 73 | #define OFFSET(x) offsetof(AudioNLMeansContext, x) |
| 66 | #define AF AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM | 74 | #define AF AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM |
| 67 | 75 | ||
| @@ -69,6 +77,10 @@ static const AVOption anlmdn_options[] = { · 1 unmodified line | |||
| 69 | { "s", "set denoising strength", OFFSET(a), AV_OPT_TYPE_FLOAT, {.dbl=0.00001},0.00001, 10, AF }, | 77 | { "s", "set denoising strength", OFFSET(a), AV_OPT_TYPE_FLOAT, {.dbl=0.00001},0.00001, 10, AF }, |
| 70 | { "p", "set patch duration", OFFSET(pd), AV_OPT_TYPE_DURATION, {.i64=2000}, 1000, 100000, AF }, | 78 | { "p", "set patch duration", OFFSET(pd), AV_OPT_TYPE_DURATION, {.i64=2000}, 1000, 100000, AF }, |
| 71 | { "r", "set research duration", OFFSET(rd), AV_OPT_TYPE_DURATION, {.i64=6000}, 2000, 300000, AF }, | 79 | { "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" }, | ||
| 72 | { NULL } | 84 | { NULL } |
| 73 | }; | 85 | }; |
| 74 | 86 | ||
| @@ -184,6 +196,7 @@ static int filter_channel(AVFilterContext *ctx, void *arg, int ch, int nb_jobs) · 109 unmodified lines | |||
| 184 | AVFrame *out = arg; | 196 | AVFrame *out = arg; |
| 185 | const int S = s->S; | 197 | const int S = s->S; |
| 186 | const int K = s->K; | 198 | const int K = s->K; |
| 199 | const int om = s->om; | ||
| 187 | const float *f = (const float *)(s->in->extended_data[ch]) + K; | 200 | const float *f = (const float *)(s->in->extended_data[ch]) + K; |
| 188 | float *cache = (float *)s->cache->extended_data[ch]; | 201 | float *cache = (float *)s->cache->extended_data[ch]; |
| 189 | const float sw = (65536.f / (4 * K + 2)) / sqrtf(s->a); | 202 | 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 | |||
| 223 | P += f[i]; | 236 | P += f[i]; |
| 224 | Q += 1; | 237 | Q += 1; |
| 225 | 238 | ||
| 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 | } | ||
| 227 | } | 244 | } |
| 228 | 245 | ||
| 229 | return 0; | 246 | return 0; |