opus_pvq: fix crashing on analysis of mono
authorRostislav Pehlivanov <atomnuker@gmail.com>
Thu, 23 Nov 2017 00:58:36 +0000 (00:58 +0000)
committerRostislav Pehlivanov <atomnuker@gmail.com>
Thu, 23 Nov 2017 01:00:08 +0000 (01:00 +0000)
Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
libavcodec/opus_pvq.c

index f98b85d..2f7aa74 100644 (file)
@@ -925,7 +925,8 @@ static float pvq_band_cost(CeltPVQ *pvq, CeltFrame *f, OpusRangeCoder *rc, int b
 
     for (i = 0; i < band_size; i++) {
         err_x += (X[i] - X_orig[i])*(X[i] - X_orig[i]);
-        err_y += (Y[i] - Y_orig[i])*(Y[i] - Y_orig[i]);
+        if (Y)
+            err_y += (Y[i] - Y_orig[i])*(Y[i] - Y_orig[i]);
     }
 
     dist = sqrtf(err_x) + sqrtf(err_y);