1 /*
2  * SpanDSP - a series of DSP components for telephony
3  *
4  * lpc10_encdecs.h - LPC10 low bit rate speech codec.
5  *
6  * Written by Steve Underwood <steveu@coppice.org>
7  *
8  * Copyright (C) 2006 Steve Underwood
9  *
10  * All rights reserved.
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU Lesser General Public License version 2.1,
14  * as published by the Free Software Foundation.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with this program; if not, write to the Free Software
23  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24  *
25  * $Id: lpc10_encdecs.h,v 1.11 2008/04/17 14:26:56 steveu Exp $
26  */
27 
28 #define LPC10_ORDER     10
29 
30 #if !defined(min)
31 #define min(a,b) ((a) <= (b) ? (a) : (b))
32 #endif
33 #if !defined(max)
34 #define max(a,b) ((a) >= (b) ? (a) : (b))
35 #endif
36 
37 void lpc10_placea(int32_t *ipitch,
38                   int32_t voibuf[4][2],
39                   int32_t *obound,
40                   int32_t af,
41                   int32_t vwin[3][2],
42                   int32_t awin[3][2],
43                   int32_t ewin[3][2],
44                   int32_t lframe,
45                   int32_t maxwin);
46 
47 void lpc10_placev(int32_t *osbuf,
48                   int32_t *osptr,
49                   int32_t oslen,
50                   int32_t *obound,
51                   int32_t vwin[3][2],
52                   int32_t af,
53                   int32_t lframe,
54                   int32_t minwin,
55                   int32_t maxwin,
56                   int32_t dvwinl,
57                   int32_t dvwinh);
58 
59 void lpc10_voicing(lpc10_encode_state_t *st,
60                    int32_t *vwin,
61                    float *inbuf,
62                    float *lpbuf,
63                    const int32_t buflim[],
64                    int32_t half,
65                    float *minamd,
66                    float *maxamd,
67 	               int32_t *mintau,
68                    float *ivrc,
69                    int32_t *obound);
70 
71 void lpc10_analyse(lpc10_encode_state_t *st, float *speech, int32_t *voice, int32_t *pitch, float *rms, float rc[]);
72 
pow_ii(int32_t x,int32_t n)73 static __inline__ int32_t pow_ii(int32_t x, int32_t n)
74 {
75     int32_t pow;
76     uint32_t u;
77 
78     if (n <= 0)
79     {
80         if (n == 0  ||  x == 1)
81             return 1;
82         if (x != -1)
83             return (x == 0)  ?  1/x  :  0;
84         n = -n;
85     }
86     u = n;
87     for (pow = 1;  ;  )
88     {
89         if ((u & 1))
90             pow *= x;
91         if ((u >>= 1) == 0)
92             break;
93         x *= x;
94     }
95     return pow;
96 }
97 /*- End of function --------------------------------------------------------*/
98 
r_sign(float a,float b)99 static __inline__ float r_sign(float a, float b)
100 {
101     float x;
102 
103     x = fabsf(a);
104     return (b >= 0.0f)  ?  x  :  -x;
105 }
106 /*- End of function --------------------------------------------------------*/
107 /*- End of file ------------------------------------------------------------*/
108