1 /*
2 * AAC encoder
3 * Copyright (C) 2008 Konstantin Shishkov
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #ifndef AVCODEC_AACENC_H
23 #define AVCODEC_AACENC_H
24
28
31
35
37
42
45
56
58
63 int win,
int group_len,
const float lambda);
65 int scale_idx,
int cb,
const float lambda,
int rtz);
84
86
95
98 int num_ele[4];
///< front, side, back, lfe
100 int index[4][8];
///< front, side, back, lfe
101 uint8_t
config_map[16];
///< configs the encoder's channel specific settings
102 uint8_t
reorder_map[16];
///< maps channels from lavc to aac order
104
105 /**
106 * List of PCE (Program Configuration Element) for the channel layouts listed
107 * in channel_layout.h
108 *
109 * For those wishing in the future to add other layouts:
110 *
111 * - num_ele: number of elements in each group of front, side, back, lfe channels
112 * (an element is of type SCE (single channel), CPE (channel pair) for
113 * the first 3 groups; and is LFE for LFE group).
114 *
115 * - pairing: 0 for an SCE element or 1 for a CPE; does not apply to LFE group
116 *
117 * - index: there are three independent indices for SCE, CPE and LFE;
118 * they are incremented irrespective of the group to which the element belongs;
119 * they are not reset when going from one group to another
120 *
121 * Example: for 7.0 channel layout,
122 * .pairing = { { 1, 0 }, { 1 }, { 1 }, }, (3 CPE and 1 SCE in front group)
123 * .index = { { 0, 0 }, { 1 }, { 2 }, },
124 * (index is 0 for the single SCE but goes from 0 to 2 for the CPEs)
125 *
126 * The index order impacts the channel ordering. But is otherwise arbitrary
127 * (the sequence could have been 2, 0, 1 instead of 0, 1, 2).
128 *
129 * Spec allows for discontinuous indices, e.g. if one has a total of two SCE,
130 * SCE.0 SCE.15 is OK per spec; BUT it won't be decoded by our AAC decoder
131 * which at this time requires that indices fully cover some range starting
132 * from 0 (SCE.1 SCE.0 is OK but not SCE.0 SCE.15).
133 *
134 * - config_map: total number of elements and their types. Beware, the way the
135 * types are ordered impacts the final channel ordering.
136 *
137 * - reorder_map: reorders the channels.
138 *
139 */
141 {
143 .num_ele = { 1, 0, 0, 0 },
144 .pairing = { { 0 }, },
145 .index = { { 0 }, },
147 .reorder_map = { 0 },
148 },
149 {
151 .num_ele = { 1, 0, 0, 0 },
152 .pairing = { { 1 }, },
153 .index = { { 0 }, },
155 .reorder_map = { 0, 1 },
156 },
157 {
159 .num_ele = { 1, 0, 0, 1 },
160 .pairing = { { 1 }, },
161 .index = { { 0 },{ 0 },{ 0 },{ 0 } },
163 .reorder_map = { 0, 1, 2 },
164 },
165 {
167 .num_ele = { 1, 0, 1, 0 },
168 .pairing = { { 1 },{ 0 },{ 0 } },
169 .index = { { 0 },{ 0 },{ 0 }, },
171 .reorder_map = { 0, 1, 2 },
172 },
173 {
175 .num_ele = { 2, 0, 0, 0 },
176 .pairing = { { 1, 0 }, },
177 .index = { { 0, 0 }, },
179 .reorder_map = { 0, 1, 2 },
180 },
181 {
183 .num_ele = { 2, 0, 0, 1 },
184 .pairing = { { 1, 0 }, },
185 .index = { { 0, 0 }, { 0 }, { 0 }, { 0 }, },
187 .reorder_map = { 0, 1, 2, 3 },
188 },
189 {
191 .num_ele = { 2, 0, 1, 0 },
192 .pairing = { { 1, 0 }, { 0 }, { 0 }, },
193 .index = { { 0, 0 }, { 0 }, { 1 } },
195 .reorder_map = { 0, 1, 2, 3 },
196 },
197 {
199 .num_ele = { 2, 1, 1, 0 },
200 .pairing = { { 1, 0 }, { 0 }, { 0 }, },
201 .index = { { 0, 0 }, { 1 }, { 2 }, { 0 } },
203 .reorder_map = { 0, 1, 2, 3, 4 },
204 },
205 {
207 .num_ele = { 1, 1, 0, 0 },
208 .pairing = { { 1 }, { 1 }, },
209 .index = { { 0 }, { 1 }, },
211 .reorder_map = { 0, 1, 2, 3 },
212 },
213 {
215 .num_ele = { 1, 0, 1, 0 },
216 .pairing = { { 1 }, { 0 }, { 1 }, },
217 .index = { { 0 }, { 0 }, { 1 } },
219 .reorder_map = { 0, 1, 2, 3 },
220 },
221 {
223 .num_ele = { 2, 1, 0, 0 },
224 .pairing = { { 1, 0 }, { 1 }, },
225 .index = { { 0, 0 }, { 1 } },
227 .reorder_map = { 0, 1, 2, 3, 4 },
228 },
229 {
231 .num_ele = { 2, 1, 1, 0 },
232 .pairing = { { 1, 0 }, { 0 }, { 1 }, },
233 .index = { { 0, 0 }, { 1 }, { 1 } },
235 .reorder_map = { 0, 1, 2, 3, 4, 5 },
236 },
237 {
239 .num_ele = { 2, 0, 1, 0 },
240 .pairing = { { 1, 0 }, { 0 }, { 1 } },
241 .index = { { 0, 0 }, { 0 }, { 1 } },
243 .reorder_map = { 0, 1, 2, 3, 4 },
244 },
245 {
247 .num_ele = { 2, 1, 1, 0 },
248 .pairing = { { 1, 0 }, { 0 }, { 1 }, },
249 .index = { { 0, 0 }, { 1 }, { 1 } },
251 .reorder_map = { 0, 1, 2, 3, 4, 5 },
252 },
253 {
255 .num_ele = { 2, 1, 1, 0 },
256 .pairing = { { 1, 0 }, { 1 }, { 0 }, },
257 .index = { { 0, 0 }, { 1 }, { 1 } },
259 .reorder_map = { 0, 1, 2, 3, 4, 5 },
260 },
261 {
263 .num_ele = { 2, 1, 0, 0 },
264 .pairing = { { 1, 1 }, { 1 } },
265 .index = { { 1, 0 }, { 2 }, },
267 .reorder_map = { 0, 1, 2, 3, 4, 5 },
268 },
269 {
271 .num_ele = { 2, 0, 2, 0 },
272 .pairing = { { 1, 0 },{ 0 },{ 1, 0 }, },
273 .index = { { 0, 0 },{ 0 },{ 1, 1 } },
275 .reorder_map = { 0, 1, 2, 3, 4, 5 },
276 },
277 {
279 .num_ele = { 2, 1, 2, 0 },
280 .pairing = { { 1, 0 },{ 0 },{ 1, 0 }, },
281 .index = { { 0, 0 },{ 1 },{ 1, 2 } },
283 .reorder_map = { 0, 1, 2, 3, 4, 5, 6 },
284 },
285 {
287 .num_ele = { 2, 1, 2, 0 },
288 .pairing = { { 1, 0 }, { 0 }, { 1, 0 }, },
289 .index = { { 0, 0 }, { 1 }, { 1, 2 } },
291 .reorder_map = { 0, 1, 2, 3, 4, 5, 6 },
292 },
293 {
295 .num_ele = { 2, 1, 2, 0 },
296 .pairing = { { 1, 0 }, { 0 }, { 1, 0 }, },
297 .index = { { 0, 0 }, { 1 }, { 1, 2 } },
299 .reorder_map = { 0, 1, 2, 3, 4, 5, 6 },
300 },
301 {
303 .num_ele = { 2, 1, 1, 0 },
304 .pairing = { { 1, 0 }, { 1 }, { 1 }, },
305 .index = { { 0, 0 }, { 1 }, { 2 }, },
307 .reorder_map = { 0, 1, 2, 3, 4, 5, 6 },
308 },
309 {
311 .num_ele = { 2, 1, 1, 0 },
312 .pairing = { { 1, 0 }, { 1 }, { 1 }, },
313 .index = { { 0, 0 }, { 1 }, { 2 }, },
315 .reorder_map = { 0, 1, 2, 3, 4, 5, 6 },
316 },
317 {
319 .num_ele = { 2, 1, 2, 0 },
320 .pairing = { { 1, 0 }, { 0 }, { 1, 1 }, },
321 .index = { { 0, 0 }, { 1 }, { 1, 2 }, { 0 } },
323 .reorder_map = { 0, 1, 2, 3, 4, 5, 6, 7 },
324 },
325 {
327 .num_ele = { 2, 1, 2, 0 },
328 .pairing = { { 1, 0 }, { 0 },{ 1, 1 }, },
329 .index = { { 0, 0 }, { 1 }, { 1, 2 }, { 0 } },
331 .reorder_map = { 0, 1, 2, 3, 4, 5, 6, 7 },
332 },
333 {
335 .num_ele = { 2, 1, 2, 0 },
336 .pairing = { { 1, 0 }, { 0 }, { 1, 1 }, },
337 .index = { { 0, 0 }, { 1 }, { 1, 2 }, { 0 } },
339 .reorder_map = { 0, 1, 2, 3, 4, 5, 6, 7 },
340 },
341 {
343 .num_ele = { 2, 1, 2, 0 },
344 .pairing = { { 1, 0 }, { 1 }, { 1, 0 }, },
345 .index = { { 0, 0 }, { 1 }, { 2, 1 } },
347 .reorder_map = { 0, 1, 2, 3, 4, 5, 6, 7 },
348 },
349 { /* Meant for order 2/mixed ambisonics */
351 .num_ele = { 2, 2, 2, 0 },
352 .pairing = { { 1, 0 }, { 1, 0 }, { 1, 0 }, },
353 .index = { { 0, 0 }, { 1, 1 }, { 2, 2 } },
355 .reorder_map = { 0, 1, 2, 3, 4, 5, 6, 7, 8 },
356 },
357 { /* Meant for order 2/mixed ambisonics */
360 .num_ele = { 2, 2, 2, 0 },
361 .pairing = { { 1, 1 }, { 1, 0 }, { 1, 0 }, },
362 .index = { { 0, 1 }, { 2, 0 }, { 3, 1 } },
364 .reorder_map = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
365 },
366 {
368 .num_ele = { 4, 2, 4, 0 },
369 .pairing = { { 1, 0, 1, 0 }, { 1, 1 }, { 1, 0, 1, 0 }, },
370 .index = { { 0, 0, 1, 1 }, { 2, 3 }, { 4, 2, 5, 3 } },
371 .config_map = { 10,
TYPE_CPE,
TYPE_SCE,
TYPE_CPE,
TYPE_SCE,
TYPE_CPE,
TYPE_CPE,
TYPE_CPE,
TYPE_SCE,
TYPE_CPE,
TYPE_SCE },
372 .reorder_map = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
373 },
374 };
375
376 /**
377 * AAC encoder context
378 */
388
395 const uint8_t *
chan_map;
///< channel configuration map
396
408
412
415
418 int size,
int is_signed,
int maxval,
const float Q34,
419 const float rounding);
420
421 struct {
425
429
430
431 #endif /* AVCODEC_AACENC_H */