From 354bf60b04c7bc2c74e2c23e5552f22a7d6b3698 Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Sat, 3 Apr 2010 09:23:29 -0400 Subject: [PATCH] Doing the spreading with a "pseudo-fractional-Hadamard" transform --- libcelt/vq.c | 112 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 66 insertions(+), 46 deletions(-) diff --git a/libcelt/vq.c b/libcelt/vq.c index 73235619..56096a11 100644 --- a/libcelt/vq.c +++ b/libcelt/vq.c @@ -45,58 +45,78 @@ #define M_PI 3.141592653 #endif -static void exp_rotation(celt_norm *X, int len, int dir, int stride, int K) +static void frac_hadamard1(celt_norm *X, int len, int stride, celt_word16 c, celt_word16 s) { - int i, k, iter; - celt_word16 c, s; - celt_word16 gain, theta; - celt_norm *Xptr; - gain = celt_div((celt_word32)MULT16_16(Q15_ONE,len),(celt_word32)(3+len+6*K)); - /* FIXME: Make that HALF16 instead of HALF32 */ - theta = SUB16(Q15ONE, HALF32(MULT16_16_Q15(gain,gain))); - /*if (len==30) + int j; + celt_norm *x, *y; + celt_norm * end; + + j = 0; + x = X; + y = X+stride; + end = X+len; + do { - for (i=0;i 8*stride) - stride *= len/(8*stride); - iter = 1; - for (k=0;k=stride) + { + j=0; + x+=stride; + y+=stride; + } + } while (y>1;j++) { - /* We could use MULT16_16_P15 instead of MULT16_16_Q15 for more accuracy, - but at this point, I really don't think it's necessary */ - Xptr = X; - for (i=0;i=0;i--) - { - celt_norm x1, x2; - x1 = Xptr[0]; - x2 = Xptr[stride]; - Xptr[stride] = EXTRACT16(SHR32(MULT16_16(c,x2) + MULT16_16(s,x1),15)); - *Xptr-- = EXTRACT16(SHR32(MULT16_16(c,x1) - MULT16_16(s,x2),15)); - } + celt_norm tmp = X[j]; + X[j] = X[len-j-1]; + X[len-j-1] = tmp; } - /*if (len==30) - { - for (i=0;i 0) + { + for (i=0;i=0;i--) + frac_hadamard1(X, len, istride[i], c, s); + } + + /* Undo last reversal */ + for (i=0;i>1;i++) + { + celt_norm tmp = X[i]; + X[i] = X[len-i-1]; + X[len-i-1] = tmp; + } +} /** Takes the pitch vector and the decoded residual vector, computes the gain that will give ||p+g*y||=1 and mixes the residual with the pitch. */