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

jm at svn.xiph.org jm at svn.xiph.org
Sun Sep 9 15:27:06 PDT 2007


Author: jm
Date: 2007-09-09 15:27:05 -0700 (Sun, 09 Sep 2007)
New Revision: 13781

Modified:
   trunk/ghost/libghost/ceft.c
Log:
Replaced noise excitation with something SBR-like


Modified: trunk/ghost/libghost/ceft.c
===================================================================
--- trunk/ghost/libghost/ceft.c	2007-09-09 12:19:09 UTC (rev 13780)
+++ trunk/ghost/libghost/ceft.c	2007-09-09 22:27:05 UTC (rev 13781)
@@ -35,6 +35,7 @@
 /* Number of pulses in each band. The number of bits for each band with a non-zero
    number of pulses is equal to  (1 + nb_pulses * log2 (2 * width_of_band) )  */
 //32 kbps
+#define WAVEFORM_END 44
 int qpulses[] = {3, 4, 4, 3, 3,  2,  2,  2,  2,  2,  2,  0,  0,  0,  0}; //85 bits
 
 //44 kbps
@@ -233,6 +234,25 @@
    }
 }
 
+/* Just replace the band with the replicated spectrum */
+void sbr_quant(float *x, int N, int K, float *p)
+{
+   int i;
+   float *sbr = x+WAVEFORM_END-N;
+
+   float E = 1e-10;
+   for (i=0;i<N;i++)
+   {
+      x[i] = sbr[i];
+      E += x[i]*x[i];
+   }
+   E = 1./sqrt(E);
+   for (i=0;i<N;i++)
+   {
+      x[i] *= E;
+   }
+}
+
 /* Compute the energy in each of the bands */
 void compute_bank(float *X, float *bank)
 {
@@ -469,7 +489,7 @@
       if (q)
          alg_quant2(X+qbank[i]*2-1, 2*(qbank[i+1]-qbank[i]), q, P+qbank[i]*2-1);
       else
-         noise_quant(X+qbank[i]*2-1, 2*(qbank[i+1]-qbank[i]), q, P+qbank[i]*2-1);
+         sbr_quant(X+qbank[i]*2-1, 2*(qbank[i+1]-qbank[i]), q, P+qbank[i]*2-1);
    }
    //FIXME: This is a kludge, even though I don't think it really matters much
    X[255] = 0;



More information about the commits mailing list