]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/opus_silk: Change silk_lsf2lpc() slightly toward silk/NLSF2A.c
authorMichael Niedermayer <michael@niedermayer.cc>
Sat, 2 Jun 2018 23:33:54 +0000 (01:33 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Mon, 4 Jun 2018 21:47:55 +0000 (23:47 +0200)
Fixes: runtime error: signed integer overflow: -1440457022 - 785819492 cannot be represented in type 'int'
Fixes: 7700/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_OPUS_fuzzer-6595838684954624
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/opus_silk.c

index 344333cc180f05d7833b9ee48fe90091bad1b39c..2fcbf3b9d3ce6533aa73d98d252309fdb12f0a77 100644 (file)
@@ -239,8 +239,10 @@ static void silk_lsf2lpc(const int16_t nlsf[16], float lpcf[16], int order)
 
     /* reconstruct A(z) */
     for (k = 0; k < order>>1; k++) {
-        lpc32[k]         = -p[k + 1] - p[k] - q[k + 1] + q[k];
-        lpc32[order-k-1] = -p[k + 1] - p[k] + q[k + 1] - q[k];
+        int32_t p_tmp = p[k + 1] + p[k];
+        int32_t q_tmp = q[k + 1] - q[k];
+        lpc32[k]         = -q_tmp - p_tmp;
+        lpc32[order-k-1] =  q_tmp - p_tmp;
     }
 
     /* limit the range of the LPC coefficients to each fit within an int16_t */