summaryrefslogtreecommitdiff
path: root/libavfilter
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2021-12-18 16:04:40 +0100
committerPaul B Mahol <onemda@gmail.com>2021-12-25 11:32:41 +0100
commit209488ccb0f38fbb384a4821f8c170986255d21b (patch)
tree28f62047adca8dab5e8ef715a11350c2b9b680f3 /libavfilter
parent2497a45562f6439f7d0002319d53d925f0c51535 (diff)
avfilter: add anlmf filter
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/Makefile1
-rw-r--r--libavfilter/af_anlms.c22
-rw-r--r--libavfilter/allfilters.c1
-rw-r--r--libavfilter/version.h2
4 files changed, 24 insertions, 2 deletions
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index cb328c2bf8..090944a99c 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -71,6 +71,7 @@ OBJS-$(CONFIG_AMIX_FILTER) += af_amix.o
OBJS-$(CONFIG_AMULTIPLY_FILTER) += af_amultiply.o
OBJS-$(CONFIG_ANEQUALIZER_FILTER) += af_anequalizer.o
OBJS-$(CONFIG_ANLMDN_FILTER) += af_anlmdn.o
+OBJS-$(CONFIG_ANLMF_FILTER) += af_anlms.o
OBJS-$(CONFIG_ANLMS_FILTER) += af_anlms.o
OBJS-$(CONFIG_ANULL_FILTER) += af_anull.o
OBJS-$(CONFIG_APAD_FILTER) += af_apad.o
diff --git a/libavfilter/af_anlms.c b/libavfilter/af_anlms.c
index f1f82b491d..f20e3c0e82 100644
--- a/libavfilter/af_anlms.c
+++ b/libavfilter/af_anlms.c
@@ -54,6 +54,8 @@ typedef struct AudioNLMSContext {
AVFrame *frame[2];
+ int anlmf;
+
AVFloatDSPContext *fdsp;
} AudioNLMSContext;
@@ -74,7 +76,7 @@ static const AVOption anlms_options[] = {
{ NULL }
};
-AVFILTER_DEFINE_CLASS(anlms);
+AVFILTER_DEFINE_CLASS_EXT(anlms, "anlm(f|s)", anlms_options);
static int query_formats(AVFilterContext *ctx)
{
@@ -130,6 +132,8 @@ static float process_sample(AudioNLMSContext *s, float input, float desired,
norm = s->eps + sum;
b = mu * e / norm;
+ if (s->anlmf)
+ b *= 4.f * e * e;
memcpy(tmp, delay + offset, order * sizeof(float));
@@ -241,6 +245,7 @@ static int config_output(AVFilterLink *outlink)
AVFilterContext *ctx = outlink->src;
AudioNLMSContext *s = ctx->priv;
+ s->anlmf = !strcmp(ctx->filter->name, "anlmf");
s->kernel_size = FFALIGN(s->order, 16);
if (!s->offset)
@@ -312,3 +317,18 @@ const AVFilter ff_af_anlms = {
.flags = AVFILTER_FLAG_SLICE_THREADS,
.process_command = ff_filter_process_command,
};
+
+const AVFilter ff_af_anlmf = {
+ .name = "anlmf",
+ .description = NULL_IF_CONFIG_SMALL("Apply Normalized Least-Mean-Fourth algorithm to first audio stream."),
+ .priv_size = sizeof(AudioNLMSContext),
+ .priv_class = &anlms_class,
+ .init = init,
+ .uninit = uninit,
+ .activate = activate,
+ FILTER_INPUTS(inputs),
+ FILTER_OUTPUTS(outputs),
+ FILTER_QUERY_FUNC(query_formats),
+ .flags = AVFILTER_FLAG_SLICE_THREADS,
+ .process_command = ff_filter_process_command,
+};
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 26f1c73505..caa755320e 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -64,6 +64,7 @@ extern const AVFilter ff_af_amix;
extern const AVFilter ff_af_amultiply;
extern const AVFilter ff_af_anequalizer;
extern const AVFilter ff_af_anlmdn;
+extern const AVFilter ff_af_anlmf;
extern const AVFilter ff_af_anlms;
extern const AVFilter ff_af_anull;
extern const AVFilter ff_af_apad;
diff --git a/libavfilter/version.h b/libavfilter/version.h
index 0253c911be..a4066fd883 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -30,7 +30,7 @@
#include "libavutil/version.h"
#define LIBAVFILTER_VERSION_MAJOR 8
-#define LIBAVFILTER_VERSION_MINOR 20
+#define LIBAVFILTER_VERSION_MINOR 21
#define LIBAVFILTER_VERSION_MICRO 100