shithub: opus

Download patch

ref: 23340e2249c660af3cd1914128e1845fceddeb97
parent: 752287825c3b7e706c3bcbf1e5f5920e222b76cf
author: Jean-Marc Valin <[email protected]>
date: Thu Feb 3 18:21:00 EST 2011

Fixes an int overflow in the VBR code

Also properly applies the MDCT filtering for resampling

--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -950,7 +950,8 @@
 
    if (st->vbr)
    {
-      vbr_rate = ((2*st->bitrate*frame_size<<BITRES)+st->mode->Fs)/(2*st->mode->Fs);
+      celt_int32 den=st->mode->Fs>>BITRES;
+      vbr_rate=(st->bitrate*frame_size+(den>>1))/den;
       effectiveBytes = vbr_rate>>3;
    } else {
       celt_int32 tmp;
@@ -2399,7 +2400,7 @@
       int bound = M*st->mode->eBands[effEnd];
       if (st->downsample!=1)
          bound = IMIN(bound, N/st->downsample);
-      for (i=M*st->mode->eBands[effEnd];i<N;i++)
+      for (i=bound;i<N;i++)
          freq[c*N+i] = 0;
    } while (++c<C);