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
;
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
)
121 BiquadsContext
*p
= ctx
->priv
;
123 if (p
->filter_type
!= biquad
) {
124 if (p
->frequency
<= 0 || p
->width
<= 0) {
125 av_log(ctx
, AV_LOG_ERROR
, "Invalid frequency %f and/or width %f <= 0\n",
126 p
->frequency
, p
->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
[] = {
146 layouts
= ff_all_channel_layouts();
148 return AVERROR(ENOMEM
);
149 ff_set_common_channel_layouts(ctx
, layouts
);
151 formats
= ff_make_format_list(sample_fmts
);
153 return AVERROR(ENOMEM
);
154 ff_set_common_formats(ctx
, formats
);
156 formats
= ff_all_samplerates();
158 return AVERROR(ENOMEM
);
159 ff_set_common_samplerates(ctx
, formats
);
164 #define BIQUAD_FILTER(name, type, min, max, need_clipping) \
165 static void biquad_## name (const void *input, void *output, int len, \
166 double *in1, double *in2, \
167 double *out1, double *out2, \
168 double b0, double b1, double b2, \
169 double a1, double a2) \
171 const type *ibuf = input; \
172 type *obuf = output; \
181 for (i = 0; i+1 < len; i++) { \
182 o2 = i2 * b2 + i1 * b1 + ibuf[i] * b0 + o2 * a2 + o1 * a1; \
184 if (need_clipping && o2 < min) { \
185 av_log(NULL, AV_LOG_WARNING, "clipping\n"); \
187 } else if (need_clipping && o2 > max) { \
188 av_log(NULL, AV_LOG_WARNING, "clipping\n"); \
194 o1 = i1 * b2 + i2 * b1 + ibuf[i] * b0 + o1 * a2 + o2 * a1; \
196 if (need_clipping && o1 < min) { \
197 av_log(NULL, AV_LOG_WARNING, "clipping\n"); \
199 } else if (need_clipping && o1 > max) { \
200 av_log(NULL, AV_LOG_WARNING, "clipping\n"); \
207 double o0 = ibuf[i] * b0 + i1 * b1 + i2 * b2 + o1 * a1 + o2 * a2; \
212 if (need_clipping && o0 < min) { \
213 av_log(NULL, AV_LOG_WARNING, "clipping\n"); \
215 } else if (need_clipping && o0 > max) { \
216 av_log(NULL, AV_LOG_WARNING, "clipping\n"); \
228 BIQUAD_FILTER(s16
, int16_t, INT16_MIN
, INT16_MAX
, 1)
229 BIQUAD_FILTER(s32
, int32_t, INT32_MIN
, INT32_MAX
, 1)
230 BIQUAD_FILTER(flt
, float, -1., 1., 0)
231 BIQUAD_FILTER(dbl
, double, -1., 1., 0)
233 static int config_output(AVFilterLink
*outlink
)
235 AVFilterContext
*ctx
= outlink
->src
;
236 BiquadsContext
*p
= ctx
->priv
;
237 AVFilterLink
*inlink
= ctx
->inputs
[0];
238 double A
= exp(p
->gain
/ 40 * log(10.));
239 double w0
= 2 * M_PI
* p
->frequency
/ inlink
->sample_rate
;
243 av_log(ctx
, AV_LOG_ERROR
,
244 "Invalid frequency %f. Frequency must be less than half the sample-rate %d.\n",
245 p
->frequency
, inlink
->sample_rate
);
246 return AVERROR(EINVAL
);
249 switch (p
->width_type
) {
254 alpha
= sin(w0
) / (2 * p
->frequency
/ p
->width
);
257 alpha
= sin(w0
) * sinh(log(2.) / 2 * p
->width
* w0
/ sin(w0
));
260 alpha
= sin(w0
) / (2 * p
->width
);
263 alpha
= sin(w0
) / 2 * sqrt((A
+ 1 / A
) * (1 / p
->width
- 1) + 2);
269 switch (p
->filter_type
) {
273 p
->a0
= 1 + alpha
/ A
;
274 p
->a1
= -2 * cos(w0
);
275 p
->a2
= 1 - alpha
/ A
;
276 p
->b0
= 1 + alpha
* A
;
277 p
->b1
= -2 * cos(w0
);
278 p
->b2
= 1 - alpha
* A
;
281 p
->a0
= (A
+ 1) + (A
- 1) * cos(w0
) + 2 * sqrt(A
) * alpha
;
282 p
->a1
= -2 * ((A
- 1) + (A
+ 1) * cos(w0
));
283 p
->a2
= (A
+ 1) + (A
- 1) * cos(w0
) - 2 * sqrt(A
) * alpha
;
284 p
->b0
= A
* ((A
+ 1) - (A
- 1) * cos(w0
) + 2 * sqrt(A
) * alpha
);
285 p
->b1
= 2 * A
* ((A
- 1) - (A
+ 1) * cos(w0
));
286 p
->b2
= A
* ((A
+ 1) - (A
- 1) * cos(w0
) - 2 * sqrt(A
) * alpha
);
289 p
->a0
= (A
+ 1) - (A
- 1) * cos(w0
) + 2 * sqrt(A
) * alpha
;
290 p
->a1
= 2 * ((A
- 1) - (A
+ 1) * cos(w0
));
291 p
->a2
= (A
+ 1) - (A
- 1) * cos(w0
) - 2 * sqrt(A
) * alpha
;
292 p
->b0
= A
* ((A
+ 1) + (A
- 1) * cos(w0
) + 2 * sqrt(A
) * alpha
);
293 p
->b1
=-2 * A
* ((A
- 1) + (A
+ 1) * cos(w0
));
294 p
->b2
= A
* ((A
+ 1) + (A
- 1) * cos(w0
) - 2 * sqrt(A
) * alpha
);
299 p
->a1
= -2 * cos(w0
);
303 p
->b2
= -sin(w0
) / 2;
306 p
->a1
= -2 * cos(w0
);
315 p
->a1
= -2 * cos(w0
);
318 p
->b1
= -2 * cos(w0
);
331 p
->a1
= -2 * cos(w0
);
333 p
->b0
= (1 - cos(w0
)) / 2;
335 p
->b2
= (1 - cos(w0
)) / 2;
343 p
->b0
= (1 - p
->a1
) / 2;
348 p
->a1
= -2 * cos(w0
);
350 p
->b0
= (1 + cos(w0
)) / 2;
351 p
->b1
= -(1 + cos(w0
));
352 p
->b2
= (1 + cos(w0
)) / 2;
357 p
->a1
= -2 * cos(w0
);
360 p
->b1
= -2 * cos(w0
);
373 p
->cache
= av_realloc_f(p
->cache
, sizeof(ChanCache
), inlink
->channels
);
375 return AVERROR(ENOMEM
);
376 memset(p
->cache
, 0, sizeof(ChanCache
) * inlink
->channels
);
378 switch (inlink
->format
) {
379 case AV_SAMPLE_FMT_S16P
: p
->filter
= biquad_s16
; break;
380 case AV_SAMPLE_FMT_S32P
: p
->filter
= biquad_s32
; break;
381 case AV_SAMPLE_FMT_FLTP
: p
->filter
= biquad_flt
; break;
382 case AV_SAMPLE_FMT_DBLP
: p
->filter
= biquad_dbl
; break;
383 default: av_assert0(0);
389 static int filter_frame(AVFilterLink
*inlink
, AVFrame
*buf
)
391 BiquadsContext
*p
= inlink
->dst
->priv
;
392 AVFilterLink
*outlink
= inlink
->dst
->outputs
[0];
394 int nb_samples
= buf
->nb_samples
;
397 if (av_frame_is_writable(buf
)) {
400 out_buf
= ff_get_audio_buffer(inlink
, nb_samples
);
402 return AVERROR(ENOMEM
);
403 av_frame_copy_props(out_buf
, buf
);
406 for (ch
= 0; ch
< av_frame_get_channels(buf
); ch
++)
407 p
->filter(buf
->extended_data
[ch
],
408 out_buf
->extended_data
[ch
], nb_samples
,
409 &p
->cache
[ch
].i1
, &p
->cache
[ch
].i2
,
410 &p
->cache
[ch
].o1
, &p
->cache
[ch
].o2
,
411 p
->b0
, p
->b1
, p
->b2
, p
->a1
, p
->a2
);
416 return ff_filter_frame(outlink
, out_buf
);
419 static av_cold
void uninit(AVFilterContext
*ctx
)
421 BiquadsContext
*p
= ctx
->priv
;
426 static const AVFilterPad inputs
[] = {
429 .type
= AVMEDIA_TYPE_AUDIO
,
430 .filter_frame
= filter_frame
,
435 static const AVFilterPad outputs
[] = {
438 .type
= AVMEDIA_TYPE_AUDIO
,
439 .config_props
= config_output
,
444 #define OFFSET(x) offsetof(BiquadsContext, x)
445 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
447 #define DEFINE_BIQUAD_FILTER(name_, description_) \
448 AVFILTER_DEFINE_CLASS(name_); \
449 static av_cold int name_##_init(AVFilterContext *ctx) \
451 BiquadsContext *p = ctx->priv; \
452 p->class = &name_##_class; \
453 p->filter_type = name_; \
457 AVFilter ff_af_##name_ = { \
459 .description = NULL_IF_CONFIG_SMALL(description_), \
460 .priv_size = sizeof(BiquadsContext), \
461 .init = name_##_init, \
463 .query_formats = query_formats, \
465 .outputs = outputs, \
466 .priv_class = &name_##_class, \
469 #if CONFIG_EQUALIZER_FILTER
470 static const AVOption equalizer_options
[] = {
471 {"frequency", "set central frequency", OFFSET(frequency
), AV_OPT_TYPE_DOUBLE
, {.dbl
=0}, 0, 999999, FLAGS
},
472 {"f", "set central frequency", OFFSET(frequency
), AV_OPT_TYPE_DOUBLE
, {.dbl
=0}, 0, 999999, FLAGS
},
473 {"width_type", "set filter-width type", OFFSET(width_type
), AV_OPT_TYPE_INT
, {.i64
=QFACTOR
}, HERTZ
, SLOPE
, FLAGS
, "width_type"},
474 {"h", "Hz", 0, AV_OPT_TYPE_CONST
, {.i64
=HERTZ
}, 0, 0, FLAGS
, "width_type"},
475 {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST
, {.i64
=QFACTOR
}, 0, 0, FLAGS
, "width_type"},
476 {"o", "octave", 0, AV_OPT_TYPE_CONST
, {.i64
=OCTAVE
}, 0, 0, FLAGS
, "width_type"},
477 {"s", "slope", 0, AV_OPT_TYPE_CONST
, {.i64
=SLOPE
}, 0, 0, FLAGS
, "width_type"},
478 {"width", "set band-width", OFFSET(width
), AV_OPT_TYPE_DOUBLE
, {.dbl
=1}, 0, 999, FLAGS
},
479 {"w", "set band-width", OFFSET(width
), AV_OPT_TYPE_DOUBLE
, {.dbl
=1}, 0, 999, FLAGS
},
480 {"gain", "set gain", OFFSET(gain
), AV_OPT_TYPE_DOUBLE
, {.dbl
=0}, -900, 900, FLAGS
},
481 {"g", "set gain", OFFSET(gain
), AV_OPT_TYPE_DOUBLE
, {.dbl
=0}, -900, 900, FLAGS
},
485 DEFINE_BIQUAD_FILTER(equalizer
, "Apply two-pole peaking equalization (EQ) filter.");
486 #endif /* CONFIG_EQUALIZER_FILTER */
487 #if CONFIG_BASS_FILTER
488 static const AVOption bass_options
[] = {
489 {"frequency", "set central frequency", OFFSET(frequency
), AV_OPT_TYPE_DOUBLE
, {.dbl
=100}, 0, 999999, FLAGS
},
490 {"f", "set central frequency", OFFSET(frequency
), AV_OPT_TYPE_DOUBLE
, {.dbl
=100}, 0, 999999, FLAGS
},
491 {"width_type", "set filter-width type", OFFSET(width_type
), AV_OPT_TYPE_INT
, {.i64
=QFACTOR
}, HERTZ
, SLOPE
, FLAGS
, "width_type"},
492 {"h", "Hz", 0, AV_OPT_TYPE_CONST
, {.i64
=HERTZ
}, 0, 0, FLAGS
, "width_type"},
493 {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST
, {.i64
=QFACTOR
}, 0, 0, FLAGS
, "width_type"},
494 {"o", "octave", 0, AV_OPT_TYPE_CONST
, {.i64
=OCTAVE
}, 0, 0, FLAGS
, "width_type"},
495 {"s", "slope", 0, AV_OPT_TYPE_CONST
, {.i64
=SLOPE
}, 0, 0, FLAGS
, "width_type"},
496 {"width", "set shelf transition steep", OFFSET(width
), AV_OPT_TYPE_DOUBLE
, {.dbl
=0.5}, 0, 99999, FLAGS
},
497 {"w", "set shelf transition steep", OFFSET(width
), AV_OPT_TYPE_DOUBLE
, {.dbl
=0.5}, 0, 99999, FLAGS
},
498 {"gain", "set gain", OFFSET(gain
), AV_OPT_TYPE_DOUBLE
, {.dbl
=0}, -900, 900, FLAGS
},
499 {"g", "set gain", OFFSET(gain
), AV_OPT_TYPE_DOUBLE
, {.dbl
=0}, -900, 900, FLAGS
},
503 DEFINE_BIQUAD_FILTER(bass
, "Boost or cut lower frequencies.");
504 #endif /* CONFIG_BASS_FILTER */
505 #if CONFIG_TREBLE_FILTER
506 static const AVOption treble_options
[] = {
507 {"frequency", "set central frequency", OFFSET(frequency
), AV_OPT_TYPE_DOUBLE
, {.dbl
=3000}, 0, 999999, FLAGS
},
508 {"f", "set central frequency", OFFSET(frequency
), AV_OPT_TYPE_DOUBLE
, {.dbl
=3000}, 0, 999999, FLAGS
},
509 {"width_type", "set filter-width type", OFFSET(width_type
), AV_OPT_TYPE_INT
, {.i64
=QFACTOR
}, HERTZ
, SLOPE
, FLAGS
, "width_type"},
510 {"h", "Hz", 0, AV_OPT_TYPE_CONST
, {.i64
=HERTZ
}, 0, 0, FLAGS
, "width_type"},
511 {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST
, {.i64
=QFACTOR
}, 0, 0, FLAGS
, "width_type"},
512 {"o", "octave", 0, AV_OPT_TYPE_CONST
, {.i64
=OCTAVE
}, 0, 0, FLAGS
, "width_type"},
513 {"s", "slope", 0, AV_OPT_TYPE_CONST
, {.i64
=SLOPE
}, 0, 0, FLAGS
, "width_type"},
514 {"width", "set shelf transition steep", OFFSET(width
), AV_OPT_TYPE_DOUBLE
, {.dbl
=0.5}, 0, 99999, FLAGS
},
515 {"w", "set shelf transition steep", OFFSET(width
), AV_OPT_TYPE_DOUBLE
, {.dbl
=0.5}, 0, 99999, FLAGS
},
516 {"gain", "set gain", OFFSET(gain
), AV_OPT_TYPE_DOUBLE
, {.dbl
=0}, -900, 900, FLAGS
},
517 {"g", "set gain", OFFSET(gain
), AV_OPT_TYPE_DOUBLE
, {.dbl
=0}, -900, 900, FLAGS
},
521 DEFINE_BIQUAD_FILTER(treble
, "Boost or cut upper frequencies.");
522 #endif /* CONFIG_TREBLE_FILTER */
523 #if CONFIG_BANDPASS_FILTER
524 static const AVOption bandpass_options
[] = {
525 {"frequency", "set central frequency", OFFSET(frequency
), AV_OPT_TYPE_DOUBLE
, {.dbl
=3000}, 0, 999999, FLAGS
},
526 {"f", "set central frequency", OFFSET(frequency
), AV_OPT_TYPE_DOUBLE
, {.dbl
=3000}, 0, 999999, FLAGS
},
527 {"width_type", "set filter-width type", OFFSET(width_type
), AV_OPT_TYPE_INT
, {.i64
=QFACTOR
}, HERTZ
, SLOPE
, FLAGS
, "width_type"},
528 {"h", "Hz", 0, AV_OPT_TYPE_CONST
, {.i64
=HERTZ
}, 0, 0, FLAGS
, "width_type"},
529 {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST
, {.i64
=QFACTOR
}, 0, 0, FLAGS
, "width_type"},
530 {"o", "octave", 0, AV_OPT_TYPE_CONST
, {.i64
=OCTAVE
}, 0, 0, FLAGS
, "width_type"},
531 {"s", "slope", 0, AV_OPT_TYPE_CONST
, {.i64
=SLOPE
}, 0, 0, FLAGS
, "width_type"},
532 {"width", "set band-width", OFFSET(width
), AV_OPT_TYPE_DOUBLE
, {.dbl
=0.5}, 0, 999, FLAGS
},
533 {"w", "set band-width", OFFSET(width
), AV_OPT_TYPE_DOUBLE
, {.dbl
=0.5}, 0, 999, FLAGS
},
534 {"csg", "use constant skirt gain", OFFSET(csg
), AV_OPT_TYPE_INT
, {.i64
=0}, 0, 1, FLAGS
},
538 DEFINE_BIQUAD_FILTER(bandpass
, "Apply a two-pole Butterworth band-pass filter.");
539 #endif /* CONFIG_BANDPASS_FILTER */
540 #if CONFIG_BANDREJECT_FILTER
541 static const AVOption bandreject_options
[] = {
542 {"frequency", "set central frequency", OFFSET(frequency
), AV_OPT_TYPE_DOUBLE
, {.dbl
=3000}, 0, 999999, FLAGS
},
543 {"f", "set central frequency", OFFSET(frequency
), AV_OPT_TYPE_DOUBLE
, {.dbl
=3000}, 0, 999999, FLAGS
},
544 {"width_type", "set filter-width type", OFFSET(width_type
), AV_OPT_TYPE_INT
, {.i64
=QFACTOR
}, HERTZ
, SLOPE
, FLAGS
, "width_type"},
545 {"h", "Hz", 0, AV_OPT_TYPE_CONST
, {.i64
=HERTZ
}, 0, 0, FLAGS
, "width_type"},
546 {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST
, {.i64
=QFACTOR
}, 0, 0, FLAGS
, "width_type"},
547 {"o", "octave", 0, AV_OPT_TYPE_CONST
, {.i64
=OCTAVE
}, 0, 0, FLAGS
, "width_type"},
548 {"s", "slope", 0, AV_OPT_TYPE_CONST
, {.i64
=SLOPE
}, 0, 0, FLAGS
, "width_type"},
549 {"width", "set band-width", OFFSET(width
), AV_OPT_TYPE_DOUBLE
, {.dbl
=0.5}, 0, 999, FLAGS
},
550 {"w", "set band-width", OFFSET(width
), AV_OPT_TYPE_DOUBLE
, {.dbl
=0.5}, 0, 999, FLAGS
},
554 DEFINE_BIQUAD_FILTER(bandreject
, "Apply a two-pole Butterworth band-reject filter.");
555 #endif /* CONFIG_BANDREJECT_FILTER */
556 #if CONFIG_LOWPASS_FILTER
557 static const AVOption lowpass_options
[] = {
558 {"frequency", "set frequency", OFFSET(frequency
), AV_OPT_TYPE_DOUBLE
, {.dbl
=500}, 0, 999999, FLAGS
},
559 {"f", "set frequency", OFFSET(frequency
), AV_OPT_TYPE_DOUBLE
, {.dbl
=500}, 0, 999999, FLAGS
},
560 {"width_type", "set filter-width type", OFFSET(width_type
), AV_OPT_TYPE_INT
, {.i64
=QFACTOR
}, HERTZ
, SLOPE
, FLAGS
, "width_type"},
561 {"h", "Hz", 0, AV_OPT_TYPE_CONST
, {.i64
=HERTZ
}, 0, 0, FLAGS
, "width_type"},
562 {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST
, {.i64
=QFACTOR
}, 0, 0, FLAGS
, "width_type"},
563 {"o", "octave", 0, AV_OPT_TYPE_CONST
, {.i64
=OCTAVE
}, 0, 0, FLAGS
, "width_type"},
564 {"s", "slope", 0, AV_OPT_TYPE_CONST
, {.i64
=SLOPE
}, 0, 0, FLAGS
, "width_type"},
565 {"width", "set width", OFFSET(width
), AV_OPT_TYPE_DOUBLE
, {.dbl
=0.707}, 0, 99999, FLAGS
},
566 {"w", "set width", OFFSET(width
), AV_OPT_TYPE_DOUBLE
, {.dbl
=0.707}, 0, 99999, FLAGS
},
567 {"poles", "set number of poles", OFFSET(poles
), AV_OPT_TYPE_INT
, {.i64
=2}, 1, 2, FLAGS
},
568 {"p", "set number of poles", OFFSET(poles
), AV_OPT_TYPE_INT
, {.i64
=2}, 1, 2, FLAGS
},
572 DEFINE_BIQUAD_FILTER(lowpass
, "Apply a low-pass filter with 3dB point frequency.");
573 #endif /* CONFIG_LOWPASS_FILTER */
574 #if CONFIG_HIGHPASS_FILTER
575 static const AVOption highpass_options
[] = {
576 {"frequency", "set frequency", OFFSET(frequency
), AV_OPT_TYPE_DOUBLE
, {.dbl
=3000}, 0, 999999, FLAGS
},
577 {"f", "set frequency", OFFSET(frequency
), AV_OPT_TYPE_DOUBLE
, {.dbl
=3000}, 0, 999999, FLAGS
},
578 {"width_type", "set filter-width type", OFFSET(width_type
), AV_OPT_TYPE_INT
, {.i64
=QFACTOR
}, HERTZ
, SLOPE
, FLAGS
, "width_type"},
579 {"h", "Hz", 0, AV_OPT_TYPE_CONST
, {.i64
=HERTZ
}, 0, 0, FLAGS
, "width_type"},
580 {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST
, {.i64
=QFACTOR
}, 0, 0, FLAGS
, "width_type"},
581 {"o", "octave", 0, AV_OPT_TYPE_CONST
, {.i64
=OCTAVE
}, 0, 0, FLAGS
, "width_type"},
582 {"s", "slope", 0, AV_OPT_TYPE_CONST
, {.i64
=SLOPE
}, 0, 0, FLAGS
, "width_type"},
583 {"width", "set width", OFFSET(width
), AV_OPT_TYPE_DOUBLE
, {.dbl
=0.707}, 0, 99999, FLAGS
},
584 {"w", "set width", OFFSET(width
), AV_OPT_TYPE_DOUBLE
, {.dbl
=0.707}, 0, 99999, FLAGS
},
585 {"poles", "set number of poles", OFFSET(poles
), AV_OPT_TYPE_INT
, {.i64
=2}, 1, 2, FLAGS
},
586 {"p", "set number of poles", OFFSET(poles
), AV_OPT_TYPE_INT
, {.i64
=2}, 1, 2, FLAGS
},
590 DEFINE_BIQUAD_FILTER(highpass
, "Apply a high-pass filter with 3dB point frequency.");
591 #endif /* CONFIG_HIGHPASS_FILTER */
592 #if CONFIG_ALLPASS_FILTER
593 static const AVOption allpass_options
[] = {
594 {"frequency", "set central frequency", OFFSET(frequency
), AV_OPT_TYPE_DOUBLE
, {.dbl
=3000}, 0, 999999, FLAGS
},
595 {"f", "set central frequency", OFFSET(frequency
), AV_OPT_TYPE_DOUBLE
, {.dbl
=3000}, 0, 999999, FLAGS
},
596 {"width_type", "set filter-width type", OFFSET(width_type
), AV_OPT_TYPE_INT
, {.i64
=HERTZ
}, HERTZ
, SLOPE
, FLAGS
, "width_type"},
597 {"h", "Hz", 0, AV_OPT_TYPE_CONST
, {.i64
=HERTZ
}, 0, 0, FLAGS
, "width_type"},
598 {"q", "Q-Factor", 0, AV_OPT_TYPE_CONST
, {.i64
=QFACTOR
}, 0, 0, FLAGS
, "width_type"},
599 {"o", "octave", 0, AV_OPT_TYPE_CONST
, {.i64
=OCTAVE
}, 0, 0, FLAGS
, "width_type"},
600 {"s", "slope", 0, AV_OPT_TYPE_CONST
, {.i64
=SLOPE
}, 0, 0, FLAGS
, "width_type"},
601 {"width", "set filter-width", OFFSET(width
), AV_OPT_TYPE_DOUBLE
, {.dbl
=707.1}, 0, 99999, FLAGS
},
602 {"w", "set filter-width", OFFSET(width
), AV_OPT_TYPE_DOUBLE
, {.dbl
=707.1}, 0, 99999, FLAGS
},
606 DEFINE_BIQUAD_FILTER(allpass
, "Apply a two-pole all-pass filter.");
607 #endif /* CONFIG_ALLPASS_FILTER */
608 #if CONFIG_BIQUAD_FILTER
609 static const AVOption biquad_options
[] = {
610 {"a0", NULL
, OFFSET(a0
), AV_OPT_TYPE_DOUBLE
, {.dbl
=1}, INT16_MIN
, INT16_MAX
, FLAGS
},
611 {"a1", NULL
, OFFSET(a1
), AV_OPT_TYPE_DOUBLE
, {.dbl
=1}, INT16_MIN
, INT16_MAX
, FLAGS
},
612 {"a2", NULL
, OFFSET(a2
), AV_OPT_TYPE_DOUBLE
, {.dbl
=1}, INT16_MIN
, INT16_MAX
, FLAGS
},
613 {"b0", NULL
, OFFSET(b0
), AV_OPT_TYPE_DOUBLE
, {.dbl
=1}, INT16_MIN
, INT16_MAX
, FLAGS
},
614 {"b1", NULL
, OFFSET(b1
), AV_OPT_TYPE_DOUBLE
, {.dbl
=1}, INT16_MIN
, INT16_MAX
, FLAGS
},
615 {"b2", NULL
, OFFSET(b2
), AV_OPT_TYPE_DOUBLE
, {.dbl
=1}, INT16_MIN
, INT16_MAX
, FLAGS
},
619 DEFINE_BIQUAD_FILTER(biquad
, "Apply a biquad IIR filter with the given coefficients.");
620 #endif /* CONFIG_BIQUAD_FILTER */