annotate libtwamr/c3_14pf.c @ 556:18aca50d68df default tip

doc/Calypso-TCH-downlink: update for FR1 BFI-with-data
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 11 Oct 2024 01:54:00 +0000
parents 5fc9a2d12048
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
321
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 ********************************************************************************
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 *
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 * R99 Version 3.3.0
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 * REL-4 Version 4.1.0
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 *
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 ********************************************************************************
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 *
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 * File : c3_14pf.c
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 * Purpose : Searches a 14 bit algebraic codebook containing 3 pulses
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 * in a frame of 40 samples.
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 *
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 ********************************************************************************
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 /*
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 ********************************************************************************
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 * MODULE INCLUDE FILE AND VERSION ID
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 ********************************************************************************
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 #include "namespace.h"
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 #include "c3_14pf.h"
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 /*
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 ********************************************************************************
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 * INCLUDE FILES
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 ********************************************************************************
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 #include "typedef.h"
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 #include "basic_op.h"
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 #include "no_count.h"
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 #include "inv_sqrt.h"
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 #include "cnst.h"
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 #include "cor_h.h"
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 #include "set_sign.h"
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 /*
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 ********************************************************************************
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 * LOCAL VARIABLES AND TABLES
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 ********************************************************************************
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 #define NB_PULSE 3
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 /*
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 ********************************************************************************
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 * DECLARATION OF PROTOTYPES
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 ********************************************************************************
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 static void search_3i40(
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 Word16 dn[], /* i : correlation between target and h[] */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 Word16 dn2[], /* i : maximum of corr. in each track. */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 Word16 rr[][L_CODE],/* i : matrix of autocorrelation */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 Word16 codvec[] /* o : algebraic codebook vector */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 );
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 static Word16 build_code(
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 Word16 codvec[], /* i : algebraic codebook vector */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 Word16 dn_sign[], /* i : sign of dn[] */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 Word16 cod[], /* o : algebraic (fixed) codebook excitation */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 Word16 h[], /* i : impulse response of weighted synthesis filter */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 Word16 y[], /* o : filtered fixed codebook excitation */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 Word16 sign[] /* o : sign of 3 pulses */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 );
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 /*
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 ********************************************************************************
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 * PUBLIC PROGRAM CODE
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 ********************************************************************************
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 /*************************************************************************
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 *
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 * FUNCTION: code_3i40_14bits()
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 *
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 * PURPOSE: Searches a 14 bit algebraic codebook containing 3 pulses
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 * in a frame of 40 samples.
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 *
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 * DESCRIPTION:
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 * The code length is 40, containing 3 nonzero pulses: i0...i2.
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 * All pulses can have two possible amplitudes: +1 or -1.
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 * Pulse i0 can have 8 possible positions, pulses i1 and i2 can have
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 * 2x8=16 positions.
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 *
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 * i0 : 0, 5, 10, 15, 20, 25, 30, 35.
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 * i1 : 1, 6, 11, 16, 21, 26, 31, 36.
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 * 3, 8, 13, 18, 23, 28, 33, 38.
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 * i2 : 2, 7, 12, 17, 22, 27, 32, 37.
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 * 4, 9, 14, 19, 24, 29, 34, 39.
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 *
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 *************************************************************************/
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 Word16 code_3i40_14bits(
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 Word16 x[], /* i : target vector */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 Word16 h[], /* i : impulse response of weighted synthesis filter */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 /* h[-L_subfr..-1] must be set to zero. */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 Word16 T0, /* i : Pitch lag */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 Word16 pitch_sharp, /* i : Last quantized pitch gain */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 Word16 code[], /* o : Innovative codebook */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 Word16 y[], /* o : filtered fixed codebook excitation */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 Word16 * sign /* o : Signs of 3 pulses */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 )
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 {
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 Word16 codvec[NB_PULSE];
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 Word16 dn[L_CODE], dn2[L_CODE], dn_sign[L_CODE];
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 Word16 rr[L_CODE][L_CODE];
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 Word16 i, index, sharp;
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 sharp = shl(pitch_sharp, 1);
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 test ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 if (sub(T0, L_CODE) < 0)
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 {
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 for (i = T0; i < L_CODE; i++) {
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 h[i] = add(h[i], mult(h[i - T0], sharp)); move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 }
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 }
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 cor_h_x(h, x, dn, 1);
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 set_sign(dn, dn_sign, dn2, 6);
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 cor_h(h, dn_sign, rr);
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 search_3i40(dn, dn2, rr, codvec);
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 move16 (); /* function result */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 index = build_code(codvec, dn_sign, code, h, y, sign);
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 /*-----------------------------------------------------------------*
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 * Compute innovation vector gain. *
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 * Include fixed-gain pitch contribution into code[]. *
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 *-----------------------------------------------------------------*/
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 test ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 if (sub(T0, L_CODE) < 0)
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 {
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 for (i = T0; i < L_CODE; i++) {
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 code[i] = add(code[i], mult(code[i - T0], sharp)); move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 }
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 }
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 return index;
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 }
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 /*
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 ********************************************************************************
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 * PRIVATE PROGRAM CODE
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 ********************************************************************************
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 /*************************************************************************
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 *
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 * FUNCTION search_3i40()
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 *
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149 * PURPOSE: Search the best codevector; determine positions of the 3 pulses
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 * in the 40-sample frame.
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 *
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 *************************************************************************/
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 #define _1_2 (Word16)(32768L/2)
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 #define _1_4 (Word16)(32768L/4)
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156 #define _1_8 (Word16)(32768L/8)
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157 #define _1_16 (Word16)(32768L/16)
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159 static void search_3i40(
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 Word16 dn[], /* i : correlation between target and h[] */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161 Word16 dn2[], /* i : maximum of corr. in each track. */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 Word16 rr[][L_CODE], /* i : matrix of autocorrelation */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163 Word16 codvec[] /* o : algebraic codebook vector */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 )
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165 {
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166 Word16 i0, i1, i2;
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167 Word16 ix = 0; /* initialization only needed to keep gcc silent */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168 Word16 ps = 0; /* initialization only needed to keep gcc silent */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
169 Word16 i, pos, track1, track2, ipos[NB_PULSE];
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
170 Word16 psk, ps0, ps1, sq, sq1;
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
171 Word16 alpk, alp, alp_16;
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172 Word32 s, alp0, alp1;
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174 psk = -1; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
175 alpk = 1; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
176 for (i = 0; i < NB_PULSE; i++)
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
177 {
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
178 codvec[i] = i; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
179 }
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
180
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
181 for (track1 = 1; track1 < 4; track1 += 2)
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
182 {
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
183 for (track2 = 2; track2 < 5; track2 += 2)
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
184 {
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
185 /* fix starting position */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
186
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
187 ipos[0] = 0; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
188 ipos[1] = track1; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
189 ipos[2] = track2; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
190
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
191 /*------------------------------------------------------------------*
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
192 * main loop: try 3 tracks. *
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
193 *------------------------------------------------------------------*/
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
194
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
195 for (i = 0; i < NB_PULSE; i++)
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
196 {
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
197 /*----------------------------------------------------------------*
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
198 * i0 loop: try 8 positions. *
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
199 *----------------------------------------------------------------*/
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
200
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
201 move16 (); /* account for ptr. init. (rr[io]) */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
202 for (i0 = ipos[0]; i0 < L_CODE; i0 += STEP)
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
203 {
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
204 test ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
205 if (dn2[i0] >= 0)
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
206 {
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
207 ps0 = dn[i0]; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
208 alp0 = L_mult(rr[i0][i0], _1_4);
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
209
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
210 /*----------------------------------------------------------------*
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
211 * i1 loop: 8 positions. *
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
212 *----------------------------------------------------------------*/
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
213
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
214 sq = -1; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
215 alp = 1; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
216 ps = 0; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
217 ix = ipos[1]; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
218
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
219 /* initialize 4 index for next loop. */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
220 /*-------------------------------------------------------------------*
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
221 * These index have low complexity address computation because *
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
222 * they are, in fact, pointers with fixed increment. For example, *
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
223 * "rr[i0][i2]" is a pointer initialized to "&rr[i0][ipos[2]]" *
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
224 * and incremented by "STEP". *
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
225 *-------------------------------------------------------------------*/
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
226
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
227 move16 (); /* account for ptr. init. (rr[i1]) */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
228 move16 (); /* account for ptr. init. (dn[i1]) */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
229 move16 (); /* account for ptr. init. (rr[io]) */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
230 for (i1 = ipos[1]; i1 < L_CODE; i1 += STEP)
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
231 {
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
232 ps1 = add(ps0, dn[i1]); /* idx increment = STEP */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
233
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
234 /* alp1 = alp0 + rr[i0][i1] + 1/2*rr[i1][i1]; */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
235
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
236 alp1 = L_mac(alp0, rr[i1][i1], _1_4); /* idx incr = STEP */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
237 alp1 = L_mac(alp1, rr[i0][i1], _1_2); /* idx incr = STEP */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
238
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
239 sq1 = mult(ps1, ps1);
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
240
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
241 alp_16 = round(alp1);
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
242
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
243 s = L_msu(L_mult(alp, sq1), sq, alp_16);
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
244
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
245 test ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
246 if (s > 0)
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
247 {
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
248 sq = sq1; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
249 ps = ps1; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
250 alp = alp_16; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
251 ix = i1; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
252 }
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
253 }
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
254 i1 = ix; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
255
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
256 /*----------------------------------------------------------------*
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
257 * i2 loop: 8 positions. *
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
258 *----------------------------------------------------------------*/
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
259
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
260 ps0 = ps; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
261 alp0 = L_mult(alp, _1_4);
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
262
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
263 sq = -1; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
264 alp = 1; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
265 ps = 0; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
266 ix = ipos[2]; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
267
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
268 /* initialize 4 index for next loop (see i1 loop) */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
269
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
270 move16 (); /* account for ptr. init. (rr[i2]) */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
271 move16 (); /* account for ptr. init. (rr[i1]) */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
272 move16 (); /* account for ptr. init. (dn[i2]) */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
273 move16 (); /* account for ptr. init. (rr[io]) */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
274 for (i2 = ipos[2]; i2 < L_CODE; i2 += STEP)
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
275 {
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
276 ps1 = add(ps0, dn[i2]); /* index increment = STEP */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
277
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
278 /* alp1 = alp0 + rr[i0][i2] + rr[i1][i2] + 1/2*rr[i2][i2]; */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
279
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
280 alp1 = L_mac(alp0, rr[i2][i2], _1_16); /* idx incr = STEP */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
281 alp1 = L_mac(alp1, rr[i1][i2], _1_8); /* idx incr = STEP */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
282 alp1 = L_mac(alp1, rr[i0][i2], _1_8); /* idx incr = STEP */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
283
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
284 sq1 = mult(ps1, ps1);
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
285
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
286 alp_16 = round(alp1);
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
287
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
288 s = L_msu(L_mult(alp, sq1), sq, alp_16);
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
289
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
290 test ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
291 if (s > 0)
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
292 {
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
293 sq = sq1; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
294 ps = ps1; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
295 alp = alp_16; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
296 ix = i2; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
297 }
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
298 }
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
299 i2 = ix; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
300
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
301 /*----------------------------------------------------------------*
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
302 * memorise codevector if this one is better than the last one. *
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
303 *----------------------------------------------------------------*/
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
304
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
305 s = L_msu(L_mult(alpk, sq), psk, alp);
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
306
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
307 test ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
308 if (s > 0)
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
309 {
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
310 psk = sq; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
311 alpk = alp; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
312 codvec[0] = i0; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
313 codvec[1] = i1; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
314 codvec[2] = i2; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
315 }
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
316 }
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
317 }
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
318 /*----------------------------------------------------------------*
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
319 * Cyclic permutation of i0, i1 and i2. *
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
320 *----------------------------------------------------------------*/
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
321
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
322 pos = ipos[2]; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
323 ipos[2] = ipos[1]; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
324 ipos[1] = ipos[0]; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
325 ipos[0] = pos; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
326 }
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
327 }
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
328 }
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
329 return;
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
330 }
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
331
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
332 /*************************************************************************
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
333 *
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
334 * FUNCTION: build_code()
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
335 *
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
336 * PURPOSE: Builds the codeword, the filtered codeword and index of the
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
337 * codevector, based on the signs and positions of 3 pulses.
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
338 *
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
339 *************************************************************************/
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
340
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
341 static Word16
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
342 build_code(
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
343 Word16 codvec[], /* i : position of pulses */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
344 Word16 dn_sign[], /* i : sign of pulses */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
345 Word16 cod[], /* o : innovative code vector */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
346 Word16 h[], /* i : impulse response of weighted synthesis filter */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
347 Word16 y[], /* o : filtered innovative code */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
348 Word16 sign[] /* o : sign of 3 pulses */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
349 )
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
350 {
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
351 Word16 i, j, k, track, index, _sign[NB_PULSE], indx, rsign;
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
352 Word16 *p0, *p1, *p2;
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
353 Word32 s;
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
354
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
355 for (i = 0; i < L_CODE; i++) {
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
356 cod[i] = 0; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
357 }
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
358
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
359 indx = 0; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
360 rsign = 0; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
361 for (k = 0; k < NB_PULSE; k++)
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
362 {
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
363 i = codvec[k]; move16 (); /* read pulse position */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
364 j = dn_sign[i]; move16 (); /* read sign */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
365
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
366 index = mult(i, 6554); /* index = pos/5 */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
367 /* track = pos%5 */
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
368 track = sub(i, extract_l(L_shr(L_mult(index, 5), 1)));
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
369
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
370 test ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
371 if (sub(track, 1) == 0)
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
372 index = shl(index, 4);
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
373 else if (sub(track, 2) == 0)
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
374 {
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
375 test ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
376 track = 2; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
377 index = shl(index, 8);
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
378 }
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
379 else if (sub(track, 3) == 0)
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
380 {
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
381 test (); test ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
382 track = 1; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
383 index = add(shl(index, 4), 8);
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
384 }
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
385 else if (sub(track, 4) == 0)
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
386 {
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
387 test (); test (); test ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
388 track = 2; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
389 index = add(shl(index, 8), 128);
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
390 }
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
391
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
392 test ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
393 if (j > 0)
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
394 {
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
395 cod[i] = 8191; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
396 _sign[k] = 32767; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
397 rsign = add(rsign, shl(1, track));
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
398 } else {
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
399 cod[i] = -8192; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
400 _sign[k] = (Word16) - 32768L; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
401 }
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
402
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
403 indx = add(indx, index);
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
404 }
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
405 *sign = rsign; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
406
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
407 p0 = h - codvec[0]; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
408 p1 = h - codvec[1]; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
409 p2 = h - codvec[2]; move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
410
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
411 for (i = 0; i < L_CODE; i++)
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
412 {
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
413 s = 0; move32 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
414 s = L_mac(s, *p0++, _sign[0]);
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
415 s = L_mac(s, *p1++, _sign[1]);
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
416 s = L_mac(s, *p2++, _sign[2]);
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
417 y[i] = round(s); move16 ();
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
418 }
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
419
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
420 return indx;
5fc9a2d12048 libtwamr: integrate c3_14pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
421 }