FreeCalypso > hg > gsm-codec-lib
annotate libtwamr/q_plsf_5.c @ 556:18aca50d68df default tip
doc/Calypso-TCH-downlink: update for FR1 BFI-with-data
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 11 Oct 2024 01:54:00 +0000 |
parents | 128ec87489b6 |
children |
rev | line source |
---|---|
373
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 ******************************************************************************** |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * R99 Version 3.3.0 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * REL-4 Version 4.1.0 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 * |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 ******************************************************************************** |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 * |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 * File : q_plsf_5.c |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 * Purpose : Quantization of 2 sets of LSF parameters using 1st |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 * order MA prediction and split by 5 matrix |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 * quantization (split-MQ) |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 * |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 ******************************************************************************** |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 /* |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 ******************************************************************************** |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 * MODULE INCLUDE FILE AND VERSION ID |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 ******************************************************************************** |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 #include "namespace.h" |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 #include "q_plsf.h" |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 /* |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 ******************************************************************************** |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 * INCLUDE FILES |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 ******************************************************************************** |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 #include "typedef.h" |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 #include "basic_op.h" |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 #include "no_count.h" |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 #include "lsp_lsf.h" |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 #include "reorder.h" |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 #include "lsfwt.h" |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 #include "q_plsf5_tab.h" |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 /* |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 ******************************************************************************** |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 * LOCAL PROGRAM CODE |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 ******************************************************************************** |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 /* Quantization of a 4 dimensional subvector */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 static Word16 Vq_subvec (/* o : quantization index, Q0 */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 Word16 *lsf_r1, /* i : 1st LSF residual vector, Q15 */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 Word16 *lsf_r2, /* i : 2nd LSF residual vector, Q15 */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 const Word16 *dico, /* i : quantization codebook, Q15 */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 Word16 *wf1, /* i : 1st LSF weighting factors Q13 */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 Word16 *wf2, /* i : 2nd LSF weighting factors Q13 */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 Word16 dico_size /* i : size of quantization codebook, Q0 */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 ) |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 { |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 Word16 index = 0; /* initialization only needed to keep gcc silent */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 Word16 i, temp; |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 const Word16 *p_dico; |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 Word32 dist_min, dist; |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 dist_min = MAX_32; move32 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 p_dico = dico; move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 for (i = 0; i < dico_size; i++) |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 { |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 temp = sub (lsf_r1[0], *p_dico++); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 temp = mult (wf1[0], temp); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 dist = L_mult (temp, temp); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 temp = sub (lsf_r1[1], *p_dico++); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 temp = mult (wf1[1], temp); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 dist = L_mac (dist, temp, temp); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 temp = sub (lsf_r2[0], *p_dico++); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 temp = mult (wf2[0], temp); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 dist = L_mac (dist, temp, temp); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 temp = sub (lsf_r2[1], *p_dico++); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 temp = mult (wf2[1], temp); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 dist = L_mac (dist, temp, temp); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 test (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 if (L_sub (dist, dist_min) < (Word32) 0) |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 { |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 dist_min = dist; move32 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 index = i; move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 } |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 } |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 /* Reading the selected vector */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 p_dico = &dico[shl (index, 2)]; move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 lsf_r1[0] = *p_dico++; move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 lsf_r1[1] = *p_dico++; move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 lsf_r2[0] = *p_dico++; move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 lsf_r2[1] = *p_dico++; move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 return index; |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 } |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 /* Quantization of a 4 dimensional subvector with a signed codebook */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 static Word16 Vq_subvec_s ( /* o : quantization index Q0 */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 Word16 *lsf_r1, /* i : 1st LSF residual vector Q15 */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 Word16 *lsf_r2, /* i : and LSF residual vector Q15 */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 const Word16 *dico, /* i : quantization codebook Q15 */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 Word16 *wf1, /* i : 1st LSF weighting factors Q13 */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 Word16 *wf2, /* i : 2nd LSF weighting factors Q13 */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 Word16 dico_size) /* i : size of quantization codebook Q0 */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 { |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 Word16 index = 0; /* initialization only needed to keep gcc silent */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 Word16 sign = 0; /* initialization only needed to keep gcc silent */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 Word16 i, temp; |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 const Word16 *p_dico; |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 Word32 dist_min, dist; |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 dist_min = MAX_32; move32 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 p_dico = dico; move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 for (i = 0; i < dico_size; i++) |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 { |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 /* test positive */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 temp = sub (lsf_r1[0], *p_dico++); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 temp = mult (wf1[0], temp); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 dist = L_mult (temp, temp); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 temp = sub (lsf_r1[1], *p_dico++); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 temp = mult (wf1[1], temp); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 dist = L_mac (dist, temp, temp); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 temp = sub (lsf_r2[0], *p_dico++); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 temp = mult (wf2[0], temp); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 dist = L_mac (dist, temp, temp); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 temp = sub (lsf_r2[1], *p_dico++); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 temp = mult (wf2[1], temp); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 dist = L_mac (dist, temp, temp); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 test (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 if (L_sub (dist, dist_min) < (Word32) 0) |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 { |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 dist_min = dist; move32 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 index = i; move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 sign = 0; move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 } |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 /* test negative */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 p_dico -= 4; move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 temp = add (lsf_r1[0], *p_dico++); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 temp = mult (wf1[0], temp); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 dist = L_mult (temp, temp); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 temp = add (lsf_r1[1], *p_dico++); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 temp = mult (wf1[1], temp); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 dist = L_mac (dist, temp, temp); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 temp = add (lsf_r2[0], *p_dico++); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 temp = mult (wf2[0], temp); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 dist = L_mac (dist, temp, temp); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 temp = add (lsf_r2[1], *p_dico++); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 temp = mult (wf2[1], temp); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 dist = L_mac (dist, temp, temp); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 test (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 if (L_sub (dist, dist_min) < (Word32) 0) |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 { |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 dist_min = dist; move32 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 index = i; move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 sign = 1; move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 } |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 } |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 /* Reading the selected vector */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 p_dico = &dico[shl (index, 2)]; move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 test (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 if (sign == 0) |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 { |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 lsf_r1[0] = *p_dico++; move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 lsf_r1[1] = *p_dico++; move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 lsf_r2[0] = *p_dico++; move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 lsf_r2[1] = *p_dico++; move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 } |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 else |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 { |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 lsf_r1[0] = negate (*p_dico++); move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 lsf_r1[1] = negate (*p_dico++); move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 lsf_r2[0] = negate (*p_dico++); move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 lsf_r2[1] = negate (*p_dico++); move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 } |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 index = shl (index, 1); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 index = add (index, sign); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 return index; |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 } |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 /* |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 ******************************************************************************** |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 * PUBLIC PROGRAM CODE |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 ******************************************************************************** |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 /************************************************************************* |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 * FUNCTION: Q_plsf_5() |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 * |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 * PURPOSE: Quantization of 2 sets of LSF parameters using 1st order MA |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 * prediction and split by 5 matrix quantization (split-MQ) |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 * |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 * DESCRIPTION: |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
212 * |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 * p[i] = pred_factor*past_rq[i]; i=0,...,m-1 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 * r1[i]= lsf1[i] - p[i]; i=0,...,m-1 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 * r2[i]= lsf2[i] - p[i]; i=0,...,m-1 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 * where: |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
217 * lsf1[i] 1st mean-removed LSF vector. |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
218 * lsf2[i] 2nd mean-removed LSF vector. |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
219 * r1[i] 1st residual prediction vector. |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
220 * r2[i] 2nd residual prediction vector. |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
221 * past_r2q[i] Past quantized residual (2nd vector). |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
222 * |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
223 * The residual vectors r1[i] and r2[i] are jointly quantized using |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
224 * split-MQ with 5 codebooks. Each 4th dimension submatrix contains 2 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
225 * elements from each residual vector. The 5 submatrices are as follows: |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
226 * {r1[0], r1[1], r2[0], r2[1]}; {r1[2], r1[3], r2[2], r2[3]}; |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
227 * {r1[4], r1[5], r2[4], r2[5]}; {r1[6], r1[7], r2[6], r2[7]}; |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
228 * {r1[8], r1[9], r2[8], r2[9]}; |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
229 * |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
230 *************************************************************************/ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
231 void Q_plsf_5 ( |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
232 Q_plsfState *st, |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
233 Word16 *lsp1, /* i : 1st LSP vector, Q15 */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
234 Word16 *lsp2, /* i : 2nd LSP vector, Q15 */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
235 Word16 *lsp1_q, /* o : quantized 1st LSP vector, Q15 */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
236 Word16 *lsp2_q, /* o : quantized 2nd LSP vector, Q15 */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
237 Word16 *indice /* o : quantization indices of 5 matrices, Q0 */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
238 ) |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
239 { |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
240 Word16 i; |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
241 Word16 lsf1[M], lsf2[M], wf1[M], wf2[M], lsf_p[M], lsf_r1[M], lsf_r2[M]; |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
242 Word16 lsf1_q[M], lsf2_q[M]; |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
243 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
244 /* convert LSFs to normalize frequency domain 0..16384 */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
245 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
246 Lsp_lsf (lsp1, lsf1, M); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
247 Lsp_lsf (lsp2, lsf2, M); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
248 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
249 /* Compute LSF weighting factors (Q13) */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
250 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
251 Lsf_wt (lsf1, wf1); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
252 Lsf_wt (lsf2, wf2); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
253 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
254 /* Compute predicted LSF and prediction error */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
255 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
256 for (i = 0; i < M; i++) |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
257 { |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
258 lsf_p[i] = add (mean_lsf[i], mult (st->past_rq[i], LSP_PRED_FAC_MR122)); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
259 move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
260 lsf_r1[i] = sub (lsf1[i], lsf_p[i]); move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
261 lsf_r2[i] = sub (lsf2[i], lsf_p[i]); move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
262 } |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
263 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
264 /*---- Split-MQ of prediction error ----*/ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
265 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
266 indice[0] = Vq_subvec (&lsf_r1[0], &lsf_r2[0], dico1_lsf, |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
267 &wf1[0], &wf2[0], DICO1_SIZE); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
268 move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
269 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
270 indice[1] = Vq_subvec (&lsf_r1[2], &lsf_r2[2], dico2_lsf, |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
271 &wf1[2], &wf2[2], DICO2_SIZE); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
272 move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
273 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
274 indice[2] = Vq_subvec_s (&lsf_r1[4], &lsf_r2[4], dico3_lsf, |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
275 &wf1[4], &wf2[4], DICO3_SIZE); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
276 move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
277 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
278 indice[3] = Vq_subvec (&lsf_r1[6], &lsf_r2[6], dico4_lsf, |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
279 &wf1[6], &wf2[6], DICO4_SIZE); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
280 move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
281 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
282 indice[4] = Vq_subvec (&lsf_r1[8], &lsf_r2[8], dico5_lsf, |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
283 &wf1[8], &wf2[8], DICO5_SIZE); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
284 move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
285 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
286 /* Compute quantized LSFs and update the past quantized residual */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
287 for (i = 0; i < M; i++) |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
288 { |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
289 lsf1_q[i] = add (lsf_r1[i], lsf_p[i]); move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
290 lsf2_q[i] = add (lsf_r2[i], lsf_p[i]); move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
291 st->past_rq[i] = lsf_r2[i]; move16 (); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
292 } |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
293 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
294 /* verification that LSFs has minimum distance of LSF_GAP */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
295 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
296 Reorder_lsf (lsf1_q, LSF_GAP, M); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
297 Reorder_lsf (lsf2_q, LSF_GAP, M); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
298 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
299 /* convert LSFs to the cosine domain */ |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
300 |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
301 Lsf_lsp (lsf1_q, lsp1_q, M); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
302 Lsf_lsp (lsf2_q, lsp2_q, M); |
128ec87489b6
libtwamr: integrate q_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
303 } |