New VQ search is now enabled by default after fixing the last remaining issues:
1) the case of the null vector and 2) getting rid of the 32-bit division
This commit is contained in:
parent
b0a73a0b1e
commit
8256ed4cf7
1 changed files with 18 additions and 6 deletions
24
libcelt/vq.c
24
libcelt/vq.c
|
@ -138,20 +138,30 @@ void alg_quant(celt_norm_t *X, celt_mask_t *W, int N, int K, celt_norm_t *P, ec_
|
||||||
xy = yy = yp = 0;
|
xy = yy = yp = 0;
|
||||||
|
|
||||||
pulsesLeft = K;
|
pulsesLeft = K;
|
||||||
#if 0
|
|
||||||
|
/* Do a pre-search by projecting on the pyramid */
|
||||||
if (K > (N>>1))
|
if (K > (N>>1))
|
||||||
{
|
{
|
||||||
celt_word32_t sum=0;
|
celt_word32_t sum=0;
|
||||||
|
celt_word16_t rcp;
|
||||||
j=0; do {
|
j=0; do {
|
||||||
sum += X[j];
|
sum += X[j];
|
||||||
} while (++j<N);
|
} while (++j<N);
|
||||||
sum = DIV32(SHL32(EXTEND32(K-1),15),EPSILON+sum);
|
if (sum == 0)
|
||||||
|
{
|
||||||
|
X[0] = 16384;
|
||||||
|
sum = 16384;
|
||||||
|
}
|
||||||
|
/* Do we have sufficient accuracy here? */
|
||||||
|
rcp = EXTRACT16(MULT16_32_Q16(K-1, celt_rcp(sum)));
|
||||||
|
/*rcp = DIV32(SHL32(EXTEND32(K-1),15),EPSILON+sum);*/
|
||||||
|
/*printf ("%d (%d %d)\n", rcp, N, K);*/
|
||||||
j=0; do {
|
j=0; do {
|
||||||
#ifdef FIXED_POINT
|
#ifdef FIXED_POINT
|
||||||
/* It's really important to round *towards zero* here */
|
/* It's really important to round *towards zero* here */
|
||||||
iy[j] = MULT16_32_Q15(X[j],sum);
|
iy[j] = MULT16_16_Q15(X[j],rcp);
|
||||||
#else
|
#else
|
||||||
iy[j] = floor(sum*X[j]);
|
iy[j] = floor(rcp*X[j]);
|
||||||
#endif
|
#endif
|
||||||
y[j] = SHL16(iy[j],yshift);
|
y[j] = SHL16(iy[j],yshift);
|
||||||
yy = MAC16_16(yy, y[j],y[j]);
|
yy = MAC16_16(yy, y[j],y[j]);
|
||||||
|
@ -161,9 +171,10 @@ 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);*/
|
/*if (pulsesLeft > N+2)
|
||||||
|
printf ("%d / %d (%d)\n", pulsesLeft, K, N);*/
|
||||||
celt_assert2(pulsesLeft>=1, "Allocated too many pulses in the quick pass");
|
celt_assert2(pulsesLeft>=1, "Allocated too many pulses in the quick pass");
|
||||||
#endif
|
|
||||||
while (pulsesLeft > 1)
|
while (pulsesLeft > 1)
|
||||||
{
|
{
|
||||||
int pulsesAtOnce=1;
|
int pulsesAtOnce=1;
|
||||||
|
@ -230,6 +241,7 @@ void alg_quant(celt_norm_t *X, celt_mask_t *W, int N, int K, celt_norm_t *P, ec_
|
||||||
pulsesLeft -= pulsesAtOnce;
|
pulsesLeft -= pulsesAtOnce;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pulsesLeft > 0)
|
||||||
{
|
{
|
||||||
celt_word16_t g;
|
celt_word16_t g;
|
||||||
celt_word16_t best_num = -VERY_LARGE16;
|
celt_word16_t best_num = -VERY_LARGE16;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue