On 17.04.2015 02:01, Luca Barbato wrote:
> On 16/04/15 20:19, Andreas Cadhalpun wrote:
>> On 16.04.2015 19:41, Claudio Freire wrote:
>>> It should be if band->thr > 0.0f, all divisions by zero return
>>> something that casts into an ~1:
> 
> is band->thr = 0.0f a valid value?

Come to think of it, that's probably invalid.
It can happen if coeffs[g].ath is not positive.
Attached patch errors out in this case.

> band->energy can be 0?

Yes, it's set to 0.0f in calc_thr_3gpp if enough coefs are 0.

Best regards,
Andreas
>From 37a67c054435e27b058c10ea0f94ec8906dc9af6 Mon Sep 17 00:00:00 2001
From: Andreas Cadhalpun <andreas.cadhal...@googlemail.com>
Date: Fri, 17 Apr 2015 15:55:32 +0200
Subject: [PATCH] aacpsy: validate absolute hearing threshold

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

diff --git a/libavcodec/aacpsy.c b/libavcodec/aacpsy.c
index 7205ee3..817140d 100644
--- a/libavcodec/aacpsy.c
+++ b/libavcodec/aacpsy.c
@@ -350,6 +350,12 @@ static av_cold int psy_3gpp_init(FFPsyContext *ctx) {
             for (i = 1; i < band_sizes[g]; i++)
                 minscale = FFMIN(minscale, ath((start + i) * line_to_frequency, ATH_ADD));
             coeffs[g].ath = minscale - minath;
+            if (coeffs[g].ath <= 0.0f) {
+                av_log(ctx->avctx, AV_LOG_ERROR,
+                       "absolute hearing threshold for band %d not positive: %f\n",
+                       g, coeffs[g].ath);
+                return AVERROR(EINVAL);
+            }
             start += band_sizes[g];
         }
     }
-- 
2.1.4

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

Reply via email to