diff mbox

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

Message ID 72239e255853a51dde84e70351d059df4bef5acd.1475977585.git.barsnick@gmx.net
State Accepted
Commit efbc37a757d6b41af1a5752ff810db1dcf3fe78c
Headers show

Commit Message

Moritz Barsnick Oct. 9, 2016, 1:49 a.m. UTC
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@gmx.net>
---
 libavfilter/af_pan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Nicolas George Oct. 10, 2016, 5:07 p.m. UTC | #1
L'octidi 18 vendémiaire, an CCXXV, Moritz Barsnick a écrit :
> 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@gmx.net>
> ---
>  libavfilter/af_pan.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

LGTM, thanks.

Regards,
Michael Niedermayer Oct. 11, 2016, 1:46 a.m. UTC | #2
On Mon, Oct 10, 2016 at 07:07:34PM +0200, Nicolas George wrote:
> L'octidi 18 vendémiaire, an CCXXV, Moritz Barsnick a écrit :
> > 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@gmx.net>
> > ---
> >  libavfilter/af_pan.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> LGTM, thanks.

applied

thx

[...]
diff mbox

Patch

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)