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