FreeCalypso > hg > gsm-codec-lib
annotate libtwamr/d_gain_p.c @ 550:de333989a12b
document gsm[e]fr-decode-tw5[-r] utilities
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 05 Oct 2024 02:16:48 +0000 |
parents | e18452a4fbac |
children |
rev | line source |
---|---|
340
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 ******************************************************************************** |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001 |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * R99 Version 3.3.0 |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * REL-4 Version 4.1.0 |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 * |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 ******************************************************************************** |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 * |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 * File : d_gain_p.c |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 * |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 ******************************************************************************** |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 */ |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 /* |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 ******************************************************************************** |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 * MODULE INCLUDE FILE AND VERSION ID |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 ******************************************************************************** |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 */ |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 #include "namespace.h" |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 #include "d_gain_p.h" |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 /* |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 ******************************************************************************** |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 * INCLUDE FILES |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 ******************************************************************************** |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 */ |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 #include "tw_amr.h" |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 #include "typedef.h" |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 #include "basic_op.h" |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 #include "oper_32b.h" |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 #include "no_count.h" |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 #include "cnst.h" |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 #include "gains_tab.h" |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 /* |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 ******************************************************************************** |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 * PUBLIC PROGRAM CODE |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 ******************************************************************************** |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 */ |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 /* |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 ************************************************************************** |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 * |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 * Function : d_gain_pitch |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 * Purpose : Decodes the pitch gain using the received index. |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 * output is in Q14 |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 * |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 ************************************************************************** |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 */ |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 Word16 d_gain_pitch ( /* return value: gain (Q14) */ |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 enum Mode mode, /* i : AMR mode */ |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 Word16 index /* i : index of quantization */ |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 ) |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 { |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 Word16 gain; |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 test (); |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 if (sub(mode, MR122) == 0) |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 { |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 /* clear 2 LSBits */ |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 gain = shl (shr (qua_gain_pitch[index], 2), 2); move16 (); |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 } |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 else |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 { |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 gain = qua_gain_pitch[index]; move16 (); |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 } |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 return gain; |
e18452a4fbac
libtwamr: integrate d_gain_p.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 } |