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

jm at svn.xiph.org jm at svn.xiph.org
Sun Aug 19 17:35:25 PDT 2007


Author: jm
Date: 2007-08-19 17:35:25 -0700 (Sun, 19 Aug 2007)
New Revision: 13573

Modified:
   trunk/ghost/libghost/ceft.c
   trunk/ghost/libghost/ghost.c
Log:
using the right signal and normalising it with sqrt(power) tends to help a lot


Modified: trunk/ghost/libghost/ceft.c
===================================================================
--- trunk/ghost/libghost/ceft.c	2007-08-20 00:35:14 UTC (rev 13572)
+++ trunk/ghost/libghost/ceft.c	2007-08-20 00:35:25 UTC (rev 13573)
@@ -23,8 +23,34 @@
 #include "filterbank.h"
 #include <stdlib.h>
 #include <stdio.h>
+#include <math.h>
+
 #include "fftwrap.h"
 
+/*
+0
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10 11
+12 13
+14 15
+16 17 18 19
+20 21 22 23
+24 25 26 27
+28 29 30 31 32 33
+34 35 36 37 38 39 49 41
+42 43 44 45 46 47 48 49
+50 .. 63   (14)
+64 .. 83   (20)
+84 .. 127  (42)
+*/
 #define BARK_BANDS 20
 
 struct CEFTState_ {
@@ -57,6 +83,8 @@
 
    filterbank_compute_bank(st->bank, Xps, bark);
    filterbank_compute_psd(st->bank, bark, Xps);
+   for(i=0;i<st->length>>1;i++)
+      Xps[i] = sqrt(Xps[i]);
    X[0] /= Xps[0];
    for (i=1;i<st->length>>1;i++)
    {
@@ -64,12 +92,30 @@
       X[2*i] /= Xps[i];
    }
    X[st->length-1] /= Xps[(st->length>>1)-1];
-   /*
-   for(i=0;i<st->length;i++)
+   
+   /*for(i=0;i<st->length;i++)
       printf ("%f ", X[i]);
    printf ("\n");
-   */
-   X[0] *= Xps[0];
+*/
+   
+   for(i=0;i<st->length;i++)
+   {
+      float q = 4;
+      if (i<16)
+         q = 8;
+      else if (i<32)
+         q = 4;
+      else if (i<48)
+         q = 2;
+      else
+         q = 1;
+      q=1;
+      int sq = floor(.5+q*X[i]);
+      //printf ("%d ", sq);
+      X[i] = (1.f/q)*sq;
+   }
+   //printf ("\n");
+   X[0]  *= Xps[0];
    for (i=1;i<st->length>>1;i++)
    {
       X[2*i-1] *= Xps[i];

Modified: trunk/ghost/libghost/ghost.c
===================================================================
--- trunk/ghost/libghost/ghost.c	2007-08-20 00:35:14 UTC (rev 13572)
+++ trunk/ghost/libghost/ghost.c	2007-08-20 00:35:25 UTC (rev 13573)
@@ -216,6 +216,16 @@
       /*for (i=0;i<st->length;i++)
       y[i] *= st->synthesis_window[i];*/
 
+#if 0
+      float z[st->length];
+      for (i=0;i<st->length;i++)
+         z[i] = x[i]-y[i];
+      ceft_encode(st->ceft, z, z);
+      for (i=0;i<st->length;i++)
+         y[i] = y[i]+z[i];
+      
+#endif
+
       for (i = 0;i < st->new_noise-st->noise_buf+st->overlap; i++)
       {
          st->noise_buf[i] = st->noise_buf[i+st->advance];
@@ -295,6 +305,7 @@
          printf ("\n");*/
          exit(1);
       }
+#if 1
       float noise[st->advance];
       //for (i=0;i<MASK_LPC_ORDER;i++)
       //   awk1[i] = 0;
@@ -312,9 +323,6 @@
             noise[i] = ener*sqrt(12.)*((((float)(rand()))/RAND_MAX)-.5);
       }
       
-#if 0
-      ceft_encode(st->ceft, noise, noise);
-#else
       /*for (i=0;i<st->advance;i++)
          printf ("%f\n", noise[i]);
       printf ("\n");*/



More information about the commits mailing list