Fixes rare overflow in intra_decision()

This commit is contained in:
Jean-Marc Valin 2010-09-14 16:06:22 -04:00
parent 3c15659c39
commit ba760bc525

View file

@ -74,11 +74,11 @@ static int intra_decision(const celt_word16 *eBands, celt_word16 *oldEBands, int
{ {
for (i=start;i<end;i++) for (i=start;i<end;i++)
{ {
celt_word16 d = SUB16(eBands[i+c*len], oldEBands[i+c*len]); celt_word16 d = SHR16(SUB16(eBands[i+c*len], oldEBands[i+c*len]),1);
dist = MAC16_16(dist, d,d); dist = MAC16_16(dist, d,d);
} }
} }
return SHR32(dist,2*DB_SHIFT) > 2*C*(end-start); return SHR32(dist,2*DB_SHIFT-2) > 2*C*(end-start);
} }
#ifndef STATIC_MODES #ifndef STATIC_MODES