FreeCalypso > hg > gsm-codec-lib
annotate libtwamr/c8_31pf.c @ 403:7e0aeab69b10
libtwamr: integrate spreproc.c
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 06 May 2024 23:11:34 +0000 |
parents | dfd5f159574b |
children |
rev | line source |
---|---|
323
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 ******************************************************************************** |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * R99 Version 3.3.0 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * REL-4 Version 4.1.0 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 * |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 ******************************************************************************** |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 * |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 * File : c8_31pf.c |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 * Purpose : Searches a 31 bit algebraic codebook containing |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 * : 8 pulses in a frame of 40 samples. |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 * : in the same manner as GSM-EFR |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 * |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 ******************************************************************************** |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 /* |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 ******************************************************************************** |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 * MODULE INCLUDE FILE AND VERSION ID |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 ******************************************************************************** |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 #include "namespace.h" |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 #include "c8_31pf.h" |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 /* |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 ******************************************************************************** |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 * INCLUDE FILES |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 ******************************************************************************** |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 #include "typedef.h" |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 #include "basic_op.h" |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 #include "no_count.h" |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 #include "cnst.h" |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 #include "inv_sqrt.h" |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 #include "cor_h.h" |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 #include "set_sign.h" |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 #include "s10_8pf.h" |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 /* |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 ******************************************************************************** |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 * LOCAL VARIABLES AND TABLES |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 ******************************************************************************** |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 #define NB_PULSE 8 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 /* define values/representation for output codevector and sign */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 #define POS_CODE 8191 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 #define NEG_CODE 8191 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 #define POS_SIGN 32767 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 #define NEG_SIGN (Word16) (-32768L) |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 /* |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 ******************************************************************************** |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 * LOCAL PROGRAM CODE |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 ******************************************************************************** |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 /************************************************************************* |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 * |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 * FUNCTION: build_code() |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 * |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 * PURPOSE: Builds the codeword, the filtered codeword and a |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 * linear uncombined version of the index of the |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 * codevector, based on the signs and positions of 8 pulses. |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 * |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 *************************************************************************/ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 static void build_code ( |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 Word16 codvec[], /* i : position of pulses */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 Word16 sign[], /* i : sign of d[n] */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 Word16 cod[], /* o : innovative code vector */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 Word16 h[], /* i : impulse response of weighted synthesis filter*/ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 Word16 y[], /* o : filtered innovative code */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 Word16 sign_indx[], /* o : signs of 4 pulses (signs only) */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 Word16 pos_indx[] /* o : position index of 8 pulses(position only) */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 ) |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 { |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 Word16 i, j, k, track, sign_index, pos_index, _sign[NB_PULSE]; |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 Word16 *p0, *p1, *p2, *p3, *p4, *p5, *p6, *p7; |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 Word32 s; |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 for (i = 0; i < L_CODE; i++) |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 { |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 cod[i] = 0; move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 } |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 for (i = 0; i < NB_TRACK_MR102; i++) |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 { |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 pos_indx[i] = -1; move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 sign_indx[i] = -1; move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 } |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 for (k = 0; k < NB_PULSE; k++) |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 { |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 /* read pulse position */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 i = codvec[k]; move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 /* read sign */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 j = sign[i]; move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 pos_index = shr(i, 2); /* index = pos/4 */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 track = i & 3; logic16 (); /* track = pos%4 */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 test (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 if (j > 0) |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 { |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 cod[i] = add (cod[i], POS_CODE); move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 _sign[k] = POS_SIGN; move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 sign_index = 0; /* bit=0 -> positive pulse */ move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 } |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 else |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 { |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 cod[i] = sub (cod[i], NEG_CODE); move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 _sign[k] = NEG_SIGN; move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 sign_index = 1; move16 (); /* bit=1 => negative pulse */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 /* index = add (index, 8); 1 = negative old code */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 } |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 test (); move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 if (pos_indx[track] < 0) |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 { /* first set first NB_TRACK pulses */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 pos_indx[track] = pos_index; move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 sign_indx[track] = sign_index; move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 } |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 else |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 { /* 2nd row of pulses , test if positions needs to be switched */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 test (); logic16 (); logic16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 if (((sign_index ^ sign_indx[track]) & 1) == 0) |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 { |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 /* sign of 1st pulse == sign of 2nd pulse */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 test (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 if (sub (pos_indx[track], pos_index) <= 0) |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 { /* no swap */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 pos_indx[track + NB_TRACK_MR102] = pos_index; move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 } |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 else |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 { /* swap*/ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 pos_indx[track + NB_TRACK_MR102] = pos_indx[track]; |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 pos_indx[track] = pos_index; move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 sign_indx[track] = sign_index; move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 } |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 } |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 else |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 { |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 /* sign of 1st pulse != sign of 2nd pulse */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 test (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 if (sub (pos_indx[track], pos_index) <= 0) |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 { /*swap*/ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 pos_indx[track + NB_TRACK_MR102] = pos_indx[track]; |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 pos_indx[track] = pos_index; move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 sign_indx[track] = sign_index; move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 } |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 else |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 { /*no swap */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 pos_indx[track + NB_TRACK_MR102] = pos_index; move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 } |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 } |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 } |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 } |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 p0 = h - codvec[0]; move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 p1 = h - codvec[1]; move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 p2 = h - codvec[2]; move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 p3 = h - codvec[3]; move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 p4 = h - codvec[4]; move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 p5 = h - codvec[5]; move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 p6 = h - codvec[6]; move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 p7 = h - codvec[7]; move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 for (i = 0; i < L_CODE; i++) |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 { |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 s = 0; move32 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 s = L_mac (s, *p0++, _sign[0]); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 s = L_mac (s, *p1++, _sign[1]); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 s = L_mac (s, *p2++, _sign[2]); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 s = L_mac (s, *p3++, _sign[3]); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 s = L_mac (s, *p4++, _sign[4]); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 s = L_mac (s, *p5++, _sign[5]); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 s = L_mac (s, *p6++, _sign[6]); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 s = L_mac (s, *p7++, _sign[7]); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 y[i] = round (s); move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 } |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 } |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 /************************************************************************* |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 * |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 * FUNCTION: compress_code() |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 * |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 * PURPOSE: compression of three indeces [0..9] to one 10 bit index |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 * minimizing the phase shift of a bit error. |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 * |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 *************************************************************************/ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 static Word16 compress10 ( |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 Word16 pos_indxA, /* i : signs of 4 pulses (signs only) */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 Word16 pos_indxB, /* i : position index of 8 pulses (pos only) */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 Word16 pos_indxC) /* i : position and sign of 8 pulses (compressed) */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 { |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 Word16 indx, ia,ib,ic; |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 ia = shr(pos_indxA, 1); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 ib = extract_l(L_shr(L_mult(shr(pos_indxB, 1), 5), 1)); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 ic = extract_l(L_shr(L_mult(shr(pos_indxC, 1), 25), 1)); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 indx = shl(add(ia, add(ib, ic)), 3); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 ia = pos_indxA & 1; logic16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 ib = shl((pos_indxB & 1), 1); logic16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 ic = shl((pos_indxC & 1), 2); logic16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
212 indx = add(indx , add(ia, add(ib, ic))); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 return indx; |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 } |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
217 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
218 /************************************************************************* |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
219 * |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
220 * FUNCTION: compress_code() |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
221 * |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
222 * PURPOSE: compression of the linear codewords to 4+three indeces |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
223 * one bit from each pulse is made robust to errors by |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
224 * minimizing the phase shift of a bit error. |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
225 * 4 signs (one for each track) |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
226 * i0,i4,i1 => one index (7+3) bits, 3 LSBs more robust |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
227 * i2,i6,i5 => one index (7+3) bits, 3 LSBs more robust |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
228 * i3,i7 => one index (5+2) bits, 2-3 LSbs more robust |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
229 * |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
230 *************************************************************************/ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
231 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
232 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
233 static void compress_code ( |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
234 Word16 sign_indx[], /* i : signs of 4 pulses (signs only) */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
235 Word16 pos_indx[], /* i : position index of 8 pulses (position only) */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
236 Word16 indx[]) /* o : position and sign of 8 pulses (compressed) */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
237 { |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
238 Word16 i, ia, ib, ic; |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
239 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
240 for (i = 0; i < NB_TRACK_MR102; i++) |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
241 { |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
242 indx[i] = sign_indx[i]; move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
243 } |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
244 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
245 /* First index |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
246 indx[NB_TRACK] = (ia/2+(ib/2)*5 +(ic/2)*25)*8 + ia%2 + (ib%2)*2 + (ic%2)*4; */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
247 move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
248 indx[NB_TRACK_MR102] = compress10(pos_indx[0],pos_indx[4],pos_indx[1]); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
249 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
250 /* Second index |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
251 indx[NB_TRACK+1] = (ia/2+(ib/2)*5 +(ic/2)*25)*8 + ia%2 + (ib%2)*2 + (ic%2)*4; */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
252 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
253 move16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
254 indx[NB_TRACK_MR102+1]= compress10(pos_indx[2],pos_indx[6],pos_indx[5]); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
255 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
256 /* |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
257 Third index |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
258 if ((ib/2)%2 == 1) |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
259 indx[NB_TRACK+2] = ((((4-ia/2) + (ib/2)*5)*32+12)/25)*4 + ia%2 + (ib%2)*2; |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
260 else |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
261 indx[NB_TRACK+2] = ((((ia/2) + (ib/2)*5)*32+12)/25)*4 + ia%2 + (ib%2)*2; |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
262 */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
263 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
264 ib = shr(pos_indx[7], 1) & 1; logic16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
265 test (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
266 if (sub(ib, 1) == 0) |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
267 ia = sub(4, shr(pos_indx[3], 1)); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
268 else |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
269 ia = shr(pos_indx[3], 1); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
270 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
271 ib = extract_l(L_shr(L_mult(shr(pos_indx[7], 1), 5), 1)); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
272 ib = add(shl(add(ia, ib), 5), 12); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
273 ic = shl(mult(ib, 1311), 2); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
274 ia = pos_indx[3] & 1; logic16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
275 ib = shl((pos_indx[7] & 1), 1); logic16 (); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
276 indx[NB_TRACK_MR102+2] = add(ia, add(ib, ic)); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
277 } |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
278 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
279 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
280 /* |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
281 ******************************************************************************** |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
282 * PUBLIC PROGRAM CODE |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
283 ******************************************************************************** |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
284 */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
285 /************************************************************************* |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
286 * |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
287 * FUNCTION: code_8i40_31bits() |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
288 * |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
289 * PURPOSE: Searches a 31 bit algebraic codebook containing 8 pulses |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
290 * in a frame of 40 samples. |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
291 * |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
292 * DESCRIPTION: |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
293 * The code contains 8 nonzero pulses: i0...i7. |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
294 * All pulses can have two possible amplitudes: +1 or -1. |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
295 * The 40 positions in a subframe are divided into 4 tracks of |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
296 * interleaved positions. Each track contains two pulses. |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
297 * The pulses can have the following possible positions: |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
298 * |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
299 * i0, i4 : 0, 4, 8, 12, 16, 20, 24, 28, 32, 36 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
300 * i1, i5 : 1, 5, 9, 13, 17, 21, 25, 29, 33, 37 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
301 * i2, i6 : 2, 6, 10, 14, 18, 22, 26, 30, 34, 38 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
302 * i3, i7 : 3, 7, 11, 15, 19, 23, 27, 31, 35, 39 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
303 * |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
304 * Each pair of pulses require 1 bit for their signs. The positions |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
305 * are encoded together 3,3 and 2 resulting in |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
306 * (7+3) + (7+3) + (5+2) bits for their |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
307 * positions. This results in a 31 (4 sign and 27 pos) bit codebook. |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
308 * The function determines the optimal pulse signs and positions, builds |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
309 * the codevector, and computes the filtered codevector. |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
310 * |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
311 *************************************************************************/ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
312 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
313 void code_8i40_31bits ( |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
314 Word16 x[], /* i : target vector */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
315 Word16 cn[], /* i : residual after long term prediction */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
316 Word16 h[], /* i : impulse response of weighted synthesis |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
317 filter */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
318 Word16 cod[], /* o : algebraic (fixed) codebook excitation */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
319 Word16 y[], /* o : filtered fixed codebook excitation */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
320 Word16 indx[] /* o : 7 Word16, index of 8 pulses (signs+positions) */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
321 ) |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
322 { |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
323 Word16 ipos[NB_PULSE], pos_max[NB_TRACK_MR102], codvec[NB_PULSE]; |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
324 Word16 dn[L_CODE], sign[L_CODE]; |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
325 Word16 rr[L_CODE][L_CODE]; |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
326 Word16 linear_signs[NB_TRACK_MR102]; |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
327 Word16 linear_codewords[NB_PULSE]; |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
328 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
329 cor_h_x2 (h, x, dn, 2, NB_TRACK_MR102, STEP_MR102); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
330 /* 2 = use GSMEFR scaling */ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
331 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
332 set_sign12k2 (dn, cn, sign, pos_max, NB_TRACK_MR102, ipos, STEP_MR102); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
333 /* same setsign alg as GSM-EFR new constants though*/ |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
334 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
335 cor_h (h, sign, rr); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
336 search_10and8i40 (NB_PULSE, STEP_MR102, NB_TRACK_MR102, |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
337 dn, rr, ipos, pos_max, codvec); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
338 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
339 build_code (codvec, sign, cod, h, y, linear_signs, linear_codewords); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
340 compress_code (linear_signs, linear_codewords, indx); |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
341 |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
342 return; |
dfd5f159574b
libtwamr: integrate c8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
343 } |