1 /*************************************************************************/
2 /*                                                                       */
3 /*                Centre for Speech Technology Research                  */
4 /*                     University of Edinburgh, UK                       */
5 /*                       Copyright (c) 1996,1997                         */
6 /*                        All Rights Reserved.                           */
7 /*                                                                       */
8 /*  Permission is hereby granted, free of charge, to use and distribute  */
9 /*  this software and its documentation without restriction, including   */
10 /*  without limitation the rights to use, copy, modify, merge, publish,  */
11 /*  distribute, sublicense, and/or sell copies of this work, and to      */
12 /*  permit persons to whom this work is furnished to do so, subject to   */
13 /*  the following conditions:                                            */
14 /*   1. The code must retain the above copyright notice, this list of    */
15 /*      conditions and the following disclaimer.                         */
16 /*   2. Any modifications must be clearly marked as such.                */
17 /*   3. Original authors' names are not deleted.                         */
18 /*   4. The authors' names are not used to endorse or promote products   */
19 /*      derived from this software without specific prior written        */
20 /*      permission.                                                      */
21 /*                                                                       */
22 /*  THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK        */
23 /*  DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING      */
24 /*  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT   */
25 /*  SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE     */
26 /*  FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES    */
27 /*  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN   */
28 /*  AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,          */
29 /*  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF       */
30 /*  THIS SOFTWARE.                                                       */
31 /*                                                                       */
32 /*************************************************************************/
33 /*             Author :  Steve Isard                                     */
34 /*             Date   :  1984                                            */
35 /*  This version was gifted by Steve for this new                        */
36 /*  copyright, the original retains their original copyright             */
37 /*                                                                       */
38 /*************************************************************************/
39 #include <math.h>
40 #include <stdio.h>
41 #include "t2s.h"
42 
43 /* transform a set of reflection coefficients to linear prediction
44  * coefficients using algorithm from HCL-H
45  */
46 
rfctolpc(float * buf)47 void rfctolpc(float *buf)
48 {
49 	float a,b;
50 	register float *cptr;
51 	register int n,k;
52 
53     /* HCL-H algorithm goes through coeffs in reverse of order in which they
54      * appear here, working on buffer numbered from 1 upwards. To get same
55      * effect, we make cptr point at space just after last coeff and let n and
56      * k go down from -1 instead of up from 1.
57      */
58 	cptr = buf + NCOEFFS; /* There should be NCOEFFS coeffs. Point just
59                                * after last one.
60                                */
61 
62 	for(n = -1; n >= -NCOEFFS; n--) {
63 		*(cptr+n) = -(*(cptr+n));
64 		for(k = -1; 2*k >= n; k--) {
65 			a = *(cptr+k);
66 			b = *(cptr+n-k);
67 			*(cptr+k) = a - b * *(cptr+n);
68 			*(cptr+n-k) = b - a * *(cptr+n);
69 		}
70 	}
71 }
72 
73