From patchwork Sat Mar 11 11:50:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sanchit Sinha X-Patchwork-Id: 2879 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.50.79 with SMTP id y76csp441626vsy; Sat, 11 Mar 2017 03:50:58 -0800 (PST) X-Received: by 10.28.63.84 with SMTP id m81mr2833151wma.42.1489233058113; Sat, 11 Mar 2017 03:50:58 -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 n38si16777378wrb.62.2017.03.11.03.50.57; Sat, 11 Mar 2017 03:50:58 -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 ACDB7689938; Sat, 11 Mar 2017 13:50:39 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr0-f176.google.com (mail-wr0-f176.google.com [209.85.128.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D7D396898B1 for ; Sat, 11 Mar 2017 13:50:32 +0200 (EET) Received: by mail-wr0-f176.google.com with SMTP id g10so78747974wrg.2 for ; Sat, 11 Mar 2017 03:50:47 -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=PkMjWFuaQDX4WQaFlaRmouxpEPj34ut3hyOJKjcCHlc=; b=ae62QFIwGiNTRxCD0RCdoACi4rciN+U8pZaxM52NcUMRN03dkYy4DVckmBQ1qYhXUf UeZoQEpeM53vKQkU/UBtghfmsuQh6l1CfO1vEGZM6+fbl/KC3pkp4Dyv+1ZmbO7tuGWO HujklF82sR9AJfdfKebHQQqiXUjk2PKNNJyM8= 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=PkMjWFuaQDX4WQaFlaRmouxpEPj34ut3hyOJKjcCHlc=; b=Dip4CZx/dFnDZRcSctAa1z9bjvGRuDdcSE+2xygkp3r46qocjIga+08YqR+sgSzM0m 8KB/4xQtJ6BpwQeveh5CwSLiZbfhKG9i6Qb3jcsYYwnT7SEYyL/BPqkv7wjbZjh6vGS6 uZ7rC7j38zw5p62kaXuHgcwtdeG247w7SZDdToA4DLiSGmgrWVFZu/+dzUGn0n1rROa2 TWwH8qwnvmDAzX5xfF0bF3Ro9ol0KTN07P946TuXN8NvavN6arACCTOQ3FEL8E3A4Oqr nXy6qYAkA140N6HBmoA2UV51R9C7zaiqEXMoRy4qMrzTZkFqTQgGNdW1sjC1ZxlbBrtP fgvQ== X-Gm-Message-State: AMke39kXpUibIDdvbf+BkDdnrYxzc9rPDBBzUTZBg2vAxWCp2X6spmjhluKvU4S4OEpjMb7RwWKdcP5YZEWze8kt X-Received: by 10.223.135.85 with SMTP id 21mr19784198wrz.93.1489233046759; Sat, 11 Mar 2017 03:50:46 -0800 (PST) MIME-Version: 1.0 Received: by 10.80.139.131 with HTTP; Sat, 11 Mar 2017 03:50:45 -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 17:20:45 +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" Patch details: File added avfilter/af_ambisonic.c Entries made in avfilter/Makefile and avfilter/allfilters.c Entry made in Changelog On Sat, Mar 11, 2017 at 4:29 PM, Sanchit Sinha wrote: > > Thanks Andy for the valuable info! It would be good to talk and learn from > these guys, especially for an amateur like me. :) > > On Sat, Mar 11, 2017 at 4:23 PM, Andy Furniss wrote: > >> Paul B Mahol wrote: >> >>> On 3/11/17, Andy Furniss wrote: >>> >>>> Sanchit Sinha wrote: >>>> >>>>> libavfilter/af_ambisonic.c | 139 >>>>> >>>> >>>> + w=(float *)(*(in->extended_data)+itr); >>>>> + x=(float *)(*(in->extended_data+1)+itr); >>>>> + y=(float *)(*(in->extended_data+2)+itr); >>>>> + >>>>> + *lf = root8 * (2*(*w)+*x+*y); >>>>> + *lb = root8 * (2*(*w)-*x+*y); >>>>> + *rb = root8 * (2*(*w)-*x-*y); >>>>> + *rf = root8 * (2*(*w)+*x-*y); >>>>> >>>> >>>> Seems a bit misleading to call something ambisonic if all it will >>>> do is 2d, so partial b-format to (square?) 4 channel. >>>> >>>> Why not be more specific in the name so the limitation is clear. >>>> >>> >>> This is just for qualification task. Later filter willl be extended. >>> >>> It will not be applied as is in tree. >>> >> >> Ahh, OK. >> >> A complicated subject. >> >> Sanchit, in case you don't know, some of the people who were around at >> the birth of ambisonics, plus ambdec author can be found on the list - >> >> https://mail.music.vt.edu/mailman/listinfo/sursound >> >> >> >> >> >> _______________________________________________ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> > > > > -- > Sanchit Sinha > B.Tech- CSE > IIIT-Delhi > Roll-2015083 > From bb9915658d1089e36f5b3131ec5851a058a57c62 Mon Sep 17 00:00:00 2001 From: Sanchit Sinha Date: Sat, 11 Mar 2017 17:04:47 +0530 Subject: [PATCH] avfiler/af_ambisonic.c: file added avfilter/allfilters.c and Makefile: entry added Changelog: entry mentioned --- Changelog | 1 + libavfilter/Makefile | 1 + libavfilter/af_ambisonic.c | 137 +++++++++++++++++++++++++++++++++++++++++++++ libavfilter/allfilters.c | 1 + 4 files changed, 140 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..16fd612 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -47,6 +47,7 @@ OBJS-$(CONFIG_ALOOP_FILTER) += f_loop.o OBJS-$(CONFIG_AMERGE_FILTER) += af_amerge.o OBJS-$(CONFIG_AMETADATA_FILTER) += f_metadata.o OBJS-$(CONFIG_AMIX_FILTER) += af_amix.o +OBJS-$(CONFIG_AMBISONIC_FILTER) += af_ambisonic.o OBJS-$(CONFIG_ANEQUALIZER_FILTER) += af_anequalizer.o OBJS-$(CONFIG_ANULL_FILTER) += af_anull.o OBJS-$(CONFIG_APAD_FILTER) += af_apad.o diff --git a/libavfilter/af_ambisonic.c b/libavfilter/af_ambisonic.c new file mode 100644 index 0000000..32f3c0c --- /dev/null +++ b/libavfilter/af_ambisonic.c @@ -0,0 +1,137 @@ +/* + * 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; + /*Not needed, if any new variables are to be used, this struct can be populated(f)*/ + +} AmbisonicContext; + +#define OFFSET(x) offsetof(AmbisonicContext, x) + +static const AVOption ambisonic_options[] = { //square will be an option +{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]; + /*If variables used, this has to be created*/ + // AmbisonicContext *s = ctx->priv; + // const float *src = (const float *)in->data[0]; + // float *dst; + AVFrame *out; + int itr; + float *w,*x,*y; + 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); + } + + /*If planar samples are used, output must be put in dst*/ + //dst = (float *)out->data[0]; + + w=(float *)in->extended_data[0]; + x=(float *)in->extended_data[1]; + y=(float *)in->extended_data[2]; + + for(itr=0;itrnb_samples;itr++) + { + /*Float pointers to the samples*/ + + 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]); + + out->extended_data[0][itr]= lf; + out->extended_data[1][itr]= lb; + out->extended_data[2][itr]= rb; + out->extended_data[3][itr]= rf; + } + + 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, + // .config_props = config_input, + }, + { 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, + // .uninit = uninit, + .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