annotate libtwamr/dec_gain.c @ 501:597b39aef484

libgsmhr1/mathhalf.h: rm unused declarations for non-saturating functions
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 19 Jun 2024 00:54:44 +0000
parents 5ccfe176bae1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
356
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 ********************************************************************************
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 *
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 * R99 Version 3.3.0
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 * REL-4 Version 4.1.0
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 *
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 ********************************************************************************
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 *
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 * File : dec_gain.c
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 * Purpose : Decode the pitch and codebook gains
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 *
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 ********************************************************************************
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 */
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 /*
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 ********************************************************************************
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 * MODULE INCLUDE FILE AND VERSION ID
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 ********************************************************************************
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 */
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 #include "namespace.h"
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 #include "dec_gain.h"
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 /*
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 ********************************************************************************
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 * INCLUDE FILES
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 ********************************************************************************
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 */
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 #include <stddef.h>
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 #include "tw_amr.h"
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 #include "typedef.h"
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 #include "basic_op.h"
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 #include "oper_32b.h"
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 #include "no_count.h"
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 #include "cnst.h"
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 #include "pow2.h"
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 #include "log2.h"
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 #include "gc_pred.h"
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 #include "qua_gain_tab.h"
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 /*
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 ********************************************************************************
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 * PUBLIC PROGRAM CODE
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 ********************************************************************************
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 */
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 /*************************************************************************
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 *
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 * FUNCTION: Dec_gain()
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 *
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 * PURPOSE: Decode the pitch and codebook gains
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 *
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 ************************************************************************/
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 void Dec_gain(
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 gc_predState *pred_state, /* i/o: MA predictor state */
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 enum Mode mode, /* i : AMR mode */
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 Word16 index, /* i : index of quantization. */
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 Word16 code[], /* i : Innovative vector. */
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 Word16 evenSubfr, /* i : Flag for even subframes */
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 Word16 * gain_pit, /* o : Pitch gain. */
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 Word16 * gain_cod /* o : Code gain. */
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 )
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 {
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 const Word16 *p;
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 Word16 frac, gcode0, exp, qua_ener, qua_ener_MR122;
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 Word16 g_code;
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 Word32 L_tmp;
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 /* Read the quantized gains (table depends on mode) */
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 index = shl (index, 2);
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 test(); test(); test();
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 if ( sub (mode, MR102) == 0
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 || sub (mode, MR74) == 0
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 || sub (mode, MR67) == 0)
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 {
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 p = &table_gain_highrates[index]; move16 ();
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 *gain_pit = *p++; move16 ();
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 g_code = *p++; move16 ();
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 qua_ener_MR122 = *p++; move16 ();
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 qua_ener = *p; move16 ();
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 }
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 else
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 {
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 test();
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 if (sub (mode, MR475) == 0)
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 {
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 index = add (index, shl(sub(1, evenSubfr), 1));
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 p = &table_gain_MR475[index]; move16 ();
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 *gain_pit = *p++; move16 ();
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 g_code = *p++; move16 ();
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 /*---------------------------------------------------------*
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 * calculate predictor update values (not stored in 4.75 *
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 * quantizer table to save space): *
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 * *
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 * qua_ener = log2(g) *
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 * qua_ener_MR122 = 20*log10(g) *
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 *---------------------------------------------------------*/
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 /* Log2(x Q12) = log2(x) + 12 */
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 Log2 (L_deposit_l (g_code), &exp, &frac);
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 exp = sub(exp, 12);
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 qua_ener_MR122 = add (shr_r (frac, 5), shl (exp, 10));
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 /* 24660 Q12 ~= 6.0206 = 20*log10(2) */
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 L_tmp = Mpy_32_16(exp, frac, 24660);
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 qua_ener = round (L_shl (L_tmp, 13)); /* Q12 * Q0 = Q13 -> Q10 */
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 }
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 else
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 {
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 p = &table_gain_lowrates[index]; move16 ();
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 *gain_pit = *p++; move16 ();
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 g_code = *p++; move16 ();
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 qua_ener_MR122 = *p++; move16 ();
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 qua_ener = *p; move16 ();
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 }
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 }
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 /*-------------------------------------------------------------------*
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 * predict codebook gain *
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 * ~~~~~~~~~~~~~~~~~~~~~ *
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 * gc0 = Pow2(int(d)+frac(d)) *
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 * = 2^exp + 2^frac *
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 * *
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 * gcode0 (Q14) = 2^14*2^frac = gc0 * 2^(14-exp) *
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 *-------------------------------------------------------------------*/
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 gc_pred(pred_state, mode, code, &exp, &frac, NULL, NULL);
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 gcode0 = extract_l(Pow2(14, frac));
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 /*------------------------------------------------------------------*
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 * read quantized gains, update table of past quantized energies *
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 * st->past_qua_en(Q10) = 20 * Log10(g_fac) / constant *
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 * = Log2(g_fac) *
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 * = qua_ener *
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 * constant = 20*Log10(2) *
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 *------------------------------------------------------------------*/
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 L_tmp = L_mult(g_code, gcode0);
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 L_tmp = L_shr(L_tmp, sub(10, exp));
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149 *gain_cod = extract_h(L_tmp);
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 /* update table of past quantized energies */
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 gc_pred_update(pred_state, qua_ener_MR122, qua_ener);
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 return;
5ccfe176bae1 libtwamr: integrate dec_gain.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156 }