ref: ff4116ccb5e771c84c8963c954a595407a95391e
parent: 9a7540b673ccd96dbfb0ee3f8ce41efd76a88d33
author: Jean-Marc Valin <[email protected]>
date: Thu Feb 3 04:16:13 EST 2011
Patch from Tim: Prevents bits2 from going negative
--- a/libcelt/rate.c
+++ b/libcelt/rate.c
@@ -589,7 +589,7 @@
for (j=end;j-->start;)
{
int N = m->eBands[j+1]-m->eBands[j];
- bits1[j] = C*N*m->allocVectors[mid*len+j]<<LM>>2;
+ bits1[j] = IMIN(C*N*m->allocVectors[mid*len+j]<<LM>>2,cap[j]);
if (bits1[j] > 0)
bits1[j] = IMAX(0, bits1[j] + trim_offset[j]);
bits1[j] += offsets[j];
@@ -615,9 +615,9 @@
for (j=start;j<end;j++)
{
int N = m->eBands[j+1]-m->eBands[j];
- bits1[j] = C*N*m->allocVectors[lo*len+j]<<LM>>2;
+ bits1[j] = IMIN(C*N*m->allocVectors[lo*len+j]<<LM>>2,cap[j]);
bits2[j] = hi>=m->nbAllocVectors ?
- cap[j] : C*N*m->allocVectors[hi*len+j]<<LM>>2;
+ cap[j] : IMIN(C*N*m->allocVectors[hi*len+j]<<LM>>2,cap[j]);
if (bits1[j] > 0)
bits1[j] = IMAX(0, bits1[j] + trim_offset[j]);
if (bits2[j] > 0)