From patchwork Sun Oct 9 01:49:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moritz Barsnick X-Patchwork-Id: 916 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.66 with SMTP id o63csp1963300vsd; Sat, 8 Oct 2016 18:55:36 -0700 (PDT) X-Received: by 10.28.168.203 with SMTP id r194mr4746123wme.103.1475978136289; Sat, 08 Oct 2016 18:55:36 -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 wf5si29062219wjb.49.2016.10.08.18.55.33; Sat, 08 Oct 2016 18:55:36 -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 5D2526898D7; Sun, 9 Oct 2016 04:55:14 +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 6B039689744 for ; Sun, 9 Oct 2016 04:55:07 +0300 (EEST) Received: from paradise.fritz.box ([80.144.19.106]) by mail.gmx.com (mrgmx003) with ESMTPSA (Nemesis) id 0MbgKD-1bcLqc0ptd-00J1wn; Sun, 09 Oct 2016 03:50:15 +0200 From: Moritz Barsnick To: FFmpeg development discussions and patches Date: Sun, 9 Oct 2016 03:49:16 +0200 Message-Id: <3c9e2a05df7e2f44fc87750122ca7ab8d85dd158.1475977585.git.barsnick@gmx.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: <72239e255853a51dde84e70351d059df4bef5acd.1475977585.git.barsnick@gmx.net> References: <72239e255853a51dde84e70351d059df4bef5acd.1475977585.git.barsnick@gmx.net> X-Provags-ID: V03:K0:Yn4UbrEUI8acl9Y2/Y5Q41rr1wBJX8WKahck2QX9HXRZ770O31y s7okPY3nOZWquteBl8ud7BjdLG+lDkS+JKvrJAQjMJOkf/Iqg549hfFGzBLix9yCiubhU7H 2jL5QcoQ4a9pbiuL7wiH92Lt94J468q6aWGgZSYhGbFdYjFk0c3jQpSByVVEsQrAeiBmye7 VdMjiLem/ORuWzi6093tA== X-UI-Out-Filterresults: notjunk:1; V01:K0:xxtG+8t+Evo=:PFR7sJjJcYUHf/kNhZva+A +jXZDy6yIegfKxHExR2BguLGrRzPE4Leh5lX4J3YhkFkquUM1fzSbnyvM/ArsfGYWTm57qwl1 Rro5cxvIWwC2YW1HOIFtuF3OJWMXGEjcLyS+IVe9Vpc90Ku15ZhA/cqPF8LfbDICX0sMdu1RD TSBOoXCR98FzQb7Z0be0IQuJ+nSqAvCFpeWEMSg0cYrgiHgnpXCfecG5Y0sJnKtLjGwtCG8bT 1eVLK3L9WwD5CwNOGWb0tF55RQr2nekB3xH3Upkwz3QA04O/UNkV9GBNPxePahvJDFbXuFNey 0nb2D7WtACUbY1IndfLgKFDeadwL1pJzIufTqjz5Ty+qdJ3vn4WVepcjB68MJ958Uxgme1g+K GN5tq1FKPBYVFlNSdlyON/HhMr5s0m2bZTBomCXTXjEhO0o8z1O+dEIiPrA5ilGggh7M7+OLc rYqWwHwOERkVqwMYifU6jHAz3In+MPQybFhltsyjVYAHaFdcj6T+oB7d12n9Em2tfHVHha9R1 5bff2J/3N4VKPgeonYkh+nrgIPylrdJ9k0xv1+3WYvgafQNcjeVYGTIVPVYgCopUKt5Jh3Lna n5YMI/iwHm3R3WXez5qBypv71LW+e9kvthZGQTNlo21LpH95cV16i90g8+Rnx8kLSLP6gYQjJ 3kfZJiUwsw5pUtteNiWHHCZ8ZUEUt/fXvCbXb+U3A/PHEqfiBJUaArFswFjak+u8TrYRKa4Yq nCLHZqyu81wpiSyW0KSNNTTV3BIe8QB2LX2CkqXm0wr3uR0V47Afn5nSD4I= 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. Signed-off-by: Moritz Barsnick --- doc/filters.texi | 2 +- libavfilter/af_pan.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 4b2f7bf..64934f7 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -3001,7 +3001,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 3037864..f395c71 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,11 +178,13 @@ 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;