[FFmpeg-cvslog] opus_pvq: prevent division by 0

Rostislav Pehlivanov git at videolan.org
Fri Feb 24 21:14:59 EET 2017


ffmpeg | branch: master | Rostislav Pehlivanov <atomnuker at gmail.com> | Fri Feb 24 19:13:44 2017 +0000| [70259737cbad1136d942fa0cca5d55be1ca37e0a] | committer: Rostislav Pehlivanov

opus_pvq: prevent division by 0

res was 0 and divided K which made it infinity which caused K to
overflow.

Signed-off-by: Rostislav Pehlivanov <atomnuker at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=70259737cbad1136d942fa0cca5d55be1ca37e0a
---

 libavcodec/opus_pvq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/opus_pvq.c b/libavcodec/opus_pvq.c
index 706e239..ce93c47 100644
--- a/libavcodec/opus_pvq.c
+++ b/libavcodec/opus_pvq.c
@@ -397,7 +397,7 @@ static void celt_pvq_search(float *X, int *y, int K, int N)
     for (i = 0; i < N; i++)
         res += FFABS(X[i]);
 
-    res = K/res;
+    res = K/(res + FLT_EPSILON);
 
     for (i = 0; i < N; i++) {
         y[i] = lrintf(res*X[i]);



More information about the ffmpeg-cvslog mailing list