FreeCalypso > hg > efr-experiments
comparison src/lsp_lsf.c @ 0:56410792419a
src: original EFR source from ETSI
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 03 Apr 2024 05:31:37 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:56410792419a |
---|---|
1 /************************************************************************* | |
2 * | |
3 * FUNCTIONS: Lsp_lsf and Lsf_lsp | |
4 * | |
5 * PURPOSE: | |
6 * Lsp_lsf: Transformation lsp to lsf | |
7 * Lsf_lsp: Transformation lsf to lsp | |
8 * | |
9 * DESCRIPTION: | |
10 * lsp[i] = cos(2*pi*lsf[i]) and lsf[i] = arccos(lsp[i])/(2*pi) | |
11 * | |
12 * The transformation from lsp[i] to lsf[i] and lsf[i] to lsp[i] are | |
13 * approximated by a look-up table and interpolation. | |
14 * | |
15 *************************************************************************/ | |
16 | |
17 #include "typedef.h" | |
18 #include "basic_op.h" | |
19 #include "count.h" | |
20 | |
21 #include "lsp_lsf.tab" /* Look-up table for transformations */ | |
22 | |
23 void Lsf_lsp ( | |
24 Word16 lsf[], /* (i) : lsf[m] normalized (range: 0.0<=val<=0.5) */ | |
25 Word16 lsp[], /* (o) : lsp[m] (range: -1<=val<1) */ | |
26 Word16 m /* (i) : LPC order */ | |
27 ) | |
28 { | |
29 Word16 i, ind, offset; | |
30 Word32 L_tmp; | |
31 | |
32 for (i = 0; i < m; i++) | |
33 { | |
34 ind = shr (lsf[i], 8); /* ind = b8-b15 of lsf[i] */ | |
35 offset = lsf[i] & 0x00ff; logic16 (); /* offset = b0-b7 of lsf[i] */ | |
36 | |
37 /* lsp[i] = table[ind]+ ((table[ind+1]-table[ind])*offset) / 256 */ | |
38 | |
39 L_tmp = L_mult (sub (table[ind + 1], table[ind]), offset); | |
40 lsp[i] = add (table[ind], extract_l (L_shr (L_tmp, 9))); | |
41 move16 (); | |
42 } | |
43 return; | |
44 } | |
45 | |
46 void Lsp_lsf ( | |
47 Word16 lsp[], /* (i) : lsp[m] (range: -1<=val<1) */ | |
48 Word16 lsf[], /* (o) : lsf[m] normalized (range: 0.0<=val<=0.5) */ | |
49 Word16 m /* (i) : LPC order */ | |
50 ) | |
51 { | |
52 Word16 i, ind; | |
53 Word32 L_tmp; | |
54 | |
55 ind = 63; /* begin at end of table -1 */ | |
56 | |
57 for (i = m - 1; i >= 0; i--) | |
58 { | |
59 /* find value in table that is just greater than lsp[i] */ | |
60 test (); | |
61 while (sub (table[ind], lsp[i]) < 0) | |
62 { | |
63 ind--; | |
64 test (); | |
65 } | |
66 | |
67 /* acos(lsp[i])= ind*256 + ( ( lsp[i]-table[ind] ) * | |
68 slope[ind] )/4096 */ | |
69 | |
70 L_tmp = L_mult (sub (lsp[i], table[ind]), slope[ind]); | |
71 /*(lsp[i]-table[ind])*slope[ind])>>12*/ | |
72 lsf[i] = round (L_shl (L_tmp, 3)); move16 (); | |
73 lsf[i] = add (lsf[i], shl (ind, 8)); move16 (); | |
74 } | |
75 return; | |
76 } |