aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libavfilter/af_biquads.c38
1 files changed, 15 insertions, 23 deletions
diff --git a/libavfilter/af_biquads.c b/libavfilter/af_biquads.c
index d82eb420a7..549724ec4e 100644
--- a/libavfilter/af_biquads.c
+++ b/libavfilter/af_biquads.c
@@ -116,6 +116,8 @@ typedef struct BiquadsContext {
int csg;
int transform_type;
+ int bypass;
+
double gain;
double frequency;
double width;
@@ -139,21 +141,6 @@ typedef struct BiquadsContext {
int disabled);
} BiquadsContext;
-static av_cold int init(AVFilterContext *ctx)
-{
- BiquadsContext *s = ctx->priv;
-
- if (s->filter_type != biquad) {
- if (s->frequency <= 0 || s->width <= 0) {
- av_log(ctx, AV_LOG_ERROR, "Invalid frequency %f and/or width %f <= 0\n",
- s->frequency, s->width);
- return AVERROR(EINVAL);
- }
- }
-
- return 0;
-}
-
static int query_formats(AVFilterContext *ctx)
{
AVFilterFormats *formats;
@@ -447,13 +434,15 @@ static int config_filter(AVFilterLink *outlink, int reset)
double K = tan(w0 / 2.);
double alpha, beta;
- if (w0 > M_PI) {
- av_log(ctx, AV_LOG_ERROR,
- "Invalid frequency %f. Frequency must be less than half the sample-rate %d.\n",
- s->frequency, inlink->sample_rate);
- return AVERROR(EINVAL);
+ s->bypass = (((w0 > M_PI || w0 <= 0.) && reset) || (s->width <= 0.)) && (s->filter_type != biquad);
+ if (s->bypass) {
+ av_log(ctx, AV_LOG_WARNING, "Invalid frequency and/or width!\n");
+ return 0;
}
+ if (w0 > M_PI || w0 <= 0.)
+ return AVERROR(EINVAL);
+
switch (s->width_type) {
case NONE:
alpha = 0.0;
@@ -748,6 +737,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
ThreadData td;
int ch;
+ if (s->bypass)
+ return ff_filter_frame(outlink, buf);
+
if (av_frame_is_writable(buf)) {
out_buf = buf;
} else {
@@ -820,15 +812,15 @@ static const AVFilterPad outputs[] = {
#define DEFINE_BIQUAD_FILTER(name_, description_) \
AVFILTER_DEFINE_CLASS(name_); \
-static av_cold int name_##_init(AVFilterContext *ctx) \
+static av_cold int name_##_init(AVFilterContext *ctx) \
{ \
BiquadsContext *s = ctx->priv; \
s->class = &name_##_class; \
s->filter_type = name_; \
- return init(ctx); \
+ return 0; \
} \
\
-AVFilter ff_af_##name_ = { \
+AVFilter ff_af_##name_ = { \
.name = #name_, \
.description = NULL_IF_CONFIG_SMALL(description_), \
.priv_size = sizeof(BiquadsContext), \