diff options
author | Paul B Mahol <onemda@gmail.com> | 2023-04-25 15:42:44 +0200 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2023-04-25 21:22:15 +0200 |
commit | bee265e5d50a6d6057fb2cf77d55851b867a41d9 (patch) | |
tree | 4899e3bd62f5665297535f6131b81ee2bff69ff8 /libavfilter | |
parent | 1835f884b7ae475d2079d044003966981823502e (diff) | |
download | ffmpeg-bee265e5d50a6d6057fb2cf77d55851b867a41d9.tar.gz |
avfilter/af_afir: add way to control loading interval of impulses
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/af_afir.c | 45 | ||||
-rw-r--r-- | libavfilter/af_afir.h | 1 |
2 files changed, 29 insertions, 17 deletions
diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c index 338e23063c..24fb8c1abe 100644 --- a/libavfilter/af_afir.c +++ b/libavfilter/af_afir.c @@ -472,27 +472,35 @@ static int activate(AVFilterContext *ctx) FF_FILTER_FORWARD_STATUS_BACK_ALL(ctx->outputs[0], ctx); if (s->response) FF_FILTER_FORWARD_STATUS_BACK_ALL(ctx->outputs[1], ctx); - if (!s->eof_coeffs[s->selir]) { - ret = check_ir(ctx->inputs[1 + s->selir]); - if (ret < 0) - return ret; - if (ff_outlink_get_status(ctx->inputs[1 + s->selir]) == AVERROR_EOF) - s->eof_coeffs[s->selir] = 1; + for (int i = 0; i < s->nb_irs; i++) { + const int selir = i; - if (!s->eof_coeffs[s->selir]) { - if (ff_outlink_frame_wanted(ctx->outputs[0])) - ff_inlink_request_frame(ctx->inputs[1 + s->selir]); - else if (s->response && ff_outlink_frame_wanted(ctx->outputs[1])) - ff_inlink_request_frame(ctx->inputs[1 + s->selir]); - return 0; + if (s->ir_load && selir != s->selir) + continue; + + if (!s->eof_coeffs[selir]) { + ret = check_ir(ctx->inputs[1 + selir]); + if (ret < 0) + return ret; + + if (ff_outlink_get_status(ctx->inputs[1 + selir]) == AVERROR_EOF) + s->eof_coeffs[selir] = 1; + + if (!s->eof_coeffs[selir]) { + if (ff_outlink_frame_wanted(ctx->outputs[0])) + ff_inlink_request_frame(ctx->inputs[1 + selir]); + else if (s->response && ff_outlink_frame_wanted(ctx->outputs[1])) + ff_inlink_request_frame(ctx->inputs[1 + selir]); + return 0; + } } - } - if (!s->have_coeffs[s->selir] && s->eof_coeffs[s->selir]) { - ret = convert_coeffs(ctx, s->selir); - if (ret < 0) - return ret; + if (!s->have_coeffs[selir] && s->eof_coeffs[selir]) { + ret = convert_coeffs(ctx, selir); + if (ret < 0) + return ret; + } } if (s->selir != s->prev_selir && s->loading[0] <= 0) { @@ -830,6 +838,9 @@ static const AVOption afir_options[] = { { "auto", "set auto processing precision", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, AF, "precision" }, { "float", "set single-floating point processing precision", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, AF, "precision" }, { "double","set double-floating point processing precision", 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, AF, "precision" }, + { "irload", "set IR loading type", OFFSET(ir_load), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, AF, "irload" }, + { "init", "load all IRs on init", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, AF, "irload" }, + { "access", "load IR on access", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, AF, "irload" }, { NULL } }; diff --git a/libavfilter/af_afir.h b/libavfilter/af_afir.h index 099897d0bb..7c9a3b3e31 100644 --- a/libavfilter/af_afir.h +++ b/libavfilter/af_afir.h @@ -65,6 +65,7 @@ typedef struct AudioFIRContext { int gtype; float ir_gain; int ir_format; + int ir_load; float max_ir_len; int response; int w, h; |