annotate libtwamr/gc_pred.h @ 556:18aca50d68df default tip

doc/Calypso-TCH-downlink: update for FR1 BFI-with-data
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 11 Oct 2024 01:54:00 +0000
parents 7f99b8ed30e5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
336
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 ********************************************************************************
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 *
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 * R99 Version 3.3.0
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 * REL-4 Version 4.1.0
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 *
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 ********************************************************************************
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 *
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 * File : gc_pred.h
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 * Purpose : codebook gain MA prediction
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 *
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 ********************************************************************************
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 */
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 #ifndef gc_pred_h
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 #define gc_pred_h "$Id $"
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 /*
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 ********************************************************************************
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 * INCLUDE FILES
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 ********************************************************************************
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 */
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 #include "tw_amr.h"
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 #include "typedef.h"
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 /*
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 ********************************************************************************
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 * LOCAL VARIABLES AND TABLES
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 ********************************************************************************
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 */
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 /*
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 ********************************************************************************
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 * DEFINITION OF DATA TYPES
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 ********************************************************************************
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 */
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 typedef struct {
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 Word16 past_qua_en[4]; /* normal MA predictor memory, Q10 */
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 /* (contains 20*log10(qua_err)) */
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 Word16 past_qua_en_MR122[4]; /* MA predictor memory for MR122 mode, Q10 */
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 /* (contains log2(qua_err)) */
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 } gc_predState;
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 /*
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 ********************************************************************************
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 * DECLARATION OF PROTOTYPES
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 ********************************************************************************
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 */
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 void gc_pred_reset (gc_predState *st);
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 /* reset of codebook gain MA predictor state (i.e. set state memory to zero)
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 returns 0 on success
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 */
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 void
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 gc_pred_copy(
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 gc_predState *st_src, /* i : State struct */
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 gc_predState *st_dest /* o : State struct */
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 );
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 /*************************************************************************
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 *
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 * FUNCTION: gc_pred()
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 *
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 * PURPOSE: MA prediction of the innovation energy
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 * (in dB/(20*log10(2))) with mean removed).
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 *
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 *************************************************************************/
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 void gc_pred(
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 gc_predState *st, /* i/o: State struct */
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 enum Mode mode, /* i : AMR mode */
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 Word16 *code, /* i : innovative codebook vector (L_SUBFR) */
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 /* MR122: Q12, other modes: Q13 */
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 Word16 *exp_gcode0, /* o : exponent of predicted gain factor, Q0 */
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 Word16 *frac_gcode0,/* o : fraction of predicted gain factor Q15 */
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 Word16 *exp_en, /* o : exponent of innovation energy, Q0 */
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 /* (only calculated for MR795) */
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 Word16 *frac_en /* o : fraction of innovation energy, Q15 */
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 /* (only calculated for MR795) */
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 );
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 /*************************************************************************
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 *
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 * FUNCTION: gc_pred_update()
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 *
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 * PURPOSE: update MA predictor with last quantized energy
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 *
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 *************************************************************************/
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 void gc_pred_update(
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 gc_predState *st, /* i/o: State struct */
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 Word16 qua_ener_MR122, /* i : quantized energy for update, Q10 */
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 /* (log2(qua_err)) */
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 Word16 qua_ener /* i : quantized energy for update, Q10 */
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 /* (20*log10(qua_err)) */
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 );
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 /*************************************************************************
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 *
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 * FUNCTION: gc_pred_average_limited()
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 *
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 * PURPOSE: get average of MA predictor state values (with a lower limit)
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 * [used in error concealment]
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 *
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 *************************************************************************/
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 void gc_pred_average_limited(
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 gc_predState *st, /* i: State struct */
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 Word16 *ener_avg_MR122, /* o: averaged quantized energy, Q10 */
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 /* (log2(qua_err)) */
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 Word16 *ener_avg /* o: averaged quantized energy, Q10 */
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 /* (20*log10(qua_err)) */
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 );
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113
7f99b8ed30e5 libtwamr: integrate gc_pred.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 #endif