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