From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id A162E42465 for ; Sat, 18 Dec 2021 15:22:40 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EAF2868AF3B; Sat, 18 Dec 2021 17:22:37 +0200 (EET) Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 179E568A877 for ; Sat, 18 Dec 2021 17:22:31 +0200 (EET) Received: by mail-wm1-f47.google.com with SMTP id bg2-20020a05600c3c8200b0034565c2be15so6163525wmb.0 for ; Sat, 18 Dec 2021 07:22:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=aoHG3VSaVhpkBFLcVPCVeZFiFC5clVObUSyY6Bc/dc4=; b=Ni1cPYVKiQItRzdZYHdnV13S21vqh+FOG5Pf7hfclw3pc2mqbI4Djxg8Qgh0PueAX0 4NmDw+w0ePgpRYst0/0ws89r0iufliJs7B/Ef+9exiHQU3DZWphXU/9Ex31nPWiD+ATT umZHP2LV4KVoKkUlWy5MTIgkxNh/kEu5KM+GhxZUlfG7ws1oxVVCA2itXmc9TMJLR67m BrB8lVKngn4i/jvW9F9JWQfVrlZtWI7LxCowomI7a/8dAb6IE3FlSNiZX91JmUvWjTOf x38HNi8DdcAiTED9Pvet5fZoL4ZA6f0h8oa2n2YvgrDwq/2lqSmbE64l8G7dQl9Ujysq gnsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=aoHG3VSaVhpkBFLcVPCVeZFiFC5clVObUSyY6Bc/dc4=; b=3uocAaHDzHp3Unn89giOafx/sxKISaZRxPcoWdnmwzMiTySLnjv7Br4YHDKZUh0kV6 yKKdVtesmhcm4HkycfrJ2biiAOOoD8ygwycS4XFFva0AzhdxJDfRMJeigg5D1mcodwmn nmaxsFU+ufJX6A4VFxwGtNA7I0+yAInIRD2hHPyAGFSwtAiI3KCZzsbG3pTHuqND2rAW 3KtB/KbU/xlKN94qNaSfTH5CntZj/2FQnaX8gmzNWEgmFwddZ4IM8RUxBnHPDp1PafAg 1TEvnv10Q1jI0MJP4xlTGedMr+2lSRoslHu0Tf46Hi2exNNpumk/hbpw+WcoYzYhMEOg AA8g== X-Gm-Message-State: AOAM532yZlQ8ThyXKK2nvjrXP6Umhl3I0Of3/HukrrvSe6vIiIERnkfg UWNKUJ27eAHLneQV9oF4sh8wwjI9Ems= X-Google-Smtp-Source: ABdhPJx/VMQk/i8vJKA9LtJiF0W6w+QBibiFBPAwwrp6tGM26xh/lF1XpeynnoEOXPvDGLpNbNly+Q== X-Received: by 2002:a05:600c:1d08:: with SMTP id l8mr10667205wms.44.1639840950510; Sat, 18 Dec 2021 07:22:30 -0800 (PST) Received: from localhost.localdomain ([95.168.120.15]) by smtp.gmail.com with ESMTPSA id p2sm1521073wrs.112.2021.12.18.07.22.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Dec 2021 07:22:30 -0800 (PST) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Sat, 18 Dec 2021 16:22:29 +0100 Message-Id: <20211218152229.937426-1-onemda@gmail.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avfilter: add anlmf filter X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Signed-off-by: Paul B Mahol --- 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".