aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2022-03-17 09:34:24 +0100
committerPaul B Mahol <onemda@gmail.com>2022-03-17 11:02:07 +0100
commit1636f9f599264450671b9c7052eae55ec97e54cd (patch)
tree29b70384557b535a66f1116340665f62127f48e8
parentbea841a7430c34c99817a056b408c58a73034e58 (diff)
downloadffmpeg-1636f9f599264450671b9c7052eae55ec97e54cd.tar.gz
avfilter/af_afftdn: expose floor offset factor option
-rw-r--r--doc/filters.texi7
-rw-r--r--libavfilter/af_afftdn.c7
2 files changed, 11 insertions, 3 deletions
diff --git a/doc/filters.texi b/doc/filters.texi
index 2607c1330b..67c125e9fd 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -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.
diff --git a/libavfilter/af_afftdn.c b/libavfilter/af_afftdn.c
index 687a1691a1..9587885627 100644
--- a/libavfilter/af_afftdn.c
+++ b/libavfilter/af_afftdn.c
@@ -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);
}
}