1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

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@gmail.com>
This commit is contained in:
Andrew D'Addesio 2017-12-02 11:36:25 -06:00 committed by Rostislav Pehlivanov
parent 511e6f17f4
commit de052ea454

View File

@ -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;