1 /* |
|
2 * Copyright (c) 2010 Ixonos Plc. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - Initial contribution |
|
11 * |
|
12 * Contributors: |
|
13 * Ixonos Plc |
|
14 * |
|
15 * Description: |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 /************************************************************************** |
|
21 chandefs.h - Constants for AAC coder. |
|
22 |
|
23 Author(s): Juha Ojanpera |
|
24 Copyright (c) 1999-2004 by Nokia Research Center, Audio-Visual Systems. |
|
25 *************************************************************************/ |
|
26 |
|
27 #ifndef AAC_CHANDEFS_H_ |
|
28 #define AAC_CHANDEFS_H_ |
|
29 |
|
30 /*-- Project Headers. --*/ |
|
31 #include "defines.h" |
|
32 |
|
33 #define GAIN_START (40) |
|
34 #define MAGIC_NUMBER (0.4054) |
|
35 #define MAGIC_NUMBER2 (1.0f - MAGIC_NUMBER) |
|
36 #define MAGIC_NUMBER3 (0.5f * MAGIC_NUMBER) |
|
37 #define QSTEP_SIZE (7) |
|
38 #define GAIN_FACTOR (1.0f / -0.25f) |
|
39 #define IMAX_QUANT (1.0f / MAX_AAC_QUANT) |
|
40 #define POWRAISE43 (4.0f / 3.0f) |
|
41 #define ILOG2 (1.0f / log10(2.0f)) |
|
42 #define LOG34 (log10(0.75f) * ILOG2) |
|
43 #define SFCGAIN (16.0f / 3.0f) |
|
44 #define QROUND_ERROR LOG2 (5.5f) |
|
45 #define MAXCOEF_LOG2_16_3_MINUS_TWO (67.33239402f) |
|
46 #define ILOG2_16_3 (17.71694984f) |
|
47 #define LOG2(x) (log10(x) * ILOG2) |
|
48 |
|
49 enum |
|
50 { |
|
51 /* |
|
52 * Channels for 5.1 main profile configuration |
|
53 * (modify for any desired decoder configuration) |
|
54 */ |
|
55 |
|
56 /*-- Front channels: left, center, right --*/ |
|
57 FChansD = 2, |
|
58 |
|
59 /*-- 1 if decoder has front center channel. --*/ |
|
60 FCenterD = 0, |
|
61 |
|
62 /*-- Side channels: --*/ |
|
63 SChansD = 0, |
|
64 |
|
65 /*-- Back channels: left surround, right surround. --*/ |
|
66 BChansD = 0, |
|
67 |
|
68 /*-- 1 if decoder has back center channel. --*/ |
|
69 BCenterD = 0, |
|
70 |
|
71 /*-- LFE channels. --*/ |
|
72 LChansD = 0, |
|
73 |
|
74 /*-- Scratch space for parsing unused channels. --*/ |
|
75 XChansD = 2, |
|
76 |
|
77 /*-- Total number of supported channels. --*/ |
|
78 ChansD = FChansD + SChansD + BChansD + LChansD + XChansD, |
|
79 |
|
80 /*-- Independently switched coupling channels. --*/ |
|
81 ICChansD = 0, |
|
82 |
|
83 /*-- Dependently switched coupling channels. --*/ |
|
84 DCChansD = 0, |
|
85 |
|
86 /*-- Scratch space index for parsing unused coupling channels. --*/ |
|
87 XCChansD = 1, |
|
88 |
|
89 /*-- Total number of supported CC channels. --*/ |
|
90 CChansD = (ICChansD + DCChansD + XCChansD), |
|
91 |
|
92 |
|
93 /*-- Block switching. --*/ |
|
94 LN = 2048, |
|
95 SN = 256, |
|
96 LN2_960 = 960, |
|
97 SN2_120 = 120, |
|
98 LN2 = LN / 2, |
|
99 SN2 = SN / 2, |
|
100 NSHORT = LN / SN, |
|
101 MAX_SBK = NSHORT, |
|
102 NUM_WIN_SEQ = 4, |
|
103 |
|
104 /*-- Max number of scale factor bands. --*/ |
|
105 MAXBANDS = 16 * NSHORT, |
|
106 MAXLONGSFBBANDS = 51, |
|
107 MAXSHORTSFBBANDS = 15, |
|
108 |
|
109 /*-- Maximum scale factor. --*/ |
|
110 SFACBOOK_SIZE = 121, |
|
111 MIDFAC = (SFACBOOK_SIZE - 1) / 2, |
|
112 |
|
113 /*-- Global gain must be positive. --*/ |
|
114 SF_OFFSET = 100, |
|
115 /*-- Quantization constants. --*/ |
|
116 MAX_QUANT_VALUE = 8191, |
|
117 |
|
118 /*-- Huffman parameters. --*/ |
|
119 ZERO_HCB = 0, |
|
120 ESCBOOK = 11, |
|
121 NSPECBOOKS = ESCBOOK + 1, |
|
122 BOOKSCL = NSPECBOOKS, |
|
123 NBOOKS = NSPECBOOKS + 1, |
|
124 INTENSITY_HCB2 = 14, |
|
125 INTENSITY_HCB = 15, |
|
126 NOISE_HCB = 13, |
|
127 NOISE_PCM_BITS = 9, |
|
128 NOISE_PCM_OFFSET = (1 << (NOISE_PCM_BITS - 1)), |
|
129 NOISE_OFFSET = 90, |
|
130 RESERVED_HCB = 13, |
|
131 SF_INDEX_OFFSET = 60, /*-- Offset for Huffman table indices of scalefactors. --*/ |
|
132 |
|
133 LONG_SECT_BITS = 5, |
|
134 SHORT_SECT_BITS = 3, |
|
135 |
|
136 /*-- Program Configuration. --*/ |
|
137 Main_Object = 0, |
|
138 LC_Object = 1, |
|
139 SSR_Object = 2, |
|
140 LTP_Object = 3, |
|
141 Scalable_Object = 4, |
|
142 |
|
143 Fs_48 = 3, |
|
144 Fs_44 = 4, |
|
145 Fs_32 = 5, |
|
146 |
|
147 /*-- Raw bitstream constants. --*/ |
|
148 LEN_SE_ID = 3, |
|
149 LEN_TAG = 4, |
|
150 LEN_COM_WIN = 1, |
|
151 LEN_ICS_RESERV = 1, |
|
152 LEN_WIN_SEQ = 2, |
|
153 LEN_WIN_SH = 1, |
|
154 LEN_MAX_SFBL = 6, |
|
155 LEN_MAX_SFBS = 4, |
|
156 LEN_CB = 4, |
|
157 LEN_SCL_PCM = 8, |
|
158 LEN_SCL_PCM_MASK = (1 << LEN_SCL_PCM) - 1, |
|
159 LEN_PRED_PRES = 1, |
|
160 LEN_PRED_RST = 1, |
|
161 LEN_PRED_RSTGRP = 5, |
|
162 LEN_PRED_ENAB = 1, |
|
163 LEN_MASK_PRES = 2, |
|
164 LEN_MASK = 1, |
|
165 |
|
166 LEN_PULSE_NPULSE = 2, |
|
167 LEN_PULSE_ST_SFB = 6, |
|
168 LEN_PULSE_POFF = 5, |
|
169 LEN_PULSE_PAMP = 4, |
|
170 NUM_PULSE_LINES = 4, |
|
171 PULSE_OFFSET_AMP = 4, |
|
172 |
|
173 LEN_IND_CCE_FLG = 1, |
|
174 LEN_NCC = 3, |
|
175 LEN_IS_CPE = 1, |
|
176 LEN_CC_LR = 1, |
|
177 LEN_CC_DOM = 1, |
|
178 LEN_CC_SGN = 1, |
|
179 LEN_CCH_GES = 2, |
|
180 LEN_CCH_CGP = 1, |
|
181 |
|
182 LEN_D_ALIGN = 1, |
|
183 LEN_D_CNT = 8, |
|
184 LEN_D_ESC = 8, |
|
185 LEN_F_CNT = 4, |
|
186 LEN_F_ESC = 8, |
|
187 LEN_NIBBLE = 4, |
|
188 LEN_BYTE = 8, |
|
189 LEN_PAD_DATA = 8, |
|
190 |
|
191 LEN_PC_COMM = 8, |
|
192 |
|
193 /*-- FILL --*/ |
|
194 LEN_EX_TYPE = 4, |
|
195 EX_FILL = 0, |
|
196 EX_FILL_DATA = 1, |
|
197 EX_DRC = 11, |
|
198 |
|
199 /*-- DRC --*/ |
|
200 LEN_DRC_PL = 7, |
|
201 LEN_DRC_PL_RESV = 1, |
|
202 LEN_DRC_PCE_RESV = (8 - LEN_TAG), |
|
203 LEN_DRC_BAND_INCR = 4, |
|
204 LEN_DRC_BAND_RESV = 4, |
|
205 LEN_DRC_BAND_TOP = 8, |
|
206 LEN_DRC_SGN = 1, |
|
207 LEN_DRC_MAG = 7, |
|
208 DRC_BAND_MULT = 4, |
|
209 |
|
210 /*-- Channel elements. --*/ |
|
211 ID_SCE = 0, |
|
212 ID_CPE, |
|
213 ID_CCE, |
|
214 ID_LFE, |
|
215 ID_DSE, |
|
216 ID_PCE, |
|
217 ID_FIL, |
|
218 ID_END, |
|
219 |
|
220 FILL_VALUE = 0x55, |
|
221 |
|
222 /*-- Bit reservoir. --*/ |
|
223 BIT_RESERVOIR_SIZE = 6144, |
|
224 |
|
225 /*-- Program configuration element --*/ |
|
226 LEN_PROFILE = 2, |
|
227 LEN_SAMP_IDX = 4, |
|
228 LEN_NUM_ELE = 4, |
|
229 LEN_NUM_LFE = 2, |
|
230 LEN_NUM_DAT = 3, |
|
231 LEN_NUM_CCE = 4, |
|
232 LEN_MMIX_IDX = 2, |
|
233 LEN_PSUR_ENAB = 1, |
|
234 LEN_ELE_IS_CPE = 1, |
|
235 LEN_IND_SW_CCE = 1, |
|
236 LEN_COMMENT_BYTES = 8, |
|
237 |
|
238 /*-- LTP constants. --*/ |
|
239 LTP_MAX_PRED_BANDS = 40, |
|
240 LTP_COEF_BITS = 3, |
|
241 LTP_LAG_BITS = 11, |
|
242 |
|
243 /*-- TNS constants. --*/ |
|
244 TNS_MAX_FILT = 3, |
|
245 TNS_MAX_COEFF_RES = 2, |
|
246 TNS_MAX_COEFF = 32, |
|
247 |
|
248 TNS_MAX_ORDER = 12, |
|
249 TNS_COEFF_RES_OFFSET = 3, |
|
250 |
|
251 /*-- BWP constants. --*/ |
|
252 MAX_PGRAD = 2, |
|
253 MINVAR = 1, |
|
254 Q_ZERO = 0x0000, |
|
255 Q_ONE = 0x3F80, |
|
256 |
|
257 /*-- PNS parameters. --*/ |
|
258 MAX_DCT_LEN = 64, |
|
259 NOISE_FREE_BANDS = 3, |
|
260 NOISE_FREE_MASK = (1 << NOISE_FREE_BANDS) - 1, |
|
261 /*-- Max length of DSE, bytes. --*/ |
|
262 MAX_DBYTES = ((1 << LEN_D_CNT) + (1 << LEN_D_ESC)), |
|
263 |
|
264 /*-- size of exp cache table. --*/ |
|
265 TEXP = 256, |
|
266 TEXP_MASK = (TEXP - 1), |
|
267 |
|
268 /*-- Size of inv quant table. --*/ |
|
269 MAX_AAC_QUANT = 255, |
|
270 MAX_IQ_TBL = MAX_AAC_QUANT + 1, |
|
271 IQ_MASK = (MAX_IQ_TBL - 1) |
|
272 }; |
|
273 |
|
274 /* |
|
275 Purpose: Mixing modes for CCE (coupling channel element). |
|
276 Explanation: - */ |
|
277 typedef enum CCmixMode |
|
278 { |
|
279 CC_BEFORE_TNS, /* Dependently switched. */ |
|
280 CC_AFTER_TNS, /* Dependently switched. */ |
|
281 CC_TIME_MIX /* Independently switched. */ |
|
282 |
|
283 } CCmixMode; |
|
284 |
|
285 /* |
|
286 Purpose: Window shapes. |
|
287 Explanation: - */ |
|
288 typedef enum WindowShape |
|
289 { |
|
290 WS_SIN = 0, /* Sine window. */ |
|
291 WS_KBD /* Kaiser-Bessel Derived window. */ |
|
292 |
|
293 } WindowShape; |
|
294 |
|
295 /* |
|
296 Purpose: AAC predictor type. |
|
297 Explanation: - */ |
|
298 typedef enum PredType |
|
299 { |
|
300 NO_PRED = 0, |
|
301 BWAP_PRED, |
|
302 LTP_PRED |
|
303 |
|
304 } PredType; |
|
305 |
|
306 /* |
|
307 Purpose: Block types for transform coders using block switching. |
|
308 Explanation: The first four describe the actual block type for each subband, |
|
309 the rest of the declarations describe the block type for the |
|
310 whole frame. */ |
|
311 typedef enum AAC_WINDOW_TYPE |
|
312 { |
|
313 ONLY_LONG_WND, |
|
314 LONG_SHORT_WND, |
|
315 ONLY_SHORT_WND, |
|
316 SHORT_LONG_WND |
|
317 |
|
318 } AAC_WINDOW_TYPE, AacWindowType; |
|
319 |
|
320 /* |
|
321 Purpose: Block sequence (long and short) parameters. |
|
322 Explanation: - */ |
|
323 class CInfo : public CBase |
|
324 { |
|
325 |
|
326 public: |
|
327 |
|
328 static CInfo* NewL(); |
|
329 ~CInfo(); |
|
330 |
|
331 int16 islong; |
|
332 int16 nsbk; |
|
333 int16 bins_per_bk; |
|
334 int16 sfb_per_bk; |
|
335 int16* bins_per_sbk; |
|
336 int16* sfb_per_sbk; |
|
337 const int16 *sbk_sfb_top[MAX_SBK]; |
|
338 int16 *sfb_width_128; |
|
339 int16* bk_sfb_top; |
|
340 int16 num_groups; |
|
341 int16* group_len; |
|
342 int16* group_offs; |
|
343 |
|
344 private: |
|
345 void ConstructL(); |
|
346 CInfo(); |
|
347 |
|
348 }; |
|
349 |
|
350 /* |
|
351 Purpose: Sampling rate dependent parameters. |
|
352 Explanation: - */ |
|
353 typedef struct Sr_InfoStr |
|
354 { |
|
355 int32 samp_rate; |
|
356 |
|
357 int16 nsfb1024; |
|
358 const int16 *SFbands1024; |
|
359 |
|
360 int16 nsfb128; |
|
361 const int16 *SFbands128; |
|
362 |
|
363 int16 nsfb960; |
|
364 const int16 *SFbands960; |
|
365 |
|
366 int16 nsfb120; |
|
367 const int16 *SFbands120; |
|
368 |
|
369 } SR_Info; |
|
370 |
|
371 /* |
|
372 Purpose: Sfb related information. |
|
373 Explanation: - */ |
|
374 class CSfb_Info : public CBase |
|
375 { |
|
376 |
|
377 public: |
|
378 |
|
379 static CSfb_Info* NewL(uint8 isEncoder = FALSE); |
|
380 ~CSfb_Info(); |
|
381 |
|
382 CInfo *only_long_info; |
|
383 CInfo *eight_short_info; |
|
384 |
|
385 CInfo *winmap[NUM_WIN_SEQ]; |
|
386 int16 sfbwidth128[1 << LEN_MAX_SFBS]; |
|
387 |
|
388 /*-- Scalefactor offsets. --*/ |
|
389 int16 *sect_sfb_offsetL; |
|
390 int16 *sect_sfb_offsetS; |
|
391 int16 *sfbOffsetTablePtr[2]; |
|
392 int16 *sect_sfb_offsetS2[NSHORT]; |
|
393 |
|
394 private: |
|
395 void ConstructL(uint8 isEncoder); |
|
396 CSfb_Info(); |
|
397 |
|
398 }; |
|
399 |
|
400 /* |
|
401 Purpose: Window shapes for this and previous frame. |
|
402 Explanation: - */ |
|
403 typedef struct Wnd_ShapeStr |
|
404 { |
|
405 uint8 this_bk; |
|
406 uint8 prev_bk; |
|
407 |
|
408 } Wnd_Shape; |
|
409 |
|
410 #endif /*-- AAC_CHANDEFS_H_ --*/ |
|