Nevcairiel / LAVFilters

LAV Filters - Open-Source DirectShow Media Splitter and Decoders
GNU General Public License v2.0
7.23k stars 786 forks source link

low volume when downmixing with clipping protection #519

Closed ghost closed 1 year ago

ghost commented 1 year ago

Volume when downmixing with clipping protection is the same as using normalization.

Bug was introduced in be65286be91ec4e5cb7a282dba9ffc305ea15c90 at line 552 almost 1 year ago. rematrix_maxval isn't a boolean but the maximum gain factor that can be applied. Official documentation suggests 1.0 for normalization and INT_MAX for clipping protection as it was before this commit.

However the code now uses 0.0 for clipping protection which luckily seems to be disregarded and to be replaced by 1.0, so we at least end up with the same volume as normalization instead of silence.

Please fix.

Nevcairiel commented 1 year ago

The default value for maxval when using floating-point audio is INT_MAX, not 1.0. Its only 1.0 if you use integer internal or output format, which LAV does not do.

https://git.1f0.de/gitweb/?p=ffmpeg.git;a=blob;f=libswresample/rematrix.c;h=c0fbb3e84dd59671b9b63e5fce20ddfa9b648935;hb=HEAD;js=1#l475

And LAV will always use FP32 as both the internal as well as output format for swresample processing, hence using that value as default.

In fact, I can also observe a clear volume difference between enabling normalization, and disabling it. And I can see clipping protection engage in the log, which it never would if the limit would indeed be 1.0

So while 0.0 might not be the best value, it does not result in any bug.

ghost commented 1 year ago

So the explanation I gave is totally wrong. Still downmixing with clipping protection has much lower volume now than before the libraries were switched. However as I'm not personally affected I won't spent any time on investigating this issues.