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

Attached patch is fixing this. With it the minimal value
of coeffs[g].ath is 0.0f. 

>> Attached patch errors out in this case.

Scratch that patch. It shouldn't be negative (fixed with
attached patch), but 0.0f is possible.

>>> band->energy can be 0?
>>
>> Yes, it's set to 0.0f in calc_thr_3gpp if enough coefs are 0.
> 
> and in that case the threshold? (that is calculated as a fraction of the
> energy at least in one place).

In that case band->thr is set to coeffs[g].ath:
    band->thr_quiet = band->thr = FFMAX(band->thr, coeffs[g].ath);

So band->thr still can be 0.0f, i.e. the patch checking for (band->thr > 0.0f)
is still necessary.

Best regards,
Andreas
>From 667787601c17bd1d461f3171bedafd17214216e6 Mon Sep 17 00:00:00 2001
From: Andreas Cadhalpun <andreas.cadhal...@googlemail.com>
Date: Sat, 18 Apr 2015 00:33:50 +0200
Subject: [PATCH] aacpsy: fix calculation of minath in psy_3gpp_init

The minimum of the ath(x, ATH_ADD) function is at 3407 (-5.24241638)
not at 3410 (-5.24237967).

Signed-off-by: Andreas Cadhalpun <andreas.cadhal...@googlemail.com>
---
 libavcodec/aacpsy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/aacpsy.c b/libavcodec/aacpsy.c
index 7205ee3..c9bcfaf 100644
--- a/libavcodec/aacpsy.c
+++ b/libavcodec/aacpsy.c
@@ -313,7 +313,7 @@ static av_cold int psy_3gpp_init(FFPsyContext *ctx) {
     ctx->bitres.size   = 6144 - pctx->frame_bits;
     ctx->bitres.size  -= ctx->bitres.size % 8;
     pctx->fill_level   = ctx->bitres.size;
-    minath = ath(3410, ATH_ADD);
+    minath = ath(3407, ATH_ADD);
     for (j = 0; j < 2; j++) {
         AacPsyCoeffs *coeffs = pctx->psy_coef[j];
         const uint8_t *band_sizes = ctx->bands[j];
-- 
2.1.4

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to