[FFmpeg-devel] [libav-devel] [PATCH] aacpsy: avoid norm_fac becoming NaN

Michael Niedermayer michaelni at gmx.at
Sat Apr 18 04:40:57 CEST 2015

On Sat, Apr 18, 2015 at 12:55:08AM +0200, Andreas Cadhalpun wrote:
> On 17.04.2015 23:39, Luca Barbato wrote:
> > On 17/04/15 16:08, Andreas Cadhalpun wrote:
> >> On 17.04.2015 02:01, Luca Barbato wrote:
> >>> is band->thr = 0.0f a valid value?
> >>
> >> Come to think of it, that's probably invalid.
> I retract that, it seems band->thr = 0.0f is valid.
> >> It can happen if coeffs[g].ath is not positive.
> > 
> > ath() returns easily Inf and negative values...
> It returns Inf for 0 and Inf, though that's not the
> problem here. Neither is that it can return negative
> values, because the minimum of the ath() function is
> (or rather should be) subtracted:
>     coeffs[g].ath = minscale - minath;
> The problem is that minath is not the minimum, only close:
>     minath = ath(3410, ATH_ADD) = -5.24237967
>              ath(3407, ATH_ADD) = -5.24241638

the exact location of the minimum depends on teh "add" value
its around 3410 for add=0 and around 3407 for add=4
for fun, 3407.080774800152 is even closer than 3407 for add=4

but the "add" parameter should probably be user selectable

also if you want to prevent coeffs[].ath from becoming negative then
you have to check coeffs[].ath, as
float rounding and optimizations can differ between platforms

you cannot even know for sure that
ath(3407, ATH_ADD) == ath(i, ATH_ADD) when i == 3407

the value calculated with a constant can be calculated at build time
but in the loop the code could have been optimized/factored/whatever
by the compiler and produce different values as a result


Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Avoid a single point of failure, be that a person or equipment.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150418/dfbc5141/attachment.asc>

More information about the ffmpeg-devel mailing list