annotate libtwamr/dec_amr.h @ 426:7bef001cd8b8

libtwamr: integrate dec_amr.c
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 07 May 2024 20:33:01 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
426
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 *****************************************************************************
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 *
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 * R99 Version 3.3.0
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 * REL-4 Version 4.1.0
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 *
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 *****************************************************************************
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 *
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 * File : dec_amr.h
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 * Purpose : Speech decoder routine.
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 *
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 *****************************************************************************
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 */
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 #ifndef dec_amr_h
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 #define dec_amr_h "$Id $"
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 /*
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 *****************************************************************************
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 * INCLUDE FILES
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 *****************************************************************************
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 */
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 #include "tw_amr.h"
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 #include "typedef.h"
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 #include "cnst.h"
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 #include "dtx_dec.h"
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 #include "d_plsf.h"
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 #include "gc_pred.h"
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 #include "ec_gains.h"
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 #include "ph_disp.h"
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 #include "c_g_aver.h"
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 #include "bgnscd.h"
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 #include "lsp_avg.h"
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 /*
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 *****************************************************************************
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 * LOCAL VARIABLES AND TABLES
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 *****************************************************************************
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 */
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 /*---------------------------------------------------------------*
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 * Postfilter constant parameters (defined in "cnst.h") *
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 *---------------------------------------------------------------*
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 * L_FRAME : Frame size. *
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 * PIT_MAX : Maximum pitch lag. *
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 * L_INTERPOL : Length of filter for interpolation. *
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 * M : LPC order. *
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 *---------------------------------------------------------------*/
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 /*
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 *****************************************************************************
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 * DEFINITION OF DATA TYPES
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 *****************************************************************************
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 */
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 typedef struct{
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 /* Excitation vector */
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 Word16 old_exc[L_SUBFR + PIT_MAX + L_INTERPOL];
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 Word16 *exc;
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 /* Lsp (Line spectral pairs) */
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 /* Word16 lsp[M]; */ /* Used by CN codec */
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 Word16 lsp_old[M];
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 /* Filter's memory */
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 Word16 mem_syn[M];
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 /* pitch sharpening */
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 Word16 sharp;
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 Word16 old_T0;
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 /* Memories for bad frame handling */
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 Word16 prev_bf;
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 Word16 prev_pdf;
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 Word16 state;
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 Word16 excEnergyHist[9];
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 /* Variable holding received ltpLag, used in background noise and BFI */
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 Word16 T0_lagBuff;
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 /* Variables for the source characteristic detector (SCD) */
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 Word16 inBackgroundNoise;
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 Word16 voicedHangover;
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 Word16 ltpGainHistory[9];
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 Bgn_scdState background_state;
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 Word16 nodataSeed;
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 Cb_gain_averageState Cb_gain_averState;
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 lsp_avgState lsp_avg_st;
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 D_plsfState lsfState;
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 ec_gain_pitchState ec_gain_p_st;
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 ec_gain_codeState ec_gain_c_st;
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 gc_predState pred_state;
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 ph_dispState ph_disp_st;
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 dtx_decState dtxDecoderState;
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 } Decoder_amrState;
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 /*
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 *****************************************************************************
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 * DECLARATION OF PROTOTYPES
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 *****************************************************************************
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 */
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 /*
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 **************************************************************************
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 *
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 * Function : Decoder_amr_reset
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 * Purpose : Resets state memory
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 * Returns : 0 on success
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 *
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 **************************************************************************
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 */
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 void Decoder_amr_reset (Decoder_amrState *st, Flag dtx_partial_reset);
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 /*
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 **************************************************************************
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 *
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 * Function : Decoder_amr
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 * Purpose : Speech decoder routine.
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 * Returns : 0
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 *
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 **************************************************************************
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 */
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 int Decoder_amr (
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 Decoder_amrState *st, /* i/o : State variables */
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 enum Mode mode, /* i : AMR mode */
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 Word16 parm[], /* i : vector of synthesis parameters
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 (PRM_SIZE) */
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 enum RXFrameType frame_type, /* i : received frame type */
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 Word16 synth[], /* o : synthesis speech (L_FRAME) */
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 Word16 A_t[] /* o : decoded LP filter in 4 subframes
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 (AZ_SIZE) */
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 );
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135
7bef001cd8b8 libtwamr: integrate dec_amr.c
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 #endif