FreeCalypso > hg > gsm-codec-lib
comparison libtwamr/d4_17pf.c @ 334:dfaa8f322a8d
libtwamr: integrate d4_17pf.c
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 18 Apr 2024 22:30:03 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
333:f4a5545ea8b2 | 334:dfaa8f322a8d |
---|---|
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 : d4_17pf.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 "d4_17pf.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 #include "graytab.h" | |
34 | |
35 /* | |
36 ******************************************************************************** | |
37 * LOCAL VARIABLES AND TABLES | |
38 ******************************************************************************** | |
39 */ | |
40 #define NB_PULSE 4 | |
41 | |
42 /* | |
43 ******************************************************************************** | |
44 * PUBLIC PROGRAM CODE | |
45 ******************************************************************************** | |
46 */ | |
47 /************************************************************************* | |
48 * | |
49 * FUNCTION: decod_ACELP() | |
50 * | |
51 * PURPOSE: Algebraic codebook decoder | |
52 * | |
53 *************************************************************************/ | |
54 | |
55 void decode_4i40_17bits( | |
56 Word16 sign, /* i : signs of 4 pulses. */ | |
57 Word16 index, /* i : Positions of the 4 pulses. */ | |
58 Word16 cod[] /* o : algebraic (fixed) codebook excitation */ | |
59 ) | |
60 { | |
61 Word16 i, j; | |
62 Word16 pos[NB_PULSE]; | |
63 | |
64 /* Decode the positions */ | |
65 | |
66 i = index & 7; logic16 (); | |
67 i = dgray[i]; move16 (); | |
68 | |
69 pos[0] = add(i, shl(i, 2)); /* pos0 =i*5 */ move16 (); | |
70 | |
71 index = shr(index, 3); | |
72 i = index & 7; logic16 (); | |
73 i = dgray[i]; move16 (); | |
74 | |
75 i = add(i, shl(i, 2)); /* pos1 =i*5+1 */ | |
76 pos[1] = add(i, 1); move16 (); | |
77 | |
78 index = shr(index, 3); | |
79 i = index & 7; logic16 (); | |
80 i = dgray[i]; move16 (); | |
81 | |
82 i = add(i, shl(i, 2)); /* pos2 =i*5+1 */ | |
83 pos[2] = add(i, 2); move16 (); | |
84 | |
85 index = shr(index, 3); | |
86 j = index & 1; logic16 (); | |
87 index = shr(index, 1); | |
88 i = index & 7; logic16 (); | |
89 i = dgray[i]; move16 (); | |
90 | |
91 i = add(i, shl(i, 2)); /* pos3 =i*5+3+j */ | |
92 i = add(i, 3); | |
93 pos[3] = add(i, j); move16 (); | |
94 | |
95 /* decode the signs and build the codeword */ | |
96 | |
97 for (i = 0; i < L_SUBFR; i++) { | |
98 cod[i] = 0; move16 (); | |
99 } | |
100 | |
101 for (j = 0; j < NB_PULSE; j++) { | |
102 i = sign & 1; logic16 (); | |
103 sign = shr(sign, 1); | |
104 | |
105 test (); | |
106 if (i != 0) { | |
107 cod[pos[j]] = 8191; move16 (); | |
108 } else { | |
109 cod[pos[j]] = -8192; move16 (); | |
110 } | |
111 } | |
112 | |
113 return; | |
114 } |