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 {
100 enum FilterType filter_type;
114 void (*filter)(const void *ibuf, void *obuf, int len,
115 double *i1, double *i2, double *o1, double *o2,
116 double b0, double b1, double b2, double a1, double a2);
119 static av_cold int init(AVFilterContext *ctx)
121 BiquadsContext *s = ctx->priv;
123 if (s->filter_type != biquad) {
124 if (s->frequency <= 0 || s->width <= 0) {
125 av_log(ctx, AV_LOG_ERROR, "Invalid frequency %f and/or width %f <= 0\n",
126 s->frequency, s->width);
127 return AVERROR(EINVAL);
134 static int query_formats(AVFilterContext *ctx)
136 AVFilterFormats *formats;
137 AVFilterChannelLayouts *layouts;
138 static const enum AVSampleFormat sample_fmts[] = {
147 layouts = ff_all_channel_counts();
149 return AVERROR(ENOMEM);
150 ret = ff_set_common_channel_layouts(ctx, layouts);
154 formats = ff_make_format_list(sample_fmts);
156 return AVERROR(ENOMEM);
157 ret = ff_set_common_formats(ctx, formats);
161 formats = ff_all_samplerates();
163 return AVERROR(ENOMEM);
164 return ff_set_common_samplerates(ctx, formats);
167 #define BIQUAD_FILTER(name, type, min, max, need_clipping) \
168 static void biquad_## name (const void *input, void *output, int len, \
169 double *in1, double *in2, \
170 double *out1, double *out2, \
171 double b0, double b1, double b2, \
172 double a1, double a2) \
174 const type *ibuf = input; \
175 type *obuf = output; \
184 for (i = 0; i+1 < len; i++) { \
185 o2 = i2 * b2 + i1 * b1 + ibuf[i] * b0 + o2 * a2 + o1 * a1; \
187 if (need_clipping && o2 < min) { \
188 av_log(NULL, AV_LOG_WARNING, "clipping\n"); \
190 } else if (need_clipping && o2 > max) { \
191 av_log(NULL, AV_LOG_WARNING, "clipping\n"); \
197 o1 = i1 * b2 + i2 * b1 + ibuf[i] * b0 + o1 * a2 + o2 * a1; \
199 if (need_clipping && o1 < min) { \
200 av_log(NULL, AV_LOG_WARNING, "clipping\n"); \
202 } else if (need_clipping && o1 > max) { \
203 av_log(NULL, AV_LOG_WARNING, "clipping\n"); \
210 double o0 = ibuf[i] * b0 + i1 * b1 + i2 * b2 + o1 * a1 + o2 * a2; \
215 if (need_clipping && o0 < min) { \
216 av_log(NULL, AV_LOG_WARNING, "clipping\n"); \
218 } else if (need_clipping && o0 > max) { \
219 av_log(NULL, AV_LOG_WARNING, "clipping\n"); \
231 BIQUAD_FILTER(s16, int16_t, INT16_MIN, INT16_MAX, 1)
232 BIQUAD_FILTER(s32, int32_t, INT32_MIN, INT32_MAX, 1)
233 BIQUAD_FILTER(flt, float, -1., 1., 0)
234 BIQUAD_FILTER(dbl, double, -1., 1., 0)
236 static int config_output(AVFilterLink *outlink)
238 AVFilterContext *ctx = outlink->src;
239 BiquadsContext *s = ctx->priv;
240 AVFilterLink *inlink = ctx->inputs[0];
241 double A = exp(s->gain / 40 * log(10.));
242 double w0 = 2 * M_PI * s->frequency / inlink->sample_rate;
246 av_log(ctx, AV_LOG_ERROR,
247 "Invalid frequency %f. Frequency must be less than half the sample-rate %d.\n",
248 s->frequency, inlink->sample_rate);
249 return AVERROR(EINVAL);
252 switch (s->width_type) {
257 alpha = sin(w0) / (2 * s->frequency / s->width);
260 alpha = sin(w0) * sinh(log(2.) / 2 * s->width * w0 / sin(w0));
263 alpha = sin(w0) / (2 * s->width);
266 alpha = sin(w0) / 2 * sqrt((A + 1 / A) * (1 / s->width - 1) + 2);
272 switch (s->filter_type) {
276 s->a0 = 1 + alpha / A;
277 s->a1 = -2 * cos(w0);
278 s->a2 = 1 - alpha / A;
279 s->b0 = 1 + alpha * A;
280 s->b1 = -2 * cos(w0);
281 s->b2 = 1 - alpha * A;
284 s->a0 = (A + 1) + (A - 1) * cos(w0) + 2 * sqrt(A) * alpha;
285 s->a1 = -2 * ((A - 1) + (A + 1) * cos(w0));
286 s->a2 = (A + 1) + (A - 1) * cos(w0) - 2 * sqrt(A) * alpha;
287 s->b0 = A * ((A + 1) - (A - 1) * cos(w0) + 2 * sqrt(A) * alpha);
288 s->b1 = 2 * A * ((A - 1) - (A + 1) * cos(w0));
289 s->b2 = A * ((A + 1) - (A - 1) * cos(w0) - 2 * sqrt(A) * alpha);
292 s->a0 = (A + 1) - (A - 1) * cos(w0) + 2 * sqrt(A) * alpha;
293 s->a1 = 2 * ((A - 1) - (A + 1) * cos(w0));
294 s->a2 = (A + 1) - (A - 1) * cos(w0) - 2 * sqrt(A) * alpha;
295 s->b0 = A * ((A + 1) + (A - 1) * cos(w0) + 2 * sqrt(A) * alpha);
296 s->b1 =-2 * A * ((A - 1) + (A + 1) * cos(w0));
297 s->b2 = A * ((A + 1) + (A - 1) * cos(w0) - 2 * sqrt(A) * alpha);
302 s->a1 = -2 * cos(w0);
306 s->b2 = -sin(w0) / 2;
309 s->a1 = -2 * cos(w0);
318 s->a1 = -2 * cos(w0);
321 s->b1 = -2 * cos(w0);
334 s->a1 = -2 * cos(w0);
336 s->b0 = (1 - cos(w0)) / 2;
338 s->b2 = (1 - cos(w0)) / 2;
346 s->b0 = (1 - s->a1) / 2;
351 s->a1 = -2 * cos(w0);
353 s->b0 = (1 + cos(w0)) / 2;
354 s->b1 = -(1 + cos(w0));
355 s->b2 = (1 + cos(w0)) / 2;
360 s->a1 = -2 * cos(w0);
363 s->b1 = -2 * cos(w0);
376 s->cache = av_realloc_f(s->cache, sizeof(ChanCache), inlink->channels);
378 return AVERROR(ENOMEM);
379 memset(s->cache, 0, sizeof(ChanCache) * inlink->channels);
381 switch (inlink->format) {
382 case AV_SAMPLE_FMT_S16P: s->filter = biquad_s16; break;
383 case AV_SAMPLE_FMT_S32P: s->filter = biquad_s32; break;
384 case AV_SAMPLE_FMT_FLTP: s->filter = biquad_flt; break;
385 case AV_SAMPLE_FMT_DBLP: s->filter = biquad_dbl; break;
386 default: av_assert0(0);
392 static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
394 BiquadsContext *s = inlink->dst->priv;
395 AVFilterLink *outlink = inlink->dst->outputs[0];
397 int nb_samples = buf->nb_samples;
400 if (av_frame_is_writable(buf)) {
403 out_buf = ff_get_audio_buffer(inlink, nb_samples);
406 return AVERROR(ENOMEM);
408 av_frame_copy_props(out_buf, buf);
411 for (ch = 0; ch < av_frame_get_channels(buf); ch++)
412 s->filter(buf->extended_data[ch],
413 out_buf->extended_data[ch], nb_samples,
414 &s->cache[ch].i1, &s->cache[ch].i2,
415 &s->cache[ch].o1, &s->cache[ch].o2,
416 s->b0, s->b1, s->b2, s->a1, s->a2);
421 return ff_filter_frame(outlink, out_buf);
424 static av_cold void uninit(AVFilterContext *ctx)
426 BiquadsContext *s = ctx->priv;
431 static const AVFilterPad inputs[] = {
434 .type = AVMEDIA_TYPE_AUDIO,
435 .filter_frame = filter_frame,
440 static const AVFilterPad outputs[] = {
443 .type = AVMEDIA_TYPE_AUDIO,
444 .config_props = config_output,
449 #define OFFSET(x) offsetof(BiquadsContext, x)
450 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
452 #define DEFINE_BIQUAD_FILTER(name_, description_) \
453 AVFILTER_DEFINE_CLASS(name_); \
454 static av_cold int name_##_init(AVFilterContext *ctx) \
456 BiquadsContext *s = ctx->priv; \
457 s->class = &name_##_class; \
458 s->filter_type = name_; \
462 AVFilter ff_af_##name_ = { \
464 .description = NULL_IF_CONFIG_SMALL(description_), \
465 .priv_size = sizeof(BiquadsContext), \
466 .init = name_##_init, \
468 .query_formats = query_formats, \
470 .outputs = outputs, \
471 .priv_class = &name_##_class, \
474 #if CONFIG_EQUALIZER_FILTER
475 static const AVOption equalizer_options[] = {
476 {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, 999999, FLAGS},
477 {"f", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, 999999, FLAGS},
478 {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, SLOPE, FLAGS, "width_type"},
479 {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HERTZ}, 0, 0, FLAGS, "width_type"},
480 {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
481 {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
482 {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
483 {"width", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 999, FLAGS},
484 {"w", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 999, FLAGS},
485 {"gain", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
486 {"g", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
490 DEFINE_BIQUAD_FILTER(equalizer, "Apply two-pole peaking equalization (EQ) filter.");
491 #endif /* CONFIG_EQUALIZER_FILTER */
492 #if CONFIG_BASS_FILTER
493 static const AVOption bass_options[] = {
494 {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=100}, 0, 999999, FLAGS},
495 {"f", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=100}, 0, 999999, FLAGS},
496 {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, SLOPE, FLAGS, "width_type"},
497 {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HERTZ}, 0, 0, FLAGS, "width_type"},
498 {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
499 {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
500 {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
501 {"width", "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS},
502 {"w", "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS},
503 {"gain", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
504 {"g", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
508 DEFINE_BIQUAD_FILTER(bass, "Boost or cut lower frequencies.");
509 #endif /* CONFIG_BASS_FILTER */
510 #if CONFIG_TREBLE_FILTER
511 static const AVOption treble_options[] = {
512 {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
513 {"f", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
514 {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, SLOPE, FLAGS, "width_type"},
515 {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HERTZ}, 0, 0, FLAGS, "width_type"},
516 {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
517 {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
518 {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
519 {"width", "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS},
520 {"w", "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS},
521 {"gain", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
522 {"g", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
526 DEFINE_BIQUAD_FILTER(treble, "Boost or cut upper frequencies.");
527 #endif /* CONFIG_TREBLE_FILTER */
528 #if CONFIG_BANDPASS_FILTER
529 static const AVOption bandpass_options[] = {
530 {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
531 {"f", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
532 {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, SLOPE, FLAGS, "width_type"},
533 {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HERTZ}, 0, 0, FLAGS, "width_type"},
534 {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
535 {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
536 {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
537 {"width", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 999, FLAGS},
538 {"w", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 999, FLAGS},
539 {"csg", "use constant skirt gain", OFFSET(csg), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
543 DEFINE_BIQUAD_FILTER(bandpass, "Apply a two-pole Butterworth band-pass filter.");
544 #endif /* CONFIG_BANDPASS_FILTER */
545 #if CONFIG_BANDREJECT_FILTER
546 static const AVOption bandreject_options[] = {
547 {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
548 {"f", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
549 {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, SLOPE, FLAGS, "width_type"},
550 {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HERTZ}, 0, 0, FLAGS, "width_type"},
551 {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
552 {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
553 {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
554 {"width", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 999, FLAGS},
555 {"w", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 999, FLAGS},
559 DEFINE_BIQUAD_FILTER(bandreject, "Apply a two-pole Butterworth band-reject filter.");
560 #endif /* CONFIG_BANDREJECT_FILTER */
561 #if CONFIG_LOWPASS_FILTER
562 static const AVOption lowpass_options[] = {
563 {"frequency", "set frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=500}, 0, 999999, FLAGS},
564 {"f", "set frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=500}, 0, 999999, FLAGS},
565 {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, SLOPE, FLAGS, "width_type"},
566 {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HERTZ}, 0, 0, FLAGS, "width_type"},
567 {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
568 {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
569 {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
570 {"width", "set width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.707}, 0, 99999, FLAGS},
571 {"w", "set width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.707}, 0, 99999, FLAGS},
572 {"poles", "set number of poles", OFFSET(poles), AV_OPT_TYPE_INT, {.i64=2}, 1, 2, FLAGS},
573 {"p", "set number of poles", OFFSET(poles), AV_OPT_TYPE_INT, {.i64=2}, 1, 2, FLAGS},
577 DEFINE_BIQUAD_FILTER(lowpass, "Apply a low-pass filter with 3dB point frequency.");
578 #endif /* CONFIG_LOWPASS_FILTER */
579 #if CONFIG_HIGHPASS_FILTER
580 static const AVOption highpass_options[] = {
581 {"frequency", "set frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
582 {"f", "set frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
583 {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HERTZ, SLOPE, FLAGS, "width_type"},
584 {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HERTZ}, 0, 0, FLAGS, "width_type"},
585 {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
586 {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
587 {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
588 {"width", "set width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.707}, 0, 99999, FLAGS},
589 {"w", "set width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.707}, 0, 99999, FLAGS},
590 {"poles", "set number of poles", OFFSET(poles), AV_OPT_TYPE_INT, {.i64=2}, 1, 2, FLAGS},
591 {"p", "set number of poles", OFFSET(poles), AV_OPT_TYPE_INT, {.i64=2}, 1, 2, FLAGS},
595 DEFINE_BIQUAD_FILTER(highpass, "Apply a high-pass filter with 3dB point frequency.");
596 #endif /* CONFIG_HIGHPASS_FILTER */
597 #if CONFIG_ALLPASS_FILTER
598 static const AVOption allpass_options[] = {
599 {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
600 {"f", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
601 {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=HERTZ}, HERTZ, SLOPE, FLAGS, "width_type"},
602 {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HERTZ}, 0, 0, FLAGS, "width_type"},
603 {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
604 {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
605 {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
606 {"width", "set filter-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=707.1}, 0, 99999, FLAGS},
607 {"w", "set filter-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=707.1}, 0, 99999, FLAGS},
611 DEFINE_BIQUAD_FILTER(allpass, "Apply a two-pole all-pass filter.");
612 #endif /* CONFIG_ALLPASS_FILTER */
613 #if CONFIG_BIQUAD_FILTER
614 static const AVOption biquad_options[] = {
615 {"a0", NULL, OFFSET(a0), AV_OPT_TYPE_DOUBLE, {.dbl=1}, INT16_MIN, INT16_MAX, FLAGS},
616 {"a1", NULL, OFFSET(a1), AV_OPT_TYPE_DOUBLE, {.dbl=1}, INT16_MIN, INT16_MAX, FLAGS},
617 {"a2", NULL, OFFSET(a2), AV_OPT_TYPE_DOUBLE, {.dbl=1}, INT16_MIN, INT16_MAX, FLAGS},
618 {"b0", NULL, OFFSET(b0), AV_OPT_TYPE_DOUBLE, {.dbl=1}, INT16_MIN, INT16_MAX, FLAGS},
619 {"b1", NULL, OFFSET(b1), AV_OPT_TYPE_DOUBLE, {.dbl=1}, INT16_MIN, INT16_MAX, FLAGS},
620 {"b2", NULL, OFFSET(b2), AV_OPT_TYPE_DOUBLE, {.dbl=1}, INT16_MIN, INT16_MAX, FLAGS},
624 DEFINE_BIQUAD_FILTER(biquad, "Apply a biquad IIR filter with the given coefficients.");
625 #endif /* CONFIG_BIQUAD_FILTER */