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/opt.h"
66 #include "libavutil/avassert.h"
92 typedef struct ChanCache {
100 enum FilterType filter_type;
101 enum WidthType width_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, const char *args)
121 BiquadsContext *p = ctx->priv;
124 av_opt_set_defaults(p);
126 if ((ret = av_set_options_string(p, args, "=", ":")) < 0)
129 if (p->filter_type != biquad) {
130 if (p->frequency <= 0 || p->width <= 0) {
131 av_log(ctx, AV_LOG_ERROR, "Invalid frequency %f and/or width %f <= 0\n",
132 p->frequency, p->width);
133 return AVERROR(EINVAL);
140 static int query_formats(AVFilterContext *ctx)
142 AVFilterFormats *formats;
143 AVFilterChannelLayouts *layouts;
144 static const enum AVSampleFormat sample_fmts[] = {
152 layouts = ff_all_channel_layouts();
154 return AVERROR(ENOMEM);
155 ff_set_common_channel_layouts(ctx, layouts);
157 formats = ff_make_format_list(sample_fmts);
159 return AVERROR(ENOMEM);
160 ff_set_common_formats(ctx, formats);
162 formats = ff_all_samplerates();
164 return AVERROR(ENOMEM);
165 ff_set_common_samplerates(ctx, formats);
170 #define BIQUAD_FILTER(name, type, min, max) \
171 static void biquad_## name (const void *input, void *output, int len, \
172 double *in1, double *in2, \
173 double *out1, double *out2, \
174 double b0, double b1, double b2, \
175 double a1, double a2) \
177 const type *ibuf = input; \
178 type *obuf = output; \
187 for (i = 0; i+1 < len; i++) { \
188 o2 = i2 * b2 + i1 * b1 + ibuf[i] * b0 + o2 * a2 + o1 * a1; \
191 av_log(NULL, AV_LOG_WARNING, "clipping\n"); \
193 } else if (o2 > max) { \
194 av_log(NULL, AV_LOG_WARNING, "clipping\n"); \
200 o1 = i1 * b2 + i2 * b1 + ibuf[i] * b0 + o1 * a2 + o2 * a1; \
203 av_log(NULL, AV_LOG_WARNING, "clipping\n"); \
205 } else if (o1 > max) { \
206 av_log(NULL, AV_LOG_WARNING, "clipping\n"); \
213 double o0 = ibuf[i] * b0 + i1 * b1 + i2 * b2 + o1 * a1 + o2 * a2; \
219 av_log(NULL, AV_LOG_WARNING, "clipping\n"); \
221 } else if (o0 > max) { \
222 av_log(NULL, AV_LOG_WARNING, "clipping\n"); \
234 BIQUAD_FILTER(s16, int16_t, INT16_MIN, INT16_MAX)
235 BIQUAD_FILTER(s32, int32_t, INT32_MIN, INT32_MAX)
236 BIQUAD_FILTER(flt, float, -1., 1.)
237 BIQUAD_FILTER(dbl, double, -1., 1.)
239 static int config_output(AVFilterLink *outlink)
241 AVFilterContext *ctx = outlink->src;
242 BiquadsContext *p = ctx->priv;
243 AVFilterLink *inlink = ctx->inputs[0];
244 double A = exp(p->gain / 40 * log(10.));
245 double w0 = 2 * M_PI * p->frequency / inlink->sample_rate;
249 av_log(ctx, AV_LOG_ERROR,
250 "Invalid frequency %f. Frequency must be less than half the sample-rate %d.\n",
251 p->frequency, inlink->sample_rate);
252 return AVERROR(EINVAL);
255 switch (p->width_type) {
260 alpha = sin(w0) / (2 * p->frequency / p->width);
263 alpha = sin(w0) * sinh(log(2.) / 2 * p->width * w0 / sin(w0));
266 alpha = sin(w0) / (2 * p->width);
269 alpha = sin(w0) / 2 * sqrt((A + 1 / A) * (1 / p->width - 1) + 2);
275 switch (p->filter_type) {
279 p->a0 = 1 + alpha / A;
280 p->a1 = -2 * cos(w0);
281 p->a2 = 1 - alpha / A;
282 p->b0 = 1 + alpha * A;
283 p->b1 = -2 * cos(w0);
284 p->b2 = 1 - alpha * A;
287 p->a0 = (A + 1) + (A - 1) * cos(w0) + 2 * sqrt(A) * alpha;
288 p->a1 = -2 * ((A - 1) + (A + 1) * cos(w0));
289 p->a2 = (A + 1) + (A - 1) * cos(w0) - 2 * sqrt(A) * alpha;
290 p->b0 = A * ((A + 1) - (A - 1) * cos(w0) + 2 * sqrt(A) * alpha);
291 p->b1 = 2 * A * ((A - 1) - (A + 1) * cos(w0));
292 p->b2 = A * ((A + 1) - (A - 1) * cos(w0) - 2 * sqrt(A) * alpha);
295 p->a0 = (A + 1) - (A - 1) * cos(w0) + 2 * sqrt(A) * alpha;
296 p->a1 = 2 * ((A - 1) - (A + 1) * cos(w0));
297 p->a2 = (A + 1) - (A - 1) * cos(w0) - 2 * sqrt(A) * alpha;
298 p->b0 = A * ((A + 1) + (A - 1) * cos(w0) + 2 * sqrt(A) * alpha);
299 p->b1 =-2 * A * ((A - 1) + (A + 1) * cos(w0));
300 p->b2 = A * ((A + 1) + (A - 1) * cos(w0) - 2 * sqrt(A) * alpha);
305 p->a1 = -2 * cos(w0);
309 p->b2 = -sin(w0) / 2;
312 p->a1 = -2 * cos(w0);
321 p->a1 = -2 * cos(w0);
324 p->b1 = -2 * cos(w0);
337 p->a1 = -2 * cos(w0);
339 p->b0 = (1 - cos(w0)) / 2;
341 p->b2 = (1 - cos(w0)) / 2;
349 p->b0 = (1 - p->a1) / 2;
354 p->a1 = -2 * cos(w0);
356 p->b0 = (1 + cos(w0)) / 2;
357 p->b1 = -(1 + cos(w0));
358 p->b2 = (1 + cos(w0)) / 2;
363 p->a1 = -2 * cos(w0);
366 p->b1 = -2 * cos(w0);
379 p->cache = av_realloc_f(p->cache, sizeof(ChanCache), inlink->channels);
381 return AVERROR(ENOMEM);
383 switch (inlink->format) {
384 case AV_SAMPLE_FMT_S16P: p->filter = biquad_s16; break;
385 case AV_SAMPLE_FMT_S32P: p->filter = biquad_s32; break;
386 case AV_SAMPLE_FMT_FLTP: p->filter = biquad_flt; break;
387 case AV_SAMPLE_FMT_DBLP: p->filter = biquad_dbl; break;
388 default: av_assert0(0);
394 static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *buf)
396 BiquadsContext *p = inlink->dst->priv;
397 AVFilterLink *outlink = inlink->dst->outputs[0];
398 AVFilterBufferRef *out_buf;
399 int nb_samples = buf->audio->nb_samples;
402 if (buf->perms & AV_PERM_WRITE) {
405 out_buf = ff_get_audio_buffer(inlink, AV_PERM_WRITE, nb_samples);
407 return AVERROR(ENOMEM);
408 out_buf->pts = buf->pts;
411 for (ch = 0; ch < buf->audio->channels; ch++)
412 p->filter(buf->extended_data[ch],
413 out_buf->extended_data[ch], nb_samples,
414 &p->cache[ch].i1, &p->cache[ch].i2,
415 &p->cache[ch].o1, &p->cache[ch].o2,
416 p->b0, p->b1, p->b2, p->a1, p->a2);
419 avfilter_unref_buffer(buf);
421 return ff_filter_frame(outlink, out_buf);
424 static av_cold void uninit(AVFilterContext *ctx)
426 BiquadsContext *p = ctx->priv;
432 static const AVFilterPad inputs[] = {
435 .type = AVMEDIA_TYPE_AUDIO,
436 .filter_frame = filter_frame,
441 static const AVFilterPad outputs[] = {
444 .type = AVMEDIA_TYPE_AUDIO,
445 .config_props = config_output,
450 #define OFFSET(x) offsetof(BiquadsContext, x)
451 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
453 #define DEFINE_BIQUAD_FILTER(name_, description_) \
454 AVFILTER_DEFINE_CLASS(name_); \
455 static av_cold int name_##_init(AVFilterContext *ctx, const char *args) \
457 BiquadsContext *p = ctx->priv; \
458 p->class = &name_##_class; \
459 p->filter_type = name_; \
460 return init(ctx, args); \
463 AVFilter avfilter_af_##name_ = { \
465 .description = NULL_IF_CONFIG_SMALL(description_), \
466 .priv_size = sizeof(BiquadsContext), \
467 .init = name_##_init, \
469 .query_formats = query_formats, \
471 .outputs = outputs, \
472 .priv_class = &name_##_class, \
475 #if CONFIG_EQUALIZER_FILTER
476 static const AVOption equalizer_options[] = {
477 {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, 999999, FLAGS},
478 {"f", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, 999999, FLAGS},
479 {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HZ, SLOPE, FLAGS, "width_type"},
480 {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HZ}, 0, 0, FLAGS, "width_type"},
481 {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
482 {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
483 {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
484 {"width", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 999, FLAGS},
485 {"w", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 999, FLAGS},
486 {"gain", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
487 {"g", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
491 DEFINE_BIQUAD_FILTER(equalizer, "Apply two-pole peaking equalization (EQ) filter.");
492 #endif /* CONFIG_EQUALIZER_FILTER */
493 #if CONFIG_BASS_FILTER
494 static const AVOption bass_options[] = {
495 {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=100}, 0, 999999, FLAGS},
496 {"f", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=100}, 0, 999999, FLAGS},
497 {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HZ, SLOPE, FLAGS, "width_type"},
498 {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HZ}, 0, 0, FLAGS, "width_type"},
499 {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
500 {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
501 {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
502 {"width", "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS},
503 {"w", "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS},
504 {"gain", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
505 {"g", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
509 DEFINE_BIQUAD_FILTER(bass, "Boost or cut lower frequencies.");
510 #endif /* CONFIG_BASS_FILTER */
511 #if CONFIG_TREBLE_FILTER
512 static const AVOption treble_options[] = {
513 {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
514 {"f", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
515 {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HZ, SLOPE, FLAGS, "width_type"},
516 {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HZ}, 0, 0, FLAGS, "width_type"},
517 {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
518 {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
519 {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
520 {"width", "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS},
521 {"w", "set shelf transition steep", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 99999, FLAGS},
522 {"gain", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
523 {"g", "set gain", OFFSET(gain), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -900, 900, FLAGS},
527 DEFINE_BIQUAD_FILTER(treble, "Boost or cut upper frequencies.");
528 #endif /* CONFIG_TREBLE_FILTER */
529 #if CONFIG_BANDPASS_FILTER
530 static const AVOption bandpass_options[] = {
531 {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
532 {"f", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
533 {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HZ, SLOPE, FLAGS, "width_type"},
534 {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HZ}, 0, 0, FLAGS, "width_type"},
535 {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
536 {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
537 {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
538 {"width", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 999, FLAGS},
539 {"w", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 999, FLAGS},
540 {"csg", "use constant skirt gain", OFFSET(csg), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS},
544 DEFINE_BIQUAD_FILTER(bandpass, "Apply a two-pole Butterworth band-pass filter.");
545 #endif /* CONFIG_BANDPASS_FILTER */
546 #if CONFIG_BANDREJECT_FILTER
547 static const AVOption bandreject_options[] = {
548 {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
549 {"f", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
550 {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HZ, SLOPE, FLAGS, "width_type"},
551 {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HZ}, 0, 0, FLAGS, "width_type"},
552 {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
553 {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
554 {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
555 {"width", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 999, FLAGS},
556 {"w", "set band-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.5}, 0, 999, FLAGS},
560 DEFINE_BIQUAD_FILTER(bandreject, "Apply a two-pole Butterworth band-reject filter.");
561 #endif /* CONFIG_BANDREJECT_FILTER */
562 #if CONFIG_LOWPASS_FILTER
563 static const AVOption lowpass_options[] = {
564 {"frequency", "set frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=500}, 0, 999999, FLAGS},
565 {"f", "set frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=500}, 0, 999999, FLAGS},
566 {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HZ, SLOPE, FLAGS, "width_type"},
567 {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HZ}, 0, 0, FLAGS, "width_type"},
568 {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
569 {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
570 {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
571 {"width", "set width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.707}, 0, 99999, FLAGS},
572 {"w", "set width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.707}, 0, 99999, FLAGS},
573 {"poles", "set number of poles", OFFSET(poles), AV_OPT_TYPE_INT, {.i64=2}, 1, 2, FLAGS},
574 {"p", "set number of poles", OFFSET(poles), AV_OPT_TYPE_INT, {.i64=2}, 1, 2, FLAGS},
578 DEFINE_BIQUAD_FILTER(lowpass, "Apply a low-pass filter with 3dB point frequency.");
579 #endif /* CONFIG_LOWPASS_FILTER */
580 #if CONFIG_HIGHPASS_FILTER
581 static const AVOption highpass_options[] = {
582 {"frequency", "set frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
583 {"f", "set frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
584 {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=QFACTOR}, HZ, SLOPE, FLAGS, "width_type"},
585 {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HZ}, 0, 0, FLAGS, "width_type"},
586 {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
587 {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
588 {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
589 {"width", "set width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.707}, 0, 99999, FLAGS},
590 {"w", "set width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=0.707}, 0, 99999, FLAGS},
591 {"poles", "set number of poles", OFFSET(poles), AV_OPT_TYPE_INT, {.i64=2}, 1, 2, FLAGS},
592 {"p", "set number of poles", OFFSET(poles), AV_OPT_TYPE_INT, {.i64=2}, 1, 2, FLAGS},
596 DEFINE_BIQUAD_FILTER(highpass, "Apply a high-pass filter with 3dB point frequency.");
597 #endif /* CONFIG_HIGHPASS_FILTER */
598 #if CONFIG_ALLPASS_FILTER
599 static const AVOption allpass_options[] = {
600 {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
601 {"f", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=3000}, 0, 999999, FLAGS},
602 {"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=HZ}, HZ, SLOPE, FLAGS, "width_type"},
603 {"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HZ}, 0, 0, FLAGS, "width_type"},
604 {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"},
605 {"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"},
606 {"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"},
607 {"width", "set filter-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=707.1}, 0, 99999, FLAGS},
608 {"w", "set filter-width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=707.1}, 0, 99999, FLAGS},
612 DEFINE_BIQUAD_FILTER(allpass, "Apply a two-pole all-pass filter.");
613 #endif /* CONFIG_ALLPASS_FILTER */
614 #if CONFIG_BIQUAD_FILTER
615 static const AVOption biquad_options[] = {
616 {"a0", NULL, OFFSET(a0), AV_OPT_TYPE_DOUBLE, {.dbl=1}, INT16_MAX, INT16_MAX, FLAGS},
617 {"a1", NULL, OFFSET(a1), AV_OPT_TYPE_DOUBLE, {.dbl=1}, INT16_MAX, INT16_MAX, FLAGS},
618 {"a2", NULL, OFFSET(a2), AV_OPT_TYPE_DOUBLE, {.dbl=1}, INT16_MAX, INT16_MAX, FLAGS},
619 {"b0", NULL, OFFSET(b0), AV_OPT_TYPE_DOUBLE, {.dbl=1}, INT16_MAX, INT16_MAX, FLAGS},
620 {"b1", NULL, OFFSET(b1), AV_OPT_TYPE_DOUBLE, {.dbl=1}, INT16_MAX, INT16_MAX, FLAGS},
621 {"b2", NULL, OFFSET(b2), AV_OPT_TYPE_DOUBLE, {.dbl=1}, INT16_MAX, INT16_MAX, FLAGS},
625 DEFINE_BIQUAD_FILTER(biquad, "Apply a biquad IIR filter with the given coefficients.");
626 #endif /* CONFIG_BIQUAD_FILTER */