FreeCalypso > hg > gsm-codec-lib
annotate libtwamr/q_gain_c.c @ 513:03a40ac2e931
libgsmhr1: implement validation for *.cod frames
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 25 Aug 2024 19:00:03 +0000 |
parents | 3a25bdfad0d8 |
children |
rev | line source |
---|---|
368
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 ******************************************************************************** |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001 |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * R99 Version 3.3.0 |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * REL-4 Version 4.1.0 |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 * |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 ******************************************************************************** |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 * |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 * File : q_gain_c.c |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 * Purpose : Scalar quantization of the innovative |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 * : codebook gain. |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 * |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 ******************************************************************************** |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 */ |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 /* |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 ******************************************************************************** |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 * MODULE INCLUDE FILE AND VERSION ID |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 ******************************************************************************** |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 */ |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 #include "namespace.h" |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 #include "q_gain_c.h" |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 /* |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 ******************************************************************************** |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 * INCLUDE FILES |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 ******************************************************************************** |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 */ |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 #include "tw_amr.h" |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 #include "typedef.h" |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 #include "basic_op.h" |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 #include "oper_32b.h" |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 #include "no_count.h" |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 #include "log2.h" |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 #include "pow2.h" |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 #include "gains_tab.h" |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 /* |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 ******************************************************************************** |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 * PUBLIC PROGRAM CODE |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 ******************************************************************************** |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 */ |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 /*--------------------------------------------------------------------------* |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 * Function q_gain_code() * |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 * Scalar quantization of the innovative codebook gain. * |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 * * |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 *--------------------------------------------------------------------------*/ |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 Word16 q_gain_code ( /* o : quantization index, Q0 */ |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 enum Mode mode, /* i : AMR mode */ |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 Word16 exp_gcode0, /* i : predicted CB gain (exponent), Q0 */ |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 Word16 frac_gcode0, /* i : predicted CB gain (fraction), Q15 */ |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 Word16 *gain, /* i/o: quantized fixed codebook gain, Q1 */ |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 Word16 *qua_ener_MR122, /* o : quantized energy error, Q10 */ |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 /* (for MR122 MA predictor update) */ |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 Word16 *qua_ener /* o : quantized energy error, Q10 */ |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 /* (for other MA predictor update) */ |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 ) |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 { |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 const Word16 *p; |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 Word16 i, index; |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 Word16 gcode0, err, err_min; |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 Word16 g_q0; |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 test (); |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 g_q0 = 0; move16 (); |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 test (); |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 if (sub(mode, MR122) == 0) |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 { |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 g_q0 = shr (*gain, 1); /* Q1 -> Q0 */ |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 } |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 /*-------------------------------------------------------------------* |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 * predicted codebook gain * |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 * ~~~~~~~~~~~~~~~~~~~~~~~ * |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 * gc0 = Pow2(int(d)+frac(d)) * |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 * = 2^exp + 2^frac * |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 * * |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 *-------------------------------------------------------------------*/ |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 gcode0 = extract_l (Pow2 (exp_gcode0, frac_gcode0)); /* predicted gain */ |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 test (); |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 if (sub(mode, MR122) == 0) |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 { |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 gcode0 = shl (gcode0, 4); |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 } |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 else |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 { |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 gcode0 = shl (gcode0, 5); |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 } |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 /*-------------------------------------------------------------------* |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 * Search for best quantizer * |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 *-------------------------------------------------------------------*/ |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 p = &qua_gain_code[0]; move16 (); |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 test (); |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 if (sub(mode, MR122) == 0) |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 { |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 err_min = abs_s (sub (g_q0, mult (gcode0, *p++))); |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 } |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 else |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 { |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 err_min = abs_s (sub (*gain, mult (gcode0, *p++))); |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 } |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 p += 2; /* skip quantized energy errors */ |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 index = 0; move16 (); |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 for (i = 1; i < NB_QUA_CODE; i++) |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 { |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 test (); |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 if (sub(mode, MR122) == 0) |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 { |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 err = abs_s (sub (g_q0, mult (gcode0, *p++))); |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 } |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 else |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 { |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 err = abs_s (sub (*gain, mult (gcode0, *p++))); |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 } |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 p += 2; /* skip quantized energy error */ |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 test (); |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 if (sub (err, err_min) < 0) |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 { |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 err_min = err; move16 (); |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 index = i; move16 (); |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 } |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 } |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 p = &qua_gain_code[add (add (index,index), index)]; move16 (); |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 test (); |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 if (sub(mode, MR122) == 0) |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 { |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 *gain = shl (mult (gcode0, *p++), 1); |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 } |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 else |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 { |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 *gain = mult (gcode0, *p++); |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 } |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 move16 (); |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 /* quantized error energies (for MA predictor update) */ |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 *qua_ener_MR122 = *p++; move16 (); |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 *qua_ener = *p; move16 (); |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 return index; |
3a25bdfad0d8
libtwamr: integrate q_gain_c.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 } |