Message ID | 1477656805-28401-1-git-send-email-barsnick@gmx.net |
---|---|
State | Accepted |
Commit | 0700d02a697e0a2901abc6422edfe72a246bae01 |
Headers | show |
Le septidi 7 brumaire, an CCXXV, Moritz Barsnick a écrit : > 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 <barsnick@gmx.net> > --- > doc/filters.texi | 2 +- > libavfilter/af_pan.c | 10 +++++++--- > 2 files changed, 8 insertions(+), 4 deletions(-) Still LGTM, of course, thanks. Regards,
On Sat, Oct 29, 2016 at 03:03:58PM +0200, Nicolas George wrote: > Le septidi 7 brumaire, an CCXXV, Moritz Barsnick a écrit : > > 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 <barsnick@gmx.net> > > --- > > doc/filters.texi | 2 +- > > libavfilter/af_pan.c | 10 +++++++--- > > 2 files changed, 8 insertions(+), 4 deletions(-) > > Still LGTM, of course, thanks. applied thx [...]
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++; }
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 <barsnick@gmx.net> --- doc/filters.texi | 2 +- libavfilter/af_pan.c | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-)