| @@ -166,25 +166,25 @@ static int fn(filter_channels)(AVFilterContext *ctx, void *arg, int jobnr, int n · 165 unmodified lines |
| 166 | for (int ch = start; ch < end; ch++) { | 166 | for (int ch = start; ch < end; ch++) { |
| 167 | const ftype *src = (const ftype *)in->extended_data[ch]; | 167 | const ftype *src = (const ftype *)in->extended_data[ch]; |
| 168 | ftype *dst = (ftype *)out->extended_data[ch]; | 168 | ftype *dst = (ftype *)out->extended_data[ch]; |
| 169 | ftype *state = (ftype *)s->state->extended_data[ch]; | 169 | ChannelContext *cc = &s->cc[ch]; |
| 170 | const ftype threshold = detection == 0 ? state[5] : s->threshold; | 170 | const ftype threshold = detection == 0 ? fn(cc->threshold) : s->threshold; |
| 171 | ftype fa[3], fm[3]; | 171 | ftype *fa = fn(cc->fa), *fm = fn(cc->fm); |
| | 172 | ftype *fstate = fn(cc->fstate); |
| | 173 | ftype *dstate = fn(cc->dstate); |
| | 174 | ftype gain = fn(cc->gain); |
| 172 | | 175 | |
| 173 | if (detection < 0) | 176 | if (detection < 0) |
| 174 | state[5] = threshold; | 177 | fn(cc->threshold) = threshold; |
| 175 | | | |
| 176 | memcpy(fa, state + 8, sizeof(fa)); | | |
| 177 | memcpy(fm, state + 11, sizeof(fm)); | | |
| 178 | | 178 | |
| 179 | for (int n = 0; n < out->nb_samples; n++) { | 179 | for (int n = 0; n < out->nb_samples; n++) { |
| 180 | ftype detect, gain, v, listen; | 180 | ftype detect, v, listen; |
| 181 | ftype k, g; | 181 | ftype k, g; |
| 182 | | 182 | |
| 183 | detect = listen = fn(get_svf)(src[n], dm, da, state); | 183 | detect = listen = fn(get_svf)(src[n], dm, da, dstate); |
| 184 | detect = FABS(detect); | 184 | detect = FABS(detect); |
| 185 | | 185 | |
| 186 | if (detection > 0) | 186 | if (detection > 0) |
| 187 | state[5] = FMAX(state[5], detect); | 187 | fn(cc->threshold) = FMAX(fn(cc->threshold), detect); |
| 188 | | 188 | |
| 189 | if (mode >= 0) { | 189 | if (mode >= 0) { |
| 190 | if (direction == 0 && detect < threshold) { | 190 | if (direction == 0 && detect < threshold) { |
| @@ -200,17 +200,17 @@ static int fn(filter_channels)(AVFilterContext *ctx, void *arg, int jobnr, int n · 9 unmodified lines |
| 200 | } | 200 | } |
| 201 | | 201 | |
| 202 | { | 202 | { |
| 203 | ftype delta = detect - state[4]; | 203 | ftype delta = detect - gain; |
| 204 | | 204 | |
| 205 | if (delta > EPSILON) | 205 | if (delta > EPSILON) |
| 206 | detect = state[4] + attack * delta; | 206 | detect = gain + attack * delta; |
| 207 | else if (delta < -EPSILON) | 207 | else if (delta < -EPSILON) |
| 208 | detect = state[4] + release * delta; | 208 | detect = gain + release * delta; |
| 209 | } | 209 | } |
| 210 | } | 210 | } |
| 211 | | 211 | |
| 212 | if (state[4] != detect) { | 212 | if (gain != detect) { |
| 213 | state[4] = gain = detect; | 213 | gain = detect; |
| 214 | | 214 | |
| 215 | switch (tftype) { | 215 | switch (tftype) { |
| 216 | case 0: | 216 | case 0: |
| @@ -251,13 +251,12 @@ static int fn(filter_channels)(AVFilterContext *ctx, void *arg, int jobnr, int n · 34 unmodified lines |
| 251 | } | 251 | } |
| 252 | } | 252 | } |
| 253 | | 253 | |
| 254 | v = fn(get_svf)(src[n], fm, fa, &state[2]); | 254 | v = fn(get_svf)(src[n], fm, fa, fstate); |
| 255 | v = mode == -1 ? listen : v; | 255 | v = mode == -1 ? listen : v; |
| 256 | dst[n] = ctx->is_disabled ? src[n] : v; | 256 | dst[n] = ctx->is_disabled ? src[n] : v; |
| 257 | } | 257 | } |
| 258 | | 258 | |
| 259 | memcpy(state + 8, fa, sizeof(fa)); | 259 | fn(cc->gain) = gain; |
| 260 | memcpy(state + 11, fm, sizeof(fm)); | | |
| 261 | } | 260 | } |
| 262 | | 261 | |
| 263 | return 0; | 262 | return 0; |