summaryrefslogtreecommitdiff
path: root/libavfilter/af_pan.c
diff options
context:
space:
mode:
authorMoritz Barsnick <barsnick@gmx.net>2016-10-28 14:13:25 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2016-11-24 00:54:52 +0100
commit0700d02a697e0a2901abc6422edfe72a246bae01 (patch)
tree7a45073731bd2d0af1d8603e38365dc0b29071ad /libavfilter/af_pan.c
parent584eea5bf3e40e2dbab986f8e9e8f01c8a4426d2 (diff)
lavfi/pan: allow negative gain parameters also for other inputs than the first named
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> Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavfilter/af_pan.c')
-rw-r--r--libavfilter/af_pan.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/libavfilter/af_pan.c b/libavfilter/af_pan.c
index fbd79a5a42..94f15876f5 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++;
}