From patchwork Sat Mar 11 17:23:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sanchit Sinha X-Patchwork-Id: 2885 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.50.79 with SMTP id y76csp548388vsy; Sat, 11 Mar 2017 09:23:41 -0800 (PST) X-Received: by 10.28.15.202 with SMTP id 193mr3476686wmp.99.1489253021039; Sat, 11 Mar 2017 09:23:41 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id x204si4035808wmg.164.2017.03.11.09.23.40; Sat, 11 Mar 2017 09:23:41 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@iiitd.ac.in; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 09EC6689A33; Sat, 11 Mar 2017 19:23:23 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr0-f181.google.com (mail-wr0-f181.google.com [209.85.128.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E074C689980 for ; Sat, 11 Mar 2017 19:23:16 +0200 (EET) Received: by mail-wr0-f181.google.com with SMTP id l37so81487729wrc.1 for ; Sat, 11 Mar 2017 09:23:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iiitd.ac.in; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=g/ig243yl25Nu3tyZKMIFMQT5jKaCCHdUH8EUVr8BCY=; b=Gt6i8ahsadTempQ74EA9d+Z8SpQ1LlyW1fzAIqz2ui+ybgvcz7efMtO4ezeUegLYqN z+LAQJbc4E/39e77uIBaFM4w6uiMcwEoqIFTDtPdN/ezLQmpwmBjFtrPmv3RXprXpznS V28PyMUq0JdVqK/iG7Hs2ANKNMWUa1fc+3q5E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=g/ig243yl25Nu3tyZKMIFMQT5jKaCCHdUH8EUVr8BCY=; b=lnt7h9KkxxasbSxrRr/OCWU7e1zhcMGdcED0yChvz1sMxvHO8tCCqx9Ziiwm+PyXo2 P6BfoZhTHE8XqLBFAJ13CFDEx1mw9f/BTDK7qqk9erWnd/8t9XTSgssk6yMaUaxhTL7i TxVJb9cFeEvEG50FUPM+KlEH4TjGu6XEL0rwL6pk1QbkU5oZ2UJd9/shXyq6HcZF2nAL 2KVfFYgQALrttd+Jl9c0OIYZJDyCa1Brqkme8mA0fkJCcxvbEANWvGq0ye9qlypEtc7q C8lpDO3ISPGx9e0y8YYM8JQxPlgYjzN3gS0XS8uuDlPI3w3UBH4c//50xYZly8BKArfA bIjQ== X-Gm-Message-State: AMke39l0M1hY2YmSTDTShLCGw+iWHB/yvh9TGWbinycm8422IQ/OmqjFpliHvy4XjQyU2fSODCAfYI94G8K0i4PJ X-Received: by 10.223.182.167 with SMTP id j39mr19816243wre.152.1489253011054; Sat, 11 Mar 2017 09:23:31 -0800 (PST) MIME-Version: 1.0 Received: by 10.80.139.131 with HTTP; Sat, 11 Mar 2017 09:23:30 -0800 (PST) In-Reply-To: References: <57ab03c4-ca4b-a4db-4224-15c1ce9db5f1@gmail.com> <00a6a6e3-7163-ad9c-1e0c-853e830a17bb@gmail.com> From: Sanchit Sinha Date: Sat, 11 Mar 2017 22:53:30 +0530 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: Re: [FFmpeg-devel] [PATCH] libavfilter/af_ambisonic.c Added File for Ambisonic Filter X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" On Sat, Mar 11, 2017 at 10:38 PM, Paul B Mahol wrote: > On 3/11/17, Sanchit Sinha wrote: > > On Sat, Mar 11, 2017 at 9:46 PM, Sanchit Sinha > > > wrote: > > > > tabs are forbidden use 4 spaces for identation, remove commented out code. > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > From 5bc88aeb43ffbf835910daba671ff26021457a1a Mon Sep 17 00:00:00 2001 From: Sanchit Sinha Date: Sat, 11 Mar 2017 22:51:34 +0530 Subject: [PATCH] avfilter : af_ambisonic added avfilter/Makefile allfilters updated Changelog update Signed-off-by: Sanchit Sinha --- Changelog | 1 + libavfilter/Makefile | 1 + libavfilter/af_ambisonic.c | 117 +++++++++++++++++++++++++++++++++++++++++++++ libavfilter/allfilters.c | 1 + 4 files changed, 120 insertions(+) create mode 100644 libavfilter/af_ambisonic.c diff --git a/Changelog b/Changelog index 13628ca..b917ac2 100644 --- a/Changelog +++ b/Changelog @@ -26,6 +26,7 @@ version : - native Opus encoder - ScreenPressor decoder - incomplete ClearVideo decoder +- Ambisonic Decoder version 3.2: - libopenmpt demuxer diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 0ba1c74..4ebbd5a 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -44,6 +44,7 @@ OBJS-$(CONFIG_AINTERLEAVE_FILTER) += f_interleave.o OBJS-$(CONFIG_ALIMITER_FILTER) += af_alimiter.o OBJS-$(CONFIG_ALLPASS_FILTER) += af_biquads.o OBJS-$(CONFIG_ALOOP_FILTER) += f_loop.o +OBJS-$(CONFIG_AMBISONIC_FILTER) += af_ambisonic.o OBJS-$(CONFIG_AMERGE_FILTER) += af_amerge.o OBJS-$(CONFIG_AMETADATA_FILTER) += f_metadata.o OBJS-$(CONFIG_AMIX_FILTER) += af_amix.o diff --git a/libavfilter/af_ambisonic.c b/libavfilter/af_ambisonic.c new file mode 100644 index 0000000..5974bc9 --- /dev/null +++ b/libavfilter/af_ambisonic.c @@ -0,0 +1,117 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include "libavutil/avstring.h" +#include "libavutil/channel_layout.h" +#include "libavutil/opt.h" +#include "audio.h" +#include "avfilter.h" +#include "formats.h" +#include + +typedef struct AmbisonicContext { + const AVClass *class; +} AmbisonicContext; + +#define OFFSET(x) offsetof(AmbisonicContext, x) + +static const AVOption ambisonic_options[] = { +{NULL} +}; + +AVFILTER_DEFINE_CLASS(ambisonic); +static int query_formats(AVFilterContext *ctx) +{ + AVFilterFormats *formats = NULL; + AVFilterChannelLayouts *layout = NULL; + int ret; + if ((ret = ff_add_format (&formats, AV_SAMPLE_FMT_FLTP )) < 0 || + (ret = ff_set_common_formats (ctx , formats )) < 0 || + (ret = ff_add_channel_layout (&layout , AV_CH_LAYOUT_4POINT0)) < 0 || + (ret = ff_set_common_channel_layouts (ctx , layout )) < 0) + return ret; + formats = ff_all_samplerates(); + return ff_set_common_samplerates(ctx, formats); +} +static int filter_frame(AVFilterLink *inlink, AVFrame *in) +{ + AVFilterContext *ctx = inlink->dst; + AVFilterLink *outlink = ctx->outputs[0]; + AVFrame *out; + int itr; + float *w,*x,*y,*c1,*c2,*c3,*c4; + float root8 = sqrt(8); + float lf=0,lb=0,rb=0,rf=0; + if (av_frame_is_writable(in)) { + out = in; + } else { + out = ff_get_audio_buffer(inlink, in->nb_samples); + if (!out){ + av_frame_free(&in); + return AVERROR(ENOMEM); + } + av_frame_copy_props(out, in); + } + w=(float *)in->extended_data[0]; + x=(float *)in->extended_data[1]; + y=(float *)in->extended_data[2]; + + c1=(float *)out->extended_data[0]; + c2=(float *)out->extended_data[1]; + c3=(float *)out->extended_data[2]; + c4=(float *)out->extended_data[3]; + + for(itr=0;itrnb_samples;itr++){ + lf = root8 * (2*(w[itr])+x[itr]+y[itr]); + lb = root8 * (2*(w[itr])-x[itr]+y[itr]); + rb = root8 * (2*(w[itr])-x[itr]-y[itr]); + rf = root8 * (2*(w[itr])+x[itr]-y[itr]); + c1[itr] = lf; + c2[itr] = rf; + c3[itr] = lb; + c4[itr] = rb; + } + if (out != in) + av_frame_free(&in); + return ff_filter_frame(outlink, out); +} +static const AVFilterPad inputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_AUDIO, + .filter_frame = filter_frame, + }, + { NULL } +}; +static const AVFilterPad outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_AUDIO, + }, + { NULL } +}; +AVFilter ff_af_ambisonic = { + .name = "ambisonic", + .description = NULL_IF_CONFIG_SMALL("An ambisonic filter"), + .query_formats = query_formats, + .priv_size = sizeof(AmbisonicContext), + .priv_class = &ambisonic_class, + .inputs = inputs, + .outputs = outputs, +}; \ No newline at end of file diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index df1af8d..59aeb6d 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -56,6 +56,7 @@ static void register_all(void) REGISTER_FILTER(ALIMITER, alimiter, af); REGISTER_FILTER(ALLPASS, allpass, af); REGISTER_FILTER(ALOOP, aloop, af); + REGISTER_FILTER(AMBISONIC, ambisonic, af); REGISTER_FILTER(AMERGE, amerge, af); REGISTER_FILTER(AMETADATA, ametadata, af); REGISTER_FILTER(AMIX, amix, af); -- 2.7.4