annotate libtwamr/gains_tab.c @ 477:4c9222d95647

libtwamr encoder: always emit frame->mode = mode; In the original implementation of amr_encode_frame(), the 'mode' member of the output struct was set to 0xFF if the output frame type is TX_NO_DATA. This design was made to mimic the mode field (16-bit word) being set to 0xFFFF (or -1) in 3GPP test sequence format - but nothing actually depends on this struct member being set in any way, and amr_frame_to_tseq() generates the needed 0xFFFF on its own, based on frame->type being equal to TX_NO_DATA. It is simpler and more efficient to always set frame->mode to the actual encoding mode in amr_encode_frame(), and this new behavior has already been documented in doc/AMR-library-API description in anticipation of the present change.
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 18 May 2024 22:30:42 +0000
parents 5db2c920fc23
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
338
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 ********************************************************************************
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 *
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 * R99 Version 3.3.0
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 * REL-4 Version 4.1.0
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 *
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 ********************************************************************************
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 *
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 * File : gains.tab
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 * Purpose : Scalar quantization tables of the pitch gain and
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 * : the codebook gain.
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 * $Id $
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 *
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 ********************************************************************************
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 */
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 #include "namespace.h"
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 #include "typedef.h"
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 #include "gains_tab.h"
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 const Word16 qua_gain_pitch[NB_QUA_PITCH] =
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 {
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 0, 3277, 6556, 8192, 9830, 11469, 12288, 13107,
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 13926, 14746, 15565, 16384, 17203, 18022, 18842, 19661
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 };
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 const Word16 qua_gain_code[NB_QUA_CODE*3] =
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 {
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 /* gain factor (g_fac) and quantized energy error (qua_ener_MR122, qua_ener)
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 * are stored:
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 *
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 * qua_ener_MR122 = log2(g_fac) (not the rounded floating point value, but
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 * the value the original EFR algorithm
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 * calculates from g_fac [using Log2])
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 * qua_ener = 20*log10(g_fac); (rounded floating point value)
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 *
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 *
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 * g_fac (Q11), qua_ener_MR122 (Q10), qua_ener (Q10)
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 */
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 159, -3776, -22731,
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 206, -3394, -20428,
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 268, -3005, -18088,
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 349, -2615, -15739,
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 419, -2345, -14113,
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 482, -2138, -12867,
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 554, -1932, -11629,
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 637, -1726, -10387,
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 733, -1518, -9139,
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 842, -1314, -7906,
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 969, -1106, -6656,
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 1114, -900, -5416,
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 1281, -694, -4173,
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 1473, -487, -2931,
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 1694, -281, -1688,
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 1948, -75, -445,
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 2241, 133, 801,
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 2577, 339, 2044,
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 2963, 545, 3285,
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 3408, 752, 4530,
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 3919, 958, 5772,
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 4507, 1165, 7016,
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 5183, 1371, 8259,
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 5960, 1577, 9501,
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 6855, 1784, 10745,
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 7883, 1991, 11988,
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 9065, 2197, 13231,
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 10425, 2404, 14474,
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 12510, 2673, 16096,
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 16263, 3060, 18429,
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 21142, 3448, 20763,
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 27485, 3836, 23097
5db2c920fc23 libtwamr: gains.tab integrated
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 };