[FFmpeg-cvslog] opus_celt: Fix arithmetic overflow (per RFC8251)

Andrew D'Addesio git at videolan.org
Mon Dec 4 09:31:13 EET 2017


ffmpeg | branch: master | Andrew D'Addesio <modchipv12 at gmail.com> | Sat Dec  2 11:36:25 2017 -0600| [de052ea454e06f2c1aab4e06cca0012cf80f2630] | committer: Rostislav Pehlivanov

opus_celt: Fix arithmetic overflow (per RFC8251)

As per Sec.8 of RFC8251:
    Cap on Band Energy
    NaN due to large log-energy value. Affects celt_denormalize().

Signed-off-by: Andrew D'Addesio <modchipv12 at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=de052ea454e06f2c1aab4e06cca0012cf80f2630
---

 libavcodec/opus_celt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/opus_celt.c b/libavcodec/opus_celt.c
index 84d484753b..ff56041ea6 100644
--- a/libavcodec/opus_celt.c
+++ b/libavcodec/opus_celt.c
@@ -481,7 +481,8 @@ static void celt_denormalize(CeltFrame *f, CeltBlock *block, float *data)
 
     for (i = f->start_band; i < f->end_band; i++) {
         float *dst = data + (ff_celt_freq_bands[i] << f->size);
-        float norm = exp2f(block->energy[i] + ff_celt_mean_energy[i]);
+        float log_norm = block->energy[i] + ff_celt_mean_energy[i];
+        float norm = exp2f(FFMIN(log_norm, 32.0f));
 
         for (j = 0; j < ff_celt_freq_range[i] << f->size; j++)
             dst[j] *= norm;



More information about the ffmpeg-cvslog mailing list