X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=lib%2Flpc.c;h=643ffc916af42b331d3aa5751774db175d383cae;hb=9e95db41ebc273bd436c9e5a7cfe7cc03a856f36;hp=acd009ef76331ccbaac6fbdaeebb5e557fbebd5b;hpb=3a8db75a3792eaba84ec9fad0db8d29ec1ce493f;p=platform%2Fupstream%2Flibvorbis.git diff --git a/lib/lpc.c b/lib/lpc.c index acd009e..643ffc9 100644 --- a/lib/lpc.c +++ b/lib/lpc.c @@ -5,13 +5,13 @@ * 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.33 2001/12/12 09:45:25 xiphmont Exp $ + last mod: $Id$ ********************************************************************/ @@ -58,30 +58,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(*aut)*(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--){ double d=0; /* double needed for accumulator depth */ - for(i=j;iln; - int m=l->m; - float *work=alloca(sizeof(*work)*(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 */ @@ -189,12 +154,7 @@ void vorbis_lpc_predict(float *coeff,float *prime,int m, p=m; for(j=0;j