[xiph-commits] r13636 - trunk/ghost/libghost

jm at svn.xiph.org jm at svn.xiph.org
Mon Aug 27 03:57:21 PDT 2007


Author: jm
Date: 2007-08-27 03:57:21 -0700 (Mon, 27 Aug 2007)
New Revision: 13636

Modified:
   trunk/ghost/libghost/ceft.c
Log:
Bit of cleaning up, removed some stuff I've proven cannot work.


Modified: trunk/ghost/libghost/ceft.c
===================================================================
--- trunk/ghost/libghost/ceft.c	2007-08-27 05:18:54 UTC (rev 13635)
+++ trunk/ghost/libghost/ceft.c	2007-08-27 10:57:21 UTC (rev 13636)
@@ -27,110 +27,6 @@
 
 #include "fftwrap.h"
 
-float dist(float *a, float *b, int N)
-{
-   float d = 0;
-   int i;
-   for (i=0;i<N;i++)
-   {
-      d += (a[i]-b[i])*(a[i]-b[i]);
-   }
-   return d;
-}
-
-/* First attempt at a near-uniform algebraic quantiser -- failed */
-void alg_quant_fail1(float *x, int N, int K)
-{
-   int i, j, k;
-   int level;
-   float S[N][N];
-   float NN[N][N];
-   float D[N];
-   for (i=0;i<N;i++)
-   {
-      for (j=0;j<N;j++)
-         S[i][j] = 0;
-      if (x[i]>0)
-         S[i][i] = 1;
-      else
-         S[i][i] = -1;
-   }
-   for (i=0;i<N;i++)
-   {
-      x[i] = x[i]/sqrt(N);
-   }
-   
-   for (level = 0;level < K; level++)
-   {
-
-      for (j=0;j<N;j++)
-         for(k=0;k<N;k++)
-            NN[j][k] = -100;
-
-      for (j=0;j<N;j++)
-         D[j] = 1e5;
-
-      for (i=0;i<N;i++)
-      {
-         for (j=0;j<=i;j++)
-         {
-            float E=0;
-            float tmp[N];
-            //printf("ij = %d %d (%f %f %f %f)\n", i, j, S[0][0], S[1][0], S[0][1], S[1][1]);
-            for (k=0;k<N;k++)
-            {
-               //printf("%f %f %d %d %d\n", S[i][k], S[j][k], i, j, k);
-               tmp[k] = (S[i][k]+S[j][k]);
-               E += tmp[k]*tmp[k];
-            }
-            //printf("%d %d ", i, j);
-            //for (k=0;k<N;k++)
-            //   printf("%f ", tmp[k]);
-            //printf("%f\n", E);   
-            E = 1.f/sqrt(E);
-            for (k=0;k<N;k++)
-               tmp[k] *= E;
-            float d = dist(x, tmp, N);
-            //printf("%d %d ", i, j);
-            //for (k=0;k<N;k++)
-            //   printf("%f ", tmp[k]);
-            //printf("%f\n", d);   
-            if (d<D[N-1])
-            {
-               int id = N-1;
-               while (id>0 && d<D[id-1])
-                  id--;
-               //printf ("id = %d (%f < %f)\n", id, d, D[id]);
-               int m;
-               for (m=N-1;m>id;m--)
-               {
-                  for (k=0;k<N;k++)
-                  {
-                     D[m] = D[m-1];
-                     NN[m][k] = NN[m-1][k];
-                  }
-               }
-               for (k=0;k<N;k++)
-               {
-                  NN[id][k] = tmp[k];
-                  D[id] = d;
-               }
-            }
-            //printf ("\n");
-         }
-      }
-      for (j=0;j<N;j++)
-         for(k=0;k<N;k++)
-            S[j][k] = NN[j][k];
-      
-   }
-   
-   for (i=0;i<N;i++)
-   {
-      x[i] = S[0][i]*sqrt(N);
-   }
-}
-
 /* Unit-energy pulse codebook */
 void alg_quant2(float *x, int N, int K)
 {
@@ -325,8 +221,8 @@
 }
 
 
-#define NBANDS 23 /*or 22 if we discard the small last band*/
-int qbank[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 20, 24, 28, 36, 44, 52, 68, 84, 116, 128};
+#define NBANDS 22 /*or 21 if we discard the small last band*/
+int qbank[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 20, 24, 28, 36, 44, 52, 68, 84, 116, 128};
 
 
 #if 1
@@ -345,8 +241,7 @@
 void compute_bank(float *X, float *bank)
 {
    int i;
-   bank[0] = 1e-10+fabs(X[0]);
-   for (i=1;i<NBANDS;i++)
+   for (i=0;i<NBANDS;i++)
    {
       int j;
       bank[i] = 1e-10;
@@ -365,8 +260,7 @@
 void normalise_bank(float *X, float *bank)
 {
    int i;
-   X[0] /= bank[0];
-   for (i=1;i<NBANDS;i++)
+   for (i=0;i<NBANDS;i++)
    {
       int j;
       float x = 1.f/bank[i];
@@ -383,8 +277,7 @@
 void denormalise_bank(float *X, float *bank)
 {
    int i;
-   X[0] *= bank[0];
-   for (i=1;i<NBANDS;i++)
+   for (i=0;i<NBANDS;i++)
    {
       int j;
       float x = bank[i];
@@ -402,8 +295,7 @@
 {
    int i;
    float q=8;
-   X[0] = (1.f/q)*floor(.5+q*X[0]);
-   for (i=1;i<NBANDS;i++)
+   for (i=0;i<NBANDS;i++)
    {
       int j;
       for (j=qbank[i];j<qbank[i+1];j++)
@@ -419,7 +311,7 @@
 void quant_bank2(float *X)
 {
    int i;
-   for (i=1;i<NBANDS;i++)
+   for (i=0;i<NBANDS;i++)
    {
       int q=0;
       if (i < 5)
@@ -441,7 +333,7 @@
 void quant_bank3(float *X, float *P)
 {
    int i;
-   for (i=1;i<NBANDS;i++)
+   for (i=0;i<NBANDS;i++)
    {
       int q=0;
       if (i < 5)
@@ -495,7 +387,7 @@
 void pitch_renormalise_bank(float *X, float *P)
 {
    int i;
-   for (i=1;i<NBANDS;i++)
+   for (i=0;i<NBANDS;i++)
    {
       int j;
       float Rpp=0;
@@ -545,6 +437,7 @@
    X[255] = 0;
 }
 
+
 #define BARK_BANDS 20
 
 struct CEFTState_ {
@@ -604,46 +497,15 @@
    */
    pitch_quant_bank(X, Xp);
    
-   if (1) {
-#if 0
-      for (i=0;i<st->length;i++)
-         printf ("%f ", X[i]);
-      for (i=0;i<st->length;i++)
-         printf ("%f ", Xp[i]);
-      printf ("\n");
-#endif
-#if 0
-      float err1=0, err2=0, err0=0;
-      for (i=0;i<19;i++)
-      {
-         err0 += (X[i])*(X[i]);
-         err1 += (X[i]-Xp[i])*(X[i]-Xp[i]);
-         err2 += (X[i]-.7*Xp[i])*(X[i]-.7*Xp[i]);
-      }
-      printf ("%f %f %f ", err0, err1, err2);
-#endif
-      for (i=1;i<st->length;i++)
-         X[i] -= Xp[i];
-      float tmp[NBANDS];
-      //compute_bank(X, tmp);
-      //normalise_bank(X, tmp);
-      
-   }
+   for (i=1;i<st->length;i++)
+      X[i] -= Xp[i];
+
    //Quantise input
    quant_bank3(X, Xp);
    //quant_bank2(X);
 
-   //Renormalise the quantised signal back to unity
-   float bank2[NBANDS];
-   compute_bank(X, bank2);
-   normalise_bank(X, bank2);
+   //pitch_renormalise_bank(X, Xp);
 
-   if (1) {
-   //   pitch_renormalise_bank(X, Xp);
-   }
-   compute_bank(X, bank2);
-   normalise_bank(X, bank2);
-
 #if 0
    float err = 0;
    for(i=1;i<19;i++)



More information about the commits mailing list