ref: 3d25e71b407816098a421fe6b30edcd0f5af7ad1
parent: aca7a6304046ba774e8b289203cd5e063acdc774
author: Jean-Marc Valin <[email protected]>
date: Fri Oct 15 18:45:02 EDT 2010
More simplifications to the VQ search
--- a/libcelt/vq.c
+++ b/libcelt/vq.c
@@ -167,7 +167,7 @@
VARDECL(celt_norm, y);
VARDECL(int, iy);
VARDECL(celt_word16, signx);
- int j;
+ int i, j;
celt_word16 s;
int pulsesLeft;
celt_word32 sum;
@@ -284,10 +284,10 @@
pulsesLeft=0;
}
- while (pulsesLeft > 0)
+ s = SHL16(1, yshift);
+ for (i=0;i<pulsesLeft;i++)
{
int best_id;
- celt_word16 magnitude;
celt_word32 best_num = -VERY_LARGE16;
celt_word16 best_den = 0;
#ifdef FIXED_POINT
@@ -294,21 +294,18 @@
int rshift;
#endif
#ifdef FIXED_POINT
- rshift = yshift+1+celt_ilog2(K-pulsesLeft+1);
+ rshift = yshift+1+celt_ilog2(K-pulsesLeft+i+1);
#endif
- magnitude = SHL16(1, yshift);
best_id = 0;
/* The squared magnitude term gets added anyway, so we might as well
add it outside the loop */
- yy = MAC16_16(yy, magnitude,magnitude);
+ yy = MAC16_16(yy, s,s);
/* Choose between fast and accurate strategy depending on where we are in the search */
/* This should ensure that anything we can process will have a better score */
j=0;
do {
celt_word16 Rxy, Ryy;
- /* Select sign based on X[j] alone */
- s = magnitude;
/* Temporary sums of the new pulse(s) */
Rxy = EXTRACT16(SHR32(MAC16_16(xy, s,X[j]),rshift));
/* We're multiplying y[j] by two so we don't have to do it here */
@@ -329,7 +326,6 @@
} while (++j<N);
j = best_id;
- s = SHL16(1, yshift);
/* Updating the sums of the new pulse(s) */
xy = xy + MULT16_16(s,X[j]);
@@ -340,7 +336,6 @@
/* Multiplying y[j] by 2 so we don't have to do it everywhere else */
y[j] += 2*s;
iy[j]++;
- pulsesLeft--;
}
/* Put the original sign back */