FreeCalypso > hg > gsm-codec-lib
annotate libtwamr/ph_disp.h @ 390:bde9f5804670
libtwamr: integrate ph_disp.c
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 06 May 2024 18:20:22 +0000 |
parents | |
children |
rev | line source |
---|---|
390
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 ******************************************************************************** |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * R99 Version 3.3.0 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * REL-4 Version 4.1.0 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 * |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 ******************************************************************************** |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 * |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 * File : ph_disp.h |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 * Purpose : Phase dispersion of excitation signal |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 * |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 ******************************************************************************** |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #ifndef ph_disp_h |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 #define ph_disp_h "$Id $" |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 /* |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 ******************************************************************************** |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 * INCLUDE FILES |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 ******************************************************************************** |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 #include "tw_amr.h" |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 #include "typedef.h" |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 /* |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 ******************************************************************************** |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 * LOCAL VARIABLES AND TABLES |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 ******************************************************************************** |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 #define PHDGAINMEMSIZE 5 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 #define PHDTHR1LTP 9830 /* 0.6 in Q14 */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 #define PHDTHR2LTP 14746 /* 0.9 in Q14 */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 #define ONFACTPLUS1 16384 /* 2.0 in Q13 */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 #define ONLENGTH 2 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 /* |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 ******************************************************************************** |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 * DEFINITION OF DATA TYPES |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 ******************************************************************************** |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 typedef struct { |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 Word16 gainMem[PHDGAINMEMSIZE]; |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 Word16 prevState; |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 Word16 prevCbGain; |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 Word16 lockFull; |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 Word16 onset; |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 } ph_dispState; |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 /* |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 ******************************************************************************** |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 * DECLARATION OF PROTOTYPES |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 ******************************************************************************** |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 /************************************************************************* |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 * |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 * Function: ph_disp_reset |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 * Purpose: Initializes state memory |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 * |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 ************************************************************************** |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 void ph_disp_reset (ph_dispState *state); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 /************************************************************************* |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 * |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 * Function: ph_disp_lock |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 * Purpose: mark phase dispersion as locked in state struct |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 * |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 ************************************************************************** |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 void ph_disp_lock (ph_dispState *state); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 /************************************************************************* |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 * |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 * Function: ph_disp_release |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 * Purpose: mark phase dispersion as unlocked in state struct |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 * |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 ************************************************************************** |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 void ph_disp_release (ph_dispState *state); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 /************************************************************************* |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 * |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 * Function: ph_disp |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 * Purpose: perform phase dispersion according to the specified codec |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 * mode and computes total excitation for synthesis part |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 * if decoder |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 * |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 ************************************************************************** |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 void ph_disp ( |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 ph_dispState *state, /* i/o : State struct */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 enum Mode mode, /* i : codec mode */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 Word16 x[], /* i/o Q0 : in: LTP excitation signal */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 /* out: total excitation signal */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 Word16 cbGain, /* i Q1 : Codebook gain */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 Word16 ltpGain, /* i Q14 : LTP gain */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 Word16 inno[], /* i Q13 : Innovation vector (Q12 for 12.2) */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 Word16 pitch_fac, /* i Q14 : pitch factor used to scale the |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 LTP excitation (Q13 for 12.2) */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 Word16 tmp_shift /* i Q0 : shift factor applied to sum of |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 scaled LTP ex & innov. before |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 rounding */ |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 ); |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 |
bde9f5804670
libtwamr: integrate ph_disp.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 #endif |