115 double *i1,
double *i2,
double *o1,
double *o2,
116 double b0,
double b1,
double b2,
double a1,
double a2);
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"); \
244 double A = exp(p->
gain / 40 * log(10.));
250 "Invalid frequency %f. Frequency must be less than half the sample-rate %d.\n",
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);
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);
451 #define OFFSET(x) offsetof(BiquadsContext, x)
452 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
454 #define DEFINE_BIQUAD_FILTER(name_, description_) \
455 AVFILTER_DEFINE_CLASS(name_); \
456 static av_cold int name_##_init(AVFilterContext *ctx, const char *args) \
458 BiquadsContext *p = ctx->priv; \
459 p->class = &name_##_class; \
460 p->filter_type = name_; \
461 return init(ctx, args); \
464 AVFilter avfilter_af_##name_ = { \
466 .description = NULL_IF_CONFIG_SMALL(description_), \
467 .priv_size = sizeof(BiquadsContext), \
468 .init = name_##_init, \
470 .query_formats = query_formats, \
472 .outputs = outputs, \
473 .priv_class = &name_##_class, \
476 #if CONFIG_EQUALIZER_FILTER
477 static const AVOption equalizer_options[] = {
494 #if CONFIG_BASS_FILTER
495 static const AVOption bass_options[] = {
512 #if CONFIG_TREBLE_FILTER
513 static const AVOption treble_options[] = {
530 #if CONFIG_BANDPASS_FILTER
531 static const AVOption bandpass_options[] = {
547 #if CONFIG_BANDREJECT_FILTER
548 static const AVOption bandreject_options[] = {
563 #if CONFIG_LOWPASS_FILTER
564 static const AVOption lowpass_options[] = {
581 #if CONFIG_HIGHPASS_FILTER
582 static const AVOption highpass_options[] = {
599 #if CONFIG_ALLPASS_FILTER
600 static const AVOption allpass_options[] = {
615 #if CONFIG_BIQUAD_FILTER
616 static const AVOption biquad_options[] = {