[FFmpeg-devel] avfilter/af_pan: parse properly expressions referencing the same channel multiple times

Submitted by Marton Balint on March 24, 2018, 10 p.m.

Details

Message ID 20180324220032.20158-1-cus@passwd.hu
State New
Headers show

Commit Message

Marton Balint March 24, 2018, 10 p.m.
Fixes parsing of expressions like c0=c0+c0. Previously no error was thrown and
only the last gain factor was used.

Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavfilter/af_pan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Nicolas George March 25, 2018, 1:36 p.m.
Marton Balint (2018-03-24):
> Fixes parsing of expressions like c0=c0+c0. Previously no error was thrown and
> only the last gain factor was used.
> 
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
>  libavfilter/af_pan.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Thanks for finding that misfeature. But I think your fixes goes in the
wrong direction. I think that "c1=c1+c1" is much more likely to be a
typo for "c1=c1+c4" than an intentional way of writing "c1=2*c1".
Therefore I think it would be better to return an error, or at least
print a warning, than accepting it silently.

Regards,

Patch hide | download patch | download mbox

diff --git a/libavfilter/af_pan.c b/libavfilter/af_pan.c
index d8a63a7952..148ac9f643 100644
--- a/libavfilter/af_pan.c
+++ b/libavfilter/af_pan.c
@@ -184,7 +184,7 @@  static av_cold int init(AVFilterContext *ctx)
                 ret = AVERROR(EINVAL);
                 goto fail;
             }
-            pan->gain[out_ch_id][in_ch_id] = sign * gain;
+            pan->gain[out_ch_id][in_ch_id] += sign * gain;
             skip_spaces(&arg);
             if (!*arg)
                 break;