FreeCalypso > hg > gsm-codec-lib
comparison libtwamr/d3_14pf.c @ 333:f4a5545ea8b2
libtwamr: integrate d3_14pf.c
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 18 Apr 2024 22:23:42 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
332:2303ba1490dd | 333:f4a5545ea8b2 |
---|---|
1 /* | |
2 ******************************************************************************** | |
3 * | |
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001 | |
5 * R99 Version 3.3.0 | |
6 * REL-4 Version 4.1.0 | |
7 * | |
8 ******************************************************************************** | |
9 * | |
10 * File : d3_14pf.c | |
11 * Purpose : Algebraic codebook decoder | |
12 * | |
13 ******************************************************************************** | |
14 */ | |
15 | |
16 /* | |
17 ******************************************************************************** | |
18 * MODULE INCLUDE FILE AND VERSION ID | |
19 ******************************************************************************** | |
20 */ | |
21 #include "namespace.h" | |
22 #include "d3_14pf.h" | |
23 | |
24 /* | |
25 ******************************************************************************** | |
26 * INCLUDE FILES | |
27 ******************************************************************************** | |
28 */ | |
29 #include "typedef.h" | |
30 #include "basic_op.h" | |
31 #include "no_count.h" | |
32 #include "cnst.h" | |
33 | |
34 /* | |
35 ******************************************************************************** | |
36 * LOCAL VARIABLES AND TABLES | |
37 ******************************************************************************** | |
38 */ | |
39 #define NB_PULSE 3 /* number of pulses */ | |
40 | |
41 /* | |
42 ******************************************************************************** | |
43 * PUBLIC PROGRAM CODE | |
44 ******************************************************************************** | |
45 */ | |
46 /************************************************************************* | |
47 * | |
48 * FUNCTION: decode_3i40_14bits (decod_ACELP()) | |
49 * | |
50 * PURPOSE: Algebraic codebook decoder | |
51 * | |
52 *************************************************************************/ | |
53 | |
54 void decode_3i40_14bits( | |
55 Word16 sign, /* i : signs of 3 pulses. */ | |
56 Word16 index, /* i : Positions of the 3 pulses. */ | |
57 Word16 cod[] /* o : algebraic (fixed) codebook excitation */ | |
58 ) | |
59 { | |
60 Word16 i, j; | |
61 Word16 pos[NB_PULSE]; | |
62 | |
63 /* Decode the positions */ | |
64 | |
65 i = index & 7; logic16 (); | |
66 | |
67 pos[0] = add(i, shl(i, 2)); /* pos0 =i*5 */ move16 (); | |
68 | |
69 index = shr(index, 3); | |
70 j = index & 1; logic16 (); | |
71 index = shr(index, 1); | |
72 i = index & 7; logic16 (); | |
73 | |
74 i = add(i, shl(i, 2)); /* pos1 =i*5+1+j*2 */ | |
75 i = add(i, 1); | |
76 j = shl(j, 1); | |
77 pos[1] = add(i, j); move16 (); | |
78 | |
79 index = shr(index, 3); | |
80 j = index & 1; logic16 (); | |
81 index = shr(index, 1); | |
82 i = index & 7; logic16 (); | |
83 | |
84 i = add(i, shl(i, 2)); /* pos2 =i*5+2+j*2 */ | |
85 i = add(i, 2); | |
86 j = shl(j, 1); | |
87 pos[2] = add(i, j); move16 (); | |
88 | |
89 /* decode the signs and build the codeword */ | |
90 | |
91 for (i = 0; i < L_SUBFR; i++) { | |
92 cod[i] = 0; move16 (); | |
93 } | |
94 | |
95 for (j = 0; j < NB_PULSE; j++) { | |
96 i = sign & 1; logic16 (); | |
97 sign = shr(sign, 1); | |
98 | |
99 test (); | |
100 if (i > 0) { | |
101 cod[pos[j]] = 8191; move16 (); /* +1.0 */ | |
102 } else { | |
103 cod[pos[j]] = -8192; move16 (); /* -1.0 */ | |
104 } | |
105 } | |
106 | |
107 return; | |
108 } |