X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavfilter%2Faf_crossfeed.c;h=fb0a49ec871db37b3a85a9cc144a35f735cbecee;hb=ef02cf829082686442c4c9d594651a5d34f703ef;hp=cc2db70e628f0fae3fab8c40be9d2b85b9c0d7f4;hpb=35d6001815e1282c5babf71c71f1fd04b59e5440;p=ffmpeg diff --git a/libavfilter/af_crossfeed.c b/libavfilter/af_crossfeed.c index cc2db70e628..fb0a49ec871 100644 --- a/libavfilter/af_crossfeed.c +++ b/libavfilter/af_crossfeed.c @@ -35,8 +35,7 @@ typedef struct CrossfeedContext { double a0, a1, a2; double b0, b1, b2; - double i1, i2; - double o1, o2; + double w1, w2; } CrossfeedContext; static int query_formats(AVFilterContext *ctx) @@ -92,8 +91,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) const double b0 = s->b0; const double b1 = s->b1; const double b2 = s->b2; - const double a1 = s->a1; - const double a2 = s->a2; + const double a1 = -s->a1; + const double a2 = -s->a2; AVFrame *out; double *dst; int n; @@ -113,12 +112,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) for (n = 0; n < out->nb_samples; n++, src += 2, dst += 2) { double mid = (src[0] + src[1]) * level_in * .5; double side = (src[0] - src[1]) * level_in * .5; - double oside = side * b0 + s->i1 * b1 + s->i2 * b2 - s->o1 * a1 - s->o2 * a2; + double oside = side * b0 + s->w1; - s->i2 = s->i1; - s->i1 = side; - s->o2 = s->o1; - s->o1 = oside; + s->w1 = b1 * side + s->w2 + a1 * oside; + s->w2 = b2 * side + a2 * oside; if (ctx->is_disabled) { dst[0] = src[0]; @@ -134,8 +131,20 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) return ff_filter_frame(outlink, out); } +static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, + char *res, int res_len, int flags) +{ + int ret; + + ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags); + if (ret < 0) + return ret; + + return config_input(ctx->inputs[0]); +} + #define OFFSET(x) offsetof(CrossfeedContext, x) -#define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM +#define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM static const AVOption crossfeed_options[] = { { "strength", "set crossfeed strength", OFFSET(strength), AV_OPT_TYPE_DOUBLE, {.dbl=.2}, 0, 1, FLAGS }, @@ -175,4 +184,5 @@ AVFilter ff_af_crossfeed = { .inputs = inputs, .outputs = outputs, .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL, + .process_command = process_command, };