]> git.sesse.net Git - ffmpeg/blob - libavfilter/af_biquads.c
avfilter/vf_bm3d: use boolean for ref option
[ffmpeg] / libavfilter / af_biquads.c
1 /*
2  * Copyright (c) 2013 Paul B Mahol
3  * Copyright (c) 2006-2008 Rob Sykes <robs@users.sourceforge.net>
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21
22 /*
23  * 2-pole filters designed by Robert Bristow-Johnson <rbj@audioimagination.com>
24  *   see http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt
25  *
26  * 1-pole filters based on code (c) 2000 Chris Bagwell <cbagwell@sprynet.com>
27  *   Algorithms: Recursive single pole low/high pass filter
28  *   Reference: The Scientist and Engineer's Guide to Digital Signal Processing
29  *
30  *   low-pass: output[N] = input[N] * A + output[N-1] * B
31  *     X = exp(-2.0 * pi * Fc)
32  *     A = 1 - X
33  *     B = X
34  *     Fc = cutoff freq / sample rate
35  *
36  *     Mimics an RC low-pass filter:
37  *
38  *     ---/\/\/\/\----------->
39  *                   |
40  *                  --- C
41  *                  ---
42  *                   |
43  *                   |
44  *                   V
45  *
46  *   high-pass: output[N] = A0 * input[N] + A1 * input[N-1] + B1 * output[N-1]
47  *     X  = exp(-2.0 * pi * Fc)
48  *     A0 = (1 + X) / 2
49  *     A1 = -(1 + X) / 2
50  *     B1 = X
51  *     Fc = cutoff freq / sample rate
52  *
53  *     Mimics an RC high-pass filter:
54  *
55  *         || C
56  *     ----||--------->
57  *         ||    |
58  *               <
59  *               > R
60  *               <
61  *               |
62  *               V
63  */
64
65 #include "libavutil/avassert.h"
66 #include "libavutil/ffmath.h"
67 #include "libavutil/opt.h"
68 #include "audio.h"
69 #include "avfilter.h"
70 #include "internal.h"
71
72 enum FilterType {
73     biquad,
74     equalizer,
75     bass,
76     treble,
77     bandpass,
78     bandreject,
79     allpass,
80     highpass,
81     lowpass,
82     lowshelf,
83     highshelf,
84 };
85
86 enum WidthType {
87     NONE,
88     HERTZ,
89     OCTAVE,
90     QFACTOR,
91     SLOPE,
92     KHERTZ,
93     NB_WTYPE,
94 };
95
96 typedef struct ChanCache {
97     double i1, i2;
98     double o1, o2;
99     int clippings;
100 } ChanCache;
101
102 typedef struct BiquadsContext {
103     const AVClass *class;
104
105     enum FilterType filter_type;
106     int width_type;
107     int poles;
108     int csg;
109
110     double gain;
111     double frequency;
112     double width;
113     double mix;
114     uint64_t channels;
115
116     double a0, a1, a2;
117     double b0, b1, b2;
118
119     ChanCache *cache;
120     int block_align;
121
122     void (*filter)(struct BiquadsContext *s, const void *ibuf, void *obuf, int len,
123                    double *i1, double *i2, double *o1, double *o2,
124                    double b0, double b1, double b2, double a1, double a2, int *clippings,
125                    int disabled);
126 } BiquadsContext;
127
128 static av_cold int init(AVFilterContext *ctx)
129 {
130     BiquadsContext *s = ctx->priv;
131
132     if (s->filter_type != biquad) {
133         if (s->frequency <= 0 || s->width <= 0) {
134             av_log(ctx, AV_LOG_ERROR, "Invalid frequency %f and/or width %f <= 0\n",
135                    s->frequency, s->width);
136             return AVERROR(EINVAL);
137         }
138     }
139
140     return 0;
141 }
142
143 static int query_formats(AVFilterContext *ctx)
144 {
145     AVFilterFormats *formats;
146     AVFilterChannelLayouts *layouts;
147     static const enum AVSampleFormat sample_fmts[] = {
148         AV_SAMPLE_FMT_S16P,
149         AV_SAMPLE_FMT_S32P,
150         AV_SAMPLE_FMT_FLTP,
151         AV_SAMPLE_FMT_DBLP,
152         AV_SAMPLE_FMT_NONE
153     };
154     int ret;
155
156     layouts = ff_all_channel_counts();
157     if (!layouts)
158         return AVERROR(ENOMEM);
159     ret = ff_set_common_channel_layouts(ctx, layouts);
160     if (ret < 0)
161         return ret;
162
163     formats = ff_make_format_list(sample_fmts);
164     if (!formats)
165         return AVERROR(ENOMEM);
166     ret = ff_set_common_formats(ctx, formats);
167     if (ret < 0)
168         return ret;
169
170     formats = ff_all_samplerates();
171     if (!formats)
172         return AVERROR(ENOMEM);
173     return ff_set_common_samplerates(ctx, formats);
174 }
175
176 #define BIQUAD_FILTER(name, type, min, max, need_clipping)                    \
177 static void biquad_## name (BiquadsContext *s,                                \
178                             const void *input, void *output, int len,         \
179                             double *in1, double *in2,                         \
180                             double *out1, double *out2,                       \
181                             double b0, double b1, double b2,                  \
182                             double a1, double a2, int *clippings,             \
183                             int disabled)                                     \
184 {                                                                             \
185     const type *ibuf = input;                                                 \
186     type *obuf = output;                                                      \
187     double i1 = *in1;                                                         \
188     double i2 = *in2;                                                         \
189     double o1 = *out1;                                                        \
190     double o2 = *out2;                                                        \
191     double wet = s->mix;                                                      \
192     double dry = 1. - wet;                                                    \
193     double out;                                                               \
194     int i;                                                                    \
195     a1 = -a1;                                                                 \
196     a2 = -a2;                                                                 \
197                                                                               \
198     for (i = 0; i+1 < len; i++) {                                             \
199         o2 = i2 * b2 + i1 * b1 + ibuf[i] * b0 + o2 * a2 + o1 * a1;            \
200         i2 = ibuf[i];                                                         \
201         out = o2 * wet + i2 * dry;                                            \
202         if (disabled) {                                                       \
203             obuf[i] = i2;                                                     \
204         } else if (need_clipping && out < min) {                              \
205             (*clippings)++;                                                   \
206             obuf[i] = min;                                                    \
207         } else if (need_clipping && out > max) {                              \
208             (*clippings)++;                                                   \
209             obuf[i] = max;                                                    \
210         } else {                                                              \
211             obuf[i] = out;                                                    \
212         }                                                                     \
213         i++;                                                                  \
214         o1 = i1 * b2 + i2 * b1 + ibuf[i] * b0 + o1 * a2 + o2 * a1;            \
215         i1 = ibuf[i];                                                         \
216         out = o1 * wet + i1 * dry;                                            \
217         if (disabled) {                                                       \
218             obuf[i] = i1;                                                     \
219         } else if (need_clipping && out < min) {                              \
220             (*clippings)++;                                                   \
221             obuf[i] = min;                                                    \
222         } else if (need_clipping && out > max) {                              \
223             (*clippings)++;                                                   \
224             obuf[i] = max;                                                    \
225         } else {                                                              \
226             obuf[i] = out;                                                    \
227         }                                                                     \
228     }                                                                         \
229     if (i < len) {                                                            \
230         double o0 = ibuf[i] * b0 + i1 * b1 + i2 * b2 + o1 * a1 + o2 * a2;     \
231         i2 = i1;                                                              \
232         i1 = ibuf[i];                                                         \
233         o2 = o1;                                                              \
234         o1 = o0;                                                              \
235         out = o0 * wet + i1 * dry;                                            \
236         if (disabled) {                                                       \
237             obuf[i] = i1;                                                     \
238         } else if (need_clipping && out < min) {                              \
239             (*clippings)++;                                                   \
240             obuf[i] = min;                                                    \
241         } else if (need_clipping && out > max) {                              \
242             (*clippings)++;                                                   \
243             obuf[i] = max;                                                    \
244         } else {                                                              \
245             obuf[i] = out;                                                    \
246         }                                                                     \
247     }                                                                         \
248     *in1  = i1;                                                               \
249     *in2  = i2;                                                               \
250     *out1 = o1;                                                               \
251     *out2 = o2;                                                               \
252 }
253
254 BIQUAD_FILTER(s16, int16_t, INT16_MIN, INT16_MAX, 1)
255 BIQUAD_FILTER(s32, int32_t, INT32_MIN, INT32_MAX, 1)
256 BIQUAD_FILTER(flt, float,   -1., 1., 0)
257 BIQUAD_FILTER(dbl, double,  -1., 1., 0)
258
259 static int config_filter(AVFilterLink *outlink, int reset)
260 {
261     AVFilterContext *ctx    = outlink->src;
262     BiquadsContext *s       = ctx->priv;
263     AVFilterLink *inlink    = ctx->inputs[0];
264     double A = ff_exp10(s->gain / 40);
265     double w0 = 2 * M_PI * s->frequency / inlink->sample_rate;
266     double alpha, beta;
267
268     if (w0 > M_PI) {
269         av_log(ctx, AV_LOG_ERROR,
270                "Invalid frequency %f. Frequency must be less than half the sample-rate %d.\n",
271                s->frequency, inlink->sample_rate);
272         return AVERROR(EINVAL);
273     }
274
275     switch (s->width_type) {
276     case NONE:
277         alpha = 0.0;
278         break;
279     case HERTZ:
280         alpha = sin(w0) / (2 * s->frequency / s->width);
281         break;
282     case KHERTZ:
283         alpha = sin(w0) / (2 * s->frequency / (s->width * 1000));
284         break;
285     case OCTAVE:
286         alpha = sin(w0) * sinh(log(2.) / 2 * s->width * w0 / sin(w0));
287         break;
288     case QFACTOR:
289         alpha = sin(w0) / (2 * s->width);
290         break;
291     case SLOPE:
292         alpha = sin(w0) / 2 * sqrt((A + 1 / A) * (1 / s->width - 1) + 2);
293         break;
294     default:
295         av_assert0(0);
296     }
297
298     beta = 2 * sqrt(A);
299
300     switch (s->filter_type) {
301     case biquad:
302         break;
303     case equalizer:
304         s->a0 =   1 + alpha / A;
305         s->a1 =  -2 * cos(w0);
306         s->a2 =   1 - alpha / A;
307         s->b0 =   1 + alpha * A;
308         s->b1 =  -2 * cos(w0);
309         s->b2 =   1 - alpha * A;
310         break;
311     case bass:
312         beta = sqrt((A * A + 1) - (A - 1) * (A - 1));
313     case lowshelf:
314         s->a0 =          (A + 1) + (A - 1) * cos(w0) + beta * alpha;
315         s->a1 =    -2 * ((A - 1) + (A + 1) * cos(w0));
316         s->a2 =          (A + 1) + (A - 1) * cos(w0) - beta * alpha;
317         s->b0 =     A * ((A + 1) - (A - 1) * cos(w0) + beta * alpha);
318         s->b1 = 2 * A * ((A - 1) - (A + 1) * cos(w0));
319         s->b2 =     A * ((A + 1) - (A - 1) * cos(w0) - beta * alpha);
320         break;
321     case treble:
322         beta = sqrt((A * A + 1) - (A - 1) * (A - 1));
323     case highshelf:
324         s->a0 =          (A + 1) - (A - 1) * cos(w0) + beta * alpha;
325         s->a1 =     2 * ((A - 1) - (A + 1) * cos(w0));
326         s->a2 =          (A + 1) - (A - 1) * cos(w0) - beta * alpha;
327         s->b0 =     A * ((A + 1) + (A - 1) * cos(w0) + beta * alpha);
328         s->b1 =-2 * A * ((A - 1) + (A + 1) * cos(w0));
329         s->b2 =     A * ((A + 1) + (A - 1) * cos(w0) - beta * alpha);
330         break;
331     case bandpass:
332         if (s->csg) {
333             s->a0 =  1 + alpha;
334             s->a1 = -2 * cos(w0);
335             s->a2 =  1 - alpha;
336             s->b0 =  sin(w0) / 2;
337             s->b1 =  0;
338             s->b2 = -sin(w0) / 2;
339         } else {
340             s->a0 =  1 + alpha;
341             s->a1 = -2 * cos(w0);
342             s->a2 =  1 - alpha;
343             s->b0 =  alpha;
344             s->b1 =  0;
345             s->b2 = -alpha;
346         }
347         break;
348     case bandreject:
349         s->a0 =  1 + alpha;
350         s->a1 = -2 * cos(w0);
351         s->a2 =  1 - alpha;
352         s->b0 =  1;
353         s->b1 = -2 * cos(w0);
354         s->b2 =  1;
355         break;
356     case lowpass:
357         if (s->poles == 1) {
358             s->a0 = 1;
359             s->a1 = -exp(-w0);
360             s->a2 = 0;
361             s->b0 = 1 + s->a1;
362             s->b1 = 0;
363             s->b2 = 0;
364         } else {
365             s->a0 =  1 + alpha;
366             s->a1 = -2 * cos(w0);
367             s->a2 =  1 - alpha;
368             s->b0 = (1 - cos(w0)) / 2;
369             s->b1 =  1 - cos(w0);
370             s->b2 = (1 - cos(w0)) / 2;
371         }
372         break;
373     case highpass:
374         if (s->poles == 1) {
375             s->a0 = 1;
376             s->a1 = -exp(-w0);
377             s->a2 = 0;
378             s->b0 = (1 - s->a1) / 2;
379             s->b1 = -s->b0;
380             s->b2 = 0;
381         } else {
382             s->a0 =   1 + alpha;
383             s->a1 =  -2 * cos(w0);
384             s->a2 =   1 - alpha;
385             s->b0 =  (1 + cos(w0)) / 2;
386             s->b1 = -(1 + cos(w0));
387             s->b2 =  (1 + cos(w0)) / 2;
388         }
389         break;
390     case allpass:
391         s->a0 =  1 + alpha;
392         s->a1 = -2 * cos(w0);
393         s->a2 =  1 - alpha;
394         s->b0 =  1 - alpha;
395         s->b1 = -2 * cos(w0);
396         s->b2 =  1 + alpha;
397         break;
398     default:
399         av_assert0(0);
400     }
401
402     av_log(ctx, AV_LOG_VERBOSE, "a=%f %f %f:b=%f %f %f\n", s->a0, s->a1, s->a2, s->b0, s->b1, s->b2);
403
404     s->a1 /= s->a0;
405     s->a2 /= s->a0;
406     s->b0 /= s->a0;
407     s->b1 /= s->a0;
408     s->b2 /= s->a0;
409     s->a0 /= s->a0;
410
411     s->cache = av_realloc_f(s->cache, sizeof(ChanCache), inlink->channels);
412     if (!s->cache)
413         return AVERROR(ENOMEM);
414     if (reset)
415         memset(s->cache, 0, sizeof(ChanCache) * inlink->channels);
416
417     switch (inlink->format) {
418     case AV_SAMPLE_FMT_S16P: s->filter = biquad_s16; break;
419     case AV_SAMPLE_FMT_S32P: s->filter = biquad_s32; break;
420     case AV_SAMPLE_FMT_FLTP: s->filter = biquad_flt; break;
421     case AV_SAMPLE_FMT_DBLP: s->filter = biquad_dbl; break;
422     default: av_assert0(0);
423     }
424
425     s->block_align = av_get_bytes_per_sample(inlink->format);
426
427     return 0;
428 }
429
430 static int config_output(AVFilterLink *outlink)
431 {
432     return config_filter(outlink, 1);
433 }
434
435 typedef struct ThreadData {
436     AVFrame *in, *out;
437 } ThreadData;
438
439 static int filter_channel(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
440 {
441     AVFilterLink *inlink = ctx->inputs[0];
442     ThreadData *td = arg;
443     AVFrame *buf = td->in;
444     AVFrame *out_buf = td->out;
445     BiquadsContext *s = ctx->priv;
446     const int start = (buf->channels * jobnr) / nb_jobs;
447     const int end = (buf->channels * (jobnr+1)) / nb_jobs;
448     int ch;
449
450     for (ch = start; ch < end; ch++) {
451         if (!((av_channel_layout_extract_channel(inlink->channel_layout, ch) & s->channels))) {
452             if (buf != out_buf)
453                 memcpy(out_buf->extended_data[ch], buf->extended_data[ch],
454                        buf->nb_samples * s->block_align);
455             continue;
456         }
457
458         s->filter(s, buf->extended_data[ch], out_buf->extended_data[ch], buf->nb_samples,
459                   &s->cache[ch].i1, &s->cache[ch].i2, &s->cache[ch].o1, &s->cache[ch].o2,
460                   s->b0, s->b1, s->b2, s->a1, s->a2, &s->cache[ch].clippings, ctx->is_disabled);
461     }
462
463     return 0;
464 }
465
466 static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
467 {
468     AVFilterContext  *ctx = inlink->dst;
469     BiquadsContext *s     = ctx->priv;
470     AVFilterLink *outlink = ctx->outputs[0];
471     AVFrame *out_buf;
472     ThreadData td;
473     int ch;
474
475     if (av_frame_is_writable(buf)) {
476         out_buf = buf;
477     } else {
478         out_buf = ff_get_audio_buffer(outlink, buf->nb_samples);
479         if (!out_buf) {
480             av_frame_free(&buf);
481             return AVERROR(ENOMEM);
482         }
483         av_frame_copy_props(out_buf, buf);
484     }
485
486     td.in = buf;
487     td.out = out_buf;
488     ctx->internal->execute(ctx, filter_channel, &td, NULL, FFMIN(outlink->channels, ff_filter_get_nb_threads(ctx)));
489
490     for (ch = 0; ch < outlink->channels; ch++) {
491         if (s->cache[ch].clippings > 0)
492             av_log(ctx, AV_LOG_WARNING, "Channel %d clipping %d times. Please reduce gain.\n",
493                    ch, s->cache[ch].clippings);
494         s->cache[ch].clippings = 0;
495     }
496
497     if (buf != out_buf)
498         av_frame_free(&buf);
499
500     return ff_filter_frame(outlink, out_buf);
501 }
502
503 static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
504                            char *res, int res_len, int flags)
505 {
506     AVFilterLink *outlink = ctx->outputs[0];
507     int ret;
508
509     ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
510     if (ret < 0)
511         return ret;
512
513     return config_filter(outlink, 0);
514 }
515
516 static av_cold void uninit(AVFilterContext *ctx)
517 {
518     BiquadsContext *s = ctx->priv;
519
520     av_freep(&s->cache);
521 }
522
523 static const AVFilterPad inputs[] = {
524     {
525         .name         = "default",
526         .type         = AVMEDIA_TYPE_AUDIO,
527         .filter_frame = filter_frame,
528     },
529     { NULL }
530 };
531
532 static const AVFilterPad outputs[] = {
533     {
534         .name         = "default",
535         .type         = AVMEDIA_TYPE_AUDIO,
536         .config_props = config_output,
537     },
538     { NULL }
539 };
540
541 #define OFFSET(x) offsetof(BiquadsContext, x)
542 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
543 #define AF AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
544
545 #define DEFINE_BIQUAD_FILTER(name_, description_)                       \
546 AVFILTER_DEFINE_CLASS(name_);                                           \
547 static av_cold int name_##_init(AVFilterContext *ctx) \
548 {                                                                       \
549     BiquadsContext *s = ctx->priv;                                      \
550     s->class = &name_##_class;                                          \
551     s->filter_type = name_;                                             \
552     return init(ctx);                                             \
553 }                                                                       \
554                                                          \
555 AVFilter ff_af_##name_ = {                         \
556     .name          = #name_,                             \
557     .description   = NULL_IF_CONFIG_SMALL(description_), \
558     .priv_size     = sizeof(BiquadsContext),             \
559     .init          = name_##_init,                       \
560     .uninit        = uninit,                             \
561     .query_formats = query_formats,                      \
562     .inputs        = inputs,                             \
563     .outputs       = outputs,                            \
564     .priv_class    = &name_##_class,                     \
565     .process_command = process_command,                  \
566     .flags         = AVFILTER_FLAG_SLICE_THREADS | AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL, \
567 }
568
569 #if CONFIG_EQUALIZER_FILTER
570 static const AVOption equalizer_options[] = {
571     {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, 999999, FLAGS},
572     {"f",         "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, 999999, FLAGS},
573     {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, NB_WTYPE-1, FLAGS, "width_type"},
574     {"t",          "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, NB_WTYPE-1, FLAGS, "width_type"},
575     {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HERTZ}, 0, 0, FLAGS, "width_type"},
576     {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
577     {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
578     {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
579     {"k", "kHz", 0, AV_OPT_TYPE_CONST, {.i64=KHERTZ}, 0, 0, FLAGS, "width_type"},
580     {"width", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 99999, FLAGS},
581     {"w",     "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 99999, FLAGS},
582     {"gain", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
583     {"g",    "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
584     {"mix", "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS},
585     {"m",   "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS},
586     {"channels", "set channels to filter", OFFSET(channels), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=-1}, INT64_MIN, INT64_MAX, FLAGS},
587     {"c",        "set channels to filter", OFFSET(channels), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=-1}, INT64_MIN, INT64_MAX, FLAGS},
588     {NULL}
589 };
590
591 DEFINE_BIQUAD_FILTER(equalizer, "Apply two-pole peaking equalization (EQ) filter.");
592 #endif  /* CONFIG_EQUALIZER_FILTER */
593 #if CONFIG_BASS_FILTER
594 static const AVOption bass_options[] = {
595     {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=100}, 0, 999999, FLAGS},
596     {"f",         "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=100}, 0, 999999, FLAGS},
597     {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, NB_WTYPE-1, FLAGS, "width_type"},
598     {"t",          "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, NB_WTYPE-1, FLAGS, "width_type"},
599     {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HERTZ}, 0, 0, FLAGS, "width_type"},
600     {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
601     {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
602     {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
603     {"k", "kHz", 0, AV_OPT_TYPE_CONST, {.i64=KHERTZ}, 0, 0, FLAGS, "width_type"},
604     {"width", "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS},
605     {"w",     "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS},
606     {"gain", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
607     {"g",    "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
608     {"mix", "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS},
609     {"m",   "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS},
610     {"channels", "set channels to filter", OFFSET(channels), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=-1}, INT64_MIN, INT64_MAX, FLAGS},
611     {"c",        "set channels to filter", OFFSET(channels), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=-1}, INT64_MIN, INT64_MAX, FLAGS},
612     {NULL}
613 };
614
615 DEFINE_BIQUAD_FILTER(bass, "Boost or cut lower frequencies.");
616 #endif  /* CONFIG_BASS_FILTER */
617 #if CONFIG_TREBLE_FILTER
618 static const AVOption treble_options[] = {
619     {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
620     {"f",         "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
621     {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, NB_WTYPE-1, FLAGS, "width_type"},
622     {"t",          "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, NB_WTYPE-1, FLAGS, "width_type"},
623     {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HERTZ}, 0, 0, FLAGS, "width_type"},
624     {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
625     {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
626     {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
627     {"k", "kHz", 0, AV_OPT_TYPE_CONST, {.i64=KHERTZ}, 0, 0, FLAGS, "width_type"},
628     {"width", "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS},
629     {"w",     "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS},
630     {"gain", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
631     {"g",    "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
632     {"mix", "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS},
633     {"m",   "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS},
634     {"channels", "set channels to filter", OFFSET(channels), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=-1}, INT64_MIN, INT64_MAX, FLAGS},
635     {"c",        "set channels to filter", OFFSET(channels), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=-1}, INT64_MIN, INT64_MAX, FLAGS},
636     {NULL}
637 };
638
639 DEFINE_BIQUAD_FILTER(treble, "Boost or cut upper frequencies.");
640 #endif  /* CONFIG_TREBLE_FILTER */
641 #if CONFIG_BANDPASS_FILTER
642 static const AVOption bandpass_options[] = {
643     {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
644     {"f",         "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
645     {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, NB_WTYPE-1, FLAGS, "width_type"},
646     {"t",          "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, NB_WTYPE-1, FLAGS, "width_type"},
647     {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HERTZ}, 0, 0, FLAGS, "width_type"},
648     {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
649     {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
650     {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
651     {"k", "kHz", 0, AV_OPT_TYPE_CONST, {.i64=KHERTZ}, 0, 0, FLAGS, "width_type"},
652     {"width", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS},
653     {"w",     "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS},
654     {"csg",   "use constant skirt gain", OFFSET(csg), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
655     {"mix", "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS},
656     {"m",   "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS},
657     {"channels", "set channels to filter", OFFSET(channels), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=-1}, INT64_MIN, INT64_MAX, FLAGS},
658     {"c",        "set channels to filter", OFFSET(channels), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=-1}, INT64_MIN, INT64_MAX, FLAGS},
659     {NULL}
660 };
661
662 DEFINE_BIQUAD_FILTER(bandpass, "Apply a two-pole Butterworth band-pass filter.");
663 #endif  /* CONFIG_BANDPASS_FILTER */
664 #if CONFIG_BANDREJECT_FILTER
665 static const AVOption bandreject_options[] = {
666     {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
667     {"f",         "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
668     {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, NB_WTYPE-1, FLAGS, "width_type"},
669     {"t",          "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, NB_WTYPE-1, FLAGS, "width_type"},
670     {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HERTZ}, 0, 0, FLAGS, "width_type"},
671     {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
672     {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
673     {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
674     {"k", "kHz", 0, AV_OPT_TYPE_CONST, {.i64=KHERTZ}, 0, 0, FLAGS, "width_type"},
675     {"width", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS},
676     {"w",     "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS},
677     {"mix", "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS},
678     {"m",   "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS},
679     {"channels", "set channels to filter", OFFSET(channels), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=-1}, INT64_MIN, INT64_MAX, FLAGS},
680     {"c",        "set channels to filter", OFFSET(channels), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=-1}, INT64_MIN, INT64_MAX, FLAGS},
681     {NULL}
682 };
683
684 DEFINE_BIQUAD_FILTER(bandreject, "Apply a two-pole Butterworth band-reject filter.");
685 #endif  /* CONFIG_BANDREJECT_FILTER */
686 #if CONFIG_LOWPASS_FILTER
687 static const AVOption lowpass_options[] = {
688     {"frequency", "set frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=500}, 0, 999999, FLAGS},
689     {"f",         "set frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=500}, 0, 999999, FLAGS},
690     {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, NB_WTYPE-1, FLAGS, "width_type"},
691     {"t",          "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, NB_WTYPE-1, FLAGS, "width_type"},
692     {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HERTZ}, 0, 0, FLAGS, "width_type"},
693     {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
694     {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
695     {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
696     {"k", "kHz", 0, AV_OPT_TYPE_CONST, {.i64=KHERTZ}, 0, 0, FLAGS, "width_type"},
697     {"width", "set width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.707}, 0, 99999, FLAGS},
698     {"w",     "set width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.707}, 0, 99999, FLAGS},
699     {"poles", "set number of poles", OFFSET(poles), AV_OPT_TYPE_INT, {.i64=2}, 1, 2, AF},
700     {"p",     "set number of poles", OFFSET(poles), AV_OPT_TYPE_INT, {.i64=2}, 1, 2, AF},
701     {"mix", "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS},
702     {"m",   "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS},
703     {"channels", "set channels to filter", OFFSET(channels), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=-1}, INT64_MIN, INT64_MAX, FLAGS},
704     {"c",        "set channels to filter", OFFSET(channels), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=-1}, INT64_MIN, INT64_MAX, FLAGS},
705     {NULL}
706 };
707
708 DEFINE_BIQUAD_FILTER(lowpass, "Apply a low-pass filter with 3dB point frequency.");
709 #endif  /* CONFIG_LOWPASS_FILTER */
710 #if CONFIG_HIGHPASS_FILTER
711 static const AVOption highpass_options[] = {
712     {"frequency", "set frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
713     {"f",         "set frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
714     {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, NB_WTYPE-1, FLAGS, "width_type"},
715     {"t",          "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, NB_WTYPE-1, FLAGS, "width_type"},
716     {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HERTZ}, 0, 0, FLAGS, "width_type"},
717     {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
718     {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
719     {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
720     {"k", "kHz", 0, AV_OPT_TYPE_CONST, {.i64=KHERTZ}, 0, 0, FLAGS, "width_type"},
721     {"width", "set width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.707}, 0, 99999, FLAGS},
722     {"w",     "set width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.707}, 0, 99999, FLAGS},
723     {"poles", "set number of poles", OFFSET(poles), AV_OPT_TYPE_INT, {.i64=2}, 1, 2, AF},
724     {"p",     "set number of poles", OFFSET(poles), AV_OPT_TYPE_INT, {.i64=2}, 1, 2, AF},
725     {"mix", "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS},
726     {"m",   "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS},
727     {"channels", "set channels to filter", OFFSET(channels), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=-1}, INT64_MIN, INT64_MAX, FLAGS},
728     {"c",        "set channels to filter", OFFSET(channels), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=-1}, INT64_MIN, INT64_MAX, FLAGS},
729     {NULL}
730 };
731
732 DEFINE_BIQUAD_FILTER(highpass, "Apply a high-pass filter with 3dB point frequency.");
733 #endif  /* CONFIG_HIGHPASS_FILTER */
734 #if CONFIG_ALLPASS_FILTER
735 static const AVOption allpass_options[] = {
736     {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
737     {"f",         "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
738     {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=HERTZ}, HERTZ, NB_WTYPE-1, FLAGS, "width_type"},
739     {"t",          "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=HERTZ}, HERTZ, NB_WTYPE-1, FLAGS, "width_type"},
740     {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HERTZ}, 0, 0, FLAGS, "width_type"},
741     {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
742     {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
743     {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
744     {"k", "kHz", 0, AV_OPT_TYPE_CONST, {.i64=KHERTZ}, 0, 0, FLAGS, "width_type"},
745     {"width", "set filter-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=707.1}, 0, 99999, FLAGS},
746     {"w",     "set filter-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=707.1}, 0, 99999, FLAGS},
747     {"mix", "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS},
748     {"m",   "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS},
749     {"channels", "set channels to filter", OFFSET(channels), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=-1}, INT64_MIN, INT64_MAX, FLAGS},
750     {"c",        "set channels to filter", OFFSET(channels), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=-1}, INT64_MIN, INT64_MAX, FLAGS},
751     {NULL}
752 };
753
754 DEFINE_BIQUAD_FILTER(allpass, "Apply a two-pole all-pass filter.");
755 #endif  /* CONFIG_ALLPASS_FILTER */
756 #if CONFIG_LOWSHELF_FILTER
757 static const AVOption lowshelf_options[] = {
758     {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=100}, 0, 999999, FLAGS},
759     {"f",         "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=100}, 0, 999999, FLAGS},
760     {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, NB_WTYPE-1, FLAGS, "width_type"},
761     {"t",          "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, NB_WTYPE-1, FLAGS, "width_type"},
762     {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HERTZ}, 0, 0, FLAGS, "width_type"},
763     {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
764     {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
765     {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
766     {"k", "kHz", 0, AV_OPT_TYPE_CONST, {.i64=KHERTZ}, 0, 0, FLAGS, "width_type"},
767     {"width", "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS},
768     {"w",     "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS},
769     {"gain", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
770     {"g",    "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
771     {"mix", "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS},
772     {"m",   "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS},
773     {"channels", "set channels to filter", OFFSET(channels), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=-1}, INT64_MIN, INT64_MAX, FLAGS},
774     {"c",        "set channels to filter", OFFSET(channels), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=-1}, INT64_MIN, INT64_MAX, FLAGS},
775     {NULL}
776 };
777
778 DEFINE_BIQUAD_FILTER(lowshelf, "Apply a low shelf filter.");
779 #endif  /* CONFIG_LOWSHELF_FILTER */
780 #if CONFIG_HIGHSHELF_FILTER
781 static const AVOption highshelf_options[] = {
782     {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
783     {"f",         "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
784     {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, NB_WTYPE-1, FLAGS, "width_type"},
785     {"t",          "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, NB_WTYPE-1, FLAGS, "width_type"},
786     {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HERTZ}, 0, 0, FLAGS, "width_type"},
787     {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
788     {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
789     {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
790     {"k", "kHz", 0, AV_OPT_TYPE_CONST, {.i64=KHERTZ}, 0, 0, FLAGS, "width_type"},
791     {"width", "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS},
792     {"w",     "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS},
793     {"gain", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
794     {"g",    "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
795     {"mix", "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS},
796     {"m",   "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS},
797     {"channels", "set channels to filter", OFFSET(channels), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=-1}, INT64_MIN, INT64_MAX, FLAGS},
798     {"c",        "set channels to filter", OFFSET(channels), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=-1}, INT64_MIN, INT64_MAX, FLAGS},
799     {NULL}
800 };
801
802 DEFINE_BIQUAD_FILTER(highshelf, "Apply a high shelf filter.");
803 #endif  /* CONFIG_HIGHSHELF_FILTER */
804 #if CONFIG_BIQUAD_FILTER
805 static const AVOption biquad_options[] = {
806     {"a0", NULL, OFFSET(a0), AV_OPT_TYPE_DOUBLE, {.dbl=1}, INT32_MIN, INT32_MAX, FLAGS},
807     {"a1", NULL, OFFSET(a1), AV_OPT_TYPE_DOUBLE, {.dbl=0}, INT32_MIN, INT32_MAX, FLAGS},
808     {"a2", NULL, OFFSET(a2), AV_OPT_TYPE_DOUBLE, {.dbl=0}, INT32_MIN, INT32_MAX, FLAGS},
809     {"b0", NULL, OFFSET(b0), AV_OPT_TYPE_DOUBLE, {.dbl=0}, INT32_MIN, INT32_MAX, FLAGS},
810     {"b1", NULL, OFFSET(b1), AV_OPT_TYPE_DOUBLE, {.dbl=0}, INT32_MIN, INT32_MAX, FLAGS},
811     {"b2", NULL, OFFSET(b2), AV_OPT_TYPE_DOUBLE, {.dbl=0}, INT32_MIN, INT32_MAX, FLAGS},
812     {"mix", "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS},
813     {"m",   "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS},
814     {"channels", "set channels to filter", OFFSET(channels), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=-1}, INT64_MIN, INT64_MAX, FLAGS},
815     {"c",        "set channels to filter", OFFSET(channels), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=-1}, INT64_MIN, INT64_MAX, FLAGS},
816     {NULL}
817 };
818
819 DEFINE_BIQUAD_FILTER(biquad, "Apply a biquad IIR filter with the given coefficients.");
820 #endif  /* CONFIG_BIQUAD_FILTER */