X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavfilter%2Faf_pan.c;h=34e522c9d4eb2bf1923f38458c64d06ebe3c96c0;hb=492b312ddd855ecb9334960b9602086937196e76;hp=23b29419b635027889bff8340547028449664660;hpb=5b5365fe9d635005a9020d89c2448f4b5828d42f;p=ffmpeg diff --git a/libavfilter/af_pan.c b/libavfilter/af_pan.c index 23b29419b63..34e522c9d4e 100644 --- a/libavfilter/af_pan.c +++ b/libavfilter/af_pan.c @@ -104,6 +104,7 @@ static av_cold int init(AVFilterContext *ctx) char *arg, *arg0, *tokenizer, *args = av_strdup(pan->args); 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 + int used_out_ch[MAX_CHANNELS] = {0}; double gain; if (!pan->args) { @@ -127,6 +128,7 @@ static av_cold int init(AVFilterContext *ctx) /* parse channel specifications */ while ((arg = arg0 = av_strtok(NULL, "|", &tokenizer))) { + int used_in_ch[MAX_CHANNELS] = {0}; /* channel name */ if (parse_channel_name(&arg, &out_ch_id, &named)) { av_log(ctx, AV_LOG_ERROR, @@ -153,6 +155,13 @@ static av_cold int init(AVFilterContext *ctx) ret = AVERROR(EINVAL); goto fail; } + if (used_out_ch[out_ch_id]) { + av_log(ctx, AV_LOG_ERROR, + "Can not reference out channel %d twice\n", out_ch_id); + ret = AVERROR(EINVAL); + goto fail; + } + used_out_ch[out_ch_id] = 1; skip_spaces(&arg); if (*arg == '=') { arg++; @@ -166,6 +175,7 @@ static av_cold int init(AVFilterContext *ctx) goto fail; } /* gains */ + sign = 1; while (1) { gain = 1; if (sscanf(arg, "%lf%n *%n", &gain, &len, &len)) @@ -183,6 +193,13 @@ static av_cold int init(AVFilterContext *ctx) ret = AVERROR(EINVAL); goto fail; } + if (used_in_ch[in_ch_id]) { + av_log(ctx, AV_LOG_ERROR, + "Can not reference in channel %d twice\n", in_ch_id); + ret = AVERROR(EINVAL); + goto fail; + } + used_in_ch[in_ch_id] = 1; pan->gain[out_ch_id][in_ch_id] = sign * gain; skip_spaces(&arg); if (!*arg)