ref: 137241d089bcd25ce7f2db878a5c8dbbe4e65d9d
parent: 54aab4225f1aab00ac2c4ff8ad339c38ca6351b9
author: Jean-Marc Valin <[email protected]>
date: Sat Dec 6 18:44:55 EST 2008
Fix a case where the new search can leave us with no pulse left
--- a/libcelt/vq.c
+++ b/libcelt/vq.c
@@ -145,9 +145,10 @@
j=0; do {
sum += X[j];
} while (++j<N);
- sum = DIV32(SHL32(EXTEND32(K),15),EPSILON+sum);
+ sum = DIV32(SHL32(EXTEND32(K-1),15),EPSILON+sum);
j=0; do {
#ifdef FIXED_POINT
+ /* It's really important to round *towards zero* here */
iy[j] = MULT16_32_Q15(X[j],sum);
#else
iy[j] = floor(sum*X[j]);
@@ -160,6 +161,8 @@
pulsesLeft -= iy[j];
} while (++j<N);
}
+ /*printf ("%d / %d (%d)\n", pulsesLeft, K, N);*/
+ celt_assert2(pulsesLeft>=1, "Allocated too many pulses in the quick pass");
#endif
while (pulsesLeft > 1)
{