From patchwork Fri Oct 28 12:13:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moritz Barsnick X-Patchwork-Id: 1213 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.133 with SMTP id o127csp1059258vsd; Fri, 28 Oct 2016 05:13:58 -0700 (PDT) X-Received: by 10.28.15.202 with SMTP id 193mr2706380wmp.62.1477656838347; Fri, 28 Oct 2016 05:13:58 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id vf7si3091286wjb.199.2016.10.28.05.13.57; Fri, 28 Oct 2016 05:13:58 -0700 (PDT) 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; 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 E754A689F8E; Fri, 28 Oct 2016 15:13:51 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id ACA49689BDE for ; Fri, 28 Oct 2016 15:13:45 +0300 (EEST) Received: from paradise.fritz.box ([80.144.19.50]) by mail.gmx.com (mrgmx002) with ESMTPSA (Nemesis) id 0MH0SI-1c402j360o-00DnA7; Fri, 28 Oct 2016 14:13:47 +0200 From: Moritz Barsnick To: FFmpeg development discussions and patches Date: Fri, 28 Oct 2016 14:13:25 +0200 Message-Id: <1477656805-28401-1-git-send-email-barsnick@gmx.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <20161013093122.GA1939611@phare.normalesup.org> References: <20161013093122.GA1939611@phare.normalesup.org> X-Provags-ID: V03:K0:bUobEGSTEydGb8UfkjLc9cSXPbSv2vp7i7iDoCwL+abEJp7tQ2e gE5EagMdatp8q9iHfr7r9MmQSg2dZVE8S/IhyTiUyU9t7U9yx+2yV4K4a0gz3Zo01uv3Mvw nxPaF8gqERgFtS2m7c5VNC3hNuF066+nIMhc+3qeHnA4y0Gn89nPl3tYpbtzBnIK5mORQzk PzTww76zPRXxzhIUsrlSw== X-UI-Out-Filterresults: notjunk:1; V01:K0:8Nm4/piga90=:6AN6uFyOV44DYEJgTFGF9X MlAjoaruTIGBfhx5BBRjgVT5lNrCQnGvs2oUK65Uz1zUN6SamnkIC9QNtC2vIYZ/JAOPCzZPw 9dZqcEimki8m0G/nEvSzqP9lVjhWrL3vYa2HLvxtRnhnosMk8DItj+/CqWiszskOQltrx+6Zl woDbBb8thjm10Hn8hjAG4+VpjapHn4QKyLOsx5stqu1HhtPl0WKmBz9/bD1BA8Usbp7fvA/+A /buScLnuogEp00G992oVjEoZN/2AbQ0OXJN3LNb7hylVI/LOtcdb/U8isJxdVhZpPVIps1Tak p3k45PvVlzitZo1aYl7/MgLQy6B5kgDXByAlOuhc66c9BKbllilPlPqnNkFqvV++SFRbUxSQb BGJpyhcSQKPlavtpAKsvjJFBL7dfb3mZi1TooIOshUqSwU8x8NBki8JEKbg+78j5rdQ6X1P26 taMmFxiPxsYjeqZkFT5yQ6VCset0oAm11I0ERCKax9aj+43YJUiEs88mFNMQXPvMuABUKt5cl I62esXUpn+bQlzPkf1LbxRNE6X69Q40D0hV+TOaE9U+sX8PM/E8JN8wEMzq+ZrNxzasGpZH7J xn3ulj4grJU4eP8d+iIfCKMUja1AIpUhBpyc5nVBiwJHn/f3L06Pma4ooEcnsXlseyBYL+uDB 6aDfAF8svK6Aj4/YVxrBCalV668kk2X02xwbgZnpxSDU+uotYTcqg3Iix2CKC0jhJCsJmJsW8 GFKJ2jkLUV6CDv4mMvXRTdSZRcEQV32eVEqU8tYWUweLzFj3VHEbS97mToY= Subject: [FFmpeg-devel] [PATCH] lavfi/pan: allow negative gain parameters also for other inputs than the first named 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 Cc: Moritz Barsnick MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Expands the parser to also accept the separator '-' in addition to '+', and take the negative sign into consideration. The optional sign for the first factor in the expression is already covered by parsing for an integer. Signed-off-by: Moritz Barsnick --- doc/filters.texi | 2 +- libavfilter/af_pan.c | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index c37fa29..bff4640 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -3025,7 +3025,7 @@ output channel layout or number of channels @item outdef output channel specification, of the form: -"@var{out_name}=[@var{gain}*]@var{in_name}[+[@var{gain}*]@var{in_name}...]" +"@var{out_name}=[@var{gain}*]@var{in_name}[(+-)[@var{gain}*]@var{in_name}...]" @item out_name output channel to define, either a channel name (FL, FR, etc.) or a channel diff --git a/libavfilter/af_pan.c b/libavfilter/af_pan.c index fbd79a5..94f1587 100644 --- a/libavfilter/af_pan.c +++ b/libavfilter/af_pan.c @@ -102,7 +102,7 @@ static av_cold int init(AVFilterContext *ctx) { PanContext *const pan = ctx->priv; char *arg, *arg0, *tokenizer, *args = av_strdup(pan->args); - int out_ch_id, in_ch_id, len, named, ret; + int out_ch_id, in_ch_id, len, named, ret, sign = 1; int nb_in_channels[2] = { 0, 0 }; // number of unnamed and named input channels double gain; @@ -178,14 +178,18 @@ static av_cold int init(AVFilterContext *ctx) ret = AVERROR(EINVAL); goto fail; } - pan->gain[out_ch_id][in_ch_id] = gain; + pan->gain[out_ch_id][in_ch_id] = sign * gain; skip_spaces(&arg); if (!*arg) break; - if (*arg != '+') { + if (*arg == '-') { + sign = -1; + } else if (*arg != '+') { av_log(ctx, AV_LOG_ERROR, "Syntax error near \"%.8s\"\n", arg); ret = AVERROR(EINVAL); goto fail; + } else { + sign = 1; } arg++; }