Commit ff4116cc authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Patch from Tim: Prevents bits2 from going negative

parent 9a7540b6
......@@ -589,7 +589,7 @@ int compute_allocation(const CELTMode *m, int start, int end, const int *offsets
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 @@ int compute_allocation(const CELTMode *m, int start, int end, const int *offsets
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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment