Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -40,7 +40,7 @@ typedef struct ASubBoostContext { · 39 unmodified lines | ||
| 40 | 40 | int write_pos; |
| 41 | 41 | int buffer_samples; |
| 42 | 42 | |
| 43 | − AVFrame *i, *o; | |
| 43 | + AVFrame *w; | |
| 44 | 44 | AVFrame *buffer; |
| 45 | 45 | } ASubBoostContext; |
| 46 | 46 | |
| @@ -104,9 +104,8 @@ static int config_input(AVFilterLink *inlink) · 57 unmodified lines | ||
| 104 | 104 | ASubBoostContext *s = ctx->priv; |
| 105 | 105 | |
| 106 | 106 | s->buffer = ff_get_audio_buffer(inlink, inlink->sample_rate / 10); |
| 107 | − s->i = ff_get_audio_buffer(inlink, 2); | |
| 108 | − s->o = ff_get_audio_buffer(inlink, 2); | |
| 109 | − if (!s->buffer || !s->i || !s->o) | |
| 107 | + s->w = ff_get_audio_buffer(inlink, 2); | |
| 108 | + if (!s->buffer || !s->w) | |
| 110 | 109 | return AVERROR(ENOMEM); |
| 111 | 110 | |
| 112 | 111 | return get_coeffs(ctx); |
| @@ -117,7 +116,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 4 unmodified lines | ||
| 117 | 116 | AVFilterContext *ctx = inlink->dst; |
| 118 | 117 | AVFilterLink *outlink = ctx->outputs[0]; |
| 119 | 118 | ASubBoostContext *s = ctx->priv; |
| 120 | − const float wet = s->wet_gain, dry = s->dry_gain, feedback = s->feedback, decay = s->decay; | |
| 119 | + const double wet = s->wet_gain, dry = s->dry_gain, feedback = s->feedback, decay = s->decay; | |
| 120 | + const double b0 = s->b0; | |
| 121 | + const double b1 = s->b1; | |
| 122 | + const double b2 = s->b2; | |
| 123 | + const double a1 = -s->a1; | |
| 124 | + const double a2 = -s->a2; | |
| 121 | 125 | int write_pos; |
| 122 | 126 | AVFrame *out; |
| 123 | 127 | |
| @@ -136,18 +140,15 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 12 unmodified lines | ||
| 136 | 140 | const double *src = (const double *)in->extended_data[ch]; |
| 137 | 141 | double *dst = (double *)out->extended_data[ch]; |
| 138 | 142 | double *buffer = (double *)s->buffer->extended_data[ch]; |
| 139 | − double *ix = (double *)s->i->extended_data[ch]; | |
| 140 | − double *ox = (double *)s->o->extended_data[ch]; | |
| 143 | + double *w = (double *)s->w->extended_data[ch]; | |
| 141 | 144 | |
| 142 | 145 | write_pos = s->write_pos; |
| 143 | 146 | for (int n = 0; n < in->nb_samples; n++) { |
| 144 | 147 | double out_sample; |
| 145 | 148 | |
| 146 | − out_sample = src[n] * s->b0 + ix[0] * s->b1 + ix[1] * s->b2 - ox[0] * s->a1 - ox[1] * s->a2; | |
| 147 | − ix[1] = ix[0]; | |
| 148 | − ix[0] = src[n]; | |
| 149 | − ox[1] = ox[0]; | |
| 150 | − ox[0] = out_sample; | |
| 149 | + out_sample = src[n] * b0 + w[0]; | |
| 150 | + w[0] = b1 * src[n] + w[1] + a1 * out_sample; | |
| 151 | + w[1] = b2 * src[n] + a2 * out_sample; | |
| 151 | 152 | |
| 152 | 153 | buffer[write_pos] = buffer[write_pos] * decay + out_sample * feedback; |
| 153 | 154 | dst[n] = src[n] * dry + buffer[write_pos] * wet; |
| @@ -169,8 +170,7 @@ static av_cold void uninit(AVFilterContext *ctx) · 15 unmodified lines | ||
| 169 | 170 | ASubBoostContext *s = ctx->priv; |
| 170 | 171 | |
| 171 | 172 | av_frame_free(&s->buffer); |
| 172 | − av_frame_free(&s->i); | |
| 173 | − av_frame_free(&s->o); | |
| 173 | + av_frame_free(&s->w); | |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, |