]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/opus_silk.c
lavc: prefer the mp3float decoder to the mp3 decoder
[ffmpeg] / libavcodec / opus_silk.c
index 3c9c849c21de94176c647b99874573691e3e50bd..344333cc180f05d7833b9ee48fe90091bad1b39c 100644 (file)
@@ -185,8 +185,15 @@ static inline int silk_is_lpc_stable(const int16_t lpc[16], int order)
         row = lpc32[k & 1];
 
         for (j = 0; j < k; j++) {
-            int x = prevrow[j] - ROUND_MULL(prevrow[k - j - 1], rc, 31);
-            row[j] = ROUND_MULL(x, gain, fbits);
+            int x = av_sat_sub32(prevrow[j], ROUND_MULL(prevrow[k - j - 1], rc, 31));
+            int64_t tmp = ROUND_MULL(x, gain, fbits);
+
+            /* per RFC 8251 section 6, if this calculation overflows, the filter
+               is considered unstable. */
+            if (tmp < INT32_MIN || tmp > INT32_MAX)
+                return 0;
+
+            row[j] = (int32_t)tmp;
         }
     }
 }