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

jm at svn.xiph.org jm at svn.xiph.org
Sun Jul 24 19:41:01 PDT 2005


Author: jm
Date: 2005-07-24 19:40:59 -0700 (Sun, 24 Jul 2005)
New Revision: 9621

Added:
   trunk/ghost/libghost/lifting.c
   trunk/ghost/libghost/lifting.h
Modified:
   trunk/ghost/libghost/Makefile.am
   trunk/ghost/libghost/ghost.c
Log:
Lifting wavelet scheme


Modified: trunk/ghost/libghost/Makefile.am
===================================================================
--- trunk/ghost/libghost/Makefile.am	2005-07-24 21:45:38 UTC (rev 9620)
+++ trunk/ghost/libghost/Makefile.am	2005-07-25 02:40:59 UTC (rev 9621)
@@ -9,13 +9,13 @@
 lib_LTLIBRARIES = libghost.la
 
 # Sources for compilation in the library
-libghost_la_SOURCES = ghost.c 			sinusoids.c pitch.c
+libghost_la_SOURCES = ghost.c 			sinusoids.c pitch.c lifting.c
 
 #noinst_HEADERS =
 
 libghost_la_LDFLAGS = -version-info @GHOST_LT_CURRENT@:@GHOST_LT_REVISION@:@GHOST_LT_AGE@
 
-noinst_HEADERS = ghost.h pitch.h
+noinst_HEADERS = ghost.h pitch.h lifting.h
 noinst_PROGRAMS = testghost
 testghost_SOURCES = testghost.c
 testghost_LDADD = $(top_builddir)/libghost/libghost.la

Modified: trunk/ghost/libghost/ghost.c
===================================================================
--- trunk/ghost/libghost/ghost.c	2005-07-24 21:45:38 UTC (rev 9620)
+++ trunk/ghost/libghost/ghost.c	2005-07-25 02:40:59 UTC (rev 9621)
@@ -66,6 +66,7 @@
    for (i=0;i<st->frame_size;i++)
       st->current_pcm[i]=pcm[i];
    find_pitch(st->current_pcm, &gain, &pitch, 100, 768, st->frame_size);
+   //pitch = 256;
    //printf ("%d %f\n", pitch, gain);
    w = 2*M_PI/pitch;
    {

Added: trunk/ghost/libghost/lifting.c
===================================================================
--- trunk/ghost/libghost/lifting.c	2005-07-24 21:45:38 UTC (rev 9620)
+++ trunk/ghost/libghost/lifting.c	2005-07-25 02:40:59 UTC (rev 9621)
@@ -0,0 +1,89 @@
+/* Copyright (C) 2005 */
+/**
+   @file lifting.c
+   @brief Lifting wavelet transform
+ */
+/*
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+   
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+   
+   - Neither the name of the Xiph.org Foundation nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+   
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "lifting.h"
+
+void lifting_forward(float *x, struct LiftingBasis *basis, int len, int stride)
+{
+   int i,j;
+   float *r, *rstart; /* residue/modified value */
+   float *y; /* prediction start */
+   
+   /* Prediction */
+   if (basis->predict_delay > 1)
+      rstart = x-2*stride*(basis->predict_delay-1);
+   else
+      rstart = x;
+   r = rstart;
+   y = x + 1 - 2*stride*(basis->predict_length - basis->predict_delay);
+   
+   for (i=0;i<len;i++)
+   {
+      float sum = 0;
+      float *p = basis->predict;
+      float *y2 = y;
+      for (j=0;j<basis->predict_length;j++)
+      {
+         sum += *p++ * *y2;
+         y2 += stride;
+      }
+      *r -= sum;
+      r += stride;
+      y += stride;
+   }
+   
+   r = rstart + 1 - 2*stride*basis->update_delay;
+   y = rstart - 2*stride*(basis->update_length - basis->update_delay - 1);
+
+   for (i=0;i<len;i++)
+   {
+      float sum = 0;
+      float *p = basis->update;
+      float *y2 = y;
+      for (j=0;j<basis->update_length;j++)
+      {
+         sum += *p++ * *y2;
+         y2 += stride;
+      }
+      *r += sum;
+      r += stride;
+      y += stride;
+   }
+}
+
+void lifting_backward(float *x, struct LiftingBasis *basis, int len, int stride)
+{
+   
+}
+

Added: trunk/ghost/libghost/lifting.h
===================================================================
--- trunk/ghost/libghost/lifting.h	2005-07-24 21:45:38 UTC (rev 9620)
+++ trunk/ghost/libghost/lifting.h	2005-07-25 02:40:59 UTC (rev 9621)
@@ -0,0 +1,51 @@
+/* Copyright (C) 2005 */
+/**
+   @file lifting.h
+   @brief Lifting wavelet transform
+ */
+/*
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+   
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+   
+   - Neither the name of the Xiph.org Foundation nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+   
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef _LIFTING_H
+#define _LIFTING_H
+
+struct LiftingBasis {
+   float *predict;
+   int predict_length;
+   int predict_delay;
+   float *update;
+   int update_length;
+   int update_delay;
+};
+
+void lifting_forward(float *x, struct LiftingBasis *basis, int len, int stride);
+
+void lifting_backward(float *x, struct LiftingBasis *basis, int len, int stride);
+
+#endif



More information about the commits mailing list