History

avfilter/af_afftdn: simplify changing commands

Paul B Mahol committed 6 years ago

Commit 84e9a551 parent 8e2a8321 file · +23 −41Browse files

Unified · Split

libavfilter/af_afftdn.c+23−41
@@ -141,24 +141,25 @@ typedef struct AudioFFTDeNoiseContext { · 140 unmodified lines
141} AudioFFTDeNoiseContext;141} AudioFFTDeNoiseContext;
142 142
143#define OFFSET(x) offsetof(AudioFFTDeNoiseContext, x)143#define OFFSET(x) offsetof(AudioFFTDeNoiseContext, x)
144#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM144#define AF AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
145#define AFR AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
145 146
146static const AVOption afftdn_options[] = {147static const AVOption afftdn_options[] = {
147 { "nr", "set the noise reduction", OFFSET(noise_reduction), AV_OPT_TYPE_FLOAT, {.dbl = 12}, .01, 97, A },148 { "nr", "set the noise reduction", OFFSET(noise_reduction), AV_OPT_TYPE_FLOAT, {.dbl = 12}, .01, 97, AFR },
148 { "nf", "set the noise floor", OFFSET(noise_floor), AV_OPT_TYPE_FLOAT, {.dbl =-50}, -80,-20, A },149 { "nf", "set the noise floor", OFFSET(noise_floor), AV_OPT_TYPE_FLOAT, {.dbl =-50}, -80,-20, AFR },
149 { "nt", "set the noise type", OFFSET(noise_type), AV_OPT_TYPE_INT, {.i64 = WHITE_NOISE}, WHITE_NOISE, NB_NOISE-1, A, "type" },150 { "nt", "set the noise type", OFFSET(noise_type), AV_OPT_TYPE_INT, {.i64 = WHITE_NOISE}, WHITE_NOISE, NB_NOISE-1, AF, "type" },
150 { "w", "white noise", 0, AV_OPT_TYPE_CONST, {.i64 = WHITE_NOISE}, 0, 0, A, "type" },151 { "w", "white noise", 0, AV_OPT_TYPE_CONST, {.i64 = WHITE_NOISE}, 0, 0, AF, "type" },
151 { "v", "vinyl noise", 0, AV_OPT_TYPE_CONST, {.i64 = VINYL_NOISE}, 0, 0, A, "type" },152 { "v", "vinyl noise", 0, AV_OPT_TYPE_CONST, {.i64 = VINYL_NOISE}, 0, 0, AF, "type" },
152 { "s", "shellac noise", 0, AV_OPT_TYPE_CONST, {.i64 = SHELLAC_NOISE}, 0, 0, A, "type" },153 { "s", "shellac noise", 0, AV_OPT_TYPE_CONST, {.i64 = SHELLAC_NOISE}, 0, 0, AF, "type" },
153 { "c", "custom noise", 0, AV_OPT_TYPE_CONST, {.i64 = CUSTOM_NOISE}, 0, 0, A, "type" },154 { "c", "custom noise", 0, AV_OPT_TYPE_CONST, {.i64 = CUSTOM_NOISE}, 0, 0, AF, "type" },
154 { "bn", "set the custom bands noise", OFFSET(band_noise_str), AV_OPT_TYPE_STRING, {.str = 0}, 0, 0, A },155 { "bn", "set the custom bands noise", OFFSET(band_noise_str), AV_OPT_TYPE_STRING, {.str = 0}, 0, 0, AF },
155 { "rf", "set the residual floor", OFFSET(residual_floor), AV_OPT_TYPE_FLOAT, {.dbl =-38}, -80,-20, A },156 { "rf", "set the residual floor", OFFSET(residual_floor), AV_OPT_TYPE_FLOAT, {.dbl =-38}, -80,-20, AFR },
156 { "tn", "track noise", OFFSET(track_noise), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, A },157 { "tn", "track noise", OFFSET(track_noise), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, AFR },
157 { "tr", "track residual", OFFSET(track_residual), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, A },158 { "tr", "track residual", OFFSET(track_residual), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, AFR },
158 { "om", "set output mode", OFFSET(output_mode), AV_OPT_TYPE_INT, {.i64 = OUT_MODE}, 0, NB_MODES-1, A, "mode" },159 { "om", "set output mode", OFFSET(output_mode), AV_OPT_TYPE_INT, {.i64 = OUT_MODE}, 0, NB_MODES-1, AFR, "mode" },
159 { "i", "input", 0, AV_OPT_TYPE_CONST, {.i64 = IN_MODE}, 0, 0, A, "mode" },160 { "i", "input", 0, AV_OPT_TYPE_CONST, {.i64 = IN_MODE}, 0, 0, AFR, "mode" },
160 { "o", "output", 0, AV_OPT_TYPE_CONST, {.i64 = OUT_MODE}, 0, 0, A, "mode" },161 { "o", "output", 0, AV_OPT_TYPE_CONST, {.i64 = OUT_MODE}, 0, 0, AFR, "mode" },
161 { "n", "noise", 0, AV_OPT_TYPE_CONST, {.i64 = NOISE_MODE}, 0, 0, A, "mode" },162 { "n", "noise", 0, AV_OPT_TYPE_CONST, {.i64 = NOISE_MODE}, 0, 0, AFR, "mode" },
162 { NULL }163 { NULL }
163};164};
164 165
@@ -1375,6 +1376,7 @@ static int process_command(AVFilterContext *ctx, const char *cmd, const char *ar · 1210 unmodified lines
1375{1376{
1376 AudioFFTDeNoiseContext *s = ctx->priv;1377 AudioFFTDeNoiseContext *s = ctx->priv;
1377 int need_reset = 0;1378 int need_reset = 0;
1379 int ret = 0;
1378 1380
1379 if (!strcmp(cmd, "sample_noise") ||1381 if (!strcmp(cmd, "sample_noise") ||
1380 !strcmp(cmd, "sn")) {1382 !strcmp(cmd, "sn")) {
@@ -1386,31 +1388,11 @@ static int process_command(AVFilterContext *ctx, const char *cmd, const char *ar · 5 unmodified lines
1386 s->sample_noise_start = 0;1388 s->sample_noise_start = 0;
1387 s->sample_noise_end = 1;1389 s->sample_noise_end = 1;
1388 }1390 }
1389 } else if (!strcmp(cmd, "nr") ||1391 } else {
1390 !strcmp(cmd, "noise_reduction")) {1392 ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
1391 float nr;1393 if (ret < 0)
1392 1394 return ret;
1393 if (av_sscanf(args, "%f", &nr) == 1) {1395 need_reset = 1;
1394 s->noise_reduction = av_clipf(nr, 0.01, 97);
1395 need_reset = 1;
1396 }
1397 } else if (!strcmp(cmd, "nf") ||
1398 !strcmp(cmd, "noise_floor")) {
1399 float nf;
1400
1401 if (av_sscanf(args, "%f", &nf) == 1) {
1402 s->noise_floor = av_clipf(nf, -80, -20);
1403 need_reset = 1;
1404 }
1405 } else if (!strcmp(cmd, "output_mode") ||
1406 !strcmp(cmd, "om")) {
1407 if (!strcmp(args, "i")) {
1408 s->output_mode = IN_MODE;
1409 } else if (!strcmp(args, "o")) {
1410 s->output_mode = OUT_MODE;
1411 } else if (!strcmp(args, "n")) {
1412 s->output_mode = NOISE_MODE;
1413 }
1414 }1396 }
1415 1397
1416 if (need_reset)1398 if (need_reset)

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