115 double *i1,
double *i2,
double *o1,
double *o2,
116 double b0,
double b1,
double b2,
double a1,
double a2);
164 #define BIQUAD_FILTER(name, type, min, max) \
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; \
185 av_log(NULL, AV_LOG_WARNING, "clipping\n"); \
187 } else if (o2 > max) { \
188 av_log(NULL, AV_LOG_WARNING, "clipping\n"); \
194 o1 = i1 * b2 + i2 * b1 + ibuf[i] * b0 + o1 * a2 + o2 * a1; \
197 av_log(NULL, AV_LOG_WARNING, "clipping\n"); \
199 } else if (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; \
213 av_log(NULL, AV_LOG_WARNING, "clipping\n"); \
215 } else if (o0 > max) { \
216 av_log(NULL, AV_LOG_WARNING, "clipping\n"); \
238 double A = exp(p->
gain / 40 * log(10.));
244 "Invalid frequency %f. Frequency must be less than half the sample-rate %d.\n",
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);
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);
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 avfilter_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[] = {
487 #if CONFIG_BASS_FILTER
488 static const AVOption bass_options[] = {
505 #if CONFIG_TREBLE_FILTER
506 static const AVOption treble_options[] = {
523 #if CONFIG_BANDPASS_FILTER
524 static const AVOption bandpass_options[] = {
540 #if CONFIG_BANDREJECT_FILTER
541 static const AVOption bandreject_options[] = {
556 #if CONFIG_LOWPASS_FILTER
557 static const AVOption lowpass_options[] = {
574 #if CONFIG_HIGHPASS_FILTER
575 static const AVOption highpass_options[] = {
592 #if CONFIG_ALLPASS_FILTER
593 static const AVOption allpass_options[] = {
608 #if CONFIG_BIQUAD_FILTER
609 static const AVOption biquad_options[] = {