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