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