FreeCalypso > hg > gsm-codec-lib
annotate libtwamr/d_plsf_5.c @ 477:4c9222d95647
libtwamr encoder: always emit frame->mode = mode;
In the original implementation of amr_encode_frame(), the 'mode' member
of the output struct was set to 0xFF if the output frame type is TX_NO_DATA.
This design was made to mimic the mode field (16-bit word) being set to
0xFFFF (or -1) in 3GPP test sequence format - but nothing actually depends
on this struct member being set in any way, and amr_frame_to_tseq()
generates the needed 0xFFFF on its own, based on frame->type being equal
to TX_NO_DATA.
It is simpler and more efficient to always set frame->mode to the actual
encoding mode in amr_encode_frame(), and this new behavior has already
been documented in doc/AMR-library-API description in anticipation of
the present change.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 18 May 2024 22:30:42 +0000 |
parents | 29769a9b89d3 |
children |
rev | line source |
---|---|
345
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 ***************************************************************************** |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * |
29769a9b89d3
libtwamr: integrate d_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 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * R99 Version 3.3.0 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * REL-4 Version 4.1.0 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 * |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 ***************************************************************************** |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 * |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 * File : d_plsf_5.c |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 * |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 ***************************************************************************** |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 */ |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 /* |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 ***************************************************************************** |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 * MODULE INCLUDE FILE AND VERSION ID |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 ***************************************************************************** |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 */ |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 #include "namespace.h" |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 #include "d_plsf.h" |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 /* |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 ***************************************************************************** |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 * INCLUDE FILES |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 ***************************************************************************** |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 */ |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 #include "typedef.h" |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 #include "basic_op.h" |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 #include "no_count.h" |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 #include "lsp_lsf.h" |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 #include "reorder.h" |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 #include "cnst.h" |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 #include "memops.h" |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 #include "q_plsf5_tab.h" |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 /* |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 ***************************************************************************** |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 * LOCAL VARIABLES AND TABLES |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 ***************************************************************************** |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 */ |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 /* ALPHA -> 0.95 */ |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 /* ONE_ALPHA-> (1.0-ALPHA) */ |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 #define ALPHA 31128 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 #define ONE_ALPHA 1639 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 /* |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 *--------------------------------------------------* |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 * Constants (defined in cnst.h) * |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 *--------------------------------------------------* |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 * M : LPC order |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 *--------------------------------------------------* |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 */ |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 /* |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 ***************************************************************************** |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 * PUBLIC PROGRAM CODE |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 ***************************************************************************** |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 */ |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 /* |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 ************************************************************************** |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 * |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 * Function : D_plsf_5 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 * Purpose : Decodes the 2 sets of LSP parameters in a frame |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 * using the received quantization indices. |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 * |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 ************************************************************************** |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 */ |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 int D_plsf_5 ( |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 D_plsfState *st, /* i/o: State variables */ |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 Word16 bfi, /* i : bad frame indicator (set to 1 if a bad |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 frame is received) */ |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 Word16 *indice, /* i : quantization indices of 5 submatrices, Q0 */ |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 Word16 *lsp1_q, /* o : quantized 1st LSP vector (M), Q15 */ |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 Word16 *lsp2_q /* o : quantized 2nd LSP vector (M), Q15 */ |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 ) |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 { |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 Word16 i; |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 const Word16 *p_dico; |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 Word16 temp, sign; |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 Word16 lsf1_r[M], lsf2_r[M]; |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 Word16 lsf1_q[M], lsf2_q[M]; |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 test (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 if (bfi != 0) /* if bad frame */ |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 { |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 /* use the past LSFs slightly shifted towards their mean */ |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 for (i = 0; i < M; i++) |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 { |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 /* lsfi_q[i] = ALPHA*st->past_lsf_q[i] + ONE_ALPHA*mean_lsf[i]; */ |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 lsf1_q[i] = add (mult (st->past_lsf_q[i], ALPHA), |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 mult (mean_lsf[i], ONE_ALPHA)); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 lsf2_q[i] = lsf1_q[i]; move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 } |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 /* estimate past quantized residual to be used in next frame */ |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 for (i = 0; i < M; i++) |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 { |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 /* temp = mean_lsf[i] + st->past_r_q[i] * LSP_PRED_FAC_MR122; */ |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 temp = add (mean_lsf[i], mult (st->past_r_q[i], |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 LSP_PRED_FAC_MR122)); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 st->past_r_q[i] = sub (lsf2_q[i], temp); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 } |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 } |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 else |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 /* if good LSFs received */ |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 { |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 /* decode prediction residuals from 5 received indices */ |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 p_dico = &dico1_lsf[shl (indice[0], 2)];move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 lsf1_r[0] = *p_dico++; move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 lsf1_r[1] = *p_dico++; move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 lsf2_r[0] = *p_dico++; move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 lsf2_r[1] = *p_dico++; move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 p_dico = &dico2_lsf[shl (indice[1], 2)];move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 lsf1_r[2] = *p_dico++; move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 lsf1_r[3] = *p_dico++; move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 lsf2_r[2] = *p_dico++; move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 lsf2_r[3] = *p_dico++; move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 sign = indice[2] & 1; logic16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 i = shr (indice[2], 1); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 p_dico = &dico3_lsf[shl (i, 2)]; move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 test (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 if (sign == 0) |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 { |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 lsf1_r[4] = *p_dico++; move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 lsf1_r[5] = *p_dico++; move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 lsf2_r[4] = *p_dico++; move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 lsf2_r[5] = *p_dico++; move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 } |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 else |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 { |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 lsf1_r[4] = negate (*p_dico++); move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 lsf1_r[5] = negate (*p_dico++); move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 lsf2_r[4] = negate (*p_dico++); move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 lsf2_r[5] = negate (*p_dico++); move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 } |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 p_dico = &dico4_lsf[shl (indice[3], 2)];move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 lsf1_r[6] = *p_dico++; move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 lsf1_r[7] = *p_dico++; move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 lsf2_r[6] = *p_dico++; move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 lsf2_r[7] = *p_dico++; move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 p_dico = &dico5_lsf[shl (indice[4], 2)];move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 lsf1_r[8] = *p_dico++; move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 lsf1_r[9] = *p_dico++; move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 lsf2_r[8] = *p_dico++; move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 lsf2_r[9] = *p_dico++; move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 /* Compute quantized LSFs and update the past quantized residual */ |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 for (i = 0; i < M; i++) |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 { |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 temp = add (mean_lsf[i], mult (st->past_r_q[i], |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 LSP_PRED_FAC_MR122)); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 lsf1_q[i] = add (lsf1_r[i], temp); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 lsf2_q[i] = add (lsf2_r[i], temp); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 st->past_r_q[i] = lsf2_r[i]; move16 (); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 } |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 } |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 /* verification that LSFs have minimum distance of LSF_GAP Hz */ |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 Reorder_lsf (lsf1_q, LSF_GAP, M); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 Reorder_lsf (lsf2_q, LSF_GAP, M); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 Copy (lsf2_q, st->past_lsf_q, M); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 /* convert LSFs to the cosine domain */ |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 Lsf_lsp (lsf1_q, lsp1_q, M); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 Lsf_lsp (lsf2_q, lsp2_q, M); |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 return 0; |
29769a9b89d3
libtwamr: integrate d_plsf_5.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 } |