annotate libtwamr/d8_31pf.c @ 483:4f13db3a7086

doc/Utils-overview: document new utilities
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 20 May 2024 01:26:12 +0000
parents 03198f6b0427
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
335
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 ********************************************************************************
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 *
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 * R99 Version 3.3.0
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 * REL-4 Version 4.1.0
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 *
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 ********************************************************************************
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 *
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 * File : d8_31pf.c
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 * Purpose : Builds the innovative codevector
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 *
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 ********************************************************************************
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 */
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 /*
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 ********************************************************************************
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 * MODULE INCLUDE FILE AND VERSION ID
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 ********************************************************************************
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 */
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 #include "namespace.h"
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 #include "d8_31pf.h"
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 /*
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 ********************************************************************************
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 * INCLUDE FILES
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 ********************************************************************************
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 */
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 #include "typedef.h"
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 #include "basic_op.h"
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 #include "no_count.h"
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 #include "cnst.h"
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 /*
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 ********************************************************************************
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 * LOCAL VARIABLES AND TABLES
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 ********************************************************************************
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 */
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 #define NB_PULSE 8 /* number of pulses */
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 /* define values/representation for output codevector and sign */
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 #define POS_CODE 8191
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 #define NEG_CODE 8191
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 static void decompress10 (
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 Word16 MSBs, /* i : MSB part of the index */
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 Word16 LSBs, /* i : LSB part of the index */
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 Word16 index1, /* i : index for first pos in pos_index[] */
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 Word16 index2, /* i : index for second pos in pos_index[] */
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 Word16 index3, /* i : index for third pos in pos_index[] */
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 Word16 pos_indx[]) /* o : position of 3 pulses (decompressed) */
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 {
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 Word16 ia, ib, ic;
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 /*
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 pos_indx[index1] = ((MSBs-25*(MSBs/25))%5)*2 + (LSBs-4*(LSBs/4))%2;
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 pos_indx[index2] = ((MSBs-25*(MSBs/25))/5)*2 + (LSBs-4*(LSBs/4))/2;
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 pos_indx[index3] = (MSBs/25)*2 + LSBs/4;
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 */
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 test ();
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 if (sub(MSBs, 124) > 0)
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 {
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 MSBs = 124; move16 ();
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 }
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 ia = mult(MSBs, 1311);
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 ia = sub(MSBs, extract_l(L_shr(L_mult(ia, 25), 1)));
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 ib = shl(sub(ia, extract_l(L_shr(L_mult(mult(ia, 6554), 5), 1))), 1);
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 ic = shl(shr(LSBs, 2), 2);
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 ic = sub(LSBs, ic);
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 pos_indx[index1] = add(ib, (ic & 1)); logic16 ();
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 ib = shl(mult(ia, 6554), 1);
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 pos_indx[index2] = add(ib, shr(ic, 1));
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 pos_indx[index3] = add(shl(mult(MSBs, 1311), 1), shr(LSBs, 2));
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 return;
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 }
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 /*************************************************************************
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 *
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 * FUNCTION: decompress_code()
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 *
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 * PURPOSE: decompression of the linear codewords to 4+three indeces
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 * one bit from each pulse is made robust to errors by
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 * minimizing the phase shift of a bit error.
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 * 4 signs (one for each track)
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 * i0,i4,i1 => one index (7+3) bits, 3 LSBs more robust
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 * i2,i6,i5 => one index (7+3) bits, 3 LSBs more robust
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 * i3,i7 => one index (5+2) bits, 2-3 LSbs more robust
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 *
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 *************************************************************************/
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 static void decompress_code (
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 Word16 indx[], /* i : position and sign of 8 pulses (compressed) */
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 Word16 sign_indx[], /* o : signs of 4 pulses (signs only) */
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 Word16 pos_indx[] /* o : position index of 8 pulses (position only) */
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 )
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 {
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 Word16 i, ia, ib, MSBs, LSBs, MSBs0_24;
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 for (i = 0; i < NB_TRACK_MR102; i++)
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 {
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 sign_indx[i] = indx[i]; move16 ();
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 }
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 /*
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 First index: 10x10x10 -> 2x5x2x5x2x5-> 125x2x2x2 -> 7+1x3 bits
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 MSBs = indx[NB_TRACK]/8;
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 LSBs = indx[NB_TRACK]%8;
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 */
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 MSBs = shr(indx[NB_TRACK_MR102], 3);
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 LSBs = indx[NB_TRACK_MR102] & 7; logic16 ();
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 decompress10 (MSBs, LSBs, 0, 4, 1, pos_indx);
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 /*
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 Second index: 10x10x10 -> 2x5x2x5x2x5-> 125x2x2x2 -> 7+1x3 bits
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 MSBs = indx[NB_TRACK+1]/8;
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 LSBs = indx[NB_TRACK+1]%8;
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 */
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 MSBs = shr(indx[NB_TRACK_MR102+1], 3);
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 LSBs = indx[NB_TRACK_MR102+1] & 7; logic16 ();
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 decompress10 (MSBs, LSBs, 2, 6, 5, pos_indx);
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 /*
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 Third index: 10x10 -> 2x5x2x5-> 25x2x2 -> 5+1x2 bits
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 MSBs = indx[NB_TRACK+2]/4;
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 LSBs = indx[NB_TRACK+2]%4;
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 MSBs0_24 = (MSBs*25+12)/32;
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 if ((MSBs0_24/5)%2==1)
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 pos_indx[3] = (4-(MSBs0_24%5))*2 + LSBs%2;
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 else
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 pos_indx[3] = (MSBs0_24%5)*2 + LSBs%2;
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 pos_indx[7] = (MSBs0_24/5)*2 + LSBs/2;
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 */
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 MSBs = shr(indx[NB_TRACK_MR102+2], 2);
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 LSBs = indx[NB_TRACK_MR102+2] & 3; logic16 ();
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 MSBs0_24 = shr(add(extract_l(L_shr(L_mult(MSBs, 25), 1)), 12), 5);
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 ia = mult(MSBs0_24, 6554) & 1;
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 ib = sub(MSBs0_24, extract_l(L_shr(L_mult(mult(MSBs0_24, 6554), 5), 1)));
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 test ();
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 if (sub(ia, 1) == 0)
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 {
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149 ib = sub(4, ib);
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 }
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 pos_indx[3] = add(shl(ib, 1), (LSBs & 1)); logic16 ();
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 ia = shl(mult(MSBs0_24, 6554), 1);
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 pos_indx[7] = add(ia, shr(LSBs, 1));
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 }
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157 /*
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 ********************************************************************************
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159 * PUBLIC PROGRAM CODE
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 ********************************************************************************
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161 */
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 /*************************************************************************
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163 *
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 * FUNCTION: dec_8i40_31bits()
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165 *
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166 * PURPOSE: Builds the innovative codevector from the received
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167 * index of algebraic codebook.
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168 *
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
169 * See c8_31pf.c for more details about the algebraic codebook structure.
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
170 *
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
171 *************************************************************************/
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173 void dec_8i40_31bits (
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174 Word16 index[], /* i : index of 8 pulses (sign+position) */
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
175 Word16 cod[] /* o : algebraic (fixed) codebook excitation */
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
176 )
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
177 {
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
178 Word16 i, j, pos1, pos2, sign;
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
179 Word16 linear_signs[NB_TRACK_MR102];
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
180 Word16 linear_codewords[NB_PULSE];
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
181
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
182 for (i = 0; i < L_CODE; i++)
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
183 {
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
184 cod[i] = 0; move16 ();
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
185 }
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
186
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
187 decompress_code (index, linear_signs, linear_codewords);
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
188
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
189 /* decode the positions and signs of pulses and build the codeword */
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
190
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
191 for (j = 0; j < NB_TRACK_MR102; j++)
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
192 {
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
193 /* compute index i */
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
194
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
195 i = linear_codewords[j];
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
196 i = extract_l (L_shr (L_mult (i, 4), 1));
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
197 pos1 = add (i, j); /* position of pulse "j" */
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
198
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
199 test ();
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
200 if (linear_signs[j] == 0)
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
201 {
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
202 sign = POS_CODE; move16 (); /* +1.0 */
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
203 }
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
204 else
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
205 {
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
206 sign = -NEG_CODE; move16 (); /* -1.0 */
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
207 }
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
208
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
209 cod[pos1] = sign; move16 ();
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
210
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
211 /* compute index i */
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
212
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
213 i = linear_codewords[add (j, 4)];
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
214 i = extract_l (L_shr (L_mult (i, 4), 1));
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
215 pos2 = add (i, j); /* position of pulse "j+4" */
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
216
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
217 test ();
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
218 if (sub (pos2, pos1) < 0)
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
219 {
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
220 sign = negate (sign);
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
221 }
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
222 cod[pos2] = add (cod[pos2], sign); move16 ();
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
223 }
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
224
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
225 return;
03198f6b0427 libtwamr: integrate d8_31pf.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
226 }