summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <[email protected]>2018-06-03 00:48:06 +0200
committerMichael Niedermayer <[email protected]>2018-06-15 22:31:13 +0200
commit65b2b0d98a7da084bdd235768aeae6807c6050d5 (patch)
treec48872a675f82ce624a39e545ed5e8b39efa6290
parent0097cc0ea36c9350af585afdb5737e7bb1406618 (diff)
avcodec/amrwbdec: Fix division by 0 in find_hb_gain()
This restructures the code slightly toward D_UTIL_dec_synthesis() Fixes: 7420/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AMRWB_fuzzer-6577305112543232 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <[email protected]> (cherry picked from commit dce80a4b47efaba97707bda781a9ee57f5a26974) Signed-off-by: Michael Niedermayer <[email protected]>
-rw-r--r--libavcodec/amrwbdec.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c
index 7f2874d35f..47fe7eb55e 100644
--- a/libavcodec/amrwbdec.c
+++ b/libavcodec/amrwbdec.c
@@ -862,15 +862,20 @@ static float find_hb_gain(AMRWBContext *ctx, const float *synth,
{
int wsp = (vad > 0);
float tilt;
+ float tmp;
if (ctx->fr_cur_mode == MODE_23k85)
return qua_hb_gain[hb_idx] * (1.0f / (1 << 14));
- tilt = ctx->celpm_ctx.dot_productf(synth, synth + 1, AMRWB_SFR_SIZE - 1) /
- ctx->celpm_ctx.dot_productf(synth, synth, AMRWB_SFR_SIZE);
+ tmp = ctx->celpm_ctx.dot_productf(synth, synth + 1, AMRWB_SFR_SIZE - 1);
+
+ if (tmp > 0) {
+ tilt = tmp / ctx->celpm_ctx.dot_productf(synth, synth, AMRWB_SFR_SIZE);
+ } else
+ tilt = 0;
/* return gain bounded by [0.1, 1.0] */
- return av_clipf((1.0 - FFMAX(0.0, tilt)) * (1.25 - 0.25 * wsp), 0.1, 1.0);
+ return av_clipf((1.0 - tilt) * (1.25 - 0.25 * wsp), 0.1, 1.0);
}
/**