FreeCalypso > hg > gsm-codec-lib
annotate libtwamr/gain_q.h @ 514:67b13a6a63c9
libgsmhr1: implement validation for *.dec frames
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 25 Aug 2024 19:14:40 +0000 |
parents | ccba5812fa44 |
children |
rev | line source |
---|---|
378
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 ******************************************************************************** |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001 |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * R99 Version 3.3.0 |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * REL-4 Version 4.1.0 |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 * |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 ******************************************************************************** |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 * |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 * File : gainQuant.h |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 * Purpose : Quantazation of gains |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 * |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 ******************************************************************************** |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 */ |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #ifndef gain_q_h |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #define gain_q_h "$Id $" |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 /* |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 ******************************************************************************** |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 * INCLUDE FILES |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 ******************************************************************************** |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 */ |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 #include "tw_amr.h" |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 #include "typedef.h" |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 #include "gc_pred.h" |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 #include "g_adapt.h" |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 /* |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 ******************************************************************************** |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 * DEFINITION OF DATA TYPES |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 ******************************************************************************** |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 */ |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 typedef struct { |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 Word16 sf0_exp_gcode0; |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 Word16 sf0_frac_gcode0; |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 Word16 sf0_exp_target_en; |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 Word16 sf0_frac_target_en; |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 Word16 sf0_exp_coeff[5]; |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 Word16 sf0_frac_coeff[5]; |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 Word16 *gain_idx_ptr; |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 gc_predState gc_predSt; |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 gc_predState gc_predUnqSt; |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 GainAdaptState adaptSt; |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 } gainQuantState; |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 /* |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 ******************************************************************************** |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 * DECLARATION OF PROTOTYPES |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 ******************************************************************************** |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 */ |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 void gainQuant_reset (gainQuantState *st); |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 /* reset of pre processing state (i.e. set state memory to zero) |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 returns 0 on success |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 */ |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 int gainQuant( |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 gainQuantState *st, /* i/o : State struct */ |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 enum Mode mode, /* i : coder mode */ |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 Word16 res[], /* i : LP residual, Q0 */ |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 Word16 exc[], /* i : LTP excitation (unfiltered), Q0 */ |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 Word16 code[], /* i : CB innovation (unfiltered), Q13 */ |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 /* (unsharpened for MR475) */ |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 Word16 xn[], /* i : Target vector. */ |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 Word16 xn2[], /* i : Target vector. */ |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 Word16 y1[], /* i : Adaptive codebook. */ |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 Word16 Y2[], /* i : Filtered innovative vector. */ |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 Word16 g_coeff[], /* i : Correlations <xn y1> <y1 y1> */ |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 /* Compute in G_pitch(). */ |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 Word16 even_subframe, /* i : even subframe indicator flag */ |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 Word16 gp_limit, /* i : pitch gain limit */ |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 Word16 *sf0_gain_pit, /* o : Pitch gain sf 0. MR475 */ |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 Word16 *sf0_gain_cod, /* o : Code gain sf 0. MR475 */ |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 Word16 *gain_pit, /* i/o : Pitch gain. */ |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 Word16 *gain_cod, /* o : Code gain. */ |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 /* MR475: gain_* unquantized in even */ |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 /* subframes, quantized otherwise */ |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 Word16 **anap /* o : Index of quantization */ |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 ); |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 |
ccba5812fa44
libtwamr: integrate gain_q.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 #endif |