|
|
|
@ -158,25 +158,41 @@ static int fn(filter_channels)(AVFilterContext *ctx, void *arg, int jobnr, int n |
|
|
|
|
const ftype fg = TAN(M_PI * tfrequency / sample_rate); |
|
|
|
|
const int start = (in->ch_layout.nb_channels * jobnr) / nb_jobs; |
|
|
|
|
const int end = (in->ch_layout.nb_channels * (jobnr+1)) / nb_jobs; |
|
|
|
|
const int is_disabled = ctx->is_disabled; |
|
|
|
|
const int detection = s->detection; |
|
|
|
|
const int tftype = s->tftype; |
|
|
|
|
const ftype *da = fn(s->da); |
|
|
|
|
const ftype *dm = fn(s->dm); |
|
|
|
|
|
|
|
|
|
if (detection > 0) { |
|
|
|
|
for (int ch = start; ch < end; ch++) { |
|
|
|
|
const ftype *src = (const ftype *)in->extended_data[ch]; |
|
|
|
|
ChannelContext *cc = &s->cc[ch]; |
|
|
|
|
ftype *tstate = fn(cc->tstate); |
|
|
|
|
|
|
|
|
|
for (int n = 0; n < in->nb_samples; n++) { |
|
|
|
|
ftype detect = fn(get_svf)(src[n], dm, da, tstate); |
|
|
|
|
fn(cc->threshold) = FMAX(fn(cc->threshold), detect); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else if (detection < 0) { |
|
|
|
|
for (int ch = start; ch < end; ch++) { |
|
|
|
|
ChannelContext *cc = &s->cc[ch]; |
|
|
|
|
fn(cc->threshold) = s->threshold; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (int ch = start; ch < end; ch++) { |
|
|
|
|
const ftype *src = (const ftype *)in->extended_data[ch]; |
|
|
|
|
ftype *dst = (ftype *)out->extended_data[ch]; |
|
|
|
|
ChannelContext *cc = &s->cc[ch]; |
|
|
|
|
const ftype threshold = detection == 0 ? fn(cc->threshold) : s->threshold; |
|
|
|
|
const ftype threshold = fn(cc->threshold); |
|
|
|
|
ftype *fa = fn(cc->fa), *fm = fn(cc->fm); |
|
|
|
|
ftype *fstate = fn(cc->fstate); |
|
|
|
|
ftype *dstate = fn(cc->dstate); |
|
|
|
|
ftype gain = fn(cc->gain); |
|
|
|
|
const int init = cc->init; |
|
|
|
|
|
|
|
|
|
if (detection < 0) |
|
|
|
|
fn(cc->threshold) = threshold; |
|
|
|
|
|
|
|
|
|
for (int n = 0; n < out->nb_samples; n++) { |
|
|
|
|
ftype detect, v, listen, new_gain = ONE; |
|
|
|
|
ftype k, g; |
|
|
|
@ -184,9 +200,6 @@ static int fn(filter_channels)(AVFilterContext *ctx, void *arg, int jobnr, int n |
|
|
|
|
detect = listen = fn(get_svf)(src[n], dm, da, dstate); |
|
|
|
|
detect = FABS(detect); |
|
|
|
|
|
|
|
|
|
if (detection > 0) |
|
|
|
|
fn(cc->threshold) = FMAX(fn(cc->threshold), detect); |
|
|
|
|
|
|
|
|
|
switch (mode) { |
|
|
|
|
case LISTEN: |
|
|
|
|
break; |
|
|
|
@ -258,7 +271,7 @@ static int fn(filter_channels)(AVFilterContext *ctx, void *arg, int jobnr, int n |
|
|
|
|
|
|
|
|
|
v = fn(get_svf)(src[n], fm, fa, fstate); |
|
|
|
|
v = mode == -1 ? listen : v; |
|
|
|
|
dst[n] = ctx->is_disabled ? src[n] : v; |
|
|
|
|
dst[n] = is_disabled ? src[n] : v; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fn(cc->gain) = gain; |
|
|
|
|