X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=lib%2Flpc.c;h=643ffc916af42b331d3aa5751774db175d383cae;hb=8ca7e05637cf091470f8e39d686087b38f72c860;hp=4dc76bef2990a51506f4286ceeddad29746b88d6;hpb=67f833635368a912b53f68ec55840e4f7cdd69c5;p=platform%2Fupstream%2Flibvorbis.git diff --git a/lib/lpc.c b/lib/lpc.c index 4dc76be..643ffc9 100644 --- a/lib/lpc.c +++ b/lib/lpc.c @@ -1,18 +1,17 @@ /******************************************************************** * * - * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY * - * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE. * - * PLEASE READ THESE TERMS DISTRIBUTING. * + * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * - * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-2000 * - * by Monty and 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.21 2000/06/14 01:38:31 xiphmont Exp $ + last mod: $Id$ ********************************************************************/ @@ -59,30 +58,34 @@ Carsten Bormann /* Input : n elements of time doamin data Output: m lpc coefficients, excitation energy */ -double vorbis_lpc_from_data(double *data,double *lpc,int n,int m){ - double *aut=alloca(sizeof(double)*(m+1)); +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; - for(i=j;iln; - int m=l->m; - double *work=alloca(sizeof(double)*(n+n)); - double fscale=.5/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; - - /* we cheat decoding the LPC spectrum via FFTs */ - drft_init(&l->fft,mapped*2); - -} - -void lpc_clear(lpc_lookup *l){ - if(l){ - drft_clear(&l->fft); - } -} + if(i&1)lpc[j]+=lpc[j]*r; -/* One can do this the long way by generating the transfer function in - the time domain and taking the forward FFT of the result. The - results from direct calculation are cleaner and faster. + error*=1.-r*r; - This version does a linear curve generation and then later - interpolates the log curve from the linear curve. */ - -void vorbis_lpc_to_curve(double *curve,double *lpc,double amp, - lpc_lookup *l){ - int i; - memset(curve,0,sizeof(double)*l->ln*2); - if(amp==0)return; - - for(i=0;im;i++){ - curve[i*2+1]=lpc[i]/(4*amp); - curve[i*2+2]=-lpc[i]/(4*amp); } - drft_backward(&l->fft,curve); /* reappropriated ;-) */ + done: + /* slightly damp the filter */ { - int l2=l->ln*2; - double unit=1./amp; - curve[0]=(1./(curve[0]*2+unit)); - for(i=1;iln;i++){ - double real=(curve[i]+curve[l2-i]); - double imag=(curve[i]-curve[l2-i]); - - double a = real + unit; - curve[i] = 1.0 / FAST_HYPOT(a, imag); + double g = .99; + double damp = g; + for(j=0;j