You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
avfilter/af_afftdn: refactor set_noise_profile()
This commit is contained in:
@@ -912,46 +912,31 @@ static void finish_sample_noise(AudioFFTDeNoiseContext *s,
|
||||
|
||||
static void set_noise_profile(AudioFFTDeNoiseContext *s,
|
||||
DeNoiseChannel *dnch,
|
||||
double *sample_noise,
|
||||
int new_profile)
|
||||
double *sample_noise)
|
||||
{
|
||||
double new_band_noise[NB_PROFILE_BANDS];
|
||||
double temp[NB_PROFILE_BANDS];
|
||||
double sum = 0.0, d1;
|
||||
float new_noise_floor;
|
||||
int i = 0, n;
|
||||
double sum = 0.0;
|
||||
|
||||
for (int m = 0; m < NB_PROFILE_BANDS; m++)
|
||||
temp[m] = sample_noise[m];
|
||||
|
||||
if (new_profile) {
|
||||
for (int m = 0; m < SOLVE_SIZE; m++) {
|
||||
for (int m = 0, i = 0; m < SOLVE_SIZE; m++) {
|
||||
sum = 0.0;
|
||||
for (n = 0; n < NB_PROFILE_BANDS; n++)
|
||||
for (int n = 0; n < NB_PROFILE_BANDS; n++)
|
||||
sum += s->matrix_b[i++] * temp[n];
|
||||
s->vector_b[m] = sum;
|
||||
}
|
||||
solve(s->matrix_a, s->vector_b, SOLVE_SIZE);
|
||||
i = 0;
|
||||
for (int m = 0; m < NB_PROFILE_BANDS; m++) {
|
||||
for (int m = 0, i = 0; m < NB_PROFILE_BANDS; m++) {
|
||||
sum = 0.0;
|
||||
for (n = 0; n < SOLVE_SIZE; n++)
|
||||
for (int n = 0; n < SOLVE_SIZE; n++)
|
||||
sum += s->matrix_c[i++] * s->vector_b[n];
|
||||
temp[m] = sum;
|
||||
}
|
||||
}
|
||||
|
||||
sum = 0.0;
|
||||
for (int m = 0; m < NB_PROFILE_BANDS; m++)
|
||||
sum += temp[m];
|
||||
reduce_mean(temp);
|
||||
|
||||
d1 = sum / NB_PROFILE_BANDS;
|
||||
for (int m = 0; m < NB_PROFILE_BANDS; m++)
|
||||
temp[m] -= d1;
|
||||
|
||||
new_noise_floor = d1;
|
||||
|
||||
if (new_profile) {
|
||||
av_log(s, AV_LOG_INFO, "bn=");
|
||||
for (int m = 0; m < NB_PROFILE_BANDS; m++) {
|
||||
new_band_noise[m] = temp[m];
|
||||
@@ -960,10 +945,6 @@ static void set_noise_profile(AudioFFTDeNoiseContext *s,
|
||||
}
|
||||
av_log(s, AV_LOG_INFO, "\n");
|
||||
memcpy(dnch->band_noise, new_band_noise, sizeof(new_band_noise));
|
||||
}
|
||||
|
||||
if (s->track_noise)
|
||||
dnch->noise_floor = new_noise_floor;
|
||||
}
|
||||
|
||||
static int filter_channel(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
|
||||
@@ -1074,7 +1055,7 @@ static int output_frame(AVFilterLink *inlink, AVFrame *in)
|
||||
double sample_noise[NB_PROFILE_BANDS];
|
||||
|
||||
finish_sample_noise(s, dnch, sample_noise);
|
||||
set_noise_profile(s, dnch, sample_noise, 1);
|
||||
set_noise_profile(s, dnch, sample_noise);
|
||||
set_parameters(s, dnch, 1, 1);
|
||||
}
|
||||
s->sample_noise = 0;
|
||||
|
Reference in New Issue
Block a user