FreeCalypso > hg > gsm-codec-lib
comparison libtwamr/calc_en.h @ 327:2df212a012af
libtwamr: integrate calc_en.c
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 18 Apr 2024 20:28:33 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
326:bfe74a9edd5a | 327:2df212a012af |
---|---|
1 /* | |
2 ******************************************************************************** | |
3 * | |
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001 | |
5 * R99 Version 3.3.0 | |
6 * REL-4 Version 4.1.0 | |
7 * | |
8 ******************************************************************************** | |
9 * | |
10 * File : calc_en.h | |
11 * Purpose : calculation of energy coefficients for quantizers | |
12 * | |
13 ******************************************************************************** | |
14 */ | |
15 #ifndef calc_en_h | |
16 #define calc_en_h "$Id $" | |
17 | |
18 /* | |
19 ******************************************************************************** | |
20 * INCLUDE FILES | |
21 ******************************************************************************** | |
22 */ | |
23 #include "tw_amr.h" | |
24 #include "typedef.h" | |
25 | |
26 /* | |
27 ******************************************************************************** | |
28 * DECLARATION OF PROTOTYPES | |
29 ******************************************************************************** | |
30 */ | |
31 | |
32 /************************************************************************* | |
33 * | |
34 * FUNCTION: calc_unfilt_energies | |
35 * | |
36 * PURPOSE: calculation of several energy coefficients for unfiltered | |
37 * excitation signals and the LTP coding gain | |
38 * | |
39 * frac_en[0]*2^exp_en[0] = <res res> // LP residual energy | |
40 * frac_en[1]*2^exp_en[1] = <exc exc> // LTP residual energy | |
41 * frac_en[2]*2^exp_en[2] = <exc code> // LTP/CB innovation dot product | |
42 * frac_en[3]*2^exp_en[3] = <lres lres> // LTP residual energy | |
43 * // (lres = res - gain_pit*exc) | |
44 * ltpg = log2(LP_res_en / LTP_res_en) | |
45 * | |
46 *************************************************************************/ | |
47 void | |
48 calc_unfilt_energies( | |
49 Word16 res[], /* i : LP residual, Q0 */ | |
50 Word16 exc[], /* i : LTP excitation (unfiltered), Q0 */ | |
51 Word16 code[], /* i : CB innovation (unfiltered), Q13 */ | |
52 Word16 gain_pit, /* i : pitch gain, Q14 */ | |
53 Word16 L_subfr, /* i : Subframe length */ | |
54 | |
55 Word16 frac_en[], /* o : energy coefficients (3), fraction part, Q15 */ | |
56 Word16 exp_en[], /* o : energy coefficients (3), exponent part, Q0 */ | |
57 Word16 *ltpg /* o : LTP coding gain (log2()), Q13 */ | |
58 ); | |
59 | |
60 /************************************************************************* | |
61 * | |
62 * FUNCTION: calc_filt_energies | |
63 * | |
64 * PURPOSE: calculation of several energy coefficients for filtered | |
65 * excitation signals | |
66 * | |
67 * Compute coefficients need for the quantization and the optimum | |
68 * codebook gain gcu (for MR475 only). | |
69 * | |
70 * coeff[0] = y1 y1 | |
71 * coeff[1] = -2 xn y1 | |
72 * coeff[2] = y2 y2 | |
73 * coeff[3] = -2 xn y2 | |
74 * coeff[4] = 2 y1 y2 | |
75 * | |
76 * | |
77 * gcu = <xn2, y2> / <y2, y2> (0 if <xn2, y2> <= 0) | |
78 * | |
79 * Product <y1 y1> and <xn y1> have been computed in G_pitch() and | |
80 * are in vector g_coeff[]. | |
81 * | |
82 *************************************************************************/ | |
83 void | |
84 calc_filt_energies( | |
85 enum Mode mode, /* i : coder mode */ | |
86 Word16 xn[], /* i : LTP target vector, Q0 */ | |
87 Word16 xn2[], /* i : CB target vector, Q0 */ | |
88 Word16 y1[], /* i : Adaptive codebook, Q0 */ | |
89 Word16 Y2[], /* i : Filtered innovative vector, Q12 */ | |
90 Word16 g_coeff[], /* i : Correlations <xn y1> <y1 y1> */ | |
91 /* computed in G_pitch() */ | |
92 | |
93 Word16 frac_coeff[],/* o : energy coefficients (5), fraction part, Q15 */ | |
94 Word16 exp_coeff[], /* o : energy coefficients (5), exponent part, Q0 */ | |
95 Word16 *cod_gain_frac,/* o: optimum codebook gain (fraction part), Q15 */ | |
96 Word16 *cod_gain_exp /* o: optimum codebook gain (exponent part), Q0 */ | |
97 ); | |
98 | |
99 /************************************************************************* | |
100 * | |
101 * FUNCTION: calc_target_energy | |
102 * | |
103 * PURPOSE: calculation of target energy | |
104 * | |
105 * en = <xn, xn> | |
106 * | |
107 *************************************************************************/ | |
108 void | |
109 calc_target_energy( | |
110 Word16 xn[], /* i: LTP target vector, Q0 */ | |
111 Word16 *en_exp, /* o: optimum codebook gain (exponent part), Q0 */ | |
112 Word16 *en_frac /* o: optimum codebook gain (fraction part), Q15 */ | |
113 ); | |
114 #endif |