annotate libtwamr/q_plsf_3.c @ 454:4b6fa53a8240

INSTALL: document the new way
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 10 May 2024 06:19:24 +0000
parents 9cca139a20a8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
372
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 *****************************************************************************
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 *
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 * R99 Version 3.3.0
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 * REL-4 Version 4.1.0
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 *
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 ****************************************************************************
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 *
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 * File : q_plsf_3.c
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 * Purpose : Quantization of LSF parameters with 1st order MA
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 * prediction and split by 3 vector quantization
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 * (split-VQ)
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 *
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 *****************************************************************************
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 /*
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 *****************************************************************************
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 * MODULE INCLUDE FILE AND VERSION ID
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 *****************************************************************************
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 #include "namespace.h"
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 #include "q_plsf.h"
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 /*
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 *****************************************************************************
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 * INCLUDE FILES
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 *****************************************************************************
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 #include "typedef.h"
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 #include "basic_op.h"
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 #include "no_count.h"
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 #include "lsp_lsf.h"
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 #include "reorder.h"
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 #include "lsfwt.h"
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 #include "memops.h"
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 #include "q_plsf3_tab.h"
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 /*
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 *****************************************************************************
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 * LOCAL VARIABLES AND TABLES
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 *****************************************************************************
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 #define PAST_RQ_INIT_SIZE 8
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 /*
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 *****************************************************************************
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 * LOCAL PROGRAM CODE
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 *****************************************************************************
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 /* Quantization of a 4 dimensional subvector */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 static Word16
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 Vq_subvec4( /* o: quantization index, Q0 */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 Word16 * lsf_r1, /* i/o: 1st LSF residual vector, Q15 */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 const Word16 * dico, /* i: quantization codebook, Q15 */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 const Word16 * wf1, /* i: 1st LSF weighting factors, Q13 */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 Word16 dico_size) /* i: size of quantization codebook, Q0 */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 {
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 Word16 i, index = 0, temp;
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 const Word16 *p_dico;
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 Word32 dist_min, dist;
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 dist_min = MAX_32; move32 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 p_dico = dico; move16 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 for (i = 0; i < dico_size; i++)
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 {
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 temp = sub (lsf_r1[0], *p_dico++);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 temp = mult (wf1[0], temp);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 dist = L_mult (temp, temp);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 temp = sub (lsf_r1[1], *p_dico++);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 temp = mult (wf1[1], temp);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 dist = L_mac (dist, temp, temp);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 temp = sub (lsf_r1[2], *p_dico++);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 temp = mult (wf1[2], temp);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 dist = L_mac (dist, temp, temp);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 temp = sub (lsf_r1[3], *p_dico++);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 temp = mult (wf1[3], temp);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 dist = L_mac (dist, temp, temp);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 test ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 if (L_sub (dist, dist_min) < (Word32) 0)
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 {
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 dist_min = dist; move32 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 index = i; move16 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 }
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 }
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 /* Reading the selected vector */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 p_dico = &dico[shl (index, 2)]; move16 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 lsf_r1[0] = *p_dico++; move16 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 lsf_r1[1] = *p_dico++; move16 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 lsf_r1[2] = *p_dico++; move16 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 lsf_r1[3] = *p_dico++; move16 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 return index;
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 }
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 /* Quantization of a 3 dimensional subvector */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 static Word16
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 Vq_subvec3( /* o: quantization index, Q0 */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 Word16 * lsf_r1, /* i/o: 1st LSF residual vector, Q15 */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 const Word16 * dico, /* i: quantization codebook, Q15 */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 const Word16 * wf1, /* i: 1st LSF weighting factors, Q13 */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 Word16 dico_size, /* i: size of quantization codebook, Q0 */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 Flag use_half) /* i: use every second entry in codebook */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 {
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 Word16 i, index = 0, temp;
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 const Word16 *p_dico;
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 Word32 dist_min, dist;
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 dist_min = MAX_32; move32 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 p_dico = dico; move16 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 test ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 if (use_half == 0) {
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 for (i = 0; i < dico_size; i++)
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 {
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 temp = sub(lsf_r1[0], *p_dico++);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 temp = mult(wf1[0], temp);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 dist = L_mult(temp, temp);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 temp = sub(lsf_r1[1], *p_dico++);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 temp = mult(wf1[1], temp);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 dist = L_mac(dist, temp, temp);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 temp = sub(lsf_r1[2], *p_dico++);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 temp = mult(wf1[2], temp);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 dist = L_mac(dist, temp, temp);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 test ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 if (L_sub(dist, dist_min) < (Word32) 0) {
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 dist_min = dist; move32 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 index = i; move16 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 }
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 }
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 p_dico = &dico[add(index, add(index, index))]; move16 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 }
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 else
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 {
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 for (i = 0; i < dico_size; i++)
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 {
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149 temp = sub(lsf_r1[0], *p_dico++);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 temp = mult(wf1[0], temp);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 dist = L_mult(temp, temp);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 temp = sub(lsf_r1[1], *p_dico++);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 temp = mult(wf1[1], temp);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 dist = L_mac(dist, temp, temp);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157 temp = sub(lsf_r1[2], *p_dico++);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 temp = mult(wf1[2], temp);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159 dist = L_mac(dist, temp, temp);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161 test ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 if (L_sub(dist, dist_min) < (Word32) 0)
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163 {
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 dist_min = dist; move32 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165 index = i; move16 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166 }
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167 p_dico = p_dico + 3; add(0,0);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168 }
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
169 p_dico = &dico[shl(add(index, add(index, index)),1)]; move16 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
170 }
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
171
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172 /* Reading the selected vector */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173 lsf_r1[0] = *p_dico++; move16 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174 lsf_r1[1] = *p_dico++; move16 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
175 lsf_r1[2] = *p_dico++; move16 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
176
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
177 return index;
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
178 }
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
179
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
180 /*
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
181 *****************************************************************************
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
182 * PUBLIC PROGRAM CODE
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
183 *****************************************************************************
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
184 */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
185
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
186 /***********************************************************************
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
187 *
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
188 * routine: Q_plsf_3()
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
189 *
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
190 * Quantization of LSF parameters with 1st order MA prediction and
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
191 * split by 3 vector quantization (split-VQ)
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
192 *
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
193 ***********************************************************************/
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
194 void Q_plsf_3(
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
195 Q_plsfState *st, /* i/o: state struct */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
196 enum Mode mode, /* i : coder mode */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
197 Word16 *lsp1, /* i : 1st LSP vector Q15 */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
198 Word16 *lsp1_q, /* o : quantized 1st LSP vector Q15 */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
199 Word16 *indice, /* o : quantization indices of 3 vectors Q0 */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
200 Word16 *pred_init_i /* o : init index for MA prediction in DTX mode */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
201 )
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
202 {
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
203 Word16 i, j;
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
204 Word16 lsf1[M], wf1[M], lsf_p[M], lsf_r1[M];
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
205 Word16 lsf1_q[M];
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
206
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
207 Word32 L_pred_init_err;
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
208 Word32 L_min_pred_init_err;
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
209 Word16 temp_r1[M];
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
210 Word16 temp_p[M];
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
211
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
212 /* convert LSFs to normalize frequency domain 0..16384 */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
213
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
214 Lsp_lsf(lsp1, lsf1, M);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
215
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
216 /* compute LSF weighting factors (Q13) */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
217
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
218 Lsf_wt(lsf1, wf1);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
219
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
220 /* Compute predicted LSF and prediction error */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
221 if (test(), sub(mode, MRDTX) != 0)
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
222 {
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
223 for (i = 0; i < M; i++)
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
224 {
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
225 lsf_p[i] = add(mean_lsf3[i],
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
226 mult(st->past_rq[i],
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
227 pred_fac[i])); move16 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
228 lsf_r1[i] = sub(lsf1[i], lsf_p[i]); move16 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
229 }
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
230 }
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
231 else
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
232 {
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
233 /* DTX mode, search the init vector that yields */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
234 /* lowest prediction resuidual energy */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
235 *pred_init_i = 0; move16 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
236 L_min_pred_init_err = 0x7fffffff; /* 2^31 - 1 */ move32 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
237 for (j = 0; j < PAST_RQ_INIT_SIZE; j++)
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
238 {
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
239 L_pred_init_err = 0; move32 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
240 for (i = 0; i < M; i++)
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
241 {
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
242 temp_p[i] = add(mean_lsf3[i], past_rq_init[j*M+i]);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
243 temp_r1[i] = sub(lsf1[i],temp_p[i]);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
244 L_pred_init_err = L_mac(L_pred_init_err, temp_r1[i], temp_r1[i]);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
245 } /* next i */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
246
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
247 test ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
248 if (L_sub(L_pred_init_err, L_min_pred_init_err) < (Word32) 0)
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
249 {
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
250 L_min_pred_init_err = L_pred_init_err; move32 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
251 Copy(temp_r1, lsf_r1, M);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
252 Copy(temp_p, lsf_p, M);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
253
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
254 /* Set zerom */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
255 Copy(&past_rq_init[j*M], st->past_rq, M);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
256 *pred_init_i = j; move16 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
257 } /* endif */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
258 } /* next j */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
259 } /* endif MRDTX */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
260
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
261 /*---- Split-VQ of prediction error ----*/
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
262 if (sub (mode, MR475) == 0 || sub (mode, MR515) == 0)
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
263 { /* MR475, MR515 */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
264 test (); test ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
265
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
266 indice[0] = Vq_subvec3(&lsf_r1[0], dico1_lsf3, &wf1[0], DICO31_SIZE, 0);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
267 move16 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
268 indice[1] = Vq_subvec3(&lsf_r1[3], dico2_lsf3, &wf1[3], DICO32_SIZE/2, 1);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
269 move16 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
270 indice[2] = Vq_subvec4(&lsf_r1[6], mr515_3_lsf, &wf1[6], MR515_3_SIZE);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
271 move16 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
272 }
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
273 else if (sub (mode, MR795) == 0)
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
274 { /* MR795 */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
275 test (); test (); test ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
276
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
277 indice[0] = Vq_subvec3(&lsf_r1[0], mr795_1_lsf, &wf1[0], MR795_1_SIZE, 0);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
278 move16 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
279 indice[1] = Vq_subvec3(&lsf_r1[3], dico2_lsf3, &wf1[3], DICO32_SIZE, 0);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
280 move16 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
281 indice[2] = Vq_subvec4(&lsf_r1[6], dico3_lsf3, &wf1[6], DICO33_SIZE);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
282 move16 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
283 }
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
284 else
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
285 { /* MR59, MR67, MR74, MR102 , MRDTX */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
286 test (); test (); test ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
287
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
288 indice[0] = Vq_subvec3(&lsf_r1[0], dico1_lsf3, &wf1[0], DICO31_SIZE, 0);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
289 move16 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
290 indice[1] = Vq_subvec3(&lsf_r1[3], dico2_lsf3, &wf1[3], DICO32_SIZE, 0);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
291 move16 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
292 indice[2] = Vq_subvec4(&lsf_r1[6], dico3_lsf3, &wf1[6], DICO33_SIZE);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
293 move16 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
294 }
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
295
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
296
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
297 /* Compute quantized LSFs and update the past quantized residual */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
298
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
299 for (i = 0; i < M; i++)
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
300 {
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
301 lsf1_q[i] = add(lsf_r1[i], lsf_p[i]); move16 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
302 st->past_rq[i] = lsf_r1[i]; move16 ();
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
303 }
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
304
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
305 /* verification that LSFs has mimimum distance of LSF_GAP Hz */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
306
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
307 Reorder_lsf(lsf1_q, LSF_GAP, M);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
308
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
309 /* convert LSFs to the cosine domain */
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
310
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
311 Lsf_lsp(lsf1_q, lsp1_q, M);
9cca139a20a8 libtwamr: integrate q_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
312 }