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

jm at svn.xiph.org jm at svn.xiph.org
Thu Jul 28 21:58:40 PDT 2005


Author: jm
Date: 2005-07-28 21:58:39 -0700 (Thu, 28 Jul 2005)
New Revision: 9638

Modified:
   trunk/ghost/libghost/lifting.c
Log:
perfect reconstruction with forward and inverse transform


Modified: trunk/ghost/libghost/lifting.c
===================================================================
--- trunk/ghost/libghost/lifting.c	2005-07-29 03:54:32 UTC (rev 9637)
+++ trunk/ghost/libghost/lifting.c	2005-07-29 04:58:39 UTC (rev 9638)
@@ -75,7 +75,7 @@
 void lifting_backward(float *x, struct LiftingBasis *basis, int len, int stride)
 {
    int i,j;
-   float *r, *rstart; /* residue/modified value */
+   float *r, *rstart, *ustart; /* residue/modified value */
    float *y; /* prediction start */
    int stride2 = 2*stride;
 
@@ -85,9 +85,10 @@
       rstart = x;
 
    /* De-update */
-   r = rstart + 1 - stride2*basis->update_delay;
+   ustart = rstart + 1 - stride2*basis->update_delay;
    y = rstart - stride2*(basis->update_length - basis->update_delay);
-
+   r = ustart;
+   
    for (i=0;i<len;i+=stride2)
    {
       float sum = 0;
@@ -103,6 +104,28 @@
       y += stride2;
    }
 
+   /* De-predict */
+   if (basis->predict_delay > 1)
+      rstart = ustart-stride2*(basis->predict_delay-1)-1;
+   else
+      rstart = ustart-1;
+   r = rstart;
+   y = ustart - stride2*(basis->predict_length - basis->predict_delay);
    
+   for (i=0;i<len;i+=stride2)
+   {
+      float sum = 0;
+      const float *p = basis->predict;
+      float *y2 = y;
+      for (j=0;j<basis->predict_length;j++)
+      {
+         sum += *p++ * *y2;
+         y2 += stride2;
+      }
+      *r += sum;
+      r += stride2;
+      y += stride2;
+   }
+
 }
 



More information about the commits mailing list