From patchwork Fri Mar 10 20:02: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: 2872 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.50.79 with SMTP id y76csp213164vsy; Fri, 10 Mar 2017 12:02:40 -0800 (PST) X-Received: by 10.28.44.66 with SMTP id s63mr525648wms.77.1489176160657; Fri, 10 Mar 2017 12:02:40 -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 s10si14176576wrb.43.2017.03.10.12.02.40; Fri, 10 Mar 2017 12:02:40 -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 E7375688274; Fri, 10 Mar 2017 22:02:22 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1146F680656 for ; Fri, 10 Mar 2017 22:02:17 +0200 (EET) Received: by mail-wm0-f66.google.com with SMTP id u132so689759wmg.1 for ; Fri, 10 Mar 2017 12:02: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=M10TKNz/9Wh+sluZtT2qJpuK6ZYYIN5T/lbvPL1Rmzw=; b=hR67fZ9MHQupaZnpkZQ5ChjCH/c7ZRiG7xMyoQ0oEPh7nmFr7EE5mFEgJ94k+6ETGm 0/xE4f6PV4abTy4hec2wbmDHa148tyYpDfTbOtHNFsMqAk79eV5zT1V/SpJjbw6eBtWY UObNf21vRzsIxB9Y5EoW5MQATZP0kVmbngF8U= 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=M10TKNz/9Wh+sluZtT2qJpuK6ZYYIN5T/lbvPL1Rmzw=; b=fz6AIb8Eea0EJ36Y0BiEZ9vjS+2ibk+mJDKMbVB/rodD+6bKCQDO4gqQ//y7YcXUzf 6Ev0lj8xoBMAZmL90ou9rDtTPleo3+wamiMjIUS938G7uyMsNCOQWIhH1QXslRY+gTmh so1c52DP4Jy3YOyDE7zVnbkNha5CBrxAzUpG2r5eZ0jKksg/BfQegbjhFluwkcv7Yd7y BPD2uOiMZWsxvpQTEJ2x5iAR6A23rlyai+GAVWiEagmWXKnm3wLUU5NhOnCH7/A9NzNO Kv1NYJ/uUHNpfBMqsME60D7QJgMJg8W24SbvFcYLrNo2IiI+G9XLRk8A0EcwzdZ00m4w 9HQA== X-Gm-Message-State: AFeK/H3JysE1KheMxqufTfPuIVwoGxiO/Rrxx42SK27gh11ixVbwHv4MHvlWLruJqWwNI8MYsnHBuFp7MyBgtOgv X-Received: by 10.28.26.196 with SMTP id a187mr578895wma.33.1489176150779; Fri, 10 Mar 2017 12:02:30 -0800 (PST) MIME-Version: 1.0 Received: by 10.80.139.131 with HTTP; Fri, 10 Mar 2017 12:02:30 -0800 (PST) In-Reply-To: References: From: Sanchit Sinha Date: Sat, 11 Mar 2017 01:32: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" Okay made some changes, From c0c1a1e7d4ad1fcbd96827725a47af20145c7621 Mon Sep 17 00:00:00 2001 From: Sanchit Sinha Date: Sat, 11 Mar 2017 01:27:38 +0530 Subject: [PATCH] Changes to af_ambisonic.c, makefile and allfilters.c --- libavfilter/af_ambisonic.c | 136 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 libavfilter/af_ambisonic.c + .outputs = outputs, +}; \ No newline at end of file diff --git a/libavfilter/af_ambisonic.c b/libavfilter/af_ambisonic.c new file mode 100644 index 0000000..03409a6 --- /dev/null +++ b/libavfilter/af_ambisonic.c @@ -0,0 +1,136 @@ +/* + * 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; + + 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]; + + float root8= sqrt(8); + float lf=0,lb=0,rb=0,rf=0; + for(itr=0;itrnb_samples;itr++) + { + /*Float pointers to the samples*/ + 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); + + 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,