2 * Copyright (c) 2013 Paul B Mahol
3 * Copyright (c) 2006-2008 Rob Sykes <robs@users.sourceforge.net>
5 * This file is part of FFmpeg.
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.
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.
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
23 * 2-pole filters designed by Robert Bristow-Johnson <rbj@audioimagination.com>
24 * see http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt
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
30 * low-pass: output[N] = input[N] * A + output[N-1] * B
31 * X = exp(-2.0 * pi * Fc)
34 * Fc = cutoff freq / sample rate
36 * Mimics an RC low-pass filter:
38 * ---/\/\/\/\----------->
46 * high-pass: output[N] = A0 * input[N] + A1 * input[N-1] + B1 * output[N-1]
47 * X = exp(-2.0 * pi * Fc)
51 * Fc = cutoff freq / sample rate
53 * Mimics an RC high-pass filter:
65 #include "libavutil/avassert.h"
66 #include "libavutil/opt.h"
92 typedef struct ChanCache {
97 typedef struct BiquadsContext {
100 enum FilterType filter_type;
115 void (*filter)(struct BiquadsContext *s, const void *ibuf, void *obuf, int len,
116 double *i1, double *i2, double *o1, double *o2,
117 double b0, double b1, double b2, double a1, double a2);
120 static av_cold int init(AVFilterContext *ctx)
122 BiquadsContext *s = ctx->priv;
124 if (s->filter_type != biquad) {
125 if (s->frequency <= 0 || s->width <= 0) {
126 av_log(ctx, AV_LOG_ERROR, "Invalid frequency %f and/or width %f <= 0\n",
127 s->frequency, s->width);
128 return AVERROR(EINVAL);
135 static int query_formats(AVFilterContext *ctx)
137 AVFilterFormats *formats;
138 AVFilterChannelLayouts *layouts;
139 static const enum AVSampleFormat sample_fmts[] = {
148 layouts = ff_all_channel_counts();
150 return AVERROR(ENOMEM);
151 ret = ff_set_common_channel_layouts(ctx, layouts);
155 formats = ff_make_format_list(sample_fmts);
157 return AVERROR(ENOMEM);
158 ret = ff_set_common_formats(ctx, formats);
162 formats = ff_all_samplerates();
164 return AVERROR(ENOMEM);
165 return ff_set_common_samplerates(ctx, formats);
168 #define BIQUAD_FILTER(name, type, min, max, need_clipping) \
169 static void biquad_## name (BiquadsContext *s, \
170 const void *input, void *output, int len, \
171 double *in1, double *in2, \
172 double *out1, double *out2, \
173 double b0, double b1, double b2, \
174 double a1, double a2) \
176 const type *ibuf = input; \
177 type *obuf = output; \
186 for (i = 0; i+1 < len; i++) { \
187 o2 = i2 * b2 + i1 * b1 + ibuf[i] * b0 + o2 * a2 + o1 * a1; \
189 if (need_clipping && o2 < min) { \
192 } else if (need_clipping && o2 > max) { \
199 o1 = i1 * b2 + i2 * b1 + ibuf[i] * b0 + o1 * a2 + o2 * a1; \
201 if (need_clipping && o1 < min) { \
204 } else if (need_clipping && o1 > max) { \
212 double o0 = ibuf[i] * b0 + i1 * b1 + i2 * b2 + o1 * a1 + o2 * a2; \
217 if (need_clipping && o0 < min) { \
220 } else if (need_clipping && o0 > max) { \
233 BIQUAD_FILTER(s16, int16_t, INT16_MIN, INT16_MAX, 1)
234 BIQUAD_FILTER(s32, int32_t, INT32_MIN, INT32_MAX, 1)
235 BIQUAD_FILTER(flt, float, -1., 1., 0)
236 BIQUAD_FILTER(dbl, double, -1., 1., 0)
238 static int config_output(AVFilterLink *outlink)
240 AVFilterContext *ctx = outlink->src;
241 BiquadsContext *s = ctx->priv;
242 AVFilterLink *inlink = ctx->inputs[0];
243 double A = exp(s->gain / 40 * log(10.));
244 double w0 = 2 * M_PI * s->frequency / inlink->sample_rate;
248 av_log(ctx, AV_LOG_ERROR,
249 "Invalid frequency %f. Frequency must be less than half the sample-rate %d.\n",
250 s->frequency, inlink->sample_rate);
251 return AVERROR(EINVAL);
254 switch (s->width_type) {
259 alpha = sin(w0) / (2 * s->frequency / s->width);
262 alpha = sin(w0) * sinh(log(2.) / 2 * s->width * w0 / sin(w0));
265 alpha = sin(w0) / (2 * s->width);
268 alpha = sin(w0) / 2 * sqrt((A + 1 / A) * (1 / s->width - 1) + 2);
274 switch (s->filter_type) {
278 s->a0 = 1 + alpha / A;
279 s->a1 = -2 * cos(w0);
280 s->a2 = 1 - alpha / A;
281 s->b0 = 1 + alpha * A;
282 s->b1 = -2 * cos(w0);
283 s->b2 = 1 - alpha * A;
286 s->a0 = (A + 1) + (A - 1) * cos(w0) + 2 * sqrt(A) * alpha;
287 s->a1 = -2 * ((A - 1) + (A + 1) * cos(w0));
288 s->a2 = (A + 1) + (A - 1) * cos(w0) - 2 * sqrt(A) * alpha;
289 s->b0 = A * ((A + 1) - (A - 1) * cos(w0) + 2 * sqrt(A) * alpha);
290 s->b1 = 2 * A * ((A - 1) - (A + 1) * cos(w0));
291 s->b2 = A * ((A + 1) - (A - 1) * cos(w0) - 2 * sqrt(A) * alpha);
294 s->a0 = (A + 1) - (A - 1) * cos(w0) + 2 * sqrt(A) * alpha;
295 s->a1 = 2 * ((A - 1) - (A + 1) * cos(w0));
296 s->a2 = (A + 1) - (A - 1) * cos(w0) - 2 * sqrt(A) * alpha;
297 s->b0 = A * ((A + 1) + (A - 1) * cos(w0) + 2 * sqrt(A) * alpha);
298 s->b1 =-2 * A * ((A - 1) + (A + 1) * cos(w0));
299 s->b2 = A * ((A + 1) + (A - 1) * cos(w0) - 2 * sqrt(A) * alpha);
304 s->a1 = -2 * cos(w0);
308 s->b2 = -sin(w0) / 2;
311 s->a1 = -2 * cos(w0);
320 s->a1 = -2 * cos(w0);
323 s->b1 = -2 * cos(w0);
336 s->a1 = -2 * cos(w0);
338 s->b0 = (1 - cos(w0)) / 2;
340 s->b2 = (1 - cos(w0)) / 2;
348 s->b0 = (1 - s->a1) / 2;
353 s->a1 = -2 * cos(w0);
355 s->b0 = (1 + cos(w0)) / 2;
356 s->b1 = -(1 + cos(w0));
357 s->b2 = (1 + cos(w0)) / 2;
362 s->a1 = -2 * cos(w0);
365 s->b1 = -2 * cos(w0);
378 s->cache = av_realloc_f(s->cache, sizeof(ChanCache), inlink->channels);
380 return AVERROR(ENOMEM);
381 memset(s->cache, 0, sizeof(ChanCache) * inlink->channels);
383 switch (inlink->format) {
384 case AV_SAMPLE_FMT_S16P: s->filter = biquad_s16; break;
385 case AV_SAMPLE_FMT_S32P: s->filter = biquad_s32; break;
386 case AV_SAMPLE_FMT_FLTP: s->filter = biquad_flt; break;
387 case AV_SAMPLE_FMT_DBLP: s->filter = biquad_dbl; break;
388 default: av_assert0(0);
394 static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
396 AVFilterContext *ctx = inlink->dst;
397 BiquadsContext *s = ctx->priv;
398 AVFilterLink *outlink = ctx->outputs[0];
400 int nb_samples = buf->nb_samples;
403 if (av_frame_is_writable(buf)) {
406 out_buf = ff_get_audio_buffer(inlink, nb_samples);
409 return AVERROR(ENOMEM);
411 av_frame_copy_props(out_buf, buf);
414 for (ch = 0; ch < av_frame_get_channels(buf); ch++)
415 s->filter(s, buf->extended_data[ch],
416 out_buf->extended_data[ch], nb_samples,
417 &s->cache[ch].i1, &s->cache[ch].i2,
418 &s->cache[ch].o1, &s->cache[ch].o2,
419 s->b0, s->b1, s->b2, s->a1, s->a2);
421 if (s->clippings > 0)
422 av_log(ctx, AV_LOG_WARNING, "clipping %d times. Please reduce gain.\n", s->clippings);
428 return ff_filter_frame(outlink, out_buf);
431 static av_cold void uninit(AVFilterContext *ctx)
433 BiquadsContext *s = ctx->priv;
438 static const AVFilterPad inputs[] = {
441 .type = AVMEDIA_TYPE_AUDIO,
442 .filter_frame = filter_frame,
447 static const AVFilterPad outputs[] = {
450 .type = AVMEDIA_TYPE_AUDIO,
451 .config_props = config_output,
456 #define OFFSET(x) offsetof(BiquadsContext, x)
457 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
459 #define DEFINE_BIQUAD_FILTER(name_, description_) \
460 AVFILTER_DEFINE_CLASS(name_); \
461 static av_cold int name_##_init(AVFilterContext *ctx) \
463 BiquadsContext *s = ctx->priv; \
464 s->class = &name_##_class; \
465 s->filter_type = name_; \
469 AVFilter ff_af_##name_ = { \
471 .description = NULL_IF_CONFIG_SMALL(description_), \
472 .priv_size = sizeof(BiquadsContext), \
473 .init = name_##_init, \
475 .query_formats = query_formats, \
477 .outputs = outputs, \
478 .priv_class = &name_##_class, \
481 #if CONFIG_EQUALIZER_FILTER
482 static const AVOption equalizer_options[] = {
483 {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, 999999, FLAGS},
484 {"f", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, 999999, FLAGS},
485 {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, SLOPE, FLAGS, "width_type"},
486 {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HERTZ}, 0, 0, FLAGS, "width_type"},
487 {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
488 {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
489 {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
490 {"width", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 999, FLAGS},
491 {"w", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 999, FLAGS},
492 {"gain", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
493 {"g", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
497 DEFINE_BIQUAD_FILTER(equalizer, "Apply two-pole peaking equalization (EQ) filter.");
498 #endif /* CONFIG_EQUALIZER_FILTER */
499 #if CONFIG_BASS_FILTER
500 static const AVOption bass_options[] = {
501 {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=100}, 0, 999999, FLAGS},
502 {"f", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=100}, 0, 999999, FLAGS},
503 {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, SLOPE, FLAGS, "width_type"},
504 {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HERTZ}, 0, 0, FLAGS, "width_type"},
505 {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
506 {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
507 {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
508 {"width", "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS},
509 {"w", "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS},
510 {"gain", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
511 {"g", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
515 DEFINE_BIQUAD_FILTER(bass, "Boost or cut lower frequencies.");
516 #endif /* CONFIG_BASS_FILTER */
517 #if CONFIG_TREBLE_FILTER
518 static const AVOption treble_options[] = {
519 {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
520 {"f", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
521 {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, SLOPE, FLAGS, "width_type"},
522 {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HERTZ}, 0, 0, FLAGS, "width_type"},
523 {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
524 {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
525 {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
526 {"width", "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS},
527 {"w", "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS},
528 {"gain", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
529 {"g", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
533 DEFINE_BIQUAD_FILTER(treble, "Boost or cut upper frequencies.");
534 #endif /* CONFIG_TREBLE_FILTER */
535 #if CONFIG_BANDPASS_FILTER
536 static const AVOption bandpass_options[] = {
537 {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
538 {"f", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
539 {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, SLOPE, FLAGS, "width_type"},
540 {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HERTZ}, 0, 0, FLAGS, "width_type"},
541 {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
542 {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
543 {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
544 {"width", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 999, FLAGS},
545 {"w", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 999, FLAGS},
546 {"csg", "use constant skirt gain", OFFSET(csg), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
550 DEFINE_BIQUAD_FILTER(bandpass, "Apply a two-pole Butterworth band-pass filter.");
551 #endif /* CONFIG_BANDPASS_FILTER */
552 #if CONFIG_BANDREJECT_FILTER
553 static const AVOption bandreject_options[] = {
554 {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
555 {"f", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
556 {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, SLOPE, FLAGS, "width_type"},
557 {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HERTZ}, 0, 0, FLAGS, "width_type"},
558 {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
559 {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
560 {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
561 {"width", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 999, FLAGS},
562 {"w", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 999, FLAGS},
566 DEFINE_BIQUAD_FILTER(bandreject, "Apply a two-pole Butterworth band-reject filter.");
567 #endif /* CONFIG_BANDREJECT_FILTER */
568 #if CONFIG_LOWPASS_FILTER
569 static const AVOption lowpass_options[] = {
570 {"frequency", "set frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=500}, 0, 999999, FLAGS},
571 {"f", "set frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=500}, 0, 999999, FLAGS},
572 {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, SLOPE, FLAGS, "width_type"},
573 {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HERTZ}, 0, 0, FLAGS, "width_type"},
574 {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
575 {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
576 {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
577 {"width", "set width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.707}, 0, 99999, FLAGS},
578 {"w", "set width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.707}, 0, 99999, FLAGS},
579 {"poles", "set number of poles", OFFSET(poles), AV_OPT_TYPE_INT, {.i64=2}, 1, 2, FLAGS},
580 {"p", "set number of poles", OFFSET(poles), AV_OPT_TYPE_INT, {.i64=2}, 1, 2, FLAGS},
584 DEFINE_BIQUAD_FILTER(lowpass, "Apply a low-pass filter with 3dB point frequency.");
585 #endif /* CONFIG_LOWPASS_FILTER */
586 #if CONFIG_HIGHPASS_FILTER
587 static const AVOption highpass_options[] = {
588 {"frequency", "set frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
589 {"f", "set frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
590 {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, SLOPE, FLAGS, "width_type"},
591 {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HERTZ}, 0, 0, FLAGS, "width_type"},
592 {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
593 {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
594 {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
595 {"width", "set width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.707}, 0, 99999, FLAGS},
596 {"w", "set width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.707}, 0, 99999, FLAGS},
597 {"poles", "set number of poles", OFFSET(poles), AV_OPT_TYPE_INT, {.i64=2}, 1, 2, FLAGS},
598 {"p", "set number of poles", OFFSET(poles), AV_OPT_TYPE_INT, {.i64=2}, 1, 2, FLAGS},
602 DEFINE_BIQUAD_FILTER(highpass, "Apply a high-pass filter with 3dB point frequency.");
603 #endif /* CONFIG_HIGHPASS_FILTER */
604 #if CONFIG_ALLPASS_FILTER
605 static const AVOption allpass_options[] = {
606 {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
607 {"f", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
608 {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=HERTZ}, HERTZ, SLOPE, FLAGS, "width_type"},
609 {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HERTZ}, 0, 0, FLAGS, "width_type"},
610 {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
611 {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
612 {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
613 {"width", "set filter-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=707.1}, 0, 99999, FLAGS},
614 {"w", "set filter-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=707.1}, 0, 99999, FLAGS},
618 DEFINE_BIQUAD_FILTER(allpass, "Apply a two-pole all-pass filter.");
619 #endif /* CONFIG_ALLPASS_FILTER */
620 #if CONFIG_BIQUAD_FILTER
621 static const AVOption biquad_options[] = {
622 {"a0", NULL, OFFSET(a0), AV_OPT_TYPE_DOUBLE, {.dbl=1}, INT16_MIN, INT16_MAX, FLAGS},
623 {"a1", NULL, OFFSET(a1), AV_OPT_TYPE_DOUBLE, {.dbl=1}, INT16_MIN, INT16_MAX, FLAGS},
624 {"a2", NULL, OFFSET(a2), AV_OPT_TYPE_DOUBLE, {.dbl=1}, INT16_MIN, INT16_MAX, FLAGS},
625 {"b0", NULL, OFFSET(b0), AV_OPT_TYPE_DOUBLE, {.dbl=1}, INT16_MIN, INT16_MAX, FLAGS},
626 {"b1", NULL, OFFSET(b1), AV_OPT_TYPE_DOUBLE, {.dbl=1}, INT16_MIN, INT16_MAX, FLAGS},
627 {"b2", NULL, OFFSET(b2), AV_OPT_TYPE_DOUBLE, {.dbl=1}, INT16_MIN, INT16_MAX, FLAGS},
631 DEFINE_BIQUAD_FILTER(biquad, "Apply a biquad IIR filter with the given coefficients.");
632 #endif /* CONFIG_BIQUAD_FILTER */