double a0, a1, a2;
double b0, b1, b2;
- double i1, i2;
- double o1, o2;
+ double w1, w2;
} CrossfeedContext;
static int query_formats(AVFilterContext *ctx)
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;
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];
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 },
{ NULL }
};
-AVFilter ff_af_crossfeed = {
+const AVFilter ff_af_crossfeed = {
.name = "crossfeed",
.description = NULL_IF_CONFIG_SMALL("Apply headphone crossfeed filter."),
.query_formats = query_formats,
.inputs = inputs,
.outputs = outputs,
.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL,
+ .process_command = process_command,
};