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

jm at svn.xiph.org jm at svn.xiph.org
Mon Sep 3 17:04:13 PDT 2007


Author: jm
Date: 2007-09-03 17:04:13 -0700 (Mon, 03 Sep 2007)
New Revision: 13711

Added:
   trunk/ghost/libghost/pitch_quant.h
Modified:
   trunk/ghost/libghost/ceft.c
   trunk/ghost/libghost/vq.c
Log:
Pitch gain quantisation


Modified: trunk/ghost/libghost/ceft.c
===================================================================
--- trunk/ghost/libghost/ceft.c	2007-09-03 22:41:48 UTC (rev 13710)
+++ trunk/ghost/libghost/ceft.c	2007-09-04 00:04:13 UTC (rev 13711)
@@ -325,7 +325,7 @@
    X[255] = 0;
 }
 
-void pitch_quant_bank(float *X, float *P, float *gains)
+void compute_pitch_gain(float *X, float *P, float *gains)
 {
    int i;
    for (i=0;i<PBANDS;i++)
@@ -350,19 +350,37 @@
          gain = 0.0;
 
       gains[i] = gain;
+   }
+   for (i=pbank[PBANDS];i<256;i++)
+      P[i] = 0;
+   P[255] = 0;
+   /*if (rand()%10 == 0)
+   {
+      for (i=0;i<PBANDS;i++)
+         printf ("%f ", gains[i]*gains[i]);
+      printf ("\n");
+   }*/
+}
+
+void pitch_quant_bank(float *X, float *P, float *gains)
+{
+   int i;
+   for (i=0;i<PBANDS;i++)
+   {
+      int j;
       for (j=pbank[i];j<pbank[i+1];j++)
       {
-         P[j*2-1] *= gain;
-         P[j*2] *= gain;
+         P[j*2-1] *= gains[i];
+         P[j*2] *= gains[i];
       }
       //printf ("%f ", gain);
    }
    for (i=pbank[PBANDS];i<256;i++)
       P[i] = 0;
    P[255] = 0;
-   //printf ("\n");
 }
 
+
 void pitch_renormalise_bank(float *X, float *P)
 {
    int i;
@@ -522,7 +540,7 @@
 
    for (i=0;i<NBANDS;i++)
    {
-      in_bank[i] = 20*log10(bank[i]+1) + .6*last_err[i+1] - .9*last_bank[i];
+      in_bank[i] = 20*log10(bank[i]+1) + .0*last_err[i+1] - .9*last_bank[i];
    }
    for (i=0;i<NBANDS;i++)
       qbank[i] = in_bank[i];
@@ -586,6 +604,8 @@
    //random_rotation(X, 10, -1);
    //random_rotation(Xp, 10, -1);
    
+   compute_pitch_gain(X, Xp, gains);
+   quantise_pitch(gains, PBANDS);
    pitch_quant_bank(X, Xp, gains);
       
    for (i=1;i<st->length;i++)

Added: trunk/ghost/libghost/pitch_quant.h
===================================================================
--- trunk/ghost/libghost/pitch_quant.h	                        (rev 0)
+++ trunk/ghost/libghost/pitch_quant.h	2007-09-04 00:04:13 UTC (rev 13711)
@@ -0,0 +1,36 @@
+ 
+float cdbk_pitch[]={     0.00826816, 0.00646836, 0.00520978, 0.00632398, 0.0108199 ,
+  0.723347, 0.0985132, 0.630212, 0.0546661, 0.0246779 ,
+  0.802152, 0.759963, 0.453441, 0.384415, 0.0625198 ,
+  0.461809, 0.313537, 0.0465707, 0.0484357, 0.0196977 ,
+  0.704463, 0.117481, 0.0612584, 0.576791, 0.0273508 ,
+  0.798109, 0.743359, 0.706289, 0.0697711, 0.0386172 ,
+  0.228351, 0.0379557, 0.0285191, 0.0236265, 0.0248726 ,
+  0.114495, 0.279541, 0.038657, 0.0342054, 0.0319817 ,
+  0.609812, 0.0397131, 0.0266344, 0.0239864, 0.0212439 ,
+  0.781349, 0.493848, 0.0353301, 0.0267205, 0.0196015 ,
+  0.0819145, 0.0543806, 0.301274, 0.0507369, 0.0456495 ,
+  0.785118, 0.7315, 0.213724, 0.675786, 0.117822 ,
+  0.791656, 0.0322449, 0.0200075, 0.0203656, 0.0191236 ,
+  0.768495, 0.416117, 0.386172, 0.0510886, 0.022891 ,
+  0.802694, 0.790402, 0.755665, 0.71349, 0.401332 ,
+  0.142781, 0.122736, 0.195102, 0.587634, 0.0490036 ,
+  0.104903, 0.611318, 0.0587345, 0.0822444, 0.028738 ,
+  0.182943, 0.541788, 0.518271, 0.0920779, 0.0338024 ,
+  0.76004, 0.0553314, 0.293129, 0.0392962, 0.0191814 ,
+  0.776575, 0.257797, 0.0323301, 0.0290356, 0.0185467 ,
+  0.798177, 0.759494, 0.368838, 0.0497087, 0.0262797 ,
+  0.724, 0.0643148, 0.0435992, 0.275742, 0.0232963 ,
+  0.803454, 0.783768, 0.741939, 0.711135, 0.0950338 ,
+  0.138766, 0.0770751, 0.649913, 0.129772, 0.0342524 ,
+  0.795955, 0.754889, 0.044966, 0.0279729, 0.0199437 ,
+  0.784278, 0.659435, 0.0713927, 0.339058, 0.0384502 ,
+  0.145974, 0.049395, 0.0403857, 0.302676, 0.04925 ,
+  0.428821, 0.0640999, 0.368384, 0.0519584, 0.0224072 ,
+  0.425792, 0.0341016, 0.0290549, 0.0390711, 0.0227266 ,
+  0.453561, 0.623889, 0.0443806, 0.0432896, 0.0173471 ,
+  0.754851, 0.236843, 0.570091, 0.48421, 0.0622915 ,
+  0.804932, 0.782549, 0.752207, 0.390957, 0.102058    
+};
+
+

Modified: trunk/ghost/libghost/vq.c
===================================================================
--- trunk/ghost/libghost/vq.c	2007-09-03 22:41:48 UTC (rev 13710)
+++ trunk/ghost/libghost/vq.c	2007-09-04 00:04:13 UTC (rev 13711)
@@ -20,6 +20,8 @@
 */
 
 //#include "../work/bands_quant.c"
+#include "pitch_quant.h"
+#include <math.h>
 
 struct VQuantiser_ {
    int len;
@@ -98,5 +100,15 @@
    }
 
 }
+#endif
 
-#endif
+void quantise_pitch(float *gains, int len)
+{
+   int i, id;
+   float g2[len];
+   for (i=0;i<len;i++)
+      g2[i] = gains[i]*gains[i];
+   id = vq_index(g2, cdbk_pitch, len, 32);
+   for (i=0;i<len;i++)
+      gains[i] = sqrt(cdbk_pitch[id*len+i]);
+}



More information about the commits mailing list