avfilter/af_afftdn: expose floor offset factor option

This commit is contained in:
Paul B Mahol 2022-03-17 09:34:24 +01:00
parent bea841a743
commit 1636f9f599
2 changed files with 11 additions and 3 deletions

View File

@ -1319,7 +1319,7 @@ Set the residual floor in dB, allowed range is -80 to -20.
Default value is -38 dB.
@item track_noise, tn
Enable noise tracking. By default is disabled.
Enable noise floor tracking. By default is disabled.
With this enabled, noise floor is automatically adjusted.
@item track_residual, tr
@ -1348,6 +1348,11 @@ each frequency bin. Value @var{0} enables instant adaptation, while higher value
react much slower.
Allowed range is from @var{0} to @var{1}. Default value is @var{0.5}.
@item floor_offset, fo
Set the noise floor offset factor. This option is used to adjust offset applied to measured
noise floor. It is only effective when noise floor tracking is enabled.
Allowed range is from @var{-2.0} to @var{2.0}. Default value is @var{1.0}.
@item noise_link, nl
Set the noise link used for multichannel audio.

View File

@ -117,6 +117,7 @@ typedef struct AudioFFTDeNoiseContext {
int noise_floor_link;
float ratio;
float band_multiplier;
float floor_offset;
float last_residual_floor;
float last_noise_floor;
@ -196,6 +197,8 @@ static const AVOption afftdn_options[] = {
{ "n", "noise", 0, AV_OPT_TYPE_CONST, {.i64 = NOISE_MODE}, 0, 0, AFR, "mode" },
{ "adaptivity", "set adaptivity factor",OFFSET(ratio), AV_OPT_TYPE_FLOAT, {.dbl = 0.5}, 0, 1, AFR },
{ "ad", "set adaptivity factor",OFFSET(ratio), AV_OPT_TYPE_FLOAT, {.dbl = 0.5}, 0, 1, AFR },
{ "floor_offset", "set noise floor offset factor",OFFSET(floor_offset), AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, -2, 2, AFR },
{ "fo", "set noise floor offset factor",OFFSET(floor_offset), AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, -2, 2, AFR },
{ "noise_link", "set the noise floor link",OFFSET(noise_floor_link),AV_OPT_TYPE_INT,{.i64 = MIN_LINK}, 0, NB_LINK-1, AFR, "link" },
{ "nl", "set the noise floor link", OFFSET(noise_floor_link),AV_OPT_TYPE_INT,{.i64 = MIN_LINK}, 0, NB_LINK-1, AFR, "link" },
{ "none", "none", 0, AV_OPT_TYPE_CONST, {.i64 = NONE_LINK}, 0, 0, AFR, "link" },
@ -381,11 +384,11 @@ static void process_frame(AVFilterContext *ctx,
flatness = num / den;
if (flatness > 0.8) {
const double offset = floor_offset(noisy_data, s->bin_count, den);
const double offset = s->floor_offset * floor_offset(noisy_data, s->bin_count, den);
const double new_floor = av_clipd(10.0 * log10(den) - 100.0 + offset, -90., -20.);
dnch->noise_floor = 0.1 * new_floor + dnch->noise_floor * 0.9;
set_parameters(s, dnch, 1, 0);
set_parameters(s, dnch, 1, 1);
}
}