spandsp 0.0.6

lpc10_encdecs.h
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
26#define LPC10_ORDER 10
27
28#if !defined(min)
29#define min(a,b) ((a) <= (b) ? (a) : (b))
30#endif
31#if !defined(max)
32#define max(a,b) ((a) >= (b) ? (a) : (b))
33#endif
34
35 void lpc10_placea(int32_t *ipitch,
36 int32_t voibuf[4][2],
37 int32_t *obound,
38 int32_t af,
39 int32_t vwin[3][2],
40 int32_t awin[3][2],
41 int32_t ewin[3][2],
42 int32_t lframe,
43 int32_t maxwin);
44
45 void lpc10_placev(int32_t *osbuf,
46 int32_t *osptr,
47 int32_t oslen,
48 int32_t *obound,
49 int32_t vwin[3][2],
50 int32_t af,
51 int32_t lframe,
52 int32_t minwin,
53 int32_t maxwin,
54 int32_t dvwinl,
55 int32_t dvwinh);
56
57 void lpc10_voicing(lpc10_encode_state_t *st,
58 int32_t *vwin,
59 float *inbuf,
60 float *lpbuf,
61 const int32_t buflim[],
62 int32_t half,
63 float *minamd,
64 float *maxamd,
65 int32_t *mintau,
66 float *ivrc,
67 int32_t *obound);
68
69 void lpc10_analyse(lpc10_encode_state_t *st, float *speech, int32_t *voice, int32_t *pitch, float *rms, float rc[]);
70
71 static __inline__ int32_t pow_ii(int32_t x, int32_t n)
72{
73 int32_t pow;
74 uint32_t u;
75
76 if (n <= 0)
77 {
78 if (n == 0 || x == 1)
79 return 1;
80 if (x != -1)
81 return (x == 0) ? 1/x : 0;
82 n = -n;
83 }
84 u = n;
85 for (pow = 1; ; )
86 {
87 if ((u & 1))
88 pow *= x;
89 if ((u >>= 1) == 0)
90 break;
91 x *= x;
92 }
93 return pow;
94}
95/*- End of function --------------------------------------------------------*/
96
97 static __inline__ float r_sign(float a, float b)
98{
99 float x;
100
101 x = fabsf(a);
102 return (b >= 0.0f) ? x : -x;
103}
104/*- End of function --------------------------------------------------------*/
105/*- End of file ------------------------------------------------------------*/