annotate libtwamr/d_plsf_3.c @ 501:597b39aef484

libgsmhr1/mathhalf.h: rm unused declarations for non-saturating functions
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 19 Jun 2024 00:54:44 +0000
parents 05a46720af0f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
344
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 ********************************************************************************
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 *
05a46720af0f libtwamr: integrate d_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
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 * R99 Version 3.3.0
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 * REL-4 Version 4.1.0
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 *
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 ********************************************************************************
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 *
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 * File : d_plsf_3.c
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 * Purpose : Decodes the LSP parameters using the received
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 * quantization indices. 1st order MA prediction and
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 * split by 3 vector quantization (split-VQ)
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 *
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 ********************************************************************************
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 */
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 /*
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 ********************************************************************************
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 * MODULE INCLUDE FILE AND VERSION ID
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 ********************************************************************************
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 */
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 #include "namespace.h"
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 #include "d_plsf.h"
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 /*
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 ********************************************************************************
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 * INCLUDE FILES
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 ********************************************************************************
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 */
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 #include "typedef.h"
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 #include "basic_op.h"
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 #include "no_count.h"
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 #include "lsp_lsf.h"
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 #include "reorder.h"
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 #include "memops.h"
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 #include "q_plsf3_tab.h"
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 /*
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 ********************************************************************************
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 * LOCAL VARIABLES AND TABLES
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 ********************************************************************************
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 */
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 /* ALPHA -> 0.9 */
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 /* ONE_ALPHA-> (1.0-ALPHA) */
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 #define ALPHA 29491
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 #define ONE_ALPHA 3277
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 /*
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 ********************************************************************************
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 * PUBLIC PROGRAM CODE
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 ********************************************************************************
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 */
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 /*************************************************************************
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 *
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 * FUNCTION: D_plsf_3()
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 *
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 * PURPOSE: Decodes the LSP parameters using the received quantization
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 * indices.1st order MA prediction and split by 3 vector
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 * quantization (split-VQ)
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 *
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 *************************************************************************/
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 void D_plsf_3(
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 D_plsfState *st, /* i/o: State struct */
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 enum Mode mode, /* i : coder mode */
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 Word16 bfi, /* i : bad frame indicator (set to 1 if a */
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 /* bad frame is received) */
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 Word16 * indice, /* i : quantization indices of 3 submatrices, Q0 */
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 Word16 * lsp1_q /* o : quantized 1st LSP vector, Q15 */
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 )
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 {
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 Word16 i, index;
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 const Word16 *p_cb1, *p_cb2, *p_cb3, *p_dico;
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 Word16 temp;
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 Word16 lsf1_r[M];
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 Word16 lsf1_q[M];
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 test ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 if (bfi != 0) /* if bad frame */
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 {
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 /* use the past LSFs slightly shifted towards their mean */
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 for (i = 0; i < M; i++)
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 {
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 /* lsfi_q[i] = ALPHA*past_lsf_q[i] + ONE_ALPHA*mean_lsf3[i]; */
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 lsf1_q[i] = add(mult(st->past_lsf_q[i], ALPHA),
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 mult(mean_lsf3[i], ONE_ALPHA));
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 move16 ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 }
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 /* estimate past quantized residual to be used in next frame */
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 test();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 if (sub(mode, MRDTX) != 0) {
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 for (i = 0; i < M; i++) {
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 /* temp = mean_lsf3[i] + past_r2_q[i] * PRED_FAC; */
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 temp = add(mean_lsf3[i], mult(st->past_r_q[i], pred_fac[i]));
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 st->past_r_q[i] = sub(lsf1_q[i], temp); move16 ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 }
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 } else {
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 for (i = 0; i < M; i++) {
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 /* temp = mean_lsf3[i] + past_r2_q[i]; */
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 temp = add(mean_lsf3[i], st->past_r_q[i]);
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 st->past_r_q[i] = sub(lsf1_q[i], temp); move16 ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 }
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 }
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 }
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 else /* if good LSFs received */
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 {
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 test (); test ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 if (sub (mode, MR475) == 0 || sub (mode, MR515) == 0)
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 { /* MR475, MR515 */
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 p_cb1 = dico1_lsf3; move16 ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 p_cb2 = dico2_lsf3; move16 ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 p_cb3 = mr515_3_lsf; move16 ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 }
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 else if (sub (mode, MR795) == 0)
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 { /* MR795 */
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 test();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 p_cb1 = mr795_1_lsf; move16 ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 p_cb2 = dico2_lsf3; move16 ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 p_cb3 = dico3_lsf3; move16 ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 }
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 else
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 { /* MR59, MR67, MR74, MR102, MRDTX */
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 test();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 p_cb1 = dico1_lsf3; move16 ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 p_cb2 = dico2_lsf3; move16 ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 p_cb3 = dico3_lsf3; move16 ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 }
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 /* decode prediction residuals from 3 received indices */
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 index = *indice++; move16 ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 p_dico = &p_cb1[add(index, add(index, index))]; move16 ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 lsf1_r[0] = *p_dico++; move16 ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 lsf1_r[1] = *p_dico++; move16 ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 lsf1_r[2] = *p_dico++; move16 ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 index = *indice++; move16 ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 test (); test ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149 if ((sub (mode, MR475) == 0) || (sub (mode, MR515) == 0))
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 { /* MR475, MR515 only using every second entry */
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 index = shl(index,1);
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 }
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 p_dico = &p_cb2[add(index, add(index, index))]; move16 ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 lsf1_r[3] = *p_dico++; move16 ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156 lsf1_r[4] = *p_dico++; move16 ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157 lsf1_r[5] = *p_dico++; move16 ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159 index = *indice++; move16 ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 p_dico = &p_cb3[shl(index, 2)]; move16 ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161 lsf1_r[6] = *p_dico++; move16 ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 lsf1_r[7] = *p_dico++; move16 ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163 lsf1_r[8] = *p_dico++; move16 ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 lsf1_r[9] = *p_dico++; move16 ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166 /* Compute quantized LSFs and update the past quantized residual */
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168 if (sub(mode, MRDTX) != 0)
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
169 for (i = 0; i < M; i++) {
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
170 temp = add(mean_lsf3[i], mult(st->past_r_q[i], pred_fac[i]));
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
171 lsf1_q[i] = add(lsf1_r[i], temp); move16 ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172 st->past_r_q[i] = lsf1_r[i]; move16 ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173 }
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174 else
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
175 for (i = 0; i < M; i++) {
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
176 temp = add(mean_lsf3[i], st->past_r_q[i]);
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
177 lsf1_q[i] = add(lsf1_r[i], temp); move16 ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
178 st->past_r_q[i] = lsf1_r[i]; move16 ();
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
179 }
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
180 }
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
181
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
182 /* verification that LSFs has minimum distance of LSF_GAP Hz */
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
183
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
184 Reorder_lsf(lsf1_q, LSF_GAP, M);
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
185
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
186 Copy (lsf1_q, st->past_lsf_q, M);
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
187
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
188 /* convert LSFs to the cosine domain */
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
189
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
190 Lsf_lsp(lsf1_q, lsp1_q, M);
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
191
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
192 return;
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
193 }
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
194
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
195 void Init_D_plsf_3(D_plsfState *st, /* i/o: State struct */
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
196 Word16 index /* i : past_rq_init[] index [0, 7] */)
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
197 {
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
198 Copy(&past_rq_init[index * M], st->past_r_q, M);
05a46720af0f libtwamr: integrate d_plsf_3.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
199 }