FreeCalypso > hg > gsm-codec-lib
comparison libtwamr/lsp_lsf.c @ 344:05a46720af0f
libtwamr: integrate d_plsf_3.c
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 19 Apr 2024 01:23:15 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
343:3f574255c3aa | 344:05a46720af0f |
---|---|
1 /* | |
2 ******************************************************************************** | |
3 * | |
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001 | |
5 * R99 Version 3.3.0 | |
6 * REL-4 Version 4.1.0 | |
7 * | |
8 ******************************************************************************** | |
9 * | |
10 * File : lsp_lsf.c | |
11 * Purpose : Lsp_lsf: Transformation lsp to lsf | |
12 * : Lsf_lsp: Transformation lsf to lsp | |
13 * | |
14 ******************************************************************************** | |
15 */ | |
16 /* | |
17 ******************************************************************************** | |
18 * MODULE INCLUDE FILE AND VERSION ID | |
19 ******************************************************************************** | |
20 */ | |
21 #include "namespace.h" | |
22 #include "lsp_lsf.h" | |
23 | |
24 /* | |
25 ******************************************************************************** | |
26 * INCLUDE FILES | |
27 ******************************************************************************** | |
28 */ | |
29 #include "typedef.h" | |
30 #include "basic_op.h" | |
31 #include "no_count.h" | |
32 | |
33 /* | |
34 ******************************************************************************** | |
35 * LOCAL VARIABLES AND TABLES | |
36 ******************************************************************************** | |
37 */ | |
38 #include "lsp_lsf.tab" /* Look-up table for transformations */ | |
39 | |
40 /* | |
41 ******************************************************************************** | |
42 * PUBLIC PROGRAM CODE | |
43 ******************************************************************************** | |
44 */ | |
45 /************************************************************************* | |
46 * | |
47 * FUNCTIONS: Lsp_lsf and Lsf_lsp | |
48 * | |
49 * PURPOSE: | |
50 * Lsp_lsf: Transformation lsp to lsf | |
51 * Lsf_lsp: Transformation lsf to lsp | |
52 * | |
53 * DESCRIPTION: | |
54 * lsp[i] = cos(2*pi*lsf[i]) and lsf[i] = arccos(lsp[i])/(2*pi) | |
55 * | |
56 * The transformation from lsp[i] to lsf[i] and lsf[i] to lsp[i] are | |
57 * approximated by a look-up table and interpolation. | |
58 * | |
59 *************************************************************************/ | |
60 void Lsf_lsp ( | |
61 Word16 lsf[], /* (i) : lsf[m] normalized (range: 0.0<=val<=0.5) */ | |
62 Word16 lsp[], /* (o) : lsp[m] (range: -1<=val<1) */ | |
63 Word16 m /* (i) : LPC order */ | |
64 ) | |
65 { | |
66 Word16 i, ind, offset; | |
67 Word32 L_tmp; | |
68 | |
69 for (i = 0; i < m; i++) | |
70 { | |
71 ind = shr (lsf[i], 8); /* ind = b8-b15 of lsf[i] */ | |
72 offset = lsf[i] & 0x00ff; logic16 (); /* offset = b0-b7 of lsf[i] */ | |
73 | |
74 /* lsp[i] = table[ind]+ ((table[ind+1]-table[ind])*offset) / 256 */ | |
75 | |
76 L_tmp = L_mult (sub (table[ind + 1], table[ind]), offset); | |
77 lsp[i] = add (table[ind], extract_l (L_shr (L_tmp, 9))); | |
78 move16 (); | |
79 } | |
80 return; | |
81 } | |
82 | |
83 void Lsp_lsf ( | |
84 Word16 lsp[], /* (i) : lsp[m] (range: -1<=val<1) */ | |
85 Word16 lsf[], /* (o) : lsf[m] normalized (range: 0.0<=val<=0.5) */ | |
86 Word16 m /* (i) : LPC order */ | |
87 ) | |
88 { | |
89 Word16 i, ind; | |
90 Word32 L_tmp; | |
91 | |
92 ind = 63; move16 (); /* begin at end of table -1 */ | |
93 | |
94 for (i = m - 1; i >= 0; i--) | |
95 { | |
96 /* find value in table that is just greater than lsp[i] */ | |
97 test (); | |
98 while (sub (table[ind], lsp[i]) < 0) | |
99 { | |
100 ind--; | |
101 test (); | |
102 } | |
103 | |
104 /* acos(lsp[i])= ind*256 + ( ( lsp[i]-table[ind] ) * | |
105 slope[ind] )/4096 */ | |
106 | |
107 L_tmp = L_mult (sub (lsp[i], table[ind]), slope[ind]); | |
108 /*(lsp[i]-table[ind])*slope[ind])>>12*/ | |
109 lsf[i] = round (L_shl (L_tmp, 3)); move16 (); | |
110 lsf[i] = add (lsf[i], shl (ind, 8)); move16 (); | |
111 } | |
112 return; | |
113 } |