summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/filters.texi6
-rw-r--r--libavfilter/af_afir.c45
-rw-r--r--libavfilter/af_afir.h1
3 files changed, 35 insertions, 17 deletions
diff --git a/doc/filters.texi b/doc/filters.texi
index 120fe6664a..a7972ff736 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -1849,6 +1849,12 @@ Always use double-floating point precision sample format.
@end table
Default value is auto.
+
+@item irload
+Set when to load IR stream. Can be @code{init} or @code{access}.
+First one load and prepares all IRs on initialization, second one
+once on first access of specific IR.
+Default is @code{init}.
@end table
@subsection Examples
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;