From patchwork Tue Oct 11 10:10:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moritz Barsnick X-Patchwork-Id: 953 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.66 with SMTP id o63csp238395vsd; Tue, 11 Oct 2016 03:10:43 -0700 (PDT) X-Received: by 10.194.100.169 with SMTP id ez9mr3950082wjb.9.1476180643824; Tue, 11 Oct 2016 03:10:43 -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 vy10si3985437wjc.113.2016.10.11.03.10.43; Tue, 11 Oct 2016 03:10:43 -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 5FF0E689AFF; Tue, 11 Oct 2016 13:10:41 +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.17.20]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 36C9468988A for ; Tue, 11 Oct 2016 13:10:35 +0300 (EEST) Received: from paradise.fritz.box ([80.144.42.112]) by mail.gmx.com (mrgmx103) with ESMTPSA (Nemesis) id 0MgsVY-1bXxJS2KTA-00M1d8; Tue, 11 Oct 2016 12:10:34 +0200 From: Moritz Barsnick To: FFmpeg development discussions and patches Date: Tue, 11 Oct 2016 12:10:12 +0200 Message-Id: <1476180612-3933-1-git-send-email-barsnick@gmx.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <20161010170934.GB90221@phare.normalesup.org> References: <20161010170934.GB90221@phare.normalesup.org> X-Provags-ID: V03:K0:bI6D0RA1O+dcV1yVQR6F5PBkC3AyAEI+Bl5QD9a/eD1uLhQ76OP OO7vrx01ykh0ZoQM8iwsDMsgDWCXtEjoRRWLaLs/y2QBtsOEtgny38MHZrDR86vCL+dAp01 qzYcztJl85Xd1zN7Jsae91rfg1LcOPdgXEwMhuOIGDO9bYwv4SmW+nuEB4kKL5cjqAMyfYz GG9q7C5wE21GFk/XT2CFA== X-UI-Out-Filterresults: notjunk:1; V01:K0:LVbO+tgdw9k=:mffdyrz8yF4VscqMQirom4 1pc4LZyXxeA4RSKDagSt5c5cI1xaFAw1OHgSO3pCJtAa/PRDtPGvmRAfF1KIVGiPqE6wCCylO 3m9AITaXlcW+z8NSIu6vbdWuR19Top5Z2NVlau0PMvU8DrSUFnNCpkqD2RfcIX3L+Gk+KMuiB +Ll/UhYC5zhN00lMs008JxQEbKoU6haKjiMYPs10U8UAoQwr3QcshoDx5+C/XpVvp7v0iB++T lfwASsp20vCQvPkJ1scKcEIc7Fcc40EY+jS5mp1qqi08RORgK4XJ9eixg6AesZP+vvlOf+0j3 al70/ggCsIrgmM2SQDYfgbJis3U7ZMKUnqq0NeXa06XLCgsACypxNeqc+nbCYfICUHZvCsIIb LL6AXwAATMmLFyH/si7fhymddIDDhEI682zth8sY0A6itTms+CY9TDbkzfolIjyC7B80A65U2 F7oleXLRJB85WCaYhHeoy0lOsDUkAGi9TWrlkA6hnlC7TTChyPJOYNOLz+ZWJuMISc7mkVEb4 YKF0Ah0Drr4yNJ/ivf20zHKThmU7JHqGVEIoGj7vksCNSRqhEyHEiNPV49zpykP45xqOIFltt eN+YoNhT6sKilUgPVLprVpqV6dffQ4khSOYE4eoczMayg0Y1y27mTxb7CruY00fsET+t1S0Of Q8WgKHZ5PuMF7T8ZGbKLx27dzwMmekjOGPQK2RmrUiuoaM3qOLhISdsQlVrlccvmCe8B6Hp1Z 7d099KSoEBeFUWoZ1QnZJvp3SHIPr+VU0IDBgPhAlvCTv8H0DLmPuvOn+iw= 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 | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 4b2f7bf..fb4756e 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 fbd79a5..161097a 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,15 +178,20 @@ 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++; } }