Fixes a bug introduced by the previous commit
authorJean-Marc Valin <jmvalin@jmvalin.ca>
Sun, 8 Apr 2012 03:03:24 +0000 (23:03 -0400)
committerJean-Marc Valin <jmvalin@jmvalin.ca>
Sun, 8 Apr 2012 03:03:24 +0000 (23:03 -0400)
celt_ilog2() could be called with 0 which is undefined.

celt/pitch.c

index bea0c3d..06bc637 100644 (file)
@@ -106,7 +106,7 @@ void pitch_downsample(celt_sig * restrict x[], opus_val16 * restrict x_lp,
    opus_val16 lpc[4], mem[4]={0,0,0,0};
 #ifdef FIXED_POINT
    int shift;
-   opus_val32 maxabs = celt_maxabs32(x[0], len);
+   opus_val32 maxabs = MAX32(1, celt_maxabs32(x[0], len));
    if (C==2)
       maxabs = MAX32(maxabs, celt_maxabs32(x[1], len));
    shift = IMAX(0,celt_ilog2(maxabs)-11);