FreeCalypso > hg > gsm-codec-lib
annotate libtwamr/lsfwt.c @ 536:a3300483ae74
doc/FR1-library-API: document return value from gsmfr_tfo_xfrm_*
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 21 Sep 2024 20:48:58 +0000 |
parents | 8861f41e4507 |
children |
rev | line source |
---|---|
370
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 ******************************************************************************** |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001 |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * R99 Version 3.3.0 |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * REL-4 Version 4.1.0 |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 ******************************************************************************** |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 * File : lsfwt.c |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 * Purpose : Compute LSF weighting factors |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 ******************************************************************************** |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 */ |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 /* |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 ******************************************************************************** |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 * MODULE INCLUDE FILE AND VERSION ID |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 ******************************************************************************** |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 */ |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 #include "namespace.h" |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 #include "lsfwt.h" |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 /* |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 ******************************************************************************** |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 * INCLUDE FILES |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 ******************************************************************************** |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 */ |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 #include "typedef.h" |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 #include "basic_op.h" |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 #include "no_count.h" |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 #include "cnst.h" |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 /* |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 ******************************************************************************** |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 * PUBLIC PROGRAM CODE |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 ******************************************************************************** |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 */ |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 /**************************************************** |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 * FUNCTION Lsf_wt * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 * * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 **************************************************** |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 * Compute LSF weighting factors * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 * * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 * d[i] = lsf[i+1] - lsf[i-1] * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 * * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 * The weighting factors are approximated by two line segment. * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 * * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 * First segment passes by the following 2 points: * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 * * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 * d[i] = 0Hz wf[i] = 3.347 * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 * d[i] = 450Hz wf[i] = 1.8 * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 * * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 * Second segment passes by the following 2 points: * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 * * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 * d[i] = 450Hz wf[i] = 1.8 * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 * d[i] = 1500Hz wf[i] = 1.0 * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 * * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 * if( d[i] < 450Hz ) * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 * wf[i] = 3.347 - ( (3.347-1.8) / (450-0)) * d[i] * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 * else * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 * wf[i] = 1.8 - ( (1.8-1.0) / (1500-450)) * (d[i] - 450) * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 * * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 * * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 * if( d[i] < 1843) * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 * wf[i] = 3427 - (28160*d[i])>>15 * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 * else * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 * wf[i] = 1843 - (6242*(d[i]-1843))>>15 * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 * * |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 *--------------------------------------------------------------------------*/ |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 void Lsf_wt ( |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 Word16 *lsf, /* input : LSF vector */ |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 Word16 *wf) /* output: square of weighting factors */ |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 { |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 Word16 temp; |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 Word16 i; |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 /* wf[0] = lsf[1] - 0 */ |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 wf[0] = lsf[1]; move16 (); |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 for (i = 1; i < 9; i++) |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 { |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 wf[i] = sub (lsf[i + 1], lsf[i - 1]); move16 (); |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 } |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 /* wf[9] = 0.5 - lsf[8] */ |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 wf[9] = sub (16384, lsf[8]);move16 (); |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 for (i = 0; i < 10; i++) |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 { |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 temp = sub (wf[i], 1843); |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 test (); |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 if (temp < 0) |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 { |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 wf[i] = sub (3427, mult (wf[i], 28160)); move16 (); |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 } |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 else |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 { |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 wf[i] = sub (1843, mult (temp, 6242)); move16 (); |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 } |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 wf[i] = shl (wf[i], 3); move16 (); |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 } |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 return; |
8861f41e4507
libtwamr: integrate lsfwt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 } |