nuclear@1: /******************************************************************** nuclear@1: * * nuclear@1: * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * nuclear@1: * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * nuclear@1: * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * nuclear@1: * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * nuclear@1: * * nuclear@1: * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * nuclear@1: * by the Xiph.Org Foundation http://www.xiph.org/ * nuclear@1: * * nuclear@1: ******************************************************************** nuclear@1: nuclear@1: function: LPC low level routines nuclear@1: last mod: $Id: lpc.c 16227 2009-07-08 06:58:46Z xiphmont $ nuclear@1: nuclear@1: ********************************************************************/ nuclear@1: nuclear@1: /* Some of these routines (autocorrelator, LPC coefficient estimator) nuclear@1: are derived from code written by Jutta Degener and Carsten Bormann; nuclear@1: thus we include their copyright below. The entirety of this file nuclear@1: is freely redistributable on the condition that both of these nuclear@1: copyright notices are preserved without modification. */ nuclear@1: nuclear@1: /* Preserved Copyright: *********************************************/ nuclear@1: nuclear@1: /* Copyright 1992, 1993, 1994 by Jutta Degener and Carsten Bormann, nuclear@1: Technische Universita"t Berlin nuclear@1: nuclear@1: Any use of this software is permitted provided that this notice is not nuclear@1: removed and that neither the authors nor the Technische Universita"t nuclear@1: Berlin are deemed to have made any representations as to the nuclear@1: suitability of this software for any purpose nor are held responsible nuclear@1: for any defects of this software. THERE IS ABSOLUTELY NO WARRANTY FOR nuclear@1: THIS SOFTWARE. nuclear@1: nuclear@1: As a matter of courtesy, the authors request to be informed about uses nuclear@1: this software has found, about bugs in this software, and about any nuclear@1: improvements that may be of general interest. nuclear@1: nuclear@1: Berlin, 28.11.1994 nuclear@1: Jutta Degener nuclear@1: Carsten Bormann nuclear@1: nuclear@1: *********************************************************************/ nuclear@1: nuclear@1: #include nuclear@1: #include nuclear@1: #include nuclear@1: #include "os.h" nuclear@1: #include "smallft.h" nuclear@1: #include "lpc.h" nuclear@1: #include "scales.h" nuclear@1: #include "misc.h" nuclear@1: nuclear@1: /* Autocorrelation LPC coeff generation algorithm invented by nuclear@1: N. Levinson in 1947, modified by J. Durbin in 1959. */ nuclear@1: nuclear@1: /* Input : n elements of time doamin data nuclear@1: Output: m lpc coefficients, excitation energy */ nuclear@1: nuclear@1: float vorbis_lpc_from_data(float *data,float *lpci,int n,int m){ nuclear@1: double *aut=alloca(sizeof(*aut)*(m+1)); nuclear@1: double *lpc=alloca(sizeof(*lpc)*(m)); nuclear@1: double error; nuclear@1: double epsilon; nuclear@1: int i,j; nuclear@1: nuclear@1: /* autocorrelation, p+1 lag coefficients */ nuclear@1: j=m+1; nuclear@1: while(j--){ nuclear@1: double d=0; /* double needed for accumulator depth */ nuclear@1: for(i=j;i