1 /*
2 * G.723.1 common header and data tables
3 * Copyright (c) 2006 Benjamin Larsson
4 * Copyright (c) 2010 Mohamed Naufal Basheer
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 /**
24 * @file
25 * G.723.1 types, functions and data tables
26 */
27
28 #ifndef AVCODEC_G723_1_H
29 #define AVCODEC_G723_1_H
30
31 #include <stdint.h>
32
34
36 #define SUBFRAME_LEN 60
37 #define FRAME_LEN (SUBFRAME_LEN << 2)
38 #define HALF_FRAME_LEN (FRAME_LEN / 2)
39 #define LPC_FRAME (HALF_FRAME_LEN + SUBFRAME_LEN)
42 #define LSP_CB_SIZE 256
44 #define PITCH_MAX (PITCH_MIN + 127)
48 #define GAIN_LEVELS 24
49 #define COS_TBL_SIZE 512
50
51 /**
52 * Bitexact implementation of 2ab scaled by 1/2^16.
53 *
54 * @param a 32 bit multiplicand
55 * @param b 16 bit multiplier
56 */
58 ((((a) >> 16) * (b) * 2) + (((a) & 0xffff) * (b) >> 15))
59
60 /**
61 * G723.1 frame types
62 */
67 };
68
69 /**
70 * G723.1 rate values
71 */
75 };
76
77 /**
78 * G723.1 unpacked data subframe
79 */
89
90 /**
91 * Pitch postfilter parameters
92 */
94 int index;
///< postfilter backward/forward lag
98
99 /**
100 * Harmonic filter parameters
101 */
106
107 /**
108 * Optimized fixed codebook excitation parameters
109 */
118
127
135
144 ///< gain scaling unit memory
146
147 /* encoder */
150
155
158
162
165
166
167 /**
168 * Scale vector contents based on the largest of their absolutes.
169 */
171
172 /**
173 * Calculate the number of left-shifts required for normalizing the input.
174 *
175 * @param num input number
176 * @param width width of the input, 16 bits(0) / 32 bits(1)
177 */
179
181
182 /**
183 * Get delayed contribution from the previous excitation vector.
184 */
186 int lag);
187
188 /**
189 * Generate a train of dirac functions with period as pitch lag.
190 */
192
193
194 /**
195 * Generate adaptive codebook excitation.
196 */
200 /**
201 * Quantize LSP frequencies by interpolation and convert them to
202 * the corresponding LPC coefficients.
203 *
204 * @param lpc buffer for LPC coefficients
205 * @param cur_lsp the current LSP vector
206 * @param prev_lsp the previous LSP vector
207 */
209 int16_t *prev_lsp);
210
211 /**
212 * Perform inverse quantization of LSP frequencies.
213 *
214 * @param cur_lsp the current LSP vector
215 * @param prev_lsp the previous LSP vector
216 * @param lsp_index VQ indices
217 * @param bad_frame bad frame flag
218 */
220 uint8_t *lsp_index, int bad_frame);
221
223
224 /**
225 * LSP DC component
226 */
228 0x0c3b,
229 0x1271,
230 0x1e0a,
231 0x2a36,
232 0x3630,
233 0x406f,
234 0x4d28,
235 0x56f4,
236 0x638c,
237 0x6c46
238 };
239
240 /* Cosine table scaled by 2^14 */
242 #define G723_1_COS_TAB_FIRST_ELEMENT 16384
243
244 /**
245 * LSP VQ tables
246 */
250
251 /**
252 * Used for the coding/decoding of the pulses positions
253 * for the MP-MLQ codebook
254 */
256
257 /**
258 * Number of non-zero pulses in the MP-MLQ excitation
259 */
260 static const int8_t
pulses[4] = {6, 5, 6, 5};
261
263
266
267 #endif /* AVCODEC_G723_1_H */