comparison libtwamr/cod_amr.h @ 418:93d6c6960a46

libtwamr: integrate cod_amr.c
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 07 May 2024 03:50:25 +0000
parents
children
comparison
equal deleted inserted replaced
417:f17e42c63058 418:93d6c6960a46
1 /*
2 *****************************************************************************
3 *
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001
5 * R99 Version 3.3.0
6 * REL-4 Version 4.1.0
7 *
8 *****************************************************************************
9 *
10 * File : cod_amr.h
11 * Purpose : Main encoder routine operating on a frame basis.
12 *
13 *****************************************************************************
14 */
15 #ifndef cod_amr_h
16 #define cod_amr_h "$Id $"
17
18 /*
19 *****************************************************************************
20 * INCLUDE FILES
21 *****************************************************************************
22 */
23 #include "tw_amr.h"
24 #include "typedef.h"
25 #include "cnst.h"
26 #include "lpc.h"
27 #include "lsp.h"
28 #include "cl_ltp.h"
29 #include "gain_q.h"
30 #include "p_ol_wgh.h"
31 #include "ton_stab.h"
32 #include "vad.h"
33 #include "dtx_enc.h"
34
35 /*
36 *****************************************************************************
37 * DEFINITION OF DATA TYPES
38 *****************************************************************************
39 */
40 /*-----------------------------------------------------------*
41 * Coder constant parameters (defined in "cnst.h") *
42 *-----------------------------------------------------------*
43 * L_WINDOW : LPC analysis window size. *
44 * L_NEXT : Samples of next frame needed for autocor. *
45 * L_FRAME : Frame size. *
46 * L_FRAME_BY2 : Half the frame size. *
47 * L_SUBFR : Sub-frame size. *
48 * M : LPC order. *
49 * MP1 : LPC order+1 *
50 * L_TOTAL7k4 : Total size of speech buffer. *
51 * PIT_MIN7k4 : Minimum pitch lag. *
52 * PIT_MAX : Maximum pitch lag. *
53 * L_INTERPOL : Length of filter for interpolation *
54 *-----------------------------------------------------------*/
55 typedef struct {
56 /* Speech vector */
57 Word16 old_speech[L_TOTAL];
58 Word16 *speech, *p_window, *p_window_12k2;
59 Word16 *new_speech; /* Global variable */
60
61 /* Weight speech vector */
62 Word16 old_wsp[L_FRAME + PIT_MAX];
63 Word16 *wsp;
64
65 /* OL LTP states */
66 Word16 old_lags[5];
67 Word16 ol_gain_flg[2];
68
69 /* Excitation vector */
70 Word16 old_exc[L_FRAME + PIT_MAX + L_INTERPOL];
71 Word16 *exc;
72
73 /* Zero vector */
74 Word16 ai_zero[L_SUBFR + MP1];
75 Word16 *zero;
76
77 /* Impulse response vector */
78 Word16 *h1;
79 Word16 hvec[L_SUBFR * 2];
80
81 /* Substates */
82 lpcState lpcSt;
83 lspState lspSt;
84 clLtpState clLtpSt;
85 gainQuantState gainQuantSt;
86 pitchOLWghtState pitchOLWghtSt;
87 tonStabState tonStabSt;
88 vadState vadSt;
89 Flag dtx;
90 dtx_encState dtx_encSt;
91
92 /* Filter's memory */
93 Word16 mem_syn[M], mem_w0[M], mem_w[M];
94 Word16 mem_err[M + L_SUBFR], *error;
95
96 Word16 sharp;
97 } cod_amrState;
98
99 /*
100 ********************************************************************************
101 * DECLARATION OF PROTOTYPES
102 ********************************************************************************
103 */
104
105 /*
106 **************************************************************************
107 *
108 * Function : cod_amr_reset
109 * Purpose : Resets state memory
110 * Returns : 0 on success
111 *
112 **************************************************************************
113 */
114 void cod_amr_reset (cod_amrState *st, Flag dtx, Flag use_vad2);
115
116 /***************************************************************************
117 * FUNCTION: cod_amr_first
118 *
119 * PURPOSE: Copes with look-ahead.
120 *
121 * INPUTS:
122 * No input argument are passed to this function. However, before
123 * calling this function, 40 new speech data should be copied to the
124 * vector new_speech[]. This is a global pointer which is declared in
125 * this file (it points to the end of speech buffer minus 200).
126 *
127 ***************************************************************************/
128
129 int cod_amr_first(cod_amrState *st, /* i/o : State struct */
130 Word16 new_speech[] /* i : speech input (L_FRAME) */
131 );
132
133 /***************************************************************************
134 * FUNCTION: cod_amr
135 *
136 * PURPOSE: Main encoder routine.
137 *
138 * DESCRIPTION: This function is called every 20 ms speech frame,
139 * operating on the newly read 160 speech samples. It performs the
140 * principle encoding functions to produce the set of encoded parameters
141 * which include the LSP, adaptive codebook, and fixed codebook
142 * quantization indices (addresses and gains).
143 *
144 * INPUTS:
145 * No input argument are passed to this function. However, before
146 * calling this function, 160 new speech data should be copied to the
147 * vector new_speech[]. This is a global pointer which is declared in
148 * this file (it points to the end of speech buffer minus 160).
149 *
150 * OUTPUTS:
151 *
152 * ana[]: vector of analysis parameters.
153 * synth[]: Local synthesis speech (for debugging purposes)
154 *
155 ***************************************************************************/
156
157 int cod_amr(cod_amrState *st, /* i/o : State struct */
158 enum Mode mode, /* i : AMR mode */
159 Word16 new_speech[], /* i : speech input (L_FRAME) */
160 Word16 ana[], /* o : Analysis parameters */
161 enum Mode *usedMode, /* o : used mode */
162 Word16 synth[] /* o : Local synthesis */
163 );
164
165 #endif