From: Paul B Mahol <onemda@gmail.com> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH] avfilter: add anlmf filter Date: Sat, 18 Dec 2021 16:22:29 +0100 Message-ID: <20211218152229.937426-1-onemda@gmail.com> (raw) Signed-off-by: Paul B Mahol <onemda@gmail.com> --- doc/filters.texi | 4 ++-- libavfilter/Makefile | 1 + libavfilter/af_anlms.c | 22 +++++++++++++++++++++- libavfilter/allfilters.c | 1 + 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index da95688c53..05d4b1a56e 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -2301,8 +2301,8 @@ Set smooth factor. Default value is @var{11}. Allowed range is from @var{1} to @ This filter supports the all above options as @ref{commands}. -@section anlms -Apply Normalized Least-Mean-Squares algorithm to the first audio stream using the second audio stream. +@section anlmf, anlms +Apply Normalized Least-Mean-(Squares|Fourth) algorithm to the first audio stream using the second audio stream. This adaptive filter is used to mimic a desired filter by finding the filter coefficients that relate to producing the least mean square of the error signal (difference between the desired, diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 2fe495df28..e7bde11ec8 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 ec57a2c49c..7281f98d86 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; -- 2.33.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next reply other threads:[~2021-12-18 15:22 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-12-18 15:22 Paul B Mahol [this message] 2021-12-24 8:53 ` Paul B Mahol
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211218152229.937426-1-onemda@gmail.com \ --to=onemda@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git