]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/af_acrossover.c
avfilter: Constify all AVFilters
[ffmpeg] / libavfilter / af_acrossover.c
index 33a0812c9f160836aadbd509ad3b4c31672b9e90..3ba67b30e170d79083ebd160bae9937de5477336 100644 (file)
@@ -27,6 +27,7 @@
 #include "libavutil/avstring.h"
 #include "libavutil/channel_layout.h"
 #include "libavutil/eval.h"
+#include "libavutil/float_dsp.h"
 #include "libavutil/internal.h"
 #include "libavutil/opt.h"
 
 #define MAX_SPLITS 16
 #define MAX_BANDS MAX_SPLITS + 1
 
-typedef struct BiquadContext {
-    double b0, b1, b2;
-    double a1, a2;
-    double z1, z2;
-} BiquadContext;
+#define B0 0
+#define B1 1
+#define B2 2
+#define A1 3
+#define A2 4
 
-typedef struct CrossoverChannel {
-    BiquadContext lp[MAX_BANDS][20];
-    BiquadContext hp[MAX_BANDS][20];
-    BiquadContext ap[MAX_BANDS][MAX_BANDS][20];
-} CrossoverChannel;
+typedef struct BiquadCoeffs {
+    double cd[5];
+    float cf[5];
+} BiquadCoeffs;
 
 typedef struct AudioCrossoverContext {
     const AVClass *class;
 
     char *splits_str;
+    char *gains_str;
     int order_opt;
+    float level_in;
 
     int order;
     int filter_count;
     int first_order;
     int ap_filter_count;
     int nb_splits;
-    float *splits;
+    float splits[MAX_SPLITS];
 
-    CrossoverChannel *xover;
+    float gains[MAX_BANDS];
+
+    BiquadCoeffs lp[MAX_BANDS][20];
+    BiquadCoeffs hp[MAX_BANDS][20];
+    BiquadCoeffs ap[MAX_BANDS][20];
+
+    AVFrame *xover;
 
     AVFrame *input_frame;
     AVFrame *frames[MAX_BANDS];
 
     int (*filter_channels)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs);
+
+    AVFloatDSPContext *fdsp;
 } AudioCrossoverContext;
 
 #define OFFSET(x) offsetof(AudioCrossoverContext, x)
@@ -76,30 +86,67 @@ typedef struct AudioCrossoverContext {
 
 static const AVOption acrossover_options[] = {
     { "split", "set split frequencies", OFFSET(splits_str), AV_OPT_TYPE_STRING, {.str="500"}, 0, 0, AF },
-    { "order", "set order",             OFFSET(order_opt),  AV_OPT_TYPE_INT,    {.i64=1},     0, 9, AF, "m" },
-    { "2nd",   "2nd order",             0,                  AV_OPT_TYPE_CONST,  {.i64=0},     0, 0, AF, "m" },
-    { "4th",   "4th order",             0,                  AV_OPT_TYPE_CONST,  {.i64=1},     0, 0, AF, "m" },
-    { "6th",   "6th order",             0,                  AV_OPT_TYPE_CONST,  {.i64=2},     0, 0, AF, "m" },
-    { "8th",   "8th order",             0,                  AV_OPT_TYPE_CONST,  {.i64=3},     0, 0, AF, "m" },
-    { "10th",  "10th order",            0,                  AV_OPT_TYPE_CONST,  {.i64=4},     0, 0, AF, "m" },
-    { "12th",  "12th order",            0,                  AV_OPT_TYPE_CONST,  {.i64=5},     0, 0, AF, "m" },
-    { "14th",  "14th order",            0,                  AV_OPT_TYPE_CONST,  {.i64=6},     0, 0, AF, "m" },
-    { "16th",  "16th order",            0,                  AV_OPT_TYPE_CONST,  {.i64=7},     0, 0, AF, "m" },
-    { "18th",  "18th order",            0,                  AV_OPT_TYPE_CONST,  {.i64=8},     0, 0, AF, "m" },
-    { "20th",  "20th order",            0,                  AV_OPT_TYPE_CONST,  {.i64=9},     0, 0, AF, "m" },
+    { "order", "set filter order",      OFFSET(order_opt),  AV_OPT_TYPE_INT,    {.i64=1},     0, 9, AF, "m" },
+    { "2nd",   "2nd order (12 dB/8ve)", 0,                  AV_OPT_TYPE_CONST,  {.i64=0},     0, 0, AF, "m" },
+    { "4th",   "4th order (24 dB/8ve)", 0,                  AV_OPT_TYPE_CONST,  {.i64=1},     0, 0, AF, "m" },
+    { "6th",   "6th order (36 dB/8ve)", 0,                  AV_OPT_TYPE_CONST,  {.i64=2},     0, 0, AF, "m" },
+    { "8th",   "8th order (48 dB/8ve)", 0,                  AV_OPT_TYPE_CONST,  {.i64=3},     0, 0, AF, "m" },
+    { "10th",  "10th order (60 dB/8ve)",0,                  AV_OPT_TYPE_CONST,  {.i64=4},     0, 0, AF, "m" },
+    { "12th",  "12th order (72 dB/8ve)",0,                  AV_OPT_TYPE_CONST,  {.i64=5},     0, 0, AF, "m" },
+    { "14th",  "14th order (84 dB/8ve)",0,                  AV_OPT_TYPE_CONST,  {.i64=6},     0, 0, AF, "m" },
+    { "16th",  "16th order (96 dB/8ve)",0,                  AV_OPT_TYPE_CONST,  {.i64=7},     0, 0, AF, "m" },
+    { "18th",  "18th order (108 dB/8ve)",0,                 AV_OPT_TYPE_CONST,  {.i64=8},     0, 0, AF, "m" },
+    { "20th",  "20th order (120 dB/8ve)",0,                 AV_OPT_TYPE_CONST,  {.i64=9},     0, 0, AF, "m" },
+    { "level", "set input gain",        OFFSET(level_in),   AV_OPT_TYPE_FLOAT,  {.dbl=1},     0, 1, AF },
+    { "gain",  "set output bands gain", OFFSET(gains_str),  AV_OPT_TYPE_STRING, {.str="1.f"}, 0, 0, AF },
     { NULL }
 };
 
 AVFILTER_DEFINE_CLASS(acrossover);
 
+static int parse_gains(AVFilterContext *ctx)
+{
+    AudioCrossoverContext *s = ctx->priv;
+    char *p, *arg, *saveptr = NULL;
+    int i, ret = 0;
+
+    saveptr = NULL;
+    p = s->gains_str;
+    for (i = 0; i < MAX_BANDS; i++) {
+        float gain;
+        char c[3] = { 0 };
+
+        if (!(arg = av_strtok(p, " |", &saveptr)))
+            break;
+
+        p = NULL;
+
+        if (av_sscanf(arg, "%f%2s", &gain, c) < 1) {
+            av_log(ctx, AV_LOG_ERROR, "Invalid syntax for gain[%d].\n", i);
+            ret = AVERROR(EINVAL);
+            break;
+        }
+
+        if (c[0] == 'd' && c[1] == 'B')
+            s->gains[i] = expf(gain * M_LN10 / 20.f);
+        else
+            s->gains[i] = gain;
+    }
+
+    for (; i < MAX_BANDS; i++)
+        s->gains[i] = 1.f;
+
+    return ret;
+}
+
 static av_cold int init(AVFilterContext *ctx)
 {
     AudioCrossoverContext *s = ctx->priv;
     char *p, *arg, *saveptr = NULL;
     int i, ret = 0;
 
-    s->splits = av_calloc(MAX_SPLITS, sizeof(*s->splits));
-    if (!s->splits)
+    s->fdsp = avpriv_float_dsp_alloc(0);
+    if (!s->fdsp)
         return AVERROR(ENOMEM);
 
     p = s->splits_str;
@@ -130,6 +177,10 @@ static av_cold int init(AVFilterContext *ctx)
 
     s->nb_splits = i;
 
+    ret = parse_gains(ctx);
+    if (ret < 0)
+        return ret;
+
     for (i = 0; i <= s->nb_splits; i++) {
         AVFilterPad pad  = { 0 };
         char *name;
@@ -149,9 +200,9 @@ static av_cold int init(AVFilterContext *ctx)
     return ret;
 }
 
-static void set_lp(BiquadContext *b, double fc, double q, double sr)
+static void set_lp(BiquadCoeffs *b, double fc, double q, double sr)
 {
-    double omega = M_PI * fc / sr;
+    double omega = 2. * M_PI * fc / sr;
     double cosine = cos(omega);
     double alpha = sin(omega) / (2. * q);
 
@@ -162,16 +213,22 @@ static void set_lp(BiquadContext *b, double fc, double q, double sr)
     double a1 = -2. * cosine;
     double a2 = 1. - alpha;
 
-    b->b0 =  b0 / a0;
-    b->b1 =  b1 / a0;
-    b->b2 =  b2 / a0;
-    b->a1 = -a1 / a0;
-    b->a2 = -a2 / a0;
+    b->cd[B0] =  b0 / a0;
+    b->cd[B1] =  b1 / a0;
+    b->cd[B2] =  b2 / a0;
+    b->cd[A1] = -a1 / a0;
+    b->cd[A2] = -a2 / a0;
+
+    b->cf[B0] = b->cd[B0];
+    b->cf[B1] = b->cd[B1];
+    b->cf[B2] = b->cd[B2];
+    b->cf[A1] = b->cd[A1];
+    b->cf[A2] = b->cd[A2];
 }
 
-static void set_hp(BiquadContext *b, double fc, double q, double sr)
+static void set_hp(BiquadCoeffs *b, double fc, double q, double sr)
 {
-    double omega = M_PI * fc / sr;
+    double omega = 2. * M_PI * fc / sr;
     double cosine = cos(omega);
     double alpha = sin(omega) / (2. * q);
 
@@ -182,16 +239,22 @@ static void set_hp(BiquadContext *b, double fc, double q, double sr)
     double a1 = -2. * cosine;
     double a2 = 1. - alpha;
 
-    b->b0 =  b0 / a0;
-    b->b1 =  b1 / a0;
-    b->b2 =  b2 / a0;
-    b->a1 = -a1 / a0;
-    b->a2 = -a2 / a0;
+    b->cd[B0] =  b0 / a0;
+    b->cd[B1] =  b1 / a0;
+    b->cd[B2] =  b2 / a0;
+    b->cd[A1] = -a1 / a0;
+    b->cd[A2] = -a2 / a0;
+
+    b->cf[B0] = b->cd[B0];
+    b->cf[B1] = b->cd[B1];
+    b->cf[B2] = b->cd[B2];
+    b->cf[A1] = b->cd[A1];
+    b->cf[A2] = b->cd[A2];
 }
 
-static void set_ap(BiquadContext *b, double fc, double q, double sr)
+static void set_ap(BiquadCoeffs *b, double fc, double q, double sr)
 {
-    double omega = M_PI * fc / sr;
+    double omega = 2. * M_PI * fc / sr;
     double cosine = cos(omega);
     double alpha = sin(omega) / (2. * q);
 
@@ -202,22 +265,34 @@ static void set_ap(BiquadContext *b, double fc, double q, double sr)
     double b1 = a1;
     double b2 = a0;
 
-    b->b0 =  b0 / a0;
-    b->b1 =  b1 / a0;
-    b->b2 =  b2 / a0;
-    b->a1 = -a1 / a0;
-    b->a2 = -a2 / a0;
+    b->cd[B0] =  b0 / a0;
+    b->cd[B1] =  b1 / a0;
+    b->cd[B2] =  b2 / a0;
+    b->cd[A1] = -a1 / a0;
+    b->cd[A2] = -a2 / a0;
+
+    b->cf[B0] = b->cd[B0];
+    b->cf[B1] = b->cd[B1];
+    b->cf[B2] = b->cd[B2];
+    b->cf[A1] = b->cd[A1];
+    b->cf[A2] = b->cd[A2];
 }
 
-static void set_ap1(BiquadContext *b, double fc, double sr)
+static void set_ap1(BiquadCoeffs *b, double fc, double sr)
 {
-    double omega = M_PI * fc / sr;
-
-    b->a1 = exp(-omega);
-    b->a2 = 0.;
-    b->b0 = -b->a1;
-    b->b1 = 1.;
-    b->b2 = 0.;
+    double omega = 2. * M_PI * fc / sr;
+
+    b->cd[A1] = exp(-omega);
+    b->cd[A2] = 0.;
+    b->cd[B0] = -b->cd[A1];
+    b->cd[B1] = 1.;
+    b->cd[B2] = 0.;
+
+    b->cf[B0] = b->cd[B0];
+    b->cf[B1] = b->cd[B1];
+    b->cf[B2] = b->cd[B2];
+    b->cf[A1] = b->cd[A1];
+    b->cf[A2] = b->cd[A2];
 }
 
 static void calc_q_factors(int order, double *q)
@@ -259,19 +334,38 @@ static int query_formats(AVFilterContext *ctx)
 }
 
 #define BIQUAD_PROCESS(name, type)                             \
-static void biquad_process_## name(BiquadContext *b,           \
+static void biquad_process_## name(const type *const c,        \
+                                   type *b,                    \
                                    type *dst, const type *src, \
                                    int nb_samples)             \
 {                                                              \
-    const type b0 = b->b0;                                     \
-    const type b1 = b->b1;                                     \
-    const type b2 = b->b2;                                     \
-    const type a1 = b->a1;                                     \
-    const type a2 = b->a2;                                     \
-    type z1 = b->z1;                                           \
-    type z2 = b->z2;                                           \
+    const type b0 = c[B0];                                     \
+    const type b1 = c[B1];                                     \
+    const type b2 = c[B2];                                     \
+    const type a1 = c[A1];                                     \
+    const type a2 = c[A2];                                     \
+    type z1 = b[0];                                            \
+    type z2 = b[1];                                            \
+                                                               \
+    for (int n = 0; n + 1 < nb_samples; n++) {                 \
+        type in = src[n];                                      \
+        type out;                                              \
                                                                \
-    for (int n = 0; n < nb_samples; n++) {                     \
+        out = in * b0 + z1;                                    \
+        z1 = b1 * in + z2 + a1 * out;                          \
+        z2 = b2 * in + a2 * out;                               \
+        dst[n] = out;                                          \
+                                                               \
+        n++;                                                   \
+        in = src[n];                                           \
+        out = in * b0 + z1;                                    \
+        z1 = b1 * in + z2 + a1 * out;                          \
+        z2 = b2 * in + a2 * out;                               \
+        dst[n] = out;                                          \
+    }                                                          \
+                                                               \
+    if (nb_samples & 1) {                                      \
+        const int n = nb_samples - 1;                          \
         const type in = src[n];                                \
         type out;                                              \
                                                                \
@@ -281,14 +375,14 @@ static void biquad_process_## name(BiquadContext *b,           \
         dst[n] = out;                                          \
     }                                                          \
                                                                \
-    b->z1 = z1;                                                \
-    b->z2 = z2;                                                \
+    b[0] = z1;                                                 \
+    b[1] = z2;                                                 \
 }
 
 BIQUAD_PROCESS(fltp, float)
 BIQUAD_PROCESS(dblp, double)
 
-#define XOVER_PROCESS(name, type, one)                         \
+#define XOVER_PROCESS(name, type, one, ff)                                                  \
 static int filter_channels_## name(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) \
 {                                                                                           \
     AudioCrossoverContext *s = ctx->priv;                                                   \
@@ -297,64 +391,71 @@ static int filter_channels_## name(AVFilterContext *ctx, void *arg, int jobnr, i
     const int start = (in->channels * jobnr) / nb_jobs;                                     \
     const int end = (in->channels * (jobnr+1)) / nb_jobs;                                   \
     const int nb_samples = in->nb_samples;                                                  \
+    const int nb_outs = ctx->nb_outputs;                                                    \
+    const int first_order = s->first_order;                                                 \
                                                                                             \
     for (int ch = start; ch < end; ch++) {                                                  \
-        CrossoverChannel *xover = &s->xover[ch];                                            \
+        const type *src = (const type *)in->extended_data[ch];                              \
+        type *xover = (type *)s->xover->extended_data[ch];                                  \
+                                                                                            \
+        s->fdsp->vector_## ff ##mul_scalar((type *)frames[0]->extended_data[ch], src,       \
+                                    s->level_in, FFALIGN(nb_samples, sizeof(type)));        \
                                                                                             \
-        for (int band = 0; band < ctx->nb_outputs; band++) {                                \
-            for (int f = 0; band + 1 < ctx->nb_outputs && f < s->filter_count; f++) {       \
-                const type *src = (const type *)in->extended_data[ch];                      \
+        for (int band = 0; band < nb_outs; band++) {                                        \
+            for (int f = 0; band + 1 < nb_outs && f < s->filter_count; f++) {               \
                 const type *prv = (const type *)frames[band]->extended_data[ch];            \
                 type *dst = (type *)frames[band + 1]->extended_data[ch];                    \
-                const type *hsrc = (band == 0 && f == 0) ? src : f == 0 ? prv : dst;        \
-                BiquadContext *hp = &xover->hp[band][f];                                    \
+                const type *hsrc = f == 0 ? prv : dst;                                      \
+                type *hp = xover + nb_outs * 20 + band * 20 + f * 2;                        \
+                const type *const hpc = (type *)&s->hp[band][f].c ## ff;                    \
                                                                                             \
-                biquad_process_## name(hp, dst, hsrc, nb_samples);                          \
+                biquad_process_## name(hpc, hp, dst, hsrc, nb_samples);                     \
             }                                                                               \
                                                                                             \
-            for (int f = 0; band + 1 < ctx->nb_outputs && f < s->filter_count; f++) {       \
-                const type *src = (const type *)in->extended_data[ch];                      \
+            for (int f = 0; band + 1 < nb_outs && f < s->filter_count; f++) {               \
                 type *dst = (type *)frames[band]->extended_data[ch];                        \
-                const type *lsrc = (band == 0 && f == 0) ? src : dst;                       \
-                BiquadContext *lp = &xover->lp[band][f];                                    \
+                const type *lsrc = dst;                                                     \
+                type *lp = xover + band * 20 + f * 2;                                       \
+                const type *const lpc = (type *)&s->lp[band][f].c ## ff;                    \
                                                                                             \
-                biquad_process_## name(lp, dst, lsrc, nb_samples);                          \
+                biquad_process_## name(lpc, lp, dst, lsrc, nb_samples);                     \
             }                                                                               \
                                                                                             \
-            for (int aband = band + 1; aband + 1 < ctx->nb_outputs; aband++) {              \
-                if (s->first_order) {                                                       \
+            for (int aband = band + 1; aband + 1 < nb_outs; aband++) {                      \
+                if (first_order) {                                                          \
                     const type *asrc = (const type *)frames[band]->extended_data[ch];       \
                     type *dst = (type *)frames[band]->extended_data[ch];                    \
-                    BiquadContext *ap = &xover->ap[band][aband][0];                         \
+                    type *ap = xover + nb_outs * 40 + (aband * nb_outs + band) * 20;        \
+                    const type *const apc = (type *)&s->ap[aband][0].c ## ff;               \
                                                                                             \
-                    biquad_process_## name(ap, dst, asrc, nb_samples);                      \
+                    biquad_process_## name(apc, ap, dst, asrc, nb_samples);                 \
                 }                                                                           \
                                                                                             \
-                for (int f = s->first_order; f < s->ap_filter_count; f++) {                 \
+                for (int f = first_order; f < s->ap_filter_count; f++) {                    \
                     const type *asrc = (const type *)frames[band]->extended_data[ch];       \
                     type *dst = (type *)frames[band]->extended_data[ch];                    \
-                    BiquadContext *ap = &xover->ap[band][aband][f];                         \
+                    type *ap = xover + nb_outs * 40 + (aband * nb_outs + band) * 20 + f * 2;\
+                    const type *const apc = (type *)&s->ap[aband][f].c ## ff;               \
                                                                                             \
-                    biquad_process_## name(ap, dst, asrc, nb_samples);                      \
+                    biquad_process_## name(apc, ap, dst, asrc, nb_samples);                 \
                 }                                                                           \
             }                                                                               \
         }                                                                                   \
                                                                                             \
-        for (int band = 0; band < ctx->nb_outputs && s->first_order; band++) {              \
-            if (band & 1) {                                                                 \
-                type *dst = (type *)frames[band]->extended_data[ch];                        \
+        for (int band = 0; band < nb_outs; band++) {                                        \
+            const type gain = s->gains[band] * ((band & 1 && first_order) ? -one : one);    \
+            type *dst = (type *)frames[band]->extended_data[ch];                            \
                                                                                             \
-                for (int n = 0; n < nb_samples; n++)                                        \
-                    dst[n] *= -one;                                                         \
-            }                                                                               \
+            s->fdsp->vector_## ff ##mul_scalar(dst, dst, gain,                              \
+                                               FFALIGN(nb_samples, sizeof(type)));          \
         }                                                                                   \
     }                                                                                       \
                                                                                             \
     return 0;                                                                               \
 }
 
-XOVER_PROCESS(fltp, float, 1.f)
-XOVER_PROCESS(dblp, double, 1.0)
+XOVER_PROCESS(fltp, float, 1.f, f)
+XOVER_PROCESS(dblp, double, 1.0, d)
 
 static int config_input(AVFilterLink *inlink)
 {
@@ -363,39 +464,32 @@ static int config_input(AVFilterLink *inlink)
     int sample_rate = inlink->sample_rate;
     double q[16];
 
-    s->xover = av_calloc(inlink->channels, sizeof(*s->xover));
-    if (!s->xover)
-        return AVERROR(ENOMEM);
-
     s->order = (s->order_opt + 1) * 2;
     s->filter_count = s->order / 2;
     s->first_order = s->filter_count & 1;
     s->ap_filter_count = s->filter_count / 2 + s->first_order;
     calc_q_factors(s->order, q);
 
-    for (int ch = 0; ch < inlink->channels; ch++) {
-        for (int band = 0; band <= s->nb_splits; band++) {
-            if (s->first_order) {
-                set_lp(&s->xover[ch].lp[band][0], s->splits[band], 0.5, sample_rate);
-                set_hp(&s->xover[ch].hp[band][0], s->splits[band], 0.5, sample_rate);
-            }
+    for (int band = 0; band <= s->nb_splits; band++) {
+        if (s->first_order) {
+            set_lp(&s->lp[band][0], s->splits[band], 0.5, sample_rate);
+            set_hp(&s->hp[band][0], s->splits[band], 0.5, sample_rate);
+        }
 
-            for (int n = s->first_order; n < s->filter_count; n++) {
-                const int idx = s->filter_count / 2 - ((n + s->first_order) / 2 - s->first_order) - 1;
+        for (int n = s->first_order; n < s->filter_count; n++) {
+            const int idx = s->filter_count / 2 - ((n + s->first_order) / 2 - s->first_order) - 1;
 
-                set_lp(&s->xover[ch].lp[band][n], s->splits[band], q[idx], sample_rate);
-                set_hp(&s->xover[ch].hp[band][n], s->splits[band], q[idx], sample_rate);
-            }
+            set_lp(&s->lp[band][n], s->splits[band], q[idx], sample_rate);
+            set_hp(&s->hp[band][n], s->splits[band], q[idx], sample_rate);
+        }
 
-            for (int x = 0; x <= s->nb_splits && s->first_order; x++)
-                set_ap1(&s->xover[ch].ap[x][band][0], s->splits[band], sample_rate);
+        if (s->first_order)
+            set_ap1(&s->ap[band][0], s->splits[band], sample_rate);
 
-            for (int n = s->first_order; n < s->ap_filter_count; n++) {
-                const int idx = (s->filter_count / 2 - ((n * 2 + s->first_order) / 2 - s->first_order) - 1);
+        for (int n = s->first_order; n < s->ap_filter_count; n++) {
+            const int idx = (s->filter_count / 2 - ((n * 2 + s->first_order) / 2 - s->first_order) - 1);
 
-                for (int x = 0; x <= s->nb_splits; x++)
-                    set_ap(&s->xover[ch].ap[x][band][n], s->splits[band], q[idx], sample_rate);
-            }
+            set_ap(&s->ap[band][n], s->splits[band], q[idx], sample_rate);
         }
     }
 
@@ -404,6 +498,11 @@ static int config_input(AVFilterLink *inlink)
     case AV_SAMPLE_FMT_DBLP: s->filter_channels = filter_channels_dblp; break;
     }
 
+    s->xover = ff_get_audio_buffer(inlink, 2 * (ctx->nb_outputs * 10 + ctx->nb_outputs * 10 +
+                                                ctx->nb_outputs * ctx->nb_outputs * 10));
+    if (!s->xover)
+        return AVERROR(ENOMEM);
+
     return 0;
 }
 
@@ -453,8 +552,8 @@ static av_cold void uninit(AVFilterContext *ctx)
     AudioCrossoverContext *s = ctx->priv;
     int i;
 
-    av_freep(&s->splits);
-    av_freep(&s->xover);
+    av_freep(&s->fdsp);
+    av_frame_free(&s->xover);
 
     for (i = 0; i < ctx->nb_outputs; i++)
         av_freep(&ctx->output_pads[i].name);
@@ -470,7 +569,7 @@ static const AVFilterPad inputs[] = {
     { NULL }
 };
 
-AVFilter ff_af_acrossover = {
+const AVFilter ff_af_acrossover = {
     .name           = "acrossover",
     .description    = NULL_IF_CONFIG_SMALL("Split audio into per-bands streams."),
     .priv_size      = sizeof(AudioCrossoverContext),