FreeCalypso > hg > gsm-codec-lib
annotate libtwamr/residu.c @ 398:df14b0c17e6d
libtwamr: integrate pred_lt.c
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 06 May 2024 19:07:10 +0000 |
parents | a2351f2ad4f8 |
children |
rev | line source |
---|---|
393
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 ******************************************************************************** |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001 |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * R99 Version 3.3.0 |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * REL-4 Version 4.1.0 |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 * |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 ******************************************************************************** |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 * |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 * File : residu.c |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 * Purpose : Computes the LP residual. |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 * Description : The LP residual is computed by filtering the input |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 * : speech through the LP inverse filter A(z). |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 * |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 ******************************************************************************** |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 */ |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 /* |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 ******************************************************************************** |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 * MODULE INCLUDE FILE AND VERSION ID |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 ******************************************************************************** |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 */ |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 #include "namespace.h" |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 #include "residu.h" |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 /* |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 ******************************************************************************** |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 * INCLUDE FILES |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 ******************************************************************************** |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 */ |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 #include "typedef.h" |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 #include "basic_op.h" |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 #include "no_count.h" |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 #include "cnst.h" |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 /* |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 ******************************************************************************** |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 * LOCAL VARIABLES AND TABLES |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 ******************************************************************************** |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 */ |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 /* |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 *--------------------------------------* |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 * Constants (defined in cnst.h * |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 *--------------------------------------* |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 * M : LPC order * |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 *--------------------------------------* |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 */ |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 /* |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 ******************************************************************************** |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 * PUBLIC PROGRAM CODE |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 ******************************************************************************** |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 */ |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 void Residu ( |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 Word16 a[], /* (i) : prediction coefficients */ |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 Word16 x[], /* (i) : speech signal */ |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 Word16 y[], /* (o) : residual signal */ |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 Word16 lg /* (i) : size of filtering */ |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 ) |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 { |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 Word16 i, j; |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 Word32 s; |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 for (i = 0; i < lg; i++) |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 { |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 s = L_mult (x[i], a[0]); |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 for (j = 1; j <= M; j++) |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 { |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 s = L_mac (s, a[j], x[i - j]); |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 } |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 s = L_shl (s, 3); |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 y[i] = round (s); move16 (); |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 } |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 return; |
a2351f2ad4f8
libtwamr: integrate residu.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 } |