[FFmpeg-devel] [PATCH] lavfi/pan: renormalize negative gain coefficients properly

Moritz Barsnick barsnick at gmx.net
Sun Oct 9 04:49:15 EEST 2016


The parser for the outdef will accept a negative value for the first
named channel's gain. As negative values effectively only invert the
phase of the signal, and not negate the level, the gains' absolute
values must be used to correctly accumulate the levels.

Signed-off-by: Moritz Barsnick <barsnick at gmx.net>
---
 libavfilter/af_pan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/af_pan.c b/libavfilter/af_pan.c
index 1eb102c..3037864 100644
--- a/libavfilter/af_pan.c
+++ b/libavfilter/af_pan.c
@@ -322,7 +322,7 @@ static int config_props(AVFilterLink *link)
                 continue;
             t = 0;
             for (j = 0; j < link->channels; j++)
-                t += pan->gain[i][j];
+                t += fabs(pan->gain[i][j]);
             if (t > -1E-5 && t < 1E-5) {
                 // t is almost 0 but not exactly, this is probably a mistake
                 if (t)
-- 
2.7.4



More information about the ffmpeg-devel mailing list