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