X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=lib%2Flpc.c;h=798f4cf0766418856ad02c77ebdc9e583a8a01e6;hb=018ca26dece618457dd13585cad52941193c4a25;hp=6d491cd3cf3e8887cc1da61c5f9722d1996f447f;hpb=7bfceda6317dcb2cb749ad84efee310a9a792911;p=platform%2Fupstream%2Flibvorbis.git diff --git a/lib/lpc.c b/lib/lpc.c index 6d491cd..798f4cf 100644 --- a/lib/lpc.c +++ b/lib/lpc.c @@ -5,13 +5,12 @@ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * - * by the XIPHOPHORUS Company http://www.xiph.org/ * - + * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * + * by the Xiph.Org Foundation http://www.xiph.org/ * + * * ******************************************************************** function: LPC low level routines - last mod: $Id: lpc.c,v 1.31 2001/02/26 03:50:42 xiphmont Exp $ ********************************************************************/ @@ -58,30 +57,33 @@ Carsten Bormann /* Input : n elements of time doamin data Output: m lpc coefficients, excitation energy */ -float vorbis_lpc_from_data(float *data,float *lpc,int n,int m){ - float *aut=alloca(sizeof(float)*(m+1)); - float error; +float vorbis_lpc_from_data(float *data,float *lpci,int n,int m){ + double *aut=alloca(sizeof(*aut)*(m+1)); + double *lpc=alloca(sizeof(*lpc)*(m)); + double error; + double epsilon; int i,j; /* autocorrelation, p+1 lag coefficients */ - j=m+1; while(j--){ - float d=0; - for(i=j;iln; - int m=l->m; - float *work=alloca(sizeof(float)*(n+n)); - float fscale=.5f/n; - int i,j; - - /* input is a real curve. make it complex-real */ - /* This mixes phase, but the LPC generation doesn't care. */ - for(i=0;ifft,work); - - /* The autocorrelation will not be circular. Shift, else we lose - most of the power in the edges. */ - - for(i=0,j=n/2;iln=mapped; - l->m=m; + /* slightly damp the filter */ + { + double g = .99; + double damp = g; + for(j=0;jfft,mapped*2); + for(j=0;jfft); - } + return error; } void vorbis_lpc_predict(float *coeff,float *prime,int m, float *data,long n){ - /* in: coeff[0...m-1] LPC coefficients + /* in: coeff[0...m-1] LPC coefficients prime[0...m-1] initial values (allocated size of n+m-1) out: data[0...n-1] data samples */ long i,j,o,p; float y; - float *work=alloca(sizeof(float)*(m+n)); + float *work=alloca(sizeof(*work)*(m+n)); if(!prime) for(i=0;i