FreeCalypso > hg > gsm-codec-lib
annotate libtwamr/qgain475.h @ 513:03a40ac2e931
libgsmhr1: implement validation for *.cod frames
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 25 Aug 2024 19:00:03 +0000 |
parents | 1d2b39027b70 |
children |
rev | line source |
---|---|
375
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 ******************************************************************************** |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001 |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * R99 Version 3.3.0 |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * REL-4 Version 4.1.0 |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 * |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 ******************************************************************************** |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 * |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 * File : qgain475.h |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 * Purpose : Quantization of pitch and codebook gains for MR475. |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 * |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 ******************************************************************************** |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #ifndef qgain475_h |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #define qgain475_h "$Id $" |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 /* |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 ******************************************************************************** |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 * INCLUDE FILES |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 ******************************************************************************** |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 #include "typedef.h" |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 #include "gc_pred.h" |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 /* |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 ******************************************************************************** |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 * DECLARATION OF PROTOTYPES |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 ******************************************************************************** |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 /************************************************************************* |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 * |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 * FUNCTION: MR475_update_unq_pred() |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 * |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 * PURPOSE: use optimum codebook gain and update "unquantized" |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 * gain predictor with the (bounded) prediction error |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 * |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 *************************************************************************/ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 void |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 MR475_update_unq_pred( |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 gc_predState *pred_st, /* i/o: gain predictor state struct */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 Word16 exp_gcode0, /* i : predicted CB gain (exponent), Q0 */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 Word16 frac_gcode0, /* i : predicted CB gain (fraction), Q15 */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 Word16 cod_gain_exp, /* i : optimum codebook gain (exponent), Q0 */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 Word16 cod_gain_frac /* i : optimum codebook gain (fraction), Q15 */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 ); |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 /************************************************************************* |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 * |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 * FUNCTION: MR475_gain_quant() |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 * |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 * PURPOSE: Quantization of pitch and codebook gains for two subframes |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 * (using predicted codebook gain) |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 * |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 *************************************************************************/ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 Word16 |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 MR475_gain_quant( /* o : index of quantization. */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 gc_predState *pred_st, /* i/o: gain predictor state struct */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 /* data from subframe 0 (or 2) */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 Word16 sf0_exp_gcode0, /* i : predicted CB gain (exponent), Q0 */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 Word16 sf0_frac_gcode0, /* i : predicted CB gain (fraction), Q15 */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 Word16 sf0_exp_coeff[], /* i : energy coeff. (5), exponent part, Q0 */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 Word16 sf0_frac_coeff[], /* i : energy coeff. (5), fraction part, Q15 */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 /* (frac_coeff and exp_coeff computed in */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 /* calc_filt_energies()) */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 Word16 sf0_exp_target_en, /* i : exponent of target energy, Q0 */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 Word16 sf0_frac_target_en, /* i : fraction of target energy, Q15 */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 /* data from subframe 1 (or 3) */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 Word16 sf1_code_nosharp[], /* i : innovative codebook vector (L_SUBFR) */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 /* (whithout pitch sharpening) */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 Word16 sf1_exp_gcode0, /* i : predicted CB gain (exponent), Q0 */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 Word16 sf1_frac_gcode0, /* i : predicted CB gain (fraction), Q15 */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 Word16 sf1_exp_coeff[], /* i : energy coeff. (5), exponent part, Q0 */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 Word16 sf1_frac_coeff[], /* i : energy coeff. (5), fraction part, Q15 */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 /* (frac_coeff and exp_coeff computed in */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 /* calc_filt_energies()) */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 Word16 sf1_exp_target_en, /* i : exponent of target energy, Q0 */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 Word16 sf1_frac_target_en, /* i : fraction of target energy, Q15 */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 Word16 gp_limit, /* i : pitch gain limit */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 Word16 *sf0_gain_pit, /* o : Pitch gain, Q14 */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 Word16 *sf0_gain_cod, /* o : Code gain, Q1 */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 Word16 *sf1_gain_pit, /* o : Pitch gain, Q14 */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 Word16 *sf1_gain_cod /* o : Code gain, Q1 */ |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 ); |
1d2b39027b70
libtwamr: integrate qgain475.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 #endif |