diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-03-08 14:00:22 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-03-08 14:21:40 +0100 |
commit | 8978c743fb1d1f5a0d6dbdd83ff05817f8a41230 (patch) | |
tree | f651f952d834fb564ca8e01ba85f77047b45254d /libavcodec | |
parent | 199db97fbdd92c58b8f0e50eac60fead35e4dc57 (diff) | |
download | ffmpeg-8978c743fb1d1f5a0d6dbdd83ff05817f8a41230.tar.gz |
aacsbr: Check for envelope scalefactors overflowing
This prevents various values from becoming stuck at NAN and
output to become silent
If someone knows a cleaner solution, thats welcome!
Fixes Ticket2335
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/aacsbr.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/libavcodec/aacsbr.c b/libavcodec/aacsbr.c index 81b3c78ae3..2dd4c5e44c 100644 --- a/libavcodec/aacsbr.c +++ b/libavcodec/aacsbr.c @@ -1132,7 +1132,12 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac) for (k = 0; k < sbr->n[sbr->data[0].bs_freq_res[e]]; k++) { float temp1 = exp2f(sbr->data[0].env_facs[e][k] * alpha + 7.0f); float temp2 = exp2f((pan_offset - sbr->data[1].env_facs[e][k]) * alpha); - float fac = temp1 / (1.0f + temp2); + float fac; + if (temp1 > 1E20) { + av_log(NULL, AV_LOG_ERROR, "envelope scalefactor overflow in dequant\n"); + temp1 = 1; + } + fac = temp1 / (1.0f + temp2); sbr->data[0].env_facs[e][k] = fac; sbr->data[1].env_facs[e][k] = fac * temp2; } @@ -1141,7 +1146,12 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac) for (k = 0; k < sbr->n_q; k++) { float temp1 = exp2f(NOISE_FLOOR_OFFSET - sbr->data[0].noise_facs[e][k] + 1); float temp2 = exp2f(12 - sbr->data[1].noise_facs[e][k]); - float fac = temp1 / (1.0f + temp2); + float fac; + if (temp1 > 1E20) { + av_log(NULL, AV_LOG_ERROR, "envelope scalefactor overflow in dequant\n"); + temp1 = 1; + } + fac = temp1 / (1.0f + temp2); sbr->data[0].noise_facs[e][k] = fac; sbr->data[1].noise_facs[e][k] = fac * temp2; } @@ -1150,9 +1160,15 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac) for (ch = 0; ch < (id_aac == TYPE_CPE) + 1; ch++) { float alpha = sbr->data[ch].bs_amp_res ? 1.0f : 0.5f; for (e = 1; e <= sbr->data[ch].bs_num_env; e++) - for (k = 0; k < sbr->n[sbr->data[ch].bs_freq_res[e]]; k++) + for (k = 0; k < sbr->n[sbr->data[ch].bs_freq_res[e]]; k++){ sbr->data[ch].env_facs[e][k] = exp2f(alpha * sbr->data[ch].env_facs[e][k] + 6.0f); + if (sbr->data[ch].env_facs[e][k] > 1E20) { + av_log(NULL, AV_LOG_ERROR, "envelope scalefactor overflow in dequant\n"); + sbr->data[ch].env_facs[e][k] = 1; + } + } + for (e = 1; e <= sbr->data[ch].bs_num_noise; e++) for (k = 0; k < sbr->n_q; k++) sbr->data[ch].noise_facs[e][k] = |