From a71a3d1ed24fdcfb3f09795e1fbfeca990463d69 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Mon, 14 Mar 2022 10:02:18 +0100 Subject: avfilter/af_afftdn: stop producing small impulsive noise at start of output --- libavfilter/af_afftdn.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'libavfilter/af_afftdn.c') diff --git a/libavfilter/af_afftdn.c b/libavfilter/af_afftdn.c index 7257de73d3..48f7a888aa 100644 --- a/libavfilter/af_afftdn.c +++ b/libavfilter/af_afftdn.c @@ -329,13 +329,15 @@ static double limit_gain(double a, double b) return 1.0; } -static void process_frame(AudioFFTDeNoiseContext *s, DeNoiseChannel *dnch, +static void process_frame(AVFilterContext *ctx, + AudioFFTDeNoiseContext *s, DeNoiseChannel *dnch, AVComplexFloat *fft_data, double *prior, double *prior_band_excit, int track_noise) { + AVFilterLink *outlink = ctx->outputs[0]; const double sample_floor = s->sample_floor; const double *abs_var = dnch->abs_var; - const double ratio = s->ratio; + const double ratio = outlink->frame_count_out ? s->ratio : 1.0; const double rratio = 1. - ratio; const int *bin2band = s->bin2band; double *band_excit = dnch->band_excit; @@ -784,7 +786,6 @@ static int config_input(AVFilterLink *inlink) for (int ch = 0; ch < inlink->channels; ch++) { DeNoiseChannel *dnch = &s->dnch[ch]; double *prior_band_excit = dnch->prior_band_excit; - double *prior = dnch->prior; double min, max; double p1, p2; @@ -828,8 +829,6 @@ static int config_input(AVFilterLink *inlink) dnch->band_excit[i] = av_clipd(dnch->band_excit[i], min, max); } - for (int i = 0; i <= s->fft_length2; i++) - prior[i] = 1.0 - s->ratio; for (int i = 0; i < s->buffer_length; i++) dnch->out_samples[i] = 0; @@ -1067,7 +1066,7 @@ static int filter_channel(AVFilterContext *ctx, void *arg, int jobnr, int nb_job dnch->tx_fn(dnch->fft, dnch->fft_out, fft_in, sizeof(float)); - process_frame(s, dnch, dnch->fft_out, + process_frame(ctx, s, dnch, dnch->fft_out, dnch->prior, dnch->prior_band_excit, s->track_noise); -- cgit v1.2.3