Showing the changes to libavfilter (2 of 2 files). Show all
Unified · Split
| @@ -167,13 +167,16 @@ static int fn(filter_channels)(AVFilterContext *ctx, void *arg, int jobnr, int n · 166 unmodified lines | ||
| 167 | 167 | ftype *dst = (ftype *)out->extended_data[ch]; |
| 168 | 168 | ftype *state = (ftype *)s->state->extended_data[ch]; |
| 169 | 169 | const ftype threshold = detection == 0 ? state[5] : s->threshold; |
| 170 | + ftype fa[3], fm[3]; | |
| 170 | 171 | |
| 171 | 172 | if (detection < 0) |
| 172 | 173 | state[5] = threshold; |
| 173 | 174 | |
| 175 | + memcpy(fa, state + 8, sizeof(fa)); | |
| 176 | + memcpy(fm, state + 11, sizeof(fm)); | |
| 177 | + | |
| 174 | 178 | for (int n = 0; n < out->nb_samples; n++) { |
| 175 | 179 | ftype detect, gain, v, listen; |
| 176 | − ftype fa[3], fm[3]; | |
| 177 | 180 | ftype k, g; |
| 178 | 181 | |
| 179 | 182 | detect = listen = fn(get_svf)(src[n], dm, da, state); |
| @@ -182,46 +185,32 @@ static int fn(filter_channels)(AVFilterContext *ctx, void *arg, int jobnr, int n · 2 unmodified lines | ||
| 182 | 185 | if (detection > 0) |
| 183 | 186 | state[5] = FMAX(state[5], detect); |
| 184 | 187 | |
| 185 | − if (direction == 0) { | |
| 186 | − if (detect < threshold) { | |
| 187 | − if (mode == 0) | |
| 188 | − detect = ONE / CLIP(ONE + makeup + (threshold - detect) * ratio, ONE, range); | |
| 189 | − else | |
| 190 | − detect = CLIP(ONE + makeup + (threshold - detect) * ratio, ONE, range); | |
| 188 | + if (mode >= 0) { | |
| 189 | + if (direction == 0 && detect < threshold) { | |
| 190 | + detect = CLIP(ONE + makeup + (threshold - detect) * ratio, ONE, range); | |
| 191 | + if (!mode) | |
| 192 | + detect = ONE / detect; | |
| 193 | + } else if (direction == 1 && detect > threshold) { | |
| 194 | + detect = CLIP(ONE + makeup + (detect - threshold) * ratio, ONE, range); | |
| 195 | + if (!mode) | |
| 196 | + detect = ONE / detect; | |
| 191 | 197 | } else { |
| 192 | 198 | detect = ONE; |
| 193 | 199 | } |
| 194 | − } else { | |
| 195 | − if (detect > threshold) { | |
| 196 | − if (mode == 0) | |
| 197 | − detect = ONE / CLIP(ONE + makeup + (detect - threshold) * ratio, ONE, range); | |
| 198 | − else | |
| 199 | − detect = CLIP(ONE + makeup + (detect - threshold) * ratio, ONE, range); | |
| 200 | − } else { | |
| 201 | − detect = ONE; | |
| 202 | − } | |
| 203 | − } | |
| 204 | 200 | |
| 205 | − if (direction == 0) { | |
| 206 | − if (detect > state[4]) { | |
| 207 | − detect = iattack * detect + attack * state[4]; | |
| 208 | − } else { | |
| 209 | − detect = irelease * detect + release * state[4]; | |
| 210 | − } | |
| 211 | − } else { | |
| 212 | − if (detect < state[4]) { | |
| 201 | + if ((direction == 0 && detect > state[4]) || (direction == 1 && detect < state[4])) { | |
| 213 | 202 | detect = iattack * detect + attack * state[4]; |
| 214 | 203 | } else { |
| 215 | 204 | detect = irelease * detect + release * state[4]; |
| 216 | 205 | } |
| 217 | 206 | } |
| 218 | 207 | |
| 219 | − if (state[4] != detect || n == 0) { | |
| 208 | + if (state[4] != detect) { | |
| 220 | 209 | state[4] = gain = detect; |
| 221 | 210 | |
| 222 | 211 | switch (tftype) { |
| 223 | 212 | case 0: |
| 224 | − k = ONE / (tqfactor * gain); | |
| 213 | + k = itqfactor / gain; | |
| 225 | 214 | |
| 226 | 215 | fa[0] = ONE / (ONE + fg * (fg + k)); |
| 227 | 216 | fa[1] = fg * fa[0]; |
| @@ -262,6 +251,9 @@ static int fn(filter_channels)(AVFilterContext *ctx, void *arg, int jobnr, int n · 34 unmodified lines | ||
| 262 | 251 | v = mode == -1 ? listen : v; |
| 263 | 252 | dst[n] = ctx->is_disabled ? src[n] : v; |
| 264 | 253 | } |
| 254 | + | |
| 255 | + memcpy(state + 8, fa, sizeof(fa)); | |
| 256 | + memcpy(state + 11, fm, sizeof(fm)); | |
| 265 | 257 | } |
| 266 | 258 | |
| 267 | 259 | return 0; |
| @@ -96,26 +96,16 @@ static int config_input(AVFilterLink *inlink) · 95 unmodified lines | ||
| 96 | 96 | AudioDynamicEqualizerContext *s = ctx->priv; |
| 97 | 97 | |
| 98 | 98 | s->format = inlink->format; |
| 99 | − s->state = ff_get_audio_buffer(inlink, 8); | |
| 99 | + s->state = ff_get_audio_buffer(inlink, 16); | |
| 100 | 100 | if (!s->state) |
| 101 | 101 | return AVERROR(ENOMEM); |
| 102 | 102 | |
| 103 | 103 | switch (s->format) { |
| 104 | 104 | case AV_SAMPLE_FMT_DBLP: |
| 105 | − for (int ch = 0; ch < inlink->ch_layout.nb_channels; ch++) { | |
| 106 | − double *state = (double *)s->state->extended_data[ch]; | |
| 107 | − | |
| 108 | − state[4] = 1.; | |
| 109 | − } | |
| 110 | 105 | s->filter_prepare = filter_prepare_double; |
| 111 | 106 | s->filter_channels = filter_channels_double; |
| 112 | 107 | break; |
| 113 | 108 | case AV_SAMPLE_FMT_FLTP: |
| 114 | − for (int ch = 0; ch < inlink->ch_layout.nb_channels; ch++) { | |
| 115 | − float *state = (float *)s->state->extended_data[ch]; | |
| 116 | − | |
| 117 | − state[4] = 1.; | |
| 118 | − } | |
| 119 | 109 | s->filter_prepare = filter_prepare_float; |
| 120 | 110 | s->filter_channels = filter_channels_float; |
| 121 | 111 | break; |