ref: 381b29c2d2234b5941b14af78f91c3b4307b8082
parent: 05e56c4d6c38a3f25b66170ad6ffb0c123590c32
author: Jean-Marc Valin <[email protected]>
date: Thu Apr 10 07:00:51 EDT 2008
fixed ordering of the channels in the intra prediction.
--- a/libcelt/vq.c
+++ b/libcelt/vq.c
@@ -262,7 +262,7 @@
void intra_prediction(celt_norm_t *x, celt_mask_t *W, int N, int K, celt_norm_t *Y, celt_norm_t * restrict P, int B, int N0, ec_enc *enc)
{
- int i,j;
+ int i,j,c;
int best=0;
celt_word32_t best_num=-SHR32(VERY_LARGE32,4);
celt_word16_t best_den=0;
@@ -271,9 +271,22 @@
celt_word32_t E;
celt_word16_t pred_gain;
int max_pos = N0-N;
+ VARDECL(spx_norm_t, Xr);
+ SAVE_STACK;
+
+ ALLOC(Xr, B*N, celt_norm_t);
+
if (max_pos > MAX_INTRA)
max_pos = MAX_INTRA;
+ for (c=0;c<B;c++)
+ {
+ for (j=0;j<N;j++)
+ {
+ Xr[B*N-B*j-B+c] = x[B*j+c];
+ }
+ }
+
for (i=0;i<max_pos*B;i+=B)
{
celt_word32_t xy=0, yy=0;
@@ -283,7 +296,7 @@
complain to your compilor vendor */
j=0;
do {
- xy = MAC16_16(xy, x[j], Y[i+B*N-j-1]);
+ xy = MAC16_16(xy, Xr[B*N-j-1], Y[i+B*N-j-1]);
yy = MAC16_16(yy, Y[i+B*N-j-1], Y[i+B*N-j-1]);
} while (++j<B*N); /* Promises we loop at least once */
/* Using xy^2/yy as the score but without having to do the division */
@@ -322,10 +335,13 @@
else
pred_gain = pg[K];
E = EPSILON;
- for (j=0;j<B*N;j++)
+ for (c=0;c<B;c++)
{
- P[j] = s*Y[best+B*N-j-1];
- E = MAC16_16(E, P[j],P[j]);
+ for (j=0;j<N;j++)
+ {
+ P[B*j+c] = s*Y[best+B*(N-j-1)+c];
+ E = MAC16_16(E, P[j],P[j]);
+ }
}
/*pred_gain = pred_gain/sqrt(E);*/
pred_gain = MULT16_16_Q15(pred_gain,celt_rcp(SHL32(celt_sqrt(E),9)));
@@ -346,7 +362,7 @@
void intra_unquant(celt_norm_t *x, int N, int K, celt_norm_t *Y, celt_norm_t * restrict P, int B, int N0, ec_dec *dec)
{
- int j;
+ int j, c;
int sign;
celt_word16_t s;
int best;
@@ -373,10 +389,13 @@
else
pred_gain = pg[K];
E = EPSILON;
- for (j=0;j<B*N;j++)
+ for (c=0;c<B;c++)
{
- P[j] = s*Y[best+B*N-j-1];
- E = MAC16_16(E, P[j],P[j]);
+ for (j=0;j<N;j++)
+ {
+ P[B*j+c] = s*Y[best+B*(N-j-1)+c];
+ E = MAC16_16(E, P[j],P[j]);
+ }
}
/*pred_gain = pred_gain/sqrt(E);*/
pred_gain = MULT16_16_Q15(pred_gain,celt_rcp(SHL32(celt_sqrt(E),9)));