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