avfilter/af_afftdn: do not profile noise if number of sampled blocks is 0

This commit is contained in:
Paul B Mahol 2022-03-18 11:21:52 +01:00
parent 28447a4290
commit b6af56c034
1 changed files with 6 additions and 0 deletions

View File

@ -125,6 +125,7 @@ typedef struct AudioFFTDeNoiseContext {
int channels;
int sample_noise;
int sample_noise_blocks;
int sample_noise_mode;
float sample_rate;
int buffer_length;
@ -1039,6 +1040,7 @@ static int output_frame(AVFilterLink *inlink, AVFrame *in)
}
s->sample_noise_mode = SAMPLE_NONE;
s->sample_noise = 1;
s->sample_noise_blocks = 0;
}
if (s->sample_noise) {
@ -1047,6 +1049,7 @@ static int output_frame(AVFilterLink *inlink, AVFrame *in)
sample_noise_block(s, dnch, s->winframe, ch);
}
s->sample_noise_blocks++;
}
if (s->sample_noise_mode == SAMPLE_STOP) {
@ -1054,11 +1057,14 @@ static int output_frame(AVFilterLink *inlink, AVFrame *in)
DeNoiseChannel *dnch = &s->dnch[ch];
double sample_noise[NB_PROFILE_BANDS];
if (s->sample_noise_blocks <= 0)
break;
finish_sample_noise(s, dnch, sample_noise);
set_noise_profile(s, dnch, sample_noise);
set_parameters(s, dnch, 1, 1);
}
s->sample_noise = 0;
s->sample_noise_blocks = 0;
s->sample_noise_mode = SAMPLE_NONE;
}