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

jm at svn.xiph.org jm at svn.xiph.org
Tue Sep 4 08:44:12 PDT 2007


Author: jm
Date: 2007-09-04 08:44:12 -0700 (Tue, 04 Sep 2007)
New Revision: 13716

Modified:
   trunk/ghost/libghost/ceft.c
   trunk/ghost/libghost/pitch.c
Log:
Better weighting for pitch period and gain estimation


Modified: trunk/ghost/libghost/ceft.c
===================================================================
--- trunk/ghost/libghost/ceft.c	2007-09-04 15:34:22 UTC (rev 13715)
+++ trunk/ghost/libghost/ceft.c	2007-09-04 15:44:12 UTC (rev 13716)
@@ -30,10 +30,11 @@
 int qbank[] =   {1, 2, 4, 6, 8, 12, 16, 20, 24, 28, 36, 44, 52, 68, 84, 116, 128};
 //int qpulses[] = {2, 2, 2, 2, 2,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1};
 //int qpulses[] = {2, 2, 2, 2, 2,  2,  1,  1,  1,  1,  0,  0,  0,  0,  0};
-int qpulses[] = {2, 3, 2, 2, 3,  2,  2,  2,  1,  2,  1,  0,  0,  0,  0};
+//int qpulses[] = {2, 3, 2, 2, 3,  2,  2,  2,  1,  2,  1,  0,  0,  0,  0};
+int qpulses[] = {3, 4, 3, 2, 3,  2,  2,  2,  1,  2,  1,  0,  0,  0,  0};
 
 //int qpulses[] = {5, 5, 5, 5, 5,  5,  2,  2,  1,  2,  1,  0,  0,  0,  0};
-//int qpulses[] = {2, 3, 2, 2, 3,  2,  5,  5,  5,  5,  5,  5,  0,  0,  0};
+//int qpulses[] = {5, 5, 2, 2, 3,  2,  5,  5,  5,  5,  5,  5,  0,  0,  0};
 
 
 //int qpulses[] = {4, 4, 3, 3, 3,  3,  3,  2,  2,  3,  2,  2,  0,  0,  0};
@@ -425,9 +426,18 @@
    X[255] = 0;
 }
 
-void compute_pitch_gain(float *X, float *P, float *gains)
+void compute_pitch_gain(float *X, float *P, float *gains, float *bank)
 {
    int i;
+   float w[256];
+   for (i=0;i<NBANDS;i++)
+   {
+      int j;
+      for (j=qbank[i];j<qbank[i+1];j++)
+         w[j] = bank[i];
+   }
+
+   
    for (i=0;i<PBANDS;i++)
    {
       float Sxy=0;
@@ -436,9 +446,9 @@
       float gain;
       for (j=pbank[i];j<pbank[i+1];j++)
       {
-         Sxy += X[j*2-1]*P[j*2-1];
-         Sxy += X[j*2]*P[j*2];
-         Sxx += X[j*2-1]*X[j*2-1] + X[j*2]*X[j*2];
+         Sxy += X[j*2-1]*P[j*2-1]*w[j];
+         Sxy += X[j*2]*P[j*2]*w[j];
+         Sxx += X[j*2-1]*X[j*2-1]*w[j] + X[j*2]*X[j*2]*w[j];
       }
       gain = Sxy/(1e-10+Sxx);
       //gain = Sxy/(2*(pbank[i+1]-pbank[i]));
@@ -716,7 +726,7 @@
    random_rotation(X, 10, -1);
    random_rotation(Xp, 10, -1);
    
-   compute_pitch_gain(X, Xp, gains);
+   compute_pitch_gain(X, Xp, gains, bank);
    quantise_pitch(gains, PBANDS);
    pitch_quant_bank(X, Xp, gains);
       

Modified: trunk/ghost/libghost/pitch.c
===================================================================
--- trunk/ghost/libghost/pitch.c	2007-09-04 15:34:22 UTC (rev 13715)
+++ trunk/ghost/libghost/pitch.c	2007-09-04 15:44:12 UTC (rev 13716)
@@ -92,16 +92,16 @@
    {
       float n = 1.f/(1e1+sqrt((X[2*i-1]*X[2*i-1] + X[2*i  ]*X[2*i  ])*(Y[2*i-1]*Y[2*i-1] + Y[2*i  ]*Y[2*i  ])));
       //n = 1;
-      n = 1.f/sqrt(1+curve[i]);
-      if (i>10)
+      n = 1.f/(1+curve[i]);
+      /*if (i>10)
          n *= .5;
       if (i>20)
-         n *= .5;
+         n *= .5;*/
       float tmp = X[2*i-1];
       X[2*i-1] = (X[2*i-1]*Y[2*i-1] + X[2*i  ]*Y[2*i  ])*n;
       X[2*i  ] = (- X[2*i  ]*Y[2*i-1] + tmp*Y[2*i  ])*n;
    }
-   X[len-1] = X[len-1]*Y[len-1];
+   X[len-1] = 0;
    X[0] = X[len-1] = 0;
    spx_ifft(fft, X, xx);
    



More information about the commits mailing list