FreeCalypso > hg > gsm-codec-lib
comparison libtwamr/lsp.c @ 388:550d3594c878
libtwamr: integrate lsp.c
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 06 May 2024 06:43:22 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
387:7818f466a639 | 388:550d3594c878 |
---|---|
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.c | |
11 * Purpose : From A(z) to lsp. LSP quantization and interpolation | |
12 * | |
13 ******************************************************************************** | |
14 */ | |
15 | |
16 /* | |
17 ******************************************************************************** | |
18 * MODULE INCLUDE FILE AND VERSION ID | |
19 ******************************************************************************** | |
20 */ | |
21 #include "namespace.h" | |
22 #include "lsp.h" | |
23 | |
24 /* | |
25 ******************************************************************************** | |
26 * INCLUDE FILES | |
27 ******************************************************************************** | |
28 */ | |
29 #include "tw_amr.h" | |
30 #include "typedef.h" | |
31 #include "basic_op.h" | |
32 #include "oper_32b.h" | |
33 #include "q_plsf.h" | |
34 #include "memops.h" | |
35 #include "az_lsp.h" | |
36 #include "int_lpc.h" | |
37 #include "no_count.h" | |
38 #include "lsp_tab.h" | |
39 | |
40 /* | |
41 ******************************************************************************** | |
42 * PUBLIC PROGRAM CODE | |
43 ******************************************************************************** | |
44 */ | |
45 | |
46 /* | |
47 ************************************************************************** | |
48 * | |
49 * Function : lsp_reset | |
50 * | |
51 ************************************************************************** | |
52 */ | |
53 void lsp_reset (lspState *st) | |
54 { | |
55 /* Init lsp_old[] */ | |
56 Copy(lsp_init_data, &st->lsp_old[0], M); | |
57 | |
58 /* Initialize lsp_old_q[] */ | |
59 Copy(st->lsp_old, st->lsp_old_q, M); | |
60 | |
61 /* Reset quantization state */ | |
62 Q_plsf_reset(&st->qSt); | |
63 } | |
64 | |
65 /************************************************************************* | |
66 * | |
67 * FUNCTION: lsp() | |
68 * | |
69 ************************************************************************/ | |
70 int lsp(lspState *st, /* i/o : State struct */ | |
71 enum Mode req_mode, /* i : requested coder mode */ | |
72 enum Mode used_mode, /* i : used coder mode */ | |
73 Word16 az[], /* i/o : interpolated LP parameters Q12 */ | |
74 Word16 azQ[], /* o : quantization interpol. LP parameters Q12*/ | |
75 Word16 lsp_new[], /* o : new lsp vector */ | |
76 Word16 **anap /* o : analysis parameters */) | |
77 { | |
78 Word16 lsp_new_q[M]; /* LSPs at 4th subframe */ | |
79 Word16 lsp_mid[M], lsp_mid_q[M]; /* LSPs at 2nd subframe */ | |
80 | |
81 Word16 pred_init_i; /* init index for MA prediction in DTX mode */ | |
82 | |
83 test (); | |
84 if ( sub (req_mode, MR122) == 0) | |
85 { | |
86 Az_lsp (&az[MP1], lsp_mid, st->lsp_old); | |
87 Az_lsp (&az[MP1 * 3], lsp_new, lsp_mid); | |
88 | |
89 /*--------------------------------------------------------------------* | |
90 * Find interpolated LPC parameters in all subframes (both quantized * | |
91 * and unquantized). * | |
92 * The interpolated parameters are in array A_t[] of size (M+1)*4 * | |
93 * and the quantized interpolated parameters are in array Aq_t[] * | |
94 *--------------------------------------------------------------------*/ | |
95 Int_lpc_1and3_2 (st->lsp_old, lsp_mid, lsp_new, az); | |
96 | |
97 test (); | |
98 if ( sub (used_mode, MRDTX) != 0) | |
99 { | |
100 /* LSP quantization (lsp_mid[] and lsp_new[] jointly quantized) */ | |
101 Q_plsf_5 (&st->qSt, lsp_mid, lsp_new, lsp_mid_q, lsp_new_q, *anap); | |
102 | |
103 Int_lpc_1and3 (st->lsp_old_q, lsp_mid_q, lsp_new_q, azQ); | |
104 | |
105 /* Advance analysis parameters pointer */ | |
106 (*anap) += add(0,5); move16 (); | |
107 } | |
108 } | |
109 else | |
110 { | |
111 Az_lsp(&az[MP1 * 3], lsp_new, st->lsp_old); /* From A(z) to lsp */ | |
112 | |
113 /*--------------------------------------------------------------------* | |
114 * Find interpolated LPC parameters in all subframes (both quantized * | |
115 * and unquantized). * | |
116 * The interpolated parameters are in array A_t[] of size (M+1)*4 * | |
117 * and the quantized interpolated parameters are in array Aq_t[] * | |
118 *--------------------------------------------------------------------*/ | |
119 | |
120 Int_lpc_1to3_2(st->lsp_old, lsp_new, az); | |
121 | |
122 test (); | |
123 if ( sub (used_mode, MRDTX) != 0) | |
124 { | |
125 /* LSP quantization */ | |
126 Q_plsf_3(&st->qSt, req_mode, lsp_new, lsp_new_q, *anap, &pred_init_i); | |
127 | |
128 Int_lpc_1to3(st->lsp_old_q, lsp_new_q, azQ); | |
129 | |
130 /* Advance analysis parameters pointer */ | |
131 (*anap) += add (0, 3); move16 (); | |
132 } | |
133 } | |
134 | |
135 /* update the LSPs for the next frame */ | |
136 Copy (lsp_new, st->lsp_old, M); | |
137 Copy (lsp_new_q, st->lsp_old_q, M); | |
138 | |
139 return 0; | |
140 } |