FreeCalypso > hg > gsm-codec-lib
annotate libtwamr/g_adapt.h @ 368:3a25bdfad0d8
libtwamr: integrate q_gain_c.c
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 06 May 2024 03:18:47 +0000 |
parents | 2a265be82195 |
children |
rev | line source |
---|---|
365
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 ******************************************************************************** |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001 |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * R99 Version 3.3.0 |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * REL-4 Version 4.1.0 |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 * |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 ******************************************************************************** |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 * |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 * File : g_adapt.h |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 * Purpose : gain adaptation for MR795 gain quantization |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 * |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 ******************************************************************************** |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 */ |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 /* |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 ******************************************************************************** |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 * MODULE INCLUDE FILE AND VERSION ID |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 ******************************************************************************** |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 */ |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 #ifndef g_adapt_h |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 #define g_adapt_h "$Id $" |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 /* |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 ******************************************************************************** |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 * INCLUDE FILES |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 ******************************************************************************** |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 */ |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 #include "typedef.h" |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 #define LTPG_MEM_SIZE 5 /* number of stored past LTP coding gains + 1 */ |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 /* |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 ******************************************************************************** |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 * DEFINITION OF DATA TYPES |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 ******************************************************************************** |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 */ |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 typedef struct { |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 Word16 onset; /* onset state, Q0 */ |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 Word16 prev_alpha; /* previous adaptor output, Q15 */ |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 Word16 prev_gc; /* previous code gain, Q1 */ |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 Word16 ltpg_mem[LTPG_MEM_SIZE]; /* LTP coding gain history, Q13 */ |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 /* (ltpg_mem[0] not used for history) */ |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 } GainAdaptState; |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 /* |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 ******************************************************************************** |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 * DECLARATION OF PROTOTYPES |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 ******************************************************************************** |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 */ |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 void gain_adapt_reset (GainAdaptState *st); |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 /* reset of gain adaptor state (i.e. set state memory to zero) |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 returns 0 on success |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 */ |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 /************************************************************************* |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 * |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 * Function: gain_adapt() |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 * Purpose: calculate pitch/codebook gain adaptation factor alpha |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 * (and update the adaptor state) |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 * |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 ************************************************************************** |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 */ |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 void gain_adapt( |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 GainAdaptState *st, /* i : state struct */ |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 Word16 ltpg, /* i : ltp coding gain (log2()), Q */ |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 Word16 gain_cod, /* i : code gain, Q13 */ |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 Word16 *alpha /* o : gain adaptation factor, Q15 */ |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 ); |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 |
2a265be82195
libtwamr: integrate g_adapt.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 #endif |