FreeCalypso > hg > gsm-codec-lib
annotate libtwamr/syn_filt.c @ 458:e26b974f7ba3
doc/AMR-study-utils: update for the current situation
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 10 May 2024 18:45:36 +0000 |
parents | 2af94ba0c075 |
children |
rev | line source |
---|---|
394
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 ******************************************************************************** |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001 |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * R99 Version 3.3.0 |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * REL-4 Version 4.1.0 |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 * |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 ******************************************************************************** |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 * |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 * File : syn_filt.c |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 * Purpose : Perform synthesis filtering through 1/A(z). |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 * |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 ******************************************************************************** |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 */ |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 /* |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 ******************************************************************************** |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 * MODULE INCLUDE FILE AND VERSION ID |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 ******************************************************************************** |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 */ |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 #include "namespace.h" |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 #include "syn_filt.h" |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 /* |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 ******************************************************************************** |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 * INCLUDE FILES |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 ******************************************************************************** |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 */ |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 #include "typedef.h" |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 #include "basic_op.h" |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 #include "no_count.h" |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 #include "cnst.h" |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 /* |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 ******************************************************************************** |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 * LOCAL VARIABLES AND TABLES |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 ******************************************************************************** |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 */ |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 /* |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 *--------------------------------------* |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 * Constants (defined in cnst.h * |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 *--------------------------------------* |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 * M : LPC order * |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 *--------------------------------------* |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 */ |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 /* |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 ******************************************************************************** |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 * PUBLIC PROGRAM CODE |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 ******************************************************************************** |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 */ |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 void Syn_filt ( |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 Word16 a[], /* (i) : a[M+1] prediction coefficients (M=10) */ |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 Word16 x[], /* (i) : input signal */ |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 Word16 y[], /* (o) : output signal */ |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 Word16 lg, /* (i) : size of filtering */ |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 Word16 mem[], /* (i/o) : memory associated with this filtering. */ |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 Word16 update /* (i) : 0=no update, 1=update of memory. */ |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 ) |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 { |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 Word16 i, j; |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 Word32 s; |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 Word16 tmp[80]; /* This is usually done by memory allocation (lg+M) */ |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 Word16 *yy; |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 /* Copy mem[] to yy[] */ |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 yy = tmp; move16 (); |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 for (i = 0; i < M; i++) |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 { |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 *yy++ = mem[i]; move16 (); |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 } |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 /* Do the filtering. */ |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 for (i = 0; i < lg; i++) |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 { |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 s = L_mult (x[i], a[0]); |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 for (j = 1; j <= M; j++) |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 { |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 s = L_msu (s, a[j], yy[-j]); |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 } |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 s = L_shl (s, 3); |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 *yy++ = round (s); move16 (); |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 } |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 for (i = 0; i < lg; i++) |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 { |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 y[i] = tmp[i + M]; move16 (); |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 } |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 /* Update of memory if update==1 */ |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 test (); |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 if (update != 0) |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 { |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 for (i = 0; i < M; i++) |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 { |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 mem[i] = y[lg - M + i]; move16 (); |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 } |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 } |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 return; |
2af94ba0c075
libtwamr: integrate syn_filt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 } |