FreeCalypso > hg > gsm-codec-lib
annotate libtwamr/int_lsf.c @ 501:597b39aef484
libgsmhr1/mathhalf.h: rm unused declarations
for non-saturating functions
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 19 Jun 2024 00:54:44 +0000 |
parents | 693ea1d5cf1e |
children |
rev | line source |
---|---|
382
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 ******************************************************************************** |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001 |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * R99 Version 3.3.0 |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * REL-4 Version 4.1.0 |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 * |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 ******************************************************************************** |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 * |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 * File : int_lsf.c |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 * |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 ******************************************************************************** |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 */ |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 /* |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 ******************************************************************************** |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 * MODULE INCLUDE FILE AND VERSION ID |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 ******************************************************************************** |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 */ |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 #include "namespace.h" |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 #include "int_lsf.h" |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 /* |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 ******************************************************************************** |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 * INCLUDE FILES |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 ******************************************************************************** |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 */ |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 #include "typedef.h" |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 #include "basic_op.h" |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 #include "no_count.h" |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 #include "cnst.h" |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 /* |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 ******************************************************************************** |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 * LOCAL VARIABLES AND TABLES |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 ******************************************************************************** |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 */ |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 /* |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 *--------------------------------------* |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 * Constants (defined in cnst.h) * |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 *--------------------------------------* |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 * M : LSF order * |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 *--------------------------------------* |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 */ |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 /* |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 ******************************************************************************** |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 * PUBLIC PROGRAM CODE |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 ******************************************************************************** |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 */ |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 /* |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 ************************************************************************** |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 * |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 * Function : Int_lsf |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 * Purpose : Interpolates the LSFs for selected subframe |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 * Description : The 20 ms speech frame is divided into 4 subframes. |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 * The LSFs are interpolated at the 1st, 2nd and 3rd |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 * subframe and only forwarded at the 4th subframe. |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 * |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 * |------|------|------|------| |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 * sf1 sf2 sf3 sf4 |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 * F0 F1 |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 * |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 * sf1: 3/4 F0 + 1/4 F1 sf3: 1/4 F0 + 3/4 F1 |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 * sf2: 1/2 F0 + 1/2 F1 sf4: F1 |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 * Returns : void |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 * |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 ************************************************************************** |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 */ |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 void Int_lsf( |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 Word16 lsf_old[], /* i : LSF vector at the 4th SF of past frame */ |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 Word16 lsf_new[], /* i : LSF vector at the 4th SF of present frame */ |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 Word16 i_subfr, /* i : Pointer to current sf (equal to 0,40,80 or 120) */ |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 Word16 lsf_out[] /* o : interpolated LSF parameters for current sf */ |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 ) |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 { |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 Word16 i; |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 if ( i_subfr == 0 ) |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 { |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 test (); |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 for (i = 0; i < M; i++) { |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 lsf_out[i] = add(sub(lsf_old[i], shr(lsf_old[i], 2)), shr(lsf_new[i], 2)); |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 move16 (); |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 } |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 } |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 else if ( sub(i_subfr, 40) == 0 ) |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 { |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 test (); test (); |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 for (i = 0; i < M; i++) { |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 lsf_out[i] = add(shr(lsf_old[i],1), shr(lsf_new[i], 1) ); |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 move16 (); |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 } |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 } |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 else if ( sub(i_subfr, 80) == 0 ) |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 { |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 test (); test (); test (); |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 for (i = 0; i < M; i++) { |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 lsf_out[i] = add(shr(lsf_old[i], 2), sub(lsf_new[i], shr(lsf_new[i], 2))); |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 move16 (); |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 } |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 } |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 else if ( sub(i_subfr, 120) == 0 ) |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 { |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 test (); test (); test (); test (); |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 for (i = 0; i < M; i++) { |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 lsf_out[i] = lsf_new[i]; move16 (); |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 } |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 } |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 return; |
693ea1d5cf1e
libtwamr: integrate int_lsf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 } |