Fix a case where the new search can leave us with no pulse left
This commit is contained in:
parent
54aab4225f
commit
137241d089
1 changed files with 4 additions and 1 deletions
|
@ -145,9 +145,10 @@ void alg_quant(celt_norm_t *X, celt_mask_t *W, int N, int K, celt_norm_t *P, ec_
|
||||||
j=0; do {
|
j=0; do {
|
||||||
sum += X[j];
|
sum += X[j];
|
||||||
} while (++j<N);
|
} while (++j<N);
|
||||||
sum = DIV32(SHL32(EXTEND32(K),15),EPSILON+sum);
|
sum = DIV32(SHL32(EXTEND32(K-1),15),EPSILON+sum);
|
||||||
j=0; do {
|
j=0; do {
|
||||||
#ifdef FIXED_POINT
|
#ifdef FIXED_POINT
|
||||||
|
/* It's really important to round *towards zero* here */
|
||||||
iy[j] = MULT16_32_Q15(X[j],sum);
|
iy[j] = MULT16_32_Q15(X[j],sum);
|
||||||
#else
|
#else
|
||||||
iy[j] = floor(sum*X[j]);
|
iy[j] = floor(sum*X[j]);
|
||||||
|
@ -160,6 +161,8 @@ void alg_quant(celt_norm_t *X, celt_mask_t *W, int N, int K, celt_norm_t *P, ec_
|
||||||
pulsesLeft -= iy[j];
|
pulsesLeft -= iy[j];
|
||||||
} while (++j<N);
|
} while (++j<N);
|
||||||
}
|
}
|
||||||
|
/*printf ("%d / %d (%d)\n", pulsesLeft, K, N);*/
|
||||||
|
celt_assert2(pulsesLeft>=1, "Allocated too many pulses in the quick pass");
|
||||||
#endif
|
#endif
|
||||||
while (pulsesLeft > 1)
|
while (pulsesLeft > 1)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue